Overall Statistics |
Total Trades 2 Average Win 0% Average Loss 0.00% Compounding Annual Return -0.023% Drawdown 0.000% Expectancy -1 Net Profit -0.002% Sharpe Ratio 0 Sortino Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -5.496 Tracking Error 0.156 Treynor Ratio 0 Total Fees $2.00 Estimated Strategy Capacity $8200000.00 Lowest Capacity Asset SPY R735QTJ8XC9X Portfolio Turnover 0.02% |
# region imports from AlgorithmImports import * # endregion class CustomSettlementModelAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2022, 7, 1) self.SetEndDate(2022, 8, 1) self.SetCash(100000) security = self.AddEquity("SPY") security.SetSettlementModel(MySettlementModel()) self.Schedule.On( self.DateRules.EveryDay("SPY"), self.TimeRules.Every(timedelta(minutes=30)), self.plot_cash ) self.traded = False def plot_cash(self): self.Plot("Settled Cash", "USD", self.Portfolio.CashBook["USD"].Amount) self.Plot("Unsettled Cash", "USD", self.Portfolio.UnsettledCashBook["USD"].Amount) def OnData(self, data: Slice): if self.traded: return self.MarketOrder("SPY", 1) self.MarketOrder("SPY", -1) self.traded = True class MySettlementModel: def ApplyFunds(self, applyFundsParameters: ApplyFundsSettlementModelParameters) -> None: currency = applyFundsParameters.CashAmount.Currency amount = applyFundsParameters.CashAmount.Amount applyFundsParameters.Portfolio.CashBook[currency].AddAmount(amount) def Scan(self, settlementParameters: ScanSettlementModelParameters) -> None: pass def GetUnsettledCash(self) -> CashAmount: return CashAmount(0, 'USD')