In particular I would like to make the system a lot faster, since it will allow parameter searches to be carried out in a reasonable time. While Python is a great tool, it's one drawback is that it is relatively slow when compared to C/C++. Hence I will be carrying out a lot of profiling to try and improve the execution speed of both the backtest and the performance calculations.
In particular I've made the interface for beginning a new backtest a lot simpler by encapsulating a lot of the "boilerplate" code into a new Backtest class. I've also modified the system to be fully workable with multiple currency pairs. In this article I'll describe the new interface and show the usual Moving Average Crossover example on both GBP/USD and EUR/USD.
(Note that the leverage shown in Trades 2 and 3 is available for Professional clients only. A Professional client is a client who possesses the experience, knowledge and expertise to make their own investment decisions and properly assess the risks that these incur. In order to be considered to be Professional client, the client must comply with MiFID ll 2014/65/EU Annex ll requirements.)
Maintenance margin for commodities is the amount that you must maintain in your account to support the futures contract and represents the lowest level to which your account can drop before you must deposit additional funds. Commodities positions are marked to market daily, with your account adjusted for any profit or loss that occurs. Because the price of underlying commodities fluctuates, it is possible that the value of the commodity may decline to the point at which your account balance falls below the required maintenance margin. If this happens, brokers typically make a margin call, which means you must deposit additional funds to meet the margin requirement.
Brokers use margin levels in an attempt to detect whether FX traders can take any new positions or not. Different brokers have varying limits for the margin level, but most will set this limit at 100%. This limit is called a margin call level. Technically, a 100% margin call level means that when your account margin level reaches 100%, you can still close your positions, but you cannot take any new positions.
Local Portfolio Handling - In my opinion carrying out a backtest that inflates strategy performance due to unrealistic assumptions is annoying at best and extremely unprofitable at worst! Introducing a local portfolio object that replicates the OANDA calculations means that we can check our internal calculations while carrying out practice trading, which gives us greater confidence when we later use this same portfolio object for backtesting on historical data.