Skip to main content

get_history_candles

To get history candles in __init__ function with past length of period data, which is useful for strategy to calculate parameter (ex. MA) without waiting several periods of trade() for collecting data. CA.get_history_candles can only be used in __init__, so it is necessary to save the history candles once queried.

Input

  length: number;
period: number;

Return

  error: string;
candles: dictionary;

Example

def __init__(self):
self.period = 60 * 60 # 1 hour
self.subscribed_books = {}
self.options = {}
# query the past 1 days data
self.history_candles = CA.get_history_candles(24, self.period)
if self.history_candles:
CA.log(str(self.history_candles))
for exchange in self.history_candles:
for pair in self.history_candles[exchange]:
for candle in self.history_candles[exchange][pair]:
CA.log(str(candle))