Realtime Quote for Crypto

I have developed a plugin for crypto. Total volume, trade size, Bid size and Ask size for a crypto are not integer.

I assign data like that:

rt->fOpen = (float)query.getColumn(column++).getDouble();
rt->fHigh = (float)query.getColumn(column++).getDouble();
rt->fLow = (float)query.getColumn(column++).getDouble();
rt->fLast = (float)query.getColumn(column++).getDouble();
rt->fTradeVol = (float)query.getColumn(column++).getDouble();
rt->iTradeVol = rt->fTradeVol;
rt->fTotalVol = (float)query.getColumn(column++).getDouble();
rt->iTotalVol = rt->fTotalVol;
rt->fPrev = (float)query.getColumn(column++).getDouble();
rt->fChange = rt->fLast == 0 ? 0 : (rt->fLast - rt->fPrev);
rt->fBid = (float)query.getColumn(column++).getDouble();
rt->iBidSize = query.getColumn(column++).getInt();
rt->fAsk = (float)query.getColumn(column++).getDouble();
rt->iAskSize = query.getColumn(column++).getInt();

fTradeVol and fTotalVol are assigned but no luck (not showed in the window but iTradeVol and iTotalVol), there are not fBidSize and fAskSize! Any way to show fTradeVol and fTotalVol in Realtime Quote? And Is there any way to work around with AskSize and BidSize?

Beside that, when Post a WM_USER_STREAMING_UPDATE, Amibroker seem to call GetQuoteEx for all symbols in chart tabs? Is that normal?


::PostMessage(_ab_wnd, WM_USER_STREAMING_UPDATE, (WPARAM)si->GetSymbolPtr()->c_str(), (LPARAM)rt);

thanks,

PostMessage is asynchronous call (it returns immediately, but data that you pass will be used LATER). In your code are calling PostMessage with pointer that might be volatile ( si->GetSymbolPtr()->c_str(),) and may be invalid at the time it is processed. You need to make sure that the pointer you are passing is VALID for ALL the lifetime of application (it is NOT on stack and it is not freed or changed).

GetQuotesEx is sent for symbols that AmiBroker needs data for. It is NOT constant, it asks for data WHEN and only IF it really needs them (to update chart, perform Analysis) and only IF change notification for given symbol was sent or it needs data just because it doesn't have them (say you have old data in database or you just added symbol).

Bid/Ask size is integer just because it was meant for stocks, futures and options, not for cryptos.

Generally you don't try to "optimize" things, because they are optimum already.

1 Like

"si" and also "rt" are "new"ed then I think they are persistent.

should I store "LPCTSTR pszTicker" when GetQuoteEx and GetRecentInfo were called to use latter?

Why there are

float fTradeVol;// NEW 5.27 field
float fTotalVol;// NEW 5.27 field

But Amibroker does not use them when assigned? What are they for?

It uses them. Check GetRTData() and you will see.

I am developing data plugin! I think there is no this interface.

As I wrote, it was designed to work with stocks, futures and options, that naturally come in integer quantities.

1 Like

What he meant is use GetRTData in AFL, you seem to be looking in the plugin.

Also, from my notes, it is like this: And it was using version 6.10.x64

  1. Both RT Quote window and AFL::GetRTData("TradeVolume") use ri->iTradeVol
  2. If you see quote editor or actual volume(AFL::V), they use the newer ri->fTotalVol
printf("itv = %g\n", GetRTData("TradeVolume")); // what is in iTradeVol
printf("ftv = %g\n", V[BarCount-1]); // float

so if you dont set ri->iTradeVol, you will see garbage value.
In your plugin, you should set both or clear to 0.

k = j->FindMember("v");
if (k != j->MemberEnd()) {
	ri->fTradeVol = k->value.GetFloat();
	ri->iTradeVol = static_cast<int>(ri->fTradeVol);
}
else { ri->iTradeVol = 0;	ri->fTradeVol = 0; }
1 Like