开云体育

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

RealTimeBars for SPX


 

i am trying t o get realTimeBars for SPX. I have the below snippet of code ,?
?Contract contract = new Contract();
contract.symbol("SPY");
contract.secType("STK");
contract.currency("USD");
contract.exchange("SMART");
contract.primaryExch("ISLAND");
m_client.reqRealTimeBars(3010, contract, 5, "TRADES", false, null);

but when executed it throws the following error?
Error. Id: 3010, Code: 420, Msg: Invalid Real-time Query:No data of type DayChart is available for the exchange 'SMART' and the security type 'Index'' and '5 secs'

I am able to fetch historical quotes for SPX , also have tried realTimeBars for other stocks/symbols. Only while trying to pull spx real time bars i am hitting this issue.?

Has any one tried this before? am i missing something??



 

I'm a bit confused by your question. The code snippet is for SPY stock, but the error is for SPX index. SPY trades on a bunch of exchanges, and the SMART exchange collects data for all of them. However, the SPX index is only published by CBOE, so if that is what you're looking for, try something like this:

Contract contract = new Contract();
contract.symbol("SPX");
contract.secType("IND");
contract.currency("USD");
contract.exchange("CBOE");
m_client.reqRealTimeBars(3010, contract, 5, "TRADES", false, null);


 

sorry my bad. i had initially tried for SPX then later was trying to see if SPY is working . hence when i pasted the code snippet it was SPY.?
But originally my intention was to get real time bars for SPX.
The code you had posted seems to be working. thanks alot. The mistake i had done , when i was originally trying SPX was
contract.exchange("SMART")?
contract.primaryExchance("CBOE")

the above two lines seems to be the issue, in your snippet you are setting the exhange to CBOE which seems to be helping.? ?

thanks again?