Broker API - Live tick volume -> BrokerAsset *pVolume

Posted By: AndrewAMD

Broker API - Live tick volume -> BrokerAsset *pVolume - 11/02/17 13:54

jcl,

Background:

In my DLL, I have two TCP sockets, one for history and one for everything else. I do not want Zorro to make BrokerHistory2 calls just to get volume, because it would have to reconnect the history socket just to get a tiny bit of data - and then disconnect. Alas, this is in the manual:

Quote:
pVolume: Optional output, recent trade volume of the asset per minute, or 0 when the volume is unavailable. If no volume is returned in this function, Zorro retrieves it with a BrokerHistory2 call.


On the main socket, I have to subscribe to an asset. This will cause the server to stream an endless number of updates for that asset. Thus, I might have to set up a listener on its own thread (or otherwise buffer messages upon every DLL call).

Question #1
: How do I set the pVolume value? The below algorithm is a reset once-per-minute scheme. Is this the correct approach?

1. Assume BrokerAsset is called frequently.
2. Upon subscription, set pVolume to 0.
3. As ticks arrive, increment pVolume by new volume received this minute.
4. At the beginning of every minute, reset pVolume to 0.
5. Repeat steps 3 & 4 for the duration of trading.

Question #2
: If I initially set pVolume to 0 (with the intent of updating it later), is Zorro always going to call BrokerHistory2?
Posted By: Dalla

Re: Broker API - Live tick volume -> BrokerAsset *pVolume - 11/03/17 14:59

I asked this during development of the IG plugin
"... related to the BrokerAsset call, variable pVolume.
The manual states:

"Optional output, recent trade volume of the asset per minute, or 0 when the volume is unavailable. If no volume is returned in this function, Zorro retrieves it with a BrokerHistory2 call."

Ig provides volume, but I'm unsure what is meant by "recent trade volume of the asset per minute".
Should I just put the total volume for the previous minute, or an average over the previous X minutes, or accumulated volume for the current minute?"


And the answer
"We recommend returning the average volume of the previous 5 minutes divided by 5. That's what the BrokerHistory2 call does."

In the IG plugin I make one initial call to brokerHistory2 to initialize the pVolume, then update it every limit with the rolling 5 min average.

Hope this helps.
Posted By: AndrewAMD

Re: Broker API - Live tick volume -> BrokerAsset *pVolume - 11/03/17 15:28

This is helpful.

Question #3: What if the market is dead for some reason, and the volume is actually zero, so I say *pVolume = 0 in the middle of trading.

In this case, would Zorro start getting volume from BrokerHistory2 (much to my chagrin)?
Posted By: Dalla

Re: Broker API - Live tick volume -> BrokerAsset *pVolume - 11/03/17 20:57

I haven't really thought about this, but the manual says
"Optional output, recent trade volume of the asset per minute, or 0 when the volume is unavailable. If no volume is returned in this function, Zorro retrieves it with a BrokerHistory2 call."

I would think that returning 0. Not returning anything at all is what triggers a call to BrokerHistory2.
Posted By: jcl

Re: Broker API - Live tick volume -> BrokerAsset *pVolume - 11/03/17 23:05

This info in the manual was in fact outdated. Zorro does not call BrokerHistory2 when no volume is available. The volume is then zero.

Also, the volume is not strictly volume per minute anymore. It is up to the plugin what's returned in the fVol and pVolume parameters. It can be volume per minute, trade volume, quote volume, tick frequency, or anything that has something to do with supply and demand that asset. It should only be consistent in history and live trading.
Posted By: AndrewAMD

Re: Broker API - Live tick volume -> BrokerAsset *pVolume - 11/06/17 17:54

Obligatory relevant thread cross-reference:

Feature request: new brokercommand GET_BROKERASSET_VOLUME_TYPE
© 2024 lite-C Forums