Overall Statistics
Total Orders
42
Average Win
3.23%
Average Loss
-21.16%
Compounding Annual Return
-99.998%
Drawdown
99.600%
Expectancy
-0.800
Net Profit
-99.548%
Sharpe Ratio
-0.542
Sortino Ratio
-0.245
Probabilistic Sharpe Ratio
0.003%
Loss Rate
83%
Win Rate
17%
Profit-Loss Ratio
0.15
Alpha
-1.52
Beta
2.274
Annual Standard Deviation
1.826
Annual Variance
3.333
Information Ratio
-0.675
Tracking Error
1.813
Treynor Ratio
-0.435
Total Fees
$42.09
Estimated Strategy Capacity
$5200000.00
Lowest Capacity Asset
GME SC72NCBXXAHX
Portfolio Turnover
19.23%
from AlgorithmImports import *
class ShortAvailabilityDataAlgorithm(QCAlgorithm):

    def Initialize(self) -> None:

        self.SetStartDate(2021, 1, 1)
        self.SetEndDate(2021, 7, 1)
        self.SetCash(1000)
        self.SetSecurityInitializer(MySecurityInitializer(self.BrokerageModel, FuncSecuritySeeder(self.GetLastKnownPrices)))

        self.equity = self.AddEquity("GME")

        self.Schedule.On(
            self.DateRules.EveryDay(self.equity.Symbol),
            self.TimeRules.AfterMarketOpen(self.equity.Symbol, 10),
            self.Rebalance)

    def Rebalance(self) -> None:
        symbol = self.equity.Symbol
        
        shortable_quantity = self.equity.ShortableProvider.ShortableQuantity(symbol, self.Time)
        if not shortable_quantity:
            shortable_quantity = 0
        self.Plot('Total Shortable Quantity', symbol, shortable_quantity)
        self.Plot('Borrowing Cost', "Fee Rate", self.equity.ShortableProvider.FeeRate(symbol, self.Time))
        self.Plot('Borrowing Cost', "Rebate Rate", self.equity.ShortableProvider.RebateRate(symbol, self.Time))

        # Then, test whether we can short the desired quantity
        quantity = self.CalculateOrderQuantity(symbol, -1)
        if self.Shortable(symbol, quantity):
            self.MarketOrder(symbol, quantity)

    def OnMarginCallWarning(self) -> None:
        self.Liquidate()

class MySecurityInitializer(BrokerageModelSecurityInitializer):
    def __init__(self, brokerage_model: IBrokerageModel, security_seeder: ISecuritySeeder) -> None:
        super().__init__(brokerage_model, security_seeder)

    def Initialize(self, security: Security) -> None:
        super().Initialize(security)
        security.SetShortableProvider(InteractiveBrokersShortableProvider())