English
Back

Margin trading and short selling in backtest

1. What are margin trading and short selling?

  • Margin trading: This involves using securities held in a backtest account as collateral to borrow additional funds to purchase more securities. This process incurs interest and fees.

  • Short selling: This involves using securities in a backtest account as collateral to borrow and then sell securities. In the future, an equivalent number of these securities must be repurchased and returned, along with the payment of specific interest and fees.

 

Both margin trading and short selling are available in a backtest. When placing an order:

  • Selecting Max Qty to Buy (Margin): The market value of purchased securities will exceed the initial cash available in the account. The excess amount, referred to as the margin loan, incurs overnight interest calculated daily using the formula: Overnight Interest Rate = Margin Loan * Margin Rate / 365.

  • Selecting Max Qty to Buy (Cash): The market value of the securities will not surpass the account's initial cash balance. No overnight interest will be incurred.

  • Selecting Max Qty to Sell Short: A short position will accrue overnight interest on its market value, calculated as Overnight Interest Rate = Market Value of Short Position * Short Margin Rate / 365.

The provided image may not be current. Information and securities shown are for reference only and should not be considered as recommendations.

 

2. Margin Rates & Margin Details

The specific margin rate, initial and maintenance margins, short margin rate, and the availability of shares for short selling are related to the specific securities and depend on their quotes at the start of the backtest. These details can be found on the quotes page in the app.

The provided image may not be current. Information and securities shown are for reference only and should not be considered as recommendations.

Please note that the data mentioned above are not static, meaning that the maximum quantities available for buying or short selling may vary when you initiate a backtest at different times. The backtest account only supports setting initial funds in a single currency. Margin interest will be incurred if the strategy involves buying securities priced in other currencies.

For example, if the initial funds in the backtest account are set at $1 million and the strategy includes purchases of both US and Hong Kong stocks, the funds used to buy Hong Kong stocks will be borrowed, accruing interest in Hong Kong dollars. Conversely, the funds used to buy US stocks will be taken directly from the account's USD balance, thereby not generating any USD margin interest.

 

3. Liquidation

Using margin trading or short selling in backtesting increases the leverage of the account. This added leverage amplifies the impact of any changes in the value of held assets on the account's net asset value (NAV). If unfavorable price movements cause the NAV to fall below the required maintenance margin, liquidation is triggered.

Assume Apple (US.AAPL) requires an initial margin of 40% and a maintenance margin of 30%. If the initial capital in the backtest account is $400,000, it allows for the purchase of Apple shares valued at $1,000,000 (calculated as $400,000/40%).

After this purchase, the account's NAV stands at $400,000 with a position value of $1,000,000, a cash balance of -$600,000, and a margin loan of $600,000. If the stock price drops by 10%, the NAV decreases to $300,000 ($400,000 - ($1,000,000 * 10%) = $300,000), reaching the maintenance margin limit and triggering liquidation.

The provided image may not be current. Information and securities shown are for reference only and should not be considered as recommendations.

This presentation is for informational and educational use only and is not a recommendation or endorsement of any particular investment or investment strategy. Investment information provided in this content is general in nature, strictly for illustrative purposes, and may not be appropriate for all investors. It is provided without respect to individual investors’ financial sophistication, financial situation, investment objectives, investing time horizon, or risk tolerance. You should consider the appropriateness of this information, having regard to your relevant personal circumstances, before making any investment decisions. Past investment performance does not indicate or guarantee future success. Returns will vary, and all investments carry risks, including loss of principal. Our platform makes no representation or warranty as to its adequacy, completeness, accuracy, or timeliness for any particular purpose of the above content.