tg12 / FAIG

Fully Automated IG Trading
148 stars 60 forks source link

auto-track number of api calls and sleep if needed #19

Closed FlickeringIRoam closed 6 years ago

FlickeringIRoam commented 6 years ago

if number of requests tracked > 30, then trim it down to the calls in the last 60s, and wait until we're under the limit.

callamd commented 6 years ago

A better way of doing this is to work out how many seconds you would have to wait per call to never be under the limit. This ensures that you'll not have a long period of being unable to send a request. A second is a long time to block.

FlickeringIRoam commented 6 years ago

That wouldn't really work, since it's not a per-call limit, it's a per-account limit. If we know how many we're going to need per "run" then we could wait and reserve that amount beforehand, but in general, this limit shouldn't really be hit, if it is, we're probably not being picky enough with our selection. However, there IS a issue with it, in that it will always wait if we just pass 30 calls, not matter how distant. I'll fix it at some point, this was just a quick fix to address an immediate concern.

tg12 commented 6 years ago

I'm testing this now. Seems to be working so far.