开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: How to get real time data for INDEX and FUTURES using TWS API reqMktData()?


 

Example of the minimum fields to set for a march ZB futures contract:

? ? With lContractInfo
? ? ? ? .symbol = ""
? ? ? ? .secType = "FUT"
? ? ? ? .lastTradeDateOrContractMonth = ""
? ? ? ? .Strike = 0
? ? ? ? .Right = ""
? ? ? ? .multiplier = ""
? ? ? ? .Exchange = "ECBOT"
? ? ? ? .primaryExchange = ""
? ? ? ? .currency = "USD"
? ? ? ? .localSymbol = "ZB ? MAR 22"
? ? ? ? .conId = 0
? ? End With

You could also set the Symbol = "ZB" and the lastTradeDateOrContractMonth = "202203" instead of the localSymbol

El mié, 2 mar 2022 a las 6:39, Tareq Naushad (<tareq_ifti@...>) escribió:
Hi,
Normally I use the following format of code to get real-time market data for a Symbol, which works fine:
```
contract = Contract()
contract.symbol = sym
contract.secType = "STK"
contract.currency = "USD"
contract.exchange = "SMART"

reqMarketDataType(1)
reqMktData(x, contract, "", False, False, [])
```

So I want to write a similar code to get real-time data for FUTURES and INDEX. But the problem is, I have a little bit of doubt about how to write the symbol of an INDEX/FUTURES to receive actual data. Because the following code is not working:
```
contract = Contract()
contract.symbol = "/ES"
contract.secType = "IND"
contract.currency = "USD"
contract.exchange = "SMART"

reqMarketDataType(1)
reqMktData(x, contract, "", False, False, [])
```

Does anyone have any idea how to write the code for INDEX/FUTURES to receive real-time data?

Thanks
- Tareq

Join [email protected] to automatically receive all group messages.