As the title indicates, it is now possible, following an update of today, to have quantities of lots / contracts / shares with decimals!
Thus, we can now buy 1.25 contracts on the DAX for example:
BUY 1.25 CONTRACTS AT MARKET
The accuracy is 2 decimal places, and there is a minimum amount defined by IG per instrument (visible in the quantity selector in manual trading).
The calculation of market exposure will now be much more precise, it seemed important to point out! This is very important information 🙂 Do not hesitate for any questions!
Thanks! But it is not possible during back-testing?
It should work also with backtesting, why this question? Did you encounter a problem?
Yes, I actually tried it yesterday before I read this, but I guess I messed up the code. It worked perfectly today!
I called IG today and asked for some details.
In the DAX, for example, minimum size is still 1 mini contract.
However, it is now possible to buy 1.25 contracts, as Nicolas pointed out.
The position size in fractions of a contract has to be coded with exactly 2 decimals (or less), otherwise the order will be rejected by IG.
If your code calculates position size by some other algorithm (from the previous strategy profit, for example), you have to make sure that the position size turned over to IG has only 2 decimals.
For example, the following code ensures that you will have only 2 decimals maximum for the position size :
n = 1 + (strategyprofit / 145)
n = round(n * 100)
n = n / 100
buy n contracts at market
This will avoid to say “buy 1.35768 contracts at market”, but will instead send “buy 1.36 contracts at market” to IG, which will be OK.
Thank you, that’s very helpful.
Two questions –
- How do I get the new code, I can’t see how to update.
- When I have an instrument autotrading according to a trading system, I may want to change a parameter in the system or the code itself (as here, with the decimals amendment), but I can’t find a way to do that without the laborious process of deleting the system from AutoTrading, then adding back after making the alteration to the system. Is it possible to amend the system without needing to do that? If you’ve got lots of instruments trading, it takes a lot of time changing them all.
OK, thank you that’s clear.
Yes the code works, when I backtest I get position sizes to 2 decimal places, but when I dummy trade position sizes are whole numbers (1 or 10 so far today)?
No, sorry, I mean when I’m using ProOrder AutoTrading to trade a demo spreadbet account on IG Index.
Real and demo accounts with IG should have now this possibility. Are you sure you have changed your code accordingly to trade lot with decimals?
Nicolas, you’re correct! I’m really sorry, I backtested using the code with the rounding which worked properly, then I looked at current trades, which are using my old code without the rounding. I’m sure it’ll be OK now, my apologies.
I tried the:
= 1 + (strategyprofit / 145)
n = round(n * 100)
n = n / 100
buy n contracts at market
in a strategy that I was back-testing and it appeared to not sell out all of the positions bought. It was a BUY only strategy and the detailed report showed short trades when none had been taken and a time in the market of over 90% when in fact it should have been about 5%. I could see on the positions graph a fine line of pips still open that should have been sold. Any ideas why this should happen as I don’t want to add it to a live strategy until I know it will close all of a position.
@Vonasi
If you “SELL AT MARKET”, all your positions should be closed. Is it the instruction you have used in your code?
Yes that was the instruction that I used as far as I recall (testing lots of ideas at the moment so I can’t even recall which strategy it was that I noticed this on!) I’m in the middle of a walk forward at the moment but once that has finished I’ll modify this strategy and see if it does it again.
Thinking about it it may have been a strategy with cumulative positions that showed the problem.