Overall Statistics |
Total Trades 3 Average Win 0% Average Loss 0% Compounding Annual Return 58.163% Drawdown 0.400% Expectancy 0 Net Profit 0% Sharpe Ratio 8.919 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.159 Beta 0.198 Annual Standard Deviation 0.03 Annual Variance 0.001 Information Ratio -6.169 Tracking Error 0.044 Treynor Ratio 1.332 Total Fees $3.00 |
import pandas as pd class MyAlgo(QCAlgorithm): def Initialize(self): # Reference to AAPL self.SetStartDate(2017,10,2) self.SetEndDate(2017,10,6) self.SetCash(1000) self.secs = ["AAPL", "IBM", "CAT"] for stock in self.secs: self.stock = self.AddEquity(stock) self.Log("hello") self.secs_df = pd.DataFrame(index=self.secs) def OnData(self, data): ''' Runs every tick defined by resolution in initialize under equity''' # Position 100% of our portfolio to be long in AAPL len_sec = len(self.secs_df) self.Log("total securities to trade" + str(len_sec)) for stock in self.secs_df.index: self.SetHoldings(stock, 1.0/len_sec) shares_held = self.Portfolio[stock].AbsoluteQuantity self.Log('hold {:.0f} shares of {}'.format(shares_held, stock))