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.
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
Re: Oanda LotAmount in Trade Mode
[Re: JayWilly]
#484572 11/12/2116:1411/12/2116:14
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/2117:0311/13/2117:03
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/2120:4311/13/2120:43
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/2106:1411/30/2106:14
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/2109:4611/30/2109:46
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/2114:5111/30/2114:51
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/2110:1212/01/2110:12
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.