Trading volumes where lot step size is 0.01 when API says volume is of type long?

Created at 09 Oct 2016, 17:07
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
kdcp999's avatar

kdcp999

Joined 09.10.2016

Trading volumes where lot step size is 0.01 when API says volume is of type long?
09 Oct 2016, 17:07


Hi Folks

Building a bot that works with a micro account.

Currently I have an automated lot size calculator. The issue here is as follows:
I have X amount of money equating to 5.34 lots in lot steps of 0.01.
When I convert this to a long type(because the cAlgo API insists volume to be of type long) - I lose the 0.34 lots I wanted to trade. Obviously the cast truncates the precision.

Example:

Decimal this_is_a_decimal = 5.34
(long)this_is_a_decimal  == 12  // long types don't have precision 

But I don't want 5 lots I want 5.34 lots?

Any ideas - Also the "Normalize" method returns a "long" type. Hence no 0.01 precision either.

Thanks 

David


@kdcp999
Replies

kdcp999
09 Oct 2016, 17:11

RE:

haha you can't edit you own post!  O_O
There is obviously a typo in my example. sorry about that.

The example code should read:

Decimal this_is_a_decimal = 5.34
(long)this_is_a_decimal  == 5  // long types don't have precision 

 



kdcp999 said:

Hi Folks

Building a bot that works with a micro account.

Currently I have an automated lot size calculator. The issue here is as follows:
I have X amount of money equating to 5.34 lots in lot steps of 0.01.
When I convert this to a long type(because the cAlgo API insists volume to be of type long) - I lose the 0.34 lots I wanted to trade. Obviously the cast truncates the precision.

Example:

Decimal this_is_a_decimal = 5.34
(long)this_is_a_decimal  == 5  // long types don't have precision 

But I don't want 5 lots I want 5.34 lots?

Any ideas - Also the "Normalize" method returns a "long" type. Hence no 0.01 precision either.

Thanks 

David

 


@kdcp999

kdcp999
09 Oct 2016, 17:11

RE:

haha you can't edit you own post!  O_O
There is obviously a typo in my example. sorry about that.

The example code should read:

Decimal this_is_a_decimal = 5.34
(long)this_is_a_decimal  == 5  // long types don't have precision 

 



kdcp999 said:

Hi Folks

Building a bot that works with a micro account.

Currently I have an automated lot size calculator. The issue here is as follows:
I have X amount of money equating to 5.34 lots in lot steps of 0.01.
When I convert this to a long type(because the cAlgo API insists volume to be of type long) - I lose the 0.34 lots I wanted to trade. Obviously the cast truncates the precision.

Example:

Decimal this_is_a_decimal = 5.34
(long)this_is_a_decimal  == 5  // long types don't have precision 

But I don't want 5 lots I want 5.34 lots?

Any ideas - Also the "Normalize" method returns a "long" type. Hence no 0.01 precision either.

Thanks 

David

 


@kdcp999

kdcp999
09 Oct 2016, 17:11

RE:

haha you can't edit you own post!  O_O
There is obviously a typo in my example. sorry about that.

The example code should read:

Decimal this_is_a_decimal = 5.34
(long)this_is_a_decimal  == 5  // long types don't have precision 

 



kdcp999 said:

Hi Folks

Building a bot that works with a micro account.

Currently I have an automated lot size calculator. The issue here is as follows:
I have X amount of money equating to 5.34 lots in lot steps of 0.01.
When I convert this to a long type(because the cAlgo API insists volume to be of type long) - I lose the 0.34 lots I wanted to trade. Obviously the cast truncates the precision.

Example:

Decimal this_is_a_decimal = 5.34
(long)this_is_a_decimal  == 5  // long types don't have precision 

But I don't want 5 lots I want 5.34 lots?

Any ideas - Also the "Normalize" method returns a "long" type. Hence no 0.01 precision either.

Thanks 

David

 


@kdcp999

... Deleted by UFO ...

kdcp999
09 Oct 2016, 21:48

Hi Thanks for the reply. I am not sure I understand. That method will essentially do exactly the same thing I am doing in my example code. But I must admit I am probably missing something. The very fact that the function you suggested is of type "long" means that my precision value will be truncated. Or in the case of the function your suggested. Rounded down to the nearest whole number i.e 5 instead of 5.34 .. I should be able to make a trade using a volume value of exactly 5.34 lots... Not just whole numbers like 1,2,3...etc Any ideas?
@kdcp999

lezdoria
03 Mar 2017, 14:25

Hello kdcp999,

did you find a solution for that problem?

More brokers are offering micro-lots, not only to exponentially expand their customer base to enormous low-budget retail traders market, but also because it opens to a mutch better money-risk management.

According to my tests, at the moment cAlgo does not support micro-lots (cTrader does) but we are all here to automate our trading and not to step back to manual

This is why cAlgo API wants long volume type

So, for example, it's impossible to open 0.1 or 0.01 Germany30 index that is the micro-accounts value-added

I personally think Spotware should support micro-accounts because of the huge benefits for traders, brokers and Spotware itself

Any plan about it ?

Thanks
Lorenzo


@lezdoria

kricka
03 Mar 2017, 15:17

lezdoria, I fully agree with you that Spotware and the liquidity providers should support micro lots with indices and other CFDs. As you mentioned it has to do with proper risk & money management, even if one trades with larger accounts. 


@kricka