Over the years I have done some automated trading using MultiCharts, Quantopian, and TradeStation. I just started with QuantConnect this week, and as a test cloned a strategy from the forum and had it live trade in my IB account, but I have not created a strategy from scratch yet. I already have my own server where I use a Python notebook to generate trading signals using machine learning, and I have my own custom built backtesting system. But, I don't have a live trading module for it so I am not making any trades.
I could move my Python notebook to QuantConnect, but it uses some machine learning libraries QuantConnect does not use, and also all of my indicators are different than QuantConnect (I use TA-Lib plus a some custom built indicators). So one option would be for me to use a custom feed to import my trading signals, and use Quantopian only for executing the trades. I would trade every 30 minutes, where it enters the trade based on the signal (using a market order) and then exits after 30 minutes. No stop loss or other exit strategy.
My machine learning algorithm forecasts the best and worst stock from the Dow30 each half hour, and buys the one it thinks will go up and sells short an equal dollar amount of the one it thinks will go down, so overall the strategy is market neutral. I know I could just have add live trading to my existing server using the IB Python API or Backtrader, but there are too many potential problems that could come up. I like how clean and simple the QuantConnect interface is.
What is the best way for me to do this with QuantConnect?
Michael Manus
phuu you would need to implent this in quantconnect and run it live......or download the github source package and run it on your linux machine...
sending information to your live trading quantconnect algo is i think almost impossible with that resolution you work with. (seeing stock selection algos taking infos form dropbox once a day at night)
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.
Eric Borgos
So I am not able to set any schedule I want to import an external data feed? I thought that was what " "Scheduled Events" is for, at
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.
Michael Manus
you are already a pro user..... feel free to test how many times you can access an dropbox file runing a simple live algo doing nothing, only reading an online file. you could use schedule events yes....runing localy you could read a file no problem but if you have problems with your computer or power loss everything is dead.....you describe something that has to be build localy. the google quantconnect group is the right place for your question i think. quantopian or zipline-live is not needed for executing IB orders you could use quantconnect of course. you plan to work with 20 different systems alltogether.... put up something stable with one. localy you can install everything and use only one system. but future stragtegy should be running it online live on the quantconnect servers even if you would need to import the sources online file by file.
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.
Boris Sachakov
@Jared,
Would you please show me the code how to make it happen. Thanks in advance.
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.
Boris Sachakov
How should I adjust the following formula for 5-min Period?
public new TimeSpan Period { get { return QuantConnect.Time.OneDay; } }
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.
Alexandre Catarino
QuantConnect.Time Helper has the following "aliases":
QuantConnect.Time.OneDay = TimeSpan.FromDays(1); QuantConnect.Time.OneHour = TimeSpan.FromHours(1); QuantConnect.Time.OneMinute = TimeSpan.FromMinutes(1); QuantConnect.Time.OneSecond = TimeSpan.FromSeconds(1); QuantConnect.Time.OneMillisecond = TimeSpan.FromMilliseconds(1);
For other periods, we need to rely on TimeSpan.From* functions.
In this particular case, please adjust it with:
public new TimeSpan Period { get { return TimeSpan.FromMinutes(5); } }
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.
Boris Sachakov
@Alexandre,
Thanks for your advice. However, the time is still reported by 1-min off: e.g. 11:16 instead of 11:15.
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.
Jared Broad
public override DateTime EndTime { get { return Time + TimeSpan.FromMinutes(5); } }
The default resolution length is 1 minute which makes it appear 1 minute past the start time (which is infact looking into the future since your bars are 5 minutes long). If you set your bar length to 5 minutes (like above) it'll appear on the 5 minute boundary.
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.
Alexandre Catarino
Boris, you got a different result, because you removed the part we override EndTime. The complete solution would be:
public override DateTime EndTime { get { return Time + Period; } set { Time = value - Period; } } public new TimeSpan Period { get { return TimeSpam.FromMinutes(5); } }
Since Jared's solution is 5 lines shorter, we can considered it better.
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.
Boris Sachakov
Jared and Alexandre,
Thank you both for your suggestions. Both codes brought the time of events to the end of the bar. However, the time that 'Logs' and 'Trades' after Backtest show is 5 minutes later than the actual event. For example, by looking at the chart, 1st Bearish Closing Marubozu ends at 10:55, whereas the Logs record it at 11:00. Also the 'Trades' show that its price was 1988.50 USD at 11:00; but if you look at the actual records (see the link to Dropbox in GetSource), the price 1988.50 corresponds to Close at 10:55.
Basically, the candlestick pattern and the trade in reality occur at 10:55, but the records (Logs & Trades) show 11:00. Similar situation happens with the rest of patterns.
How can we fix this situation? Thanks in advance
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.
Jared Broad
That is the intended behaviour; the bars close on the end time (i.e. start + period).
20160104 10.55 ...$1988.50 + 5 minute period bar means the bar is available (closing) at 10.59.9999 and appearing in your algorithm at 11am.
If the bar was available at 10.55 you'd see into the future (as the closing price is at 10.59.99999)
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.
Boris Sachakov
Jared,
Thanks for your response. Still, there is some confusion. But I am beginning to understand the problem, possibly. When I downloaded my data, I set the time of candle correspond to Close. So in my data 10:55 is the bar's close. In your case, probably, the time corresponds to the beginning of the candle.
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.
Phillip Espina
Hi Everyone, Is there a way to do this on python?
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.
Phillip Espina
Hello everyone, I'm using candlesticks to compare if it goes beyond my Upper Bollinger Bands. To get this I need the value of the CandleStick indicator that I am using right? But it only return 1 or -1 as in detecting Bull or Bear patterns. How should I be able to do this using CandleSticks?
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.
Rene Ordosgoitia
Hello guys, I´m trying to take access to the candlestick patterns libraries that are in the GitHub LEAN documentation, but there is not too much information related to how to calculate it in a universe selection approach.
In the next code, I want to use for the moment a simple condition to filter the stock that has an RSI value lower than 40 and the DojiStar built-in CandlestickPatterns library, but I don´t know how to use it in a universe selection approach:
import typing import QuantConnect.Indicators.CandlestickPatterns import datetime class EMAMomentumUniverse(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 10, 11) self.SetEndDate(2020, 11, 11) self.SetCash(1000) self.UniverseSettings.Resolution = Resolution.Daily self.AddUniverse(self.CoarseSelectionFunction) self.averages = { } def CoarseSelectionFunction(self, universe): selected = [] universe = sorted(universe, key=lambda c: c.DollarVolume, reverse=True) universe = [c for c in universe if (c.Price > 10)][:100] for coarse in universe: symbol = coarse.Symbol if symbol not in self.averages: # 1. Call history to get an array of 200 days of history data history = self.History(symbol, 200, Resolution.Daily) #2. Adjust SelectionData to pass in the history result self.averages[symbol] = SelectionData(history) #here is where im trying to create the bool variable. self.hammer = self.CandlestickPatterns.DojiStar(symbol) self.averages[symbol].update(self.Time, coarse.AdjustedPrice) if self.averages[symbol].is_ready() and (self.averages[symbol].rsi.Current.Value < 40): selected.append(symbol) return selected[:10] def OnSecuritiesChanged(self, changes): for security in changes.RemovedSecurities: self.Liquidate(security.Symbol) for security in changes.AddedSecurities: self.SetHoldings(security.Symbol, 0.10) class SelectionData(): #3. Update the constructor to accept a history array def __init__(self, history ): self.rsi = RelativeStrengthIndex(14) #4. Loop over the history data and update the indicators for data in history.itertuples(): self.rsi.Update(data.Index[1], data.close) def is_ready(self): return self.rsi.IsReady def update(self, time, price): self.rsi.Update(time, price)
Thanks a lot for any clue!
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!