Overall Statistics
Total Orders
2
Average Win
0%
Average Loss
0%
Compounding Annual Return
435.569%
Drawdown
65.600%
Expectancy
0
Start Equity
1000000
End Equity
2823906.57
Net Profit
182.391%
Sharpe Ratio
4.085
Sortino Ratio
5.633
Probabilistic Sharpe Ratio
73.288%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
4.219
Beta
0.187
Annual Standard Deviation
1.039
Annual Variance
1.078
Information Ratio
3.952
Tracking Error
1.042
Treynor Ratio
22.707
Total Fees
$2176.29
Estimated Strategy Capacity
$39000.00
Lowest Capacity Asset
USDJPY 8G
Portfolio Turnover
37.52%
# region imports
from AlgorithmImports import *
# endregion

class YenCarryTradeAlgorithm(QCAlgorithm):

    # 1) Borrow Yen
    # 2) Convert Yen for USD
    # 3) Buy interest-producing, "risk-free" asset with USD
    # profit = interest earned from (3) - interest paid for (1)

    def initialize(self):
        self.set_start_date(2024, 1, 2)
        self.set_end_date(2024, 8, 13)
        self.set_cash(1_000_000) # 1M usd = 141M Yen Jan 1 2024.
        
        for asset in [self.add_equity("BIL", Resolution.DAILY),  self.add_forex("USDJPY", Resolution.DAILY)]:
            asset.set_leverage(100)
            asset.set_data_normalization_mode(DataNormalizationMode.RAW)
    
        self.schedule.on(self.date_rules.month_start(5), self.time_rules.at(10, 00), self._trade)

    def _trade(self):
        if not self.portfolio.invested:
            self.set_holdings("BIL", 40)
            self.set_holdings("USDJPY", 40)
            self._interest_payment = -40_000_000 * (0.0025/12) # USD
        
        # deduct interest
        self.portfolio.cash_book['USD'].add_amount(self._interest_payment)