API Support Forum
OEC API > API Support > Volume Format
Author Topic: Volume Format
(7 messages, Page 1 of 1)
Moderators: VPfau
estrader
Posts: 55
Joined: May 04, 2007


Posted: May 08, 2007 @ 03:40 PM             Msg. 1 of 7
How do I format volume so that there are 0 decimal places?

lbVolume.Text=string.Format("Last Volume {0}",
Contract.PriceToString(Contract.CurrentPrice.LastVol));


The above formats to 2 decimal places.
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: May 08, 2007 @ 03:46 PM             Msg. 2 of 7
volume is an integer value, so you should not format it using Contract.PriceToString method.

the default formatting, like

lbVolume.Text=string.Format("Last Volume {0}", Contract.CurrentPrice.LastVol);

is enough.
estrader
Posts: 55
Joined: May 04, 2007


Posted: May 08, 2007 @ 03:53 PM             Msg. 3 of 7
Excellent. Thanks. Same thing with LastDateTime?
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: May 08, 2007 @ 04:17 PM             Msg. 4 of 7
PriceToString is used only for price values, such as last, ask, bid, open, close, high, low and settlement. It formats values using given contract parameters : tick size, decimal places and divisor (for tick sizes such as 1/32).

Also note that LastDateTime value is in UTC - you may want to convert it to local time.
estrader
Posts: 55
Joined: May 04, 2007


Posted: May 09, 2007 @ 03:02 AM             Msg. 5 of 7
Thanks again for your assistance. I am slowly working my way through the Example API whilst learning C# at the same time. It's a great language but I am not familiar with the syntax. I have managed to display LastDateTime but converting it will be my next task.
estrader
Posts: 55
Joined: May 04, 2007


Posted: May 09, 2007 @ 03:13 AM             Msg. 6 of 7
Thanks again for your help skorostelyoff. Maybe this is a more appropriate area for this thread. I am working through the Example API and learning C# at the same time. I am not familiar with the syntax. I have managed to display LastDateTime but converting the time to local will be my next learning curve. I also just want to just display the time without the date as well.
Edited by estrader on May 9, 2007 at 03:13 AM
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: May 09, 2007 @ 08:16 AM             Msg. 7 of 7
Sorry, I did not provide an example:

LastDateTime.ToLocalTime() converts its UTC value to local time of user's computer.
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: May 09, 2007 @ 08:51 AM             Msg. 8 of 7