¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Looping the Historical ticks request


 

Is there a good way to create a loop for the historical ticks request? ?This could help to bypass the 1000 line limit per request. ?


 

Use?for acquiring live tick data ( as long as cancel- or API termination) - you may get a front run by parameter?numberOfTicks?for maximal 1000 historical ticks

I understand you wanting to procure more then 1000 historical ticks (by somehow looping the request) - sorry, that is not possible by that IBKR API: seems you need a 3rd party data provider.


Nick
 

That is not correct.

reqHistoricalTicks takes start and end times. You can specify the end time you want for the first request. Then subtract 1 from the oldest received timestamp and use that for the end time of the next request.

This will allow you to loop backwards and collect as many ticks as you want.

You can also use the start time and use the same approach to loop forward.

On 5/30/2021 10:11 AM, Sebastian wrote:
I understand you wanting to procure more then 1000 historical ticks (by somehow looping the request) - sorry, that is not possible by that IBKR API: seems you need a 3rd party data provider.


 

Hi,

It's done so:
start with one call

? ? ?self.reqHistoricalData(self.hisID, self.contract, self.lastxDay, "1800 S", "1 secs", BID_TYPE, 0, 1, False, [])

? ? ?def historicalData(self, reqId, bar):
? ? ? ? ?# do your stuff

Here come the magic
###################
? ? def historicalDataEnd(self, reqId: int, start: str, end: str):
? ? # once the data ends, you issue a new request, after altering the time?
? ? ?self.historicDate += datetime.timedelta(minutes=30)
? ? ?self.reqHistoricalData(self.hisID, self.contract, self.historicDate?, "1800 S", "1 secs", BID_TYPE, 0, 1, False, [])

Hope this helps


 

yes thank you!


On Mon, May 31, 2021 at 9:28 AM <erezkaplan90@...> wrote:
Hi,

It's done so:
start with one call

? ? ?self.reqHistoricalData(self.hisID, self.contract, self.lastxDay, "1800 S", "1 secs", BID_TYPE, 0, 1, False, [])

? ? ?def historicalData(self, reqId, bar):
? ? ? ? ?# do your stuff

Here come the magic
###################
? ? def historicalDataEnd(self, reqId: int, start: str, end: str):
? ? # once the data ends, you issue a new request, after altering the time?
? ? ?self.historicDate += datetime.timedelta(minutes=30)
? ? ?self.reqHistoricalData(self.hisID, self.contract, self.historicDate?, "1800 S", "1 secs", BID_TYPE, 0, 1, False, [])

Hope this helps