API Support Forum
OEC API > API Support > How do I get the volume of trades on a contract?
Author Topic: How do I get the volume of trades on a contract?
(4 messages, Page 1 of 1)
Moderators: VPfau
eo707
Posts: 68
Joined: Nov 08, 2011


Posted: Feb 08, 2012 @ 01:50 PM             Msg. 1 of 4
I am getting data with the OnPriceChagne event:
http://www.openecry.com/api/api/OEC.API.OnPriceChangedEvent.html

In it I have the Price (which is the CurrentPrice of the contract).
http://www.openecry.com/api/api/OEC.API.PriceMembers.html

The closest think I can refer to what I am looking for will be the LastVol field:
http://www.openecry.com/api/api/OEC.API.Price.LastVol.html

When I record data and calculate the SUM of the LastVol for a time frame and I try to compare with the Bar on my software I am getting different numbers.

On the bards I can see volume of 2100, and the sum of the LastVol accumulate 185..

I am looking to the the real volume, like I see in the trading software.

Can you help?

Thank you.
I
RuslanK
Posts: 69
Joined: Jun 02, 2010


Posted: Feb 08, 2012 @ 02:11 PM             Msg. 2 of 4
Hello,

The OnPriceChanged event may not occur for every trade - because trades are throttled by our servers, so may trades may come as one price update. That's why sum of LastVol does not correspond to what you see in day bar.

There are two alternatives for you:
1. Instead of accumulating LastVol manually you can use TotalVol field of Price object. This field contains most accurate sum of volume for all trades since session started.
2. If for some reason you need to sum volumes - you should subscribe to ticks instead of subscribing to quotes (please use SubscribeTicks method to do this) and then you should implement your code in a handler for OnTicksReceived event.

Please let me know if you have any questions.

Ruslan Kartokhin
Software Developer
eo707
Posts: 68
Joined: Nov 08, 2011


Posted: Feb 09, 2012 @ 03:03 AM             Msg. 3 of 4
I really appreciate your detailed response.
I have set to record the TotalVol for the next days on..

Another question related... Thank you.
I wish to get record of a very short time in history.
on Feb 03, I have specific hours/minute span that I wish to get.
But I want to get the feed of the OnPriceChagne event..

Do you allow it?

I want to analyze that data.

Thank you.
I
RuslanK
Posts: 69
Joined: Jun 02, 2010


Posted: Feb 09, 2012 @ 08:25 AM             Msg. 4 of 4
Hello,

You cannot load historical data for quotes, but you always can load trades. To do this you can use RequestTicks method which allows to load ticks for a specific period of time.

Please keep in mind that we're limiting available tick data by three business days.

Ruslan Kartokhin
Software Developer