Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 19.703% Drawdown 33.700% Expectancy 0 Net Profit 25.190% Sharpe Ratio 0.74 Probabilistic Sharpe Ratio 34.636% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.255 Beta -0.23 Annual Standard Deviation 0.279 Annual Variance 0.078 Information Ratio -0.01 Tracking Error 0.438 Treynor Ratio -0.896 Total Fees $1.58 Estimated Strategy Capacity $670000000.00 |
import numpy as np class StandardDeviation_test(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) self.SetCash(100000) self.spy = self.AddEquity("SPY", Resolution.Daily).Symbol self.SetWarmUp(101) self.std = StandardDeviation("SPY", 100) self.std_short = self.STD("SPY", 100, Resolution.Daily) def OnData(self, data): if self.IsWarmingUp: return if not self.Portfolio.Invested: self.SetHoldings("SPY", 1) def OnEndOfDay(self): if self.IsWarmingUp: return self.std.Update(self.Time, self.Securities[self.spy].Close) self.Plot('StandardDeviation', "StandardDeviation",float(self.std.Current.Value)) self.Plot('STD', "STD", float(self.std_short.Current.Value)) np_std_p = self.History([self.spy], 100, Resolution.Daily).close.std(ddof=0) self.Plot('np_std_p', 'np_std_p', float(np_std_p)) np_std_s = self.History([self.spy], 100, Resolution.Daily).close.std(ddof=1) self.Plot('np_std_s', 'np_std_s', float(np_std_s))