隻揪隻

How to query historical data for my custom instrument?

Programming


Hey, I followed this post to upload my data (https://algogene.com/community/post/26). How can I query my custom instrument for backtest?
 
admin
The same "getHistoricalBar" function (https://algogene.com/TechDoc#QueryHistory) can be used to query historical data. Suppose your custom instrument is XXX, we can implement as below. 

def on_bulkdatafeed(self, isSync, bd, ab):
    contract = {"instrument": 'XXX'}
    res = self.evt.getHistoricalBar(contract, 100, 'D')
    for t in res:
        timestamp = t
        lastprice = res[t]['c']
        # do something ...