Refer to FigureFactory.create_ohlc_increase() for docstring.
| 188 | |
| 189 | |
| 190 | class _OHLC(object): |
| 191 | """ |
| 192 | Refer to FigureFactory.create_ohlc_increase() for docstring. |
| 193 | """ |
| 194 | |
| 195 | def __init__(self, open, high, low, close, dates, **kwargs): |
| 196 | self.open = open |
| 197 | self.high = high |
| 198 | self.low = low |
| 199 | self.close = close |
| 200 | self.empty = [None] * len(open) |
| 201 | self.dates = dates |
| 202 | |
| 203 | self.all_x = [] |
| 204 | self.all_y = [] |
| 205 | self.increase_x = [] |
| 206 | self.increase_y = [] |
| 207 | self.decrease_x = [] |
| 208 | self.decrease_y = [] |
| 209 | self.get_all_xy() |
| 210 | self.separate_increase_decrease() |
| 211 | |
| 212 | def get_all_xy(self): |
| 213 | """ |
| 214 | Zip data to create OHLC shape |
| 215 | |
| 216 | OHLC shape: low to high vertical bar with |
| 217 | horizontal branches for open and close values. |
| 218 | If dates were added, the smallest date difference is calculated and |
| 219 | multiplied by .2 to get the length of the open and close branches. |
| 220 | If no date data was provided, the x-axis is a list of integers and the |
| 221 | length of the open and close branches is .2. |
| 222 | """ |
| 223 | self.all_y = list( |
| 224 | zip( |
| 225 | self.open, |
| 226 | self.open, |
| 227 | self.high, |
| 228 | self.low, |
| 229 | self.close, |
| 230 | self.close, |
| 231 | self.empty, |
| 232 | ) |
| 233 | ) |
| 234 | if self.dates is not None: |
| 235 | date_dif = [] |
| 236 | for i in range(len(self.dates) - 1): |
| 237 | date_dif.append(self.dates[i + 1] - self.dates[i]) |
| 238 | date_dif_min = (min(date_dif)) / 5 |
| 239 | self.all_x = [ |
| 240 | [x - date_dif_min, x, x, x, x, x + date_dif_min, None] |
| 241 | for x in self.dates |
| 242 | ] |
| 243 | else: |
| 244 | self.all_x = [ |
| 245 | [x - 0.2, x, x, x, x, x + 0.2, None] for x in range(len(self.open)) |
| 246 | ] |
| 247 |
no outgoing calls
no test coverage detected