Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 552 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 4 1 2 3 4
Oanda LotAmount in Trade Mode #484570
11/12/21 14:37
11/12/21 14:37
Joined: Sep 2020
Posts: 15
Toronto, Canada
J
JayWilly Offline OP
Newbie
JayWilly  Offline OP
Newbie
J

Joined: Sep 2020
Posts: 15
Toronto, Canada
Has anyone come across an issue with the LotAmount when trading Index CFDs with Oanda?

Correct me if I am wrong on this as I have been banging my head against the wall for the past couple days trying to figure this out.

There is an issue with how LotAmount and Lots are treated when in Trade mode for Index CFDs with Oanda. There is no issue when trading currencies. The requested AssetList provided by Oanda is correct with all their Index CFDs having LotAmount = 0.1. See included AssetList. The PIPCost reflects CAD currency as I am in Canada.

In Train and Test modes, all the relevant calculated positions sizes and performance values are correct. The problem comes about in Trade mode. Zorro executes the number of Lots, which to Zorro, represents (Lots * LotAmount) number of contracts in position size. So a 5 Lots execution represents 0.5 Index contracts, 5 Lots * 0.1 LotAmount. But to Oanda, the number of Zorro Lots being transacted, 5 in this example, represents (5 / 0.1) = 50 contracts of 0.1 LotAmounts, which is 10 times more than what is intended.

As you can see from a current NAS100 position in the table below pulled from the Zorro HTML Trading Status page, the Risk calculation of -$237 does not make sense for 27 Lots of 0.1 LotAmounts with a Stop distance from Entry to Stop of (16187 – 16257) = -70 PIPS. Using the PIPCost from the AssetList above, the Risk calculation should be -$2,339 ((27/0.1) * 70 * 0.123762), as to Oanda, the 27 Lots is 270 contracts of 0.1 LotAmounts. The Profit calculation of $3,861 in the table makes sense. There is also the CN50 position of 4 Lots listed.


Trade ID Lots Entry Time Entry Price Stop Trail Target Risk Profit Pips
[NAS100/USD:Trend:S00035] 35 27 11/10/2021 01:00 16187 16070 16257 15914 14985 -237$ 3861$ 1149.6p
[CN50/USD:Trend:L00047] 47 4 11/10/2021 08:00 15398 15580 14860 15780 16124 -267$ 922$ 1862.3p



I looked at changing the PIPCost by using SET_PATCH to accommodate the issue but realized that by making this adjustment, there would be unintended consequences of how Zorro calculates position sizes as I use the Risk trade parameter. I could also calculate the adjusted Lot amounts within the script to be sent to Oanda for execution but that defeats the whole purpose of Zorro’s functionality.

Oanda made changes to their Index CFD sizing earlier this year reducing the minimum trade size (LotAmount) from 1 to 0.1, which may not have been adjusted in the Oanda API. This, therefore, could be a bug with the API.

Has anyone experienced this?

I am using Zorro version 2.40.9.

Thanks, Jay

Attached Files
AssetsInd.csv (130 downloads)
Re: Oanda LotAmount in Trade Mode [Re: JayWilly] #484572
11/12/21 16:14
11/12/21 16:14
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
If your lot amount is wrong, check with Oanda which lot amount you really have on your account, and enter it in your CSV file. Oanda MT4 and Oanda API can have different lot amounts for the same asset.

Re: Oanda LotAmount in Trade Mode [Re: JayWilly] #484574
11/13/21 17:03
11/13/21 17:03
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline
User
MatPed  Offline
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
I have the same issue. I have received no support from Oanda and little from Zorro. I am trying an updated AssetFix, I will share my findings if positive. Ciao

Re: Oanda LotAmount in Trade Mode [Re: JayWilly] #484577
11/13/21 20:43
11/13/21 20:43
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
When this issue only occurs in trade mode, then you can use this condition to calculate a different lot size

Code
if(is(TRADEMODE))
{
Lots = ...;//Lots in trade mode
}
else
{
Lots = ...;//Lots in train or test mode
}


Hope this helps.

Re: Oanda LotAmount in Trade Mode [Re: JayWilly] #484579
11/14/21 05:19
11/14/21 05:19
Joined: Sep 2020
Posts: 15
Toronto, Canada
J
JayWilly Offline OP
Newbie
JayWilly  Offline OP
Newbie
J

Joined: Sep 2020
Posts: 15
Toronto, Canada
I will use your suggestion this coming week Grant. Thanks very much.

I have a query out to Oanda support about this as per Petra's suggestion with regards to the issue being account specific settings on Oanda's end. Will report back when hear anything.

Re: Oanda LotAmount in Trade Mode [Re: JayWilly] #484681
11/30/21 06:14
11/30/21 06:14
Joined: Sep 2020
Posts: 15
Toronto, Canada
J
JayWilly Offline OP
Newbie
JayWilly  Offline OP
Newbie
J

