get_history_candles
可在 __init__ 函數中取得過去 length 個週期為 period 的歷史資料,以便執行策略當下即可計算相關參數(例如 MA)。
呼叫後請儲存結果,CA.get_history_candles 僅可呼叫一次。
Input
  length: number;
  period: number;
  is_reverse: boolean = False;
回傳
  error: string;
  candles: dictionary;
範例
獲取歷史價量資料(按時間順序排列)
def __init__(self):
    self.period = 60 * 60 # 1 hour
    self.subscribed_books = {}
    self.options = {}
    # query the past 1 day 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))
獲取歷史價量資料(按時間倒序排列)
def __init__(self):
    self.period = 60 * 60 # 1 hour
    self.subscribed_books = {}
    self.options = {}
    # query the past 1 day data
    self.history_candles = CA.get_history_candles(24, self.period, True)
    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))