Overall Statistics |
Total Trades 3 Average Win 0% Average Loss -8.84% Compounding Annual Return -82.831% Drawdown 84.900% Expectancy -1 Net Profit -66.080% Sharpe Ratio -0.257 Probabilistic Sharpe Ratio 12.865% Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.378 Beta 0.128 Annual Standard Deviation 1.401 Annual Variance 1.963 Information Ratio -0.346 Tracking Error 1.438 Treynor Ratio -2.818 Total Fees $12.96 |
from clr import AddReference AddReference("System") AddReference("QuantConnect.Common") AddReference("QuantConnect.Algorithm") from System import * from QuantConnect import * from QuantConnect.Orders import * from QuantConnect.Algorithm import QCAlgorithm import numpy as np from datetime import datetime, timedelta class MarginCallEventsAlgorithm(QCAlgorithm): def Initialize(self): self.SetCash(100000) self.SetStartDate(2020,1,1) self.SetEndDate(2020,8,11) self.AddEquity("UAL", Resolution.Daily) self.AddEquity("DAL", Resolution.Daily) self.Securities["DAL"].SetLeverage(2) def OnData(self, data): if not self.Portfolio.Invested: self.SetHoldings("DAL",1.25) #self.SetHoldings("UAL",-0.5) def OnMarginCall(self, requests): self.Log("Margin Call") self.Plot("Margin", "Remaining", int(self.Portfolio.MarginRemaining / self.Portfolio.TotalPortfolioValue < -0.1)) return requests def OnEndOfDay(self): if self.Portfolio.MarginRemaining < 100000: self.Plot("Margin", "Remaining", int(self.Portfolio.MarginRemaining / self.Portfolio.TotalPortfolioValue < -0.1))