Hello all, I'm trying to run some backtests on custom data and for that I have defined a custom tick and then a custom instrument, like this
var properties = new SymbolProperties("EUR", "USD", 1, 0.00001m, 1, "EURUSD");
var exchangeHours = SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork);
this._symbol = this.AddData<MyTick>("EURUSD", properties, exchangeHours, Resolution.Tick).Symbol;
The test reads the data correctly and runs the algorithm. The problem is the profit is calculated incorrectly.
For example for the first closed trade, the two orders are:
2020-01-07 09:00:00,EURUSD,Buy,1,1.11955
2020-01-08 08:00:00,EURUSD,Sell,-1,1.115395
And if I check the portfolio, the recorder transaction value is: -0.0041550
This looks like the engine doesn't use any multiplier or lot size, and it just computes a subtraction between the two prices. I checked the securities database and for Oanda EURUSD, the lot size is 1, and the contract multiplier is 1, which is why I put the same numbers when creating my custom instrument.
What am I missing?
Nico Xenox
Hey AlexP,
did you use the last trade profit?
Best,
Nico
Alex P
Hi Nico,
if I check the last trade profit, it looks the same, very low.
To clarify here, I don't know how to set it up so that the system knows when I say “buy 1”, then the system knows that means a whole lot. So, basically, how to set up a lot size?
I tried setting lotSize to 100000, but then when I want to create an order for one lot, I get this message:
Alex P
if I set contractMultiplier to 100000, and lotSize to 1, then it seems to work properly, but I'm not sure this is the correct setup because I saw the instruments set for oanda in the database and it's not like that.
Nico Xenox
Hey Alex P,
you can find the lot size for each pair here:
Lot size in this case would be 1 for EURUSD(oanda). You will have to increment your size in these steps. The multiplier is the contract size. You can define it doing a simple calculation with risk and distance(pip) in this case it is (0.00001):
let’s say you had a risk of 20$ and pip movement of 20
Order size = risk / distance = 20$ / 0.00002 = 1000000
this would be your multiplier.
Best,
Nico
Alex P
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!