PureBytes Links
Trading Reference Links
|
Instead of using AbsValue use Round...
For Example:
Var: increment(0.05)
Round (40.23 * ( 1 / increment ), 0) * / ( 1 / increment );
I think the built-in uses AbsValue.
RM
----- Original Message -----
From: "Ivo Karindi" <ivo@xxxxxxxxx>
To: <omega-list@xxxxxxxxxx>
Sent: Monday, September 27, 2004 2:17 PM
Subject: Rounding to nearest price fraction?
Long story short - I need to program a function that will round my
calculated price for a few commodities (NG, KC, ED, CL) to the nearest
price fraction actually accepted by the broker.
For example, 40.23 has to be rounded to 40.25, not 40.20. I do know
that the built-in function Round2Fraction exists, but still want to
write my own routine as often the fractions change. For exapmle, there
are times when 0.25 only is accepted for KC, at other times it's 0.05,
and I don't want to mess with Global Server constantly in this regard
- I want to change this only once inside my function when needed and
be done with it. So I'm wondering if there are any suggestions in terms of
*simple* algorithms to accomplish this - the main objective is to
avoid any unnecessary loops etc., and accomplish this with as few lines
of code & wasted cpu cycles as possible.
TIA,
Ivo Karindi
|