Skip to content

Commit

Permalink
Subscribe to more tick data fields
Browse files Browse the repository at this point in the history
reading tick docs again revealed some ticks we weren't receiving which
may be useful in the future (and we can read them with the `info`
command manual output too).
  • Loading branch information
mattsta committed Aug 10, 2024
1 parent 1914dfc commit 758a716
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions icli/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,22 @@ def contractFromSymbolDescriptor(contractType: str, symbol: str):


def tickFieldsForContract(contract) -> str:
extraFields = []
# Available fields from:
# https://interactivebrokers.github.io/tws-api/tick_types.html
# NOTE: the number to use here is the 'Generic tick required' number and NOT the 'Tick id' number.
extraFields = [
# start with VWAP and volume data requested everywhere
233,
# also add "volume per minute"
295,
# also add "trades per minute"
294,
]

# There is also "fundamentals" as tick 258 but it returns things like this which isn't useful for us because
# it's just reporting on historical financial reports:
# fundamentalRatios=FundamentalRatios(TTMNPMGN=35.20226, NLOW=274.38, TTMPRCFPS=18.29654, TTMGROSMGN=81.49056, TTMCFSHR=25.00352, QCURRATIO=2.83036, TTMREV=149783, TTMINVTURN=nan, TTMOPMGN=39.25479, TTMPR2REV=8.03502, AEPSNORM=16.18888, TTMNIPEREM=783264.3, EPSCHNGYR=82.25327, TTMPRFCFPS=25.55114, TTMRECTURN=11.08847, TTMPTMGN=40.1354, QCSHPS=22.92933, TTMFCF=47102, LATESTADATE='2024-06-30', APTMGNPCT=35.15737, AEBTNORM=50880, TTMNIAC=52727, NetDebt_I=-39691, PRYTDPCTR=23.60872, TTMEBITD=73664, AFEEPSNTM=22.401, PR2TANBK=8.90664, EPSTRENDGR=14.79464, QTOTD2EQ=11.73045, TTMFCFSHR=17.9044, QBVPS=61.88827, NPRICE=475.73, YLD5YAVG=nan, PR13WKPCT=2.15813, PR52WKPCT=53.10076, REVTRENDGR=19.29375, AROAPCT=19.10341, TTMEPSXCLX=20.0446, QTANBVPS=53.34583, PRICE2BK=7.68692, MKTCAP=1203510, TTMPAYRAT=4.84951, TTMINTCOV=nan, TTMREVCHG=24.27752, TTMROAPCT=24.13544, TTMROEPCT=36.26391, TTMREVPERE=2225040, APENORM=29.38622, TTMROIPCT=27.75098, REVCHNGYR=22.10069, CURRENCY='USD', DIVGRPCT=nan, TTMEPSCHG=136.651, PEEXCLXOR=23.73357, QQUICKRATI=nan, TTMREVPS=56.93547, BETA=1.17755, TTMEBT=60116, ADIV5YAVG=nan, ANIACNORM=42560.56, PR1WKPCT=2.15155, QLTD2EQ=11.73045, NHIG=542.81, PR4WKPCT=-10.12431)

if isinstance(contract, Stock):
# 104:
# "The 30-day historical volatility (currently for stocks)."
Expand All @@ -475,7 +490,8 @@ def tickFieldsForContract(contract) -> str:
# "Shortable: < 1.5, not availabe
# > 1.5, if shares can be located
# > 2.5, enough shares are available (>= 1k)"
extraFields += [104, 106, 236]
# 595: Stock volume averaged over 3 minutes, 5 minutes, 10 minutes.
extraFields += [104, 106, 236, 595]

# yeah, the API wants a CSV for the tick list. sigh.
tickFields = ",".join([str(x) for x in extraFields])
Expand Down

0 comments on commit 758a716

Please sign in to comment.