##### 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.

The script is currently hardcoded to generate forex data for the entire month of January 2014. It uses the Python calendar library in order to ascertain business days (although I haven't excluded holidays yet) and then generates a set of files of the form BBBQQQ_YYYYMMDD.csv, where BBBQQQ will be the specified currency pair (e.g. GBPUSD) and YYYYMMDD is the specified date (e.g. 20140112).
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.
Let’s cover this with an example. If you have \$1,000 in your trading account and use a leverage of 1:100 you could theoretically open a position size of \$100,000. However, by doing so, your entire trading account would be allocated as the required margin for the trade, and even a single price tick against you would lead to a margin call. There would be no free margin to withstand any negative price fluctuation.
##### 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.

Let’s cover this with an example. If you have \$1,000 in your trading account and use a leverage of 1:100 you could theoretically open a position size of \$100,000. However, by doing so, your entire trading account would be allocated as the required margin for the trade, and even a single price tick against you would lead to a margin call. There would be no free margin to withstand any negative price fluctuation.

## There is one unpleasant fact for you to take into consideration about the margin call Forex. You might not even receive the margin call before your positions are liquidated. If the money in your account falls under the margin requirements, your broker will close some or all positions, as we have specified earlier in this article. This can actually help prevent your account from falling into a negative balance.

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.

# 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.

The Forex market is one of a number of financial markets that offer trading on margin through a Forex margin account. Many traders are attracted to the Forex market because of the relatively high leverage that Forex brokers offer to new traders. But, what are leverage and margin, how are they related, and what do you need to know when trading on margin? This and more will be covered in the following lines.
You could ask yourself, why wouldn’t you use the highest leverage ratio available in order to decrease your margin requirements and get an extremely high market exposure? The answer is rather simple and deals with Forex risk management. While leverage magnifies your potential profits, it also magnifies your potential losses. Trading on high leverage increases your risk in trading.

### In particular we need to modify -every- value that appears in a Position calculation to a Decimal data-type. This includes the units, exposure, pips, profit and percentage profit. This ensures we are in full control of how rounding issues are handled when dealing with currency representations that have two decimal places of precision. In particular we need to choose the method of rounding. Python supports a few different types, but we are going to go with ROUND_HALF_DOWN, which rounds to the nearest integer with ties going towards zero.

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.