I am wondering how exactly to paper trade an algorithm I found. Everytime I go to paper trade it says, "we believe that your algorithm requires equity." How do I go about fixing this? Thanks.
QUANTCONNECT COMMUNITY
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Jing Wu
We provide the free equity data feed in live environment for your paper trading. That line tells that you've selected the QC equity data feed for your live algorithm. You can click the "next" to proceed your live deployment and choose the live server.
Ken Hampel
Thank you for the response. I have another question, when I previously ran the code (during trading hours) I would not get fill prices for orders. I found somones code on here (since I am new to python) a while back and just wanted to see how things works. It worked during backtests but, I am not sure it worked with the paper trading. Thanks again.
import numpy as np
from datetime import datetime
class MovingAverage(QCAlgorithm):
def __init__(self):
self.previous = None
self.ma = None
self.position = None
self.lastMonth = -1
def Initialize(self):
self.SetStartDate(2018,10,1) #Set Start Date
self.SetEndDate(2018,10,29) #Set End Date
self.SetCash(100000) #Set Strategy Cash
self.AddSecurity(SecurityType.Equity, "SPY", Resolution.Daily)
self.AddSecurity(SecurityType.Equity, "IEF", Resolution.Daily)
self.SetWarmUp(440)
self.ma = self.SMA("SPY", 220, Resolution.Daily)
def OnData(self, data):
if self.IsWarmingUp:
return
if not data.ContainsKey("SPY"):
return
if self.lastMonth == self.Time.month:
return
if data["SPY"].Close > self.ma.Current.Value:
if self.position == None:
self.SetHoldings("SPY", 1)
else:
if self.position == "IEF":
self.Liquidate("IEF")
self.SetHoldings("SPY", 1)
self.position = "SPY"
else:
if self.position == None:
self.SetHoldings("IEF", 1)
else:
if self.position == "SPY":
self.Liquidate("SPY")
self.SetHoldings("IEF", 1)
self.position = "IEF"
self.lastMonth = self.Time.month
Jing Wu
The backtesting works fine as expected. The algorithm is based on the daily resolution, if you deploy it to live and the trading condition is satisfied, you won't get the trade immediately. The market order will be converted to the MarketOnOpenOrder. It is executed after the market opens the next day.
Ken Hampel
Ok thank you again and is there a way to have the order fill immediately instead of next day?
Jing Wu
MarketOrder() fills immediately but on what resolution the order fills depends on the data subscribed in the algorithm with self.AddSecurity(). If you choose daily resolution, OnData() is called every day. If you choose minute resolution, OnData() is called every minute.
Ken Hampel
Ok, thank you again for all the help.
Ken Hampel
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!