Refer to FigureFactory.create_candlestick() for docstring.
| 213 | |
| 214 | |
| 215 | class _Candlestick(object): |
| 216 | """ |
| 217 | Refer to FigureFactory.create_candlestick() for docstring. |
| 218 | """ |
| 219 | |
| 220 | def __init__(self, open, high, low, close, dates, **kwargs): |
| 221 | self.open = open |
| 222 | self.high = high |
| 223 | self.low = low |
| 224 | self.close = close |
| 225 | if dates is not None: |
| 226 | self.x = dates |
| 227 | else: |
| 228 | self.x = [x for x in range(len(self.open))] |
| 229 | self.get_candle_increase() |
| 230 | |
| 231 | def get_candle_increase(self): |
| 232 | """ |
| 233 | Separate increasing data from decreasing data. |
| 234 | |
| 235 | The data is increasing when close value > open value |
| 236 | and decreasing when the close value <= open value. |
| 237 | """ |
| 238 | increase_y = [] |
| 239 | increase_x = [] |
| 240 | for index in range(len(self.open)): |
| 241 | if self.close[index] > self.open[index]: |
| 242 | increase_y.append(self.low[index]) |
| 243 | increase_y.append(self.open[index]) |
| 244 | increase_y.append(self.close[index]) |
| 245 | increase_y.append(self.close[index]) |
| 246 | increase_y.append(self.close[index]) |
| 247 | increase_y.append(self.high[index]) |
| 248 | increase_x.append(self.x[index]) |
| 249 | |
| 250 | increase_x = [[x, x, x, x, x, x] for x in increase_x] |
| 251 | increase_x = utils.flatten(increase_x) |
| 252 | |
| 253 | return increase_x, increase_y |
| 254 | |
| 255 | def get_candle_decrease(self): |
| 256 | """ |
| 257 | Separate increasing data from decreasing data. |
| 258 | |
| 259 | The data is increasing when close value > open value |
| 260 | and decreasing when the close value <= open value. |
| 261 | """ |
| 262 | decrease_y = [] |
| 263 | decrease_x = [] |
| 264 | for index in range(len(self.open)): |
| 265 | if self.close[index] <= self.open[index]: |
| 266 | decrease_y.append(self.low[index]) |
| 267 | decrease_y.append(self.open[index]) |
| 268 | decrease_y.append(self.close[index]) |
| 269 | decrease_y.append(self.close[index]) |
| 270 | decrease_y.append(self.close[index]) |
| 271 | decrease_y.append(self.high[index]) |
| 272 | decrease_x.append(self.x[index]) |
no outgoing calls
no test coverage detected