Joined: Sep 2020
Posts: 15
Toronto, Canada
After multiple conversations, I was finally able to get a firm answer on the issue with Oanda. The minimum trade size for Index CFDs is 0.1 units. The issue is that the Amount variable in Zorro is defined as an integer and this needs to move to being able to handle 1 decimal place. Oanda's v20 API interpretation of Lot = 2 and Amount = 2 are the same whereby the order/trade recognized by Oanda is 20 units of 0.1 Index values. Adjusting the AssetList CSV file for Zorro to recognize the size of 1 lot being 0.1 is not being interpreted the same by Oanda. Sending an order where Lots = 23 is not 2.3 units of the Index contracts, as Zorro currently interprets it with the adjustment in the AssetList CSV file, but it is 230 units of 0.1 Index units. Sending an order with the variable Amount = 2.3 results in the truncation of the decimal place since the Amount variable can only be an Integer, which makes the Amount = 2 and then becoming 20 units of 0.1 with Oanda. Same applies to the Lots variable when equals a decimal value.

As discussed before, when in Training and Testing modes, the calculations are accurate but in Trade mode, the orders are 10 times larger and Oanda does not recognize a Lot size being 0.1.

How can this be accommodated in either the Oanda API or Zorro?

Re: Oanda LotAmount in Trade Mode [Re: JayWilly] #484684
11/30/21 09:46
11/30/21 09:46
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
The Amount variable is no integer. Maybe you confused it with Lots?

If LotAmount is 0.1 then 5 Lots is the same as 0.5 Amount.

Oanda lot sizes and other parameters depend on country and platform, so the included asset list could indeed be not suited for your account. Check your asset parameters with Oanda, then adapt your asset list as described on https://manual.zorro-project.com/account.htm. Do NOT use different lots in test and trade mode, this is a recipe for disaster. If in doubt, we also have an asset list setup service.

Re: Oanda LotAmount in Trade Mode [Re: Petra] #484686
11/30/21 14:51
11/30/21 14:51
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
Originally Posted by Petra
Do NOT use different lots in test and trade mode, this is a recipe for disaster.


Oops, my bad.

Re: Oanda LotAmount in Trade Mode [Re: Petra] #484690
12/01/21 05:43
12/01/21 05:43
Joined: Sep 2020
Posts: 15
Toronto, Canada
J
JayWilly Offline OP
Newbie
JayWilly  Offline OP
Newbie
J

Joined: Sep 2020
Posts: 15
Toronto, Canada
Thanks for the reply Petra.

The Lots variable is indeed an integer.

I agree with your LotAmount example. The only problem is that Oanda recognizes the 5 Lots as 5.0 Amount or 50 x 0.1, which is 10 times more than desired with LotAmount set as 0.1 in the AssetList table as provided in my initial Post above. Editing the AssetList does not matter as any integer value sent as Lots will be 10 times the expected amount. As it currently stands, I have to divide the Lots calculated by Zorro before the order is sent to Oanda by 10 and manage any resulting decimals by rounding up or down while using the suggested code by Grant above to distinguish when in TRADEMODE and TESTMODE for the Risk and Profit calculations to be correct. There will always be a discrepancy between the trade sizes calculated in Train /Test mode versus Trade mode unless I round the calculated amounts in Test/Train mode up to the next highest decimal place to match the behavior of what would happen in Trade mode. As you stated, using different lots in test and trade mode "is a recipe for disaster" but I understand where the issues are and have made accommodations for them.

The better option is to live with the fact that I cannot take advantage of the smaller sizes offered by Oanda and adjust the LotAmount in the AssetList table to 1 rather than 0.1 in order for the Profit and Risk calculations done by Zorro to be consistent in TRADEMODE and TESTMODE, which would match Oanda's calculations. This option would, unfortunately, require a much larger account to trade a diversified portfolio of assets to include most of the CFD Indices since the position sizes would be larger requiring more margin. I would also need to use the SET_PATCH brokerCommand to use my AssetList which should override what Oanda provides as the asset parameters.

The best option would be to edit the Oanda API to accommodate how the Oanda v20 API handles the reduced minimum CFD trade size to one decimal place they implemented earlier this year as this is a global change, not a country change, given one user from Italy had the same experience as mentioned by the user in a previous post.

Please let me know if this make sense and what can be done, if anything, to be able to accommodate the smaller CFD Index minimums offered by Oanda. Thanks.

Re: Oanda LotAmount in Trade Mode [Re: JayWilly] #484691
12/01/21 10:12
12/01/21 10:12
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
If Oanda recognizes the 5 lots as 5 contracts, then the live lot amount was obviously 1, not 0.1. Change it to 1 in the asset list and make sure that the size is then correct in test and trade mode. And check also with Oanda why they told you it was 0.1 when in fact it was 1. Maybe your account was not yet updated to 0.1 or that server returned a wrong value.

Page 1 of 4 1 2 3 4

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1