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.
Risk warning: Trading Forex (foreign exchange) or CFDs (contracts for difference) on margin carries a high level of risk and may not be suitable for all investors. There is a possibility that you may sustain a loss equal to or greater than your entire investment. Therefore, you should not invest or risk money that you cannot afford to lose. Before using Admiral Markets UK Ltd, Admiral Markets Cyprus Ltd or Admiral Markets PTY Ltd services, please acknowledge all of the risks associated with trading.
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).
As we've already stated, trading on margin is trading on money borrowed from your broker. Each time you open a trade on margin, your broker automatically allocates the required margin from your existing funds in the trading account in order to back the margin trade. The precise amount of allocated funds depends on the leverage ratio used on your account.
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.
If you sell a security short, you must have sufficient equity in your account to cover any fees associated with borrowing the security. If you borrow the security through us, we will borrow the security on your behalf and your account must have sufficient collateral to cover the margin requirements of the short sale. To cover administrative fees and stock borrowing fees, we must post 102% of the value of the security borrowed as collateral with the lender. In instances in which the security shorted is hard to borrow, borrowing fees charged by the lender may be so high (greater than the interest earned) that the short seller must pay additional interest for the privilege of borrowing a security. Customers may view the indicative short stock interest rates for a specific stock through the Short Stock (SLB) Availability tool located in the Tools section of their Account Management page. For more information concerning shorting stocks and associated fees, visit our Stock Shorting page.
Let's presume that the market keeps on going against you. In this case, the broker will simply have no choice but to shut down all your losing positions. This limit is referred to as a stop out level. For example, when the stop out level is established at 5% by a broker, the trading platform will start closing your losing positions automatically if your margin level reaches 5%. It is important to note that it starts closing from the biggest losing position.
© 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.
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.
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.
Just like securities, commodities have required initial and maintenance margins. These are typically set by the individual exchanges as a percentage of the current value of a futures contract, based on the volatility and price of the contract. The initial margin requirement for a futures contract is the amount of money you must put up as collateral to open position on the contract. To be able to buy a futures contract, you must meet the initial margin requirement, which means that you must deposit or already have that amount of money in your account.
I post this to let you know, as the title mentions it, that I made a trading diary, with google documents tool. This a generic spreadsheet which allows any trader to manage his trading (his risk, his pnl, his opened position, the orders...) with a trding diary. Every trader,should have one, and I mad mine with google docs. At least you must have an account to acces this spreadsheet.