Margin calls are mechanisms put in place by your Forex broker in order to keep your used margin secure. Remember, your used margin is allocated by your broker as the collateral for funds borrowed from your broker. A margin call happens when your free margin falls to zero, and all you have left in your trading account is your used, or required margin. When this happens, your broker will automatically close all open positions at current market rates.
The "philosophy" of the forex trading system, as with the rest of the QuantStart site, is to try and mimic real-life trading as much as possible in our backtesting. This means including the details that are often excluded from more "research oriented" backtesting situations. Latency, server outages, automation, monitoring, realistic transaction costs will all be included within the models to give us a good idea of how well a strategy is likely to perform.
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.