I’m new to Tradovate. I’ve been following the example-api-js tutorial in github to request realtime market data (example-api-js/tutorial/WebSockets/EX-08-Realtime-Market-Data at main · tradovate/example-api-js · GitHub). I can connect fine to the API but when I make a md/subscribequote or md/getchart request it does not render any quote or chart data. It just makes a https://demo.tradovateapi.com/v1/contract/find?name=MSFT request and noting else happens.
Market data subscription was bought for the current month as well as API access.
What am I doing wrong?
You most likely are connected but not catching any responses or events.
Your request to https://demo.tradovateapi.com/v1/contract/find?name=MSFT
should return a JSON response that looks like this:
{
"id": 2586692,
"name": "MSFT",
"contractMaturityId": 45734,
"status": "DefinitionChecked",
"providerTickSize": 0.01
}
Thanks for the response. Yes, I receive that JSON response.
But then I always receive this response in the data variable in the switch in the code below:
Using this code from the tutorial:
TradovateSocket.prototype.subscribe = async function({url, body, subscription}) {
...
const realtimeId = response?.d?.realtimeId || response?.d?.subscriptionId
if(body?.symbol && !body.symbol.startsWith('@')) {
const contractRes = await tvGet('/contract/find', { name: body.symbol })
contractId = contractRes?.id || null
if(!contractId) {
contractId = await tvGet('/contract/suggest', {name: body.symbol })[0].id
}
}
...
return new Promise((res, rej) => {
switch(url.toLowerCase()) {
...
case 'md/subscribequote': {
cancelUrl = 'md/unsubscribequote'
cancelBody = { symbol: body.symbol }
if(this.listeningURL !== MD_URL) rej('Cannot subscribe to Quote Data without using the Market Data URL.')
removeListener = self.addListener(data => {
if(data.d.quotes) {
data.d.quotes.forEach(quote => quote.contractId === contractId ? subscription(quote) : noop())
}
})
break
}
}
...
})
}
I’m not sure if Tradovate streams equity data. Try inputting a futures contract like ESU4
.