Overall Statistics
Total Trades
20
Average Win
0%
Average Loss
-4.05%
Compounding Annual Return
-33.016%
Drawdown
78.000%
Expectancy
-1
Net Profit
-77.706%
Sharpe Ratio
-0.924
Sortino Ratio
-1.208
Probabilistic Sharpe Ratio
0.000%
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.016
Beta
-1.64
Annual Standard Deviation
0.258
Annual Variance
0.066
Information Ratio
-0.911
Tracking Error
0.41
Treynor Ratio
0.145
Total Fees
$23.10
Estimated Strategy Capacity
$420000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
Portfolio Turnover
0.47%
# region imports
from AlgorithmImports import *
# endregion

class CustomFillModelAlgorithm(QCAlgorithm):

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

        self.Portfolio.MarginCallModel = MyMarginCallModel(self.Portfolio, self.DefaultOrderProperties)
        self.AddEquity("SPY", Resolution.Daily)

    def OnData(self, data: Slice):
        if not self.Portfolio.Invested:
            self.SetHoldings("SPY", -2)


class MyMarginCallModel(DefaultMarginCallModel):
    def __init__(self,
         portfolio: SecurityPortfolioManager,
         defaultOrderProperties: IOrderProperties):
        super().__init__(portfolio, defaultOrderProperties)

    def ExecuteMarginCall(self,
         generatedMarginCallOrders: List[SubmitOrderRequest]) -> List[OrderTicket]:
        return super().ExecuteMarginCall(generatedMarginCallOrders)

    def GetMarginCallOrders(self,
         issueMarginCallWarning: bool) -> List[SubmitOrderRequest]:
        return super().GetMarginCallOrders(issueMarginCallWarning)