Newbie here:

I am trying to add a schedule function to the algo below and keep getting an error stating

TypeError: No method matches given arguments for AfterMarketOpen: (<class 'list'>, <class 'int'>)

or

 TypeError: "No method matches given arguments for AfterMarketOpen: (, )

Will appreciate any help I can get on how to correctly schedule it.

The scheduling parameter I am trying to add are to trade: 

 - Every day market is open, 

 - 10 minutes after market opens. 

 

See algo below

  1. import numpy as np
  2. from datetime import timedelta
  3. from datetime import date, timedelta, datetime
  4. #class RSIAlgorithm(QCAlgorithm):
  5. class BasicTemplateAlgorithm(QCAlgorithm):
  6. def Initialize(self):
  7. '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
  8. self.SetStartDate(2020,6,1) # Set Start Date
  9. self.SetCash(4000) # Set Strategy Cash
  10. self.Equities = ["SPY","AMC","GME","SENS","AMSC","SNDL","HARP","EH","LOOP","QFIB","IDT",
  11. "BB","BTX","RCON","BGFV","SBOW","EDRY","BBW","CELH","DDS","RRD",
  12. "NOTV","UAN","JYNT","RFP","LOVE","NTP","RICK","SI","CMBM","DEN","CTRN",
  13. "BNTX","TGLS","TGB","HYRE","BCRX","AVID","BBIG","WINT","DOCU"]
  14. for Symbol in self.Equities:
  15. self.AddEquity(Symbol, Resolution.Daily).Symbol
  16. self.rsi = self.RSI(Symbol, 14, Resolution.Daily)
  17. self.macd = self.MACD(Symbol, 12, 26, 9, Resolution.Daily)
  18. self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.AfterMarketOpen(self.Equities, 10), self.EveryDayAfterMarketOpen)
  19. def OnData(self, data):
  20. '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
  21. Arguments:
  22. data: Slice object keyed by symbol containing the stock data
  23. '''
  24. # Make sure we are not warming up
  25. if self.IsWarmingUp: return
  26. for Symbol in self.Equities:
  27. print(self.Portfolio[Symbol].AveragePrice)
  28. print(self.Portfolio[Symbol].Price)
  29. print(self.Portfolio[Symbol].Quantity)
  30. print(self.Portfolio.Cash)
  31. Vested = self.Portfolio.Invested
  32. Aveprica = self.Portfolio[Symbol].AveragePrice
  33. Nowprica = self.Portfolio[Symbol].Price
  34. Quantity = self.Portfolio[Symbol].Quantity
  35. Bpower = self.Portfolio.Cash
  36. Rsi = self.rsi.Current.Value
  37. Macd =self.macd.Current.Value
  38. #The perfect Swing set up is Adx > 20 and Rsi > 60 and Macd > 0 and Cci > 100:
  39. if not Vested and Bpower > Nowprica and Rsi > 60 and Macd > 0:
  40. self.MarketOrder(Symbol, 1)
  41. self.Log(Aveprica)
  42. if Vested and Rsi < 30 and Macd < 0:
  43. self.SetHoldings(Symbol, 0)
  44. else:
  45. pass
+ Expand

Author

Lemuel

June 2021