Overall Statistics
Total Orders
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
-1.999%
Drawdown
2.100%
Expectancy
0
Net Profit
-1.901%
Sharpe Ratio
-8.92
Sortino Ratio
-11.322
Probabilistic Sharpe Ratio
0.042%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.057
Beta
-0.072
Annual Standard Deviation
0.008
Annual Variance
0
Information Ratio
-2.073
Tracking Error
0.103
Treynor Ratio
0.939
Total Fees
$1.00
Estimated Strategy Capacity
$7800000000.00
Lowest Capacity Asset
QQQ RIWIV7K5Z9LX
Portfolio Turnover
0.01%
# region imports
from AlgorithmImports import *
# endregion

class CustomShortableProviderAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2023, 4, 1)
        self.SetCash(100000)

        self.security = self.AddEquity("QQQ", Resolution.Daily)
        self.security.SetShortableProvider(MyShortableProvider())

    def OnData(self, data: Slice):
        if self.Portfolio.Invested:
            return
        shortable_quantity = self.security.ShortableProvider.ShortableQuantity(self.security.Symbol, self.Time)
        if not shortable_quantity:
            return
        fee_rate = self.security.ShortableProvider.FeeRate(self.security.Symbol, self.Time)
        rebate_rate = self.security.ShortableProvider.RebateRate(self.security.Symbol, self.Time)
        self.SetHoldings(self.security.Symbol, -0.05, tag=f'Borrow fee rate {fee_rate}. Borrow rebate rate {rebate_rate}')

class MyShortableProvider(NullShortableProvider):

    def FeeRate(self, symbol: Symbol, localTime: DateTime) -> float:
        return 0.0025

    def RebateRate(self, symbol: Symbol, localTime: DateTime) -> float:
        return 0.0507
    
    def ShortableQuantity(self, symbol: Symbol, localTime: datetime) -> float:
        return 10000