pysystemtrade
pysystemtrade copied to clipboard
Start collecting open interest data?
An idea for a potential new feature: collecting open interest data. IB provides it, so it shouldn't be hard at all. Example code:
from ib_insync import *
util.startLoop()
ib = IB()
ib.connect('127.0.0.1', 4001, clientId=666)
ib.reqMarketDataType(3)
contract = Future('R','202403', 'ICEEU')
ticker = ib.reqMktData(contract, '588', False, False, None)
while True:
ib.sleep(1)
print(ticker.futuresOpenInterest)
Historical open interest data is also provided by Barchart so it shouldn't be difficult to backfill it.
I can imagine that this data might be relevant for considerations of whether or not to trade a market, and that it could be used as an input to certain trading signals. If you think it would be useful, @robcarver17 , I'm happy to implement it.
Sure could be useful. For implementation, please go slowly adding the required classes bottom up* one PR at a time and ensuring existing framework is respected. Any questions just ask.
- top down would require a big bang PR, this way you can just add unused code safely.
[apologies if telling anyone how to suck eggs here]