To date, we've been experimenting with the OANDA Rest API in order to see how it compared to the API provided by Interactive Brokers. We've also seen how to add in a basic portfolio replication element as the first step towards a proper event-driven backtesting system. I've also had some helpful comments on both previous articles (#1 and #2), which suggests that many of you are keen on changing and extending the code yourselves.
Currency markets are important to a broad range of participants, from banks, brokers, hedge funds and investor traders who trade FX. Any company that operates or has customers overseas will need to trade currency. Central banks can also be active in currency markets, as they seek to keep the currency they are responsible for trading within a specific range.
Now, let’s say you open a trade worth $50,000 with the same trading account size and leverage ratio. Your required margin for this trade would be $500 (1% of your position size), and your free margin would now also amount to $500. In other words, you could withstand a negative price fluctuation of $500 until your free margin falls to zero and causes a margin call. Your position size of $50,000 could only fall to $49,500 – this would be the largest loss your trading account could withstand.
Margins are a hotly debated topic. Some traders argue that too much margin is very dangerous, however it all depends on trading style and the amount of trading experience one has. If you are going to trade on a margin account, it is important that you know what your broker's policies are on margin accounts, and that you fully understand and are comfortable with the risks involved. Be careful to avoid a Forex margin call.
Once an investor has started buying a stock on margin, the NYSE and FINRA require that a minimum amount of equity be maintained in the investor's margin account. These rules require investors to have at least 25% of the total market value of the securities they own in their margin account. This is called the maintenance margin. For market participants identified as pattern day traders, the maintenance margin requirement is a minimum of $25,000 (or 25% of the total market value of the securities, whichever is higher).
© Forex Factory 2020. All rights reserved. The Forex Factory calendar changes frequently to reflect the latest information. For the most up to date calendar, please visit https://www.forexfactory.com/calendar.php. Forex Factory takes no responsibility for decisions based on this information, please see our terms of service at https://www.forexfactory.com/legal.php.
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.
All currency trading is done in pairs. Unlike the stock market, where you can buy or sell a single stock, you have to buy one currency and sell another currency in the forex market. Next, nearly all currencies are priced out to the fourth decimal point. A pip or percentage in point is the smallest increment of trade. One pip typically equals 1/100 of 1 percent.