Now that we have discussed the longer term plan I want to present some of the changes I have made to the code since diary entry #2. In particular, I want to describe how I modified the code to handle the Decimal data-type instead of using floating point storage. This is an extremely important change as floating point representations are a substantial source of long-term error in portfolio and order management systems.
An extremely important requested feature for QSForex has been the ability to backtest over multiple days. Previously the system only supported backtesting via a single file. This was not a scalable solution as such a file must be read into memory and subsequently into a Pandas DataFrame. While the tick data files produced are not huge (roughly 3.5Mb each), they do add up quickly if we consider multiple pairs over periods of months or more.
tweet at 3:44pm: [RTRS] - U.S. CDC DIRECTOR REDFIELD SAYS RISK TO U.S. PUBLIC FROM CORONAVIRUS OUTBREAK IS LOW tweet at 3:46pm: REDFIELD SAYS THERE ARE 191 INDIVIDUALS UNDER INVESTIGATION IN U.S. AMID CORONAVIRUS OUTBREAK tweet at 3:45pm: US CDC Director Redfield: This is a significant global situation. https://t.co/Ao1Ci2OEfi tweet at 3:52pm: US declares the coronavirus a public health emergency, implementing special temporary measures $SPX
Robust Strategies - I have only demonstrated some simple random signal generating "toy" strategies to date. Now that we are beginning to create a reliable intraday forex trading system, we should start carrying out some more interesting strategies. Future diary entries will concentrate on strategies drawn from a mixture of "technical" indicators/filters as well as time series models and machine learning techniques.
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.
If you believe that a currency pair such as the Australian dollar will rise against the US Dollar you can place a buy trade on AUD/USD. If the prices rises, you will make a profit for every point that AUD appreciates against the USD. If the market falls, then you will make a loss for every point the price moves against you. Our trading platform tells you in real-time how much profit or loss you are making.
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.
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.
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.