I"m running live backtest on a scalping algo, and would love to see the difference in trading every 10 seconds rather than every minute...is that possible?
QUANTCONNECT COMMUNITY
I"m running live backtest on a scalping algo, and would love to see the difference in trading every 10 seconds rather than every minute...is that possible?
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.
Arthur Asenheimer
Hi Bryan,Â
you can use Resolution.Second and consolidate the bars to 10-second bars.Â
Bryan Cook
I think the limitations block this?
Brokerage Warning: The API request has been rate limited. To avoid this message, please reduce the frequency of API calls. Brokerage Warning: The API request has been rate limited. To avoid this message, please reduce the frequency of API calls. Brokerage Warning: The API request has been rate limited. To avoid this message, please reduce the frequency of API calls.
Bryan Cook
This is where I had defined it.
self.twtr = self.AddEquity("twtr", Resolution.Second)
Jared Broad
Yes its possible. Please post an algorithm or snippet for further assistance.
The error above is not related to LEAN but the algorithm design. It sounds like its using IB for history calls and hitting IB rate limit.
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.
Bryan Cook
Right now I'm running through Alpaca. Not trying to pull any historical data other than the current price of the ticker. Get that error if I change Resolution.Minute to Resolution.Second.
Maybe this is because I'm using "if" statements rather than something more elegant? Maybe I put in something that only loops when there's a transaction event?
from clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Common") from System import * from QuantConnect import * from QuantConnect.Algorithm import * class NadionResistanceFlange(QCAlgorithm): def Initialize(self): self.twtr = self.AddEquity("twtr", Resolution.Minute) self.Securities["twtr"].FeeModel = ConstantFeeModel(0.01) def OnData(self, data): currentprice_twtr = self.twtr.Price currentqty_twtr = self.Portfolio["twtr"].Quantity cash = self.Portfolio.Cash # define first position and trading step size. startingpoint_twtr = 46.00 stepsize_twtr = 1.00 # Define the trade value for buy and sell based on the quantity of shares held, starting point, and step size. buyprice_twtr = startingpoint_twtr-stepsize_twtr*(currentqty_twtr) sellprice_twtr = startingpoint_twtr+stepsize_twtr*(2-currentqty_twtr) #start by cancelling all open orders allCancelledOrders = self.Transactions.CancelOpenOrders() #Start of a block if currentqty_twtr == 0: self.LimitOrder("twtr",1, startingpoint_twtr) if currentqty_twtr != 0 and cash > buyprice_twtr: self.LimitOrder("twtr",1,buyprice_twtr) self.LimitOrder("twtr",-1,sellprice_twtr)
Â
Derek Melchin
Hi Bryan,
The algorithm above issues orders very frequently. Thus by setting the resolution to second, it's exceeding the API limit.
Instead of cancelling all the open orders at each timestep, consider just sending a new limit order after one of the active ones is filled.
Best,
Derek Melchin
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.
Bryan Cook
At the bottom of the code, can I add something like this that says hold until an order is filled, then loop?
Â
def OnOrderEvent(self, orderEvent): order = self.Transactions.GetOrderById(orderEvent.OrderId) if orderEvent.Status == OrderStatus.Filled: Pass
Â
Bryan Cook
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!