Hi there,
Here is a Project where Genetic Algorithms were used to develop a trading strategy by combining a fixed subset of signals chained by logical operators.
The project uses the genetic algorithm library GeneticSharp integrated with LEAN by James Smith.
The best out-of-sample trading strategy developed by the genetic algorithm showed a Sharpe Ratio of 2.28 in trading of EURUSD with 25 trades in the out-of-sample period of January – April 2017 (attached).
But more important that the results itself, are the layout of a framework flexible enough to test a wide range of strategies and the proof of concept of what is possible with two powerful open sources tools as Lean and GeneticSharp.
Also, the Lean-centric framework has two very strong advantages:
- The training evaluation can be as complex as needed (including ask-bid spread, fees, commissions, slippage model, risk management, etc.) to enhances the training by exposing the individuals to realistic environments.
- The QCAlgorithm used by the genetic algorithm to evaluate the individuals can be used to trade in live paper mode and even in real trade. Therefore, a profitable set up developed by the genetic algorithm can be tested in real time or put to trade immediately.
Here’s a kind of paper where is detailed the technical side of the implementation and the statistical analysis of the training session.
Hope you enjoy it!
James Smith
I think it's fairly clear that this raises the bar in terms of the quality of submissions to QC. The sophistication of the analysis and the approach go beyond most algorithms that are shared amongst trading communities and genuinely sets the template for an effective means to promote the on-going evolution of community driven quant trading strategies.
This algorithm represents a next-generation trading pattern super-set that is focussed on harnessing the abundance of available processing power for alpha discovery with genetic algorithms and machine learning techniques. This pattern should transfer to essentially any security and should be highly adaptable to different timescales.
@JayJayD: It might be worthwhile considering how it would be possible to extend and codify this model, so that for instance, additional indicators could be supported as well as multi-level chaining of logical operations.
It might also be helpful to outline the theoretical basis and suggested reading for this approach for anyone interested.
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.
Petter Hansson
@JayJayD: Can't view the PDF unfortunately, I will try accessing it again later.
@James Smith: The reason I didn't use the framework yet is simply because I'm using the cloud environment on QC - don't like dealing with data warehousing issues on my local machine. Are there any plans by QC to integrate your project with cloud environment?
I should say that curiously, I developed a genetic programming framework in Java prior to joining QC. However, I was analyzing daily bars and couldn't find much alpha in that case, I expect results to be much better with intraday data.
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.
JayJayD
James Smith thank you very much for your kind words, I truly appreciate it!
Respect to add more indicators, in the SetTradingRule method you can see that the number of indicators can be easily changed. In this implementation wasn’t a variable because of the difficulty of making variable the number of genes in the chromosome. But once you define your chromosome in the optimization.json in SharpNeat, you can change the number of indicators, and thus the operators.
Respect to making hierarchies of indicators, a quick way it can be implemented is through the ITechnicalIndicatorSignal implementation.
So, for example, the CrossingMovingAverages implementation send a True signal only when there is an actual crossing of MA's (as well the oscillators, this explain the low trades in the out-of-sample period), but you can easily change the GetSignal method to make more like a flag like this:
public bool GetSignal() { var signal = false; if (IsReady) { switch (_tradeRuleDirection) { case TradeRuleDirection.LongOnly: signal = Signal == CrossingMovingAveragesSignals.Bullish; break; case TradeRuleDirection.ShortOnly: signal = Signal == CrossingMovingAveragesSignals.Bearish; break; } } return signal; }
In this example a long-only CrossingMovingAverages instance will send a True signal when the fast moving average is above the slow one.
In any case the ITechnicalIndicatorSignal implementation can be as complex as you need as long as it returns a signal after an event.
Petter Hansson, the document issue is fixed, thanks for report it.
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.
Patrick Star
Beautiful code, Jay! and really appreciate you sharing it with us!
One question though... (and this maybe because I haven't tested the code yet and the answer could be in it already) how do you optimize the parameters? do you adjust them by manual testing? or by analyzing the historical data? Thanks!
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.
JayJayD
Thank youPatrick Star !
The optimization is made by GeneticSharp, using the integrationJames Smith made.
Please note that the attached backtest is a hard coded realization of a strategy developed by the GA. As is explained in the text, the algorithm used in the optimization process cannot be replicated in the QC platform because of the use of DynamicExpresso.
The mechanics is as follows:
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.
James Smith
In terms of hierarchies of indicator signals, my understanding is it should be possible to allow, for instance, ITradingSignal to have a reference to a child ITradingSignal instance along with a contingent switch that allows recursion into the hierarchy of indicator signals. So for instance you could have:
totalSignal = (parentSignal = EMA(240) > α AND RSI(240) < β) AND (childSignal = EMA(60) < γ)
Structuring this using recursion means you simply need to decide whether to branch into a child before reusing all the same logic to build the descendant. I believe one of the main problems with this approach is the complexity of the resultant models.
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.
Patrick Star
I can code almost anything but that's not the point. The real value is in creativity and ideas.. Looking at this project gives you a freash set of ideas and a different way of thinking. So thanks to both of you Jay and James. Keep it coming!
I am still slow in using LEAN locally but I will try to get it to work and learn GenericSharp and the integration part. I will ask more questions once I'm there :)
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.
JayJayD
James Smith, now I understand what you mean and yes complexity can explode. I‘m pretty sure that the chromosome represetation of framework like that should be very challenging!
Patrick Star, I’ll happy to help!
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.
Tim Butler
Fantastic stuff JayJayD and James. Spent half of yesterday getting Visual Studio up and running with the Genetic Sharp implementation and it works fantastically.
I only wish I didn't have to go and buy data for all my ideas I want to test.
I would have to say this is the only time I've ever wanted more than 4 cores.
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.
Tim Butler
One thing I'm itching to try is using different measures for fitness and seeing the results on out of sample data.
https://quantsketch.com/results_page.html#common-sense
Common Sense Ratio, Gain-to-Pain Ratio and Tail Ratio would be super interesting to play around with. I've peeked around the code and all I've managed to do so far is get lost. My C# is not strong enough.
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.
Tim Butler
Alright, so I've managed to figure out how to add the three ratios and use them as fitness measures. Just needed a bit of effort.
I'm not sure of the best way to share the changes to Lean, but if anyone is interested we can probably figure something out.
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
Tim Butler - We made all FX/CFD data free! :)
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.
JayJayD
Hey Tim Butler!
I’m so glad you find this work interesting! James made such amazing work that the GA integrations is painless.
As Jared Broad pointed out, data is not a problem. But, as you noted, one of the main drawbacks of this project is the training requirements of computational power. Is the cost of evaluating the individuals in a very realistic environment (Lean).
In every GA problem, the fitness definition is single most important definition. The indicator you mention seems pretty interesting, I’d love to see them working! Maybe you can try making some kind of weighted average between the different indicators and use it as fitness.
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.
Ryan Brickey
Hi,
When i try to run this in my live Oanda account, when i try to log in i get an error that the Oanda states are not the same. do you know where that needs to be corrected?
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
Ryan Brickey - Sounds like your oAuth got confused -- please write a quick email to support@quantconnect.com and we'll reset it for you.
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.
JayJayD
Hey Ryan Brickey, I wouldn’t put much expectation in this algorithm in particular, is just a proof of concept, the important thing here is the framework, not the resultant algorithm.
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.
Erik Bengtson
Hi JayJay,
Awesome framework.
I was able to run it on amazon EC2, but it consumed too much resources. I will consider other cheaper alternatives.
I did some modifications to the original TradingStrategies, like including Bollinger Bands, so I share it.
I would like to implement multiple rules, and for each rule have hierarchical operators for indicators. I improved somehow the parameters for a single rule, but not able to configure the hierarchy of operators. Please share if you have any ideas on how to configure hierarchical operators.
Of course, the modified strategy is meant to be used for educational purposes.
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.
James Smith
Thanks Erik. I was impressed by JayJayD's work on genetic programming and have started to work on my own derivation of this here:
jameschch/GeneticTreeAlgorithm
I have made substantial changes to the structure, fixed bugs and added unit tests. I have also provided support for a logical tree of operators including OR, NOT, (x OR y) etc. I have also added support for ADX and now plan to integrate your Bollinger bands code.
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.
James Smith
Forgot to add; I've also improved performance significantly.
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.
JayJayD
Hey Erick,
I’m so glad you found this work interesting! I’ll check the BB implementation.
You nailed it respect to its main weakness, the expensiveness of the training. If I’d deploy something like this project I’d use DigitalOcean, the VM aren’t that fast but are cheap and reliable; and the interface takes the pain away from IaaS.
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.
Link Liang
Hi KY,
Yes running Lean on your own is possible even if SLS opt-out is not prohibited in your country/region. Let us know if you have any problem in the setting up and deploying process of your server for Lean. Thanks for your support!
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.
Xiaolei
Hi,
I am trying to run Lean on my local server for live trading FX with Oanda. So what I have did so far are
Changed certain fields in `config.json`
"enviroment": "live-oanda", "oanda-environment": "Practice", "live-oanda": { "live-mode": false, ....}
and filled fields "job-user-id", "api-access-token", "oanda-access-token", "oanda-account-id" .
Then rebuild the solution. And ran a simple algorithm. However, I got an error
ERROR:: Engine.Run(): Error running algorithm System.InvalidCastException: Specified cast is not valid. at QuantConnect.Lean.Engine.Results.LiveTradingResultHandler.Initialize (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Interfaces.IMessagingHandler messagingHandler, QuantConnect.Interfaces.IApi api, QuantConnect.Lean.Engine.TransactionHandlers.ITransactionHandler transactionHandler) [0x00016] in <bc7b4fac3a6b4b2586612532d9acbdee>:0 at QuantConnect.Lean.Engine.Engine.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Lean.Engine.AlgorithmManager manager, System.String assemblyPath) [0x000b1] in <bc7b4fac3a6b4b2586612532d9acbdee>:0 20191216 09:26:36.682 ERROR:: LiveTradingResultHandler.StoreLog(): System.NullReferenceException: Object reference not set to an instance of an object at QuantConnect.Lean.Engine.Results.LiveTradingResultHandler.StoreLog (System.Collections.Generic.IEnumerable`1[T] logs) [0x00000] in <bc7b4fac3a6b4b2586612532d9acbdee>:0
Would anyone please help me with this? Or point out where can I find any documentations for setting up live trading locally.
Thanks in advance.
Xiao
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.
Xiaolei
I figured its my enviroment setting not correct, now everything works with the following settings
"live-mode-brokerage": "OandaBrokerage", "data-queue-handler": "OandaBrokerage", "setup-handler": "QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler", "result-handler": "QuantConnect.Lean.Engine.Results.LiveTradingResultHandler", "data-feed-handler": "QuantConnect.Lean.Engine.DataFeeds.LiveTradingDataFeed", "real-time-handler": "QuantConnect.Lean.Engine.RealTime.LiveTradingRealTimeHandler", "transaction-handler": "QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler", "history-provider": "BrokerageHistoryProvider"
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.
Libor Blaheta
Hello Jared
In the very first post of this thread you wrote
>>> You will need LEAN - our cross platform open-source project kernel of QuantConnect. It builds and runs locally with almost no effort. We ship small data samples with your project so you can see it working instantly. Windows, Linux or Max are supported. By default it is a CLI program and we provide a rudimentary GUI but community members have built beautiful GUI's for Windows.
Can you suggest what are those Windows GUIs, I have found only AlgoLoop on github.
Thanks
Libor
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
https://github.com/mirthestam/lean-monitor
https://github.com/Capnode/Algoloop
I didn't know about AlgoLoop! Very cool =)
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.
Shailesh Raval
Hi,
Today, I could successfully install QC-Lean on CentOS-7 VPS and run C# default algo. When I tried to run python algo, I faced some error. From error message, it looks like QC is looking for puthon 3.6 dll.executable where as I have installed python 3.8.1. on VPS.
20200118 15:49:13.936 ERROR:: Loader.TryCreatePythonAlgorithm(): System.DllNotFoundException: python3.6m assembly:<unknown assembly> type:<unknown type> member:(null)
at (wrapper managed-to-native) Python.Runtime.Runtime.Py_IsInitialized()
at Python.Runtime.Runtime.Initialize () [0x00000] in <c66998abee2f4df39ea2647af887c7b2>:0
at Python.Runtime.PythonEngine.Initialize (System.Collections.Generic.IEnumerable`1[T] args, System.Boolean setSysArgv) [0x0001e] in <c66998abee2f4df39ea2647af887c7b2>:0
Where should I change python3.6 to python3.8 ? or should I copy python3.8 as python3.6?
Thanks
Shailesh
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
Hi Shailesh Raval
Please check out the docker file we use in QuantConnect Cloud to create the images we use to run Lean.
At the moment, due to a restriction in pythonnet (the interface between C# and Python), we can only have support one version of Python and there is 3.6. So you will need to uninstall and/or downgrade your system's Python version.
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.
Shailesh Raval
Hi Alexandre,
I can not use docker file because my host server (where my VPS is hosted) is using some old 2.* verson kernel and Docker needs newer 3+ verson kernel. I can not uprade my VPS kernel..
I reinstalled python 3.6 after uninstalling/removing python 3.8. Still it is same issue. I have requested to migrate my vps to another server host which runs newer 3+ version kernel. Will try docker solution then.
Thank you very much..
Shailesh.
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.
Clyde Hunter
I just wanted to add something really fast. I'm almost done finishing my setup on my Linux server. There's a few changes to the current directions on the github README file I'd like to suggest. Is this the best way to provide those?
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
Thanks, Clyde -- best would be to create a Github issue with the proposed solution. Suggest running it by the team at support@quantconnect.com if you'd like feedback before opening the issue.
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.
Clyde Hunter
Ok cool, I figured! Just wanted to double check!
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.
Nabeel
If I understand correctly, looking at the launch script, it looks like we need to have built Lean locally already? That completely defeats the purpose of running it in Docker... for example, I develop mostly on a Mac... except, I have a minimal VS project with the dependencies loaded from nuget. I should just be able to create my own Dockerfile, sourcing from `quantconnect/lean:lean`, and then `COPY` in my algorithm and config files... building completely locally and having everything inside of Lean is way overkill.., This Docker setup makes no sense
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
Interesting feedback thanks Nabeel
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.
Sulfred
A question about Local lean. For the Coarse and Fine Universe, is it means that user need to buy the data from Morning star, receive and handle those data by themselves? Since that part is not open source ?
Thank you very much.
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
Correct Sulfred, the Morning Star dataset for the fine universe selection is not within the reach of individuals to purchase so we did not open source the processing technology for that dataset. We're happy to share it but just ask the institutions interested in using the code reach out to us at support@quantconnect.com.
Coarse universe selection you can assemble with almost any daily data source.
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.
Athon Millane
Thought I'd tack on to this thread as it's still relatively active. Has anyone running MacOS/Unix/Cloud deployment successfully got either of the open source UI offerings working? I imagine with the right configurations they could be packaged to run inside Docker. I have done very little digging but thought I might get a quick answer here. Thanks
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.
Derek Melchin
Hi Anthon,
We do not currently have any open-source UI offerings. Refer to this readme for instructions instructions with docker.
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.
Athon Millane
Hi Derek,
My question was referring in particular to Jared's links to 2 open source UI contributions in this comment earlier in the year.
https://github.com/mirthestam/lean-monitor
https://github.com/Capnode/Algoloop
Both appear to be designed to support Windows, but I (and I'm sure many others) use MacOS or remote containerised stacks (as suggested in Jared's original post about avoiding vendor lock in). My question was directed primarily at this subset of users asking whether anyone had successfully packaged either of these UIs to work system agnostic or within Docker.
If not, I'll experiment and see if I can set something up with these existing tools. Failing that I'd be happy to work towards an open source UI using Bokeh or some other toolset that closer approximates a Unix / open data science stack.
Thanks,
Athon
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
@Athon Millane no -- they're both windows only GUI's. We're trying to make something agnostic with Electron but it's quite picky. I think at this point just HTML+a charting lib like Bokeh would be a good option for LEAN open source.
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.
Carsten
I got Lean running on a Mac with python. I generated from a quandl bulk CSV the daily.zip(csv insid), the factor_files and map_files. Tested with this code, several ticker and everything fine, same resuts as zipline.
class tesla(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2010,1, 1)
self.SetEndDate(2020,1,1)
self.SetCash(50000)
self.AddEquity("AMZN", Resolution.Daily)
def OnData(self, data):
if not self.Portfolio.Invested:
self.SetHoldings("AMZN", 1)
BUT, if I use a universe
class test(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2018, 1, 1)
self.SetEndDate(2018, 6, 30)
self.SetCash(50000)
... more code in-between
self.AddUniverse(self.MyCoarseFilterFunction)
# plain vanilla universe
def MyCoarseFilterFunction(self, coarse):
sortedByDollarVolume = sorted(coarse, key=lambda x: x.DollarVolume, reverse=True)
filtered = [ x.Symbol for x in sortedByDollarVolume
if x.Price > 10 and x.DollarVolume > 10000000 ]
return filtered[:500]
I don't get any errors, but get returns of zerro.
I belive I have to tell the system what kind of stocks are availabe....
found in /Data/equity/usa/fundamental/coarse some csv files, should be easy to re-enginiere with a definition of the header and how to smoke the numbers behind the tickers? (try to copy a picture but did not display...but I guess its obvious wjat kind of csv files im talking about)
I hope I don't need the jason files which look more complicated and contain some fundamntal data.
Do I need more to get the system running?
Thanks Carsten
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!