Back

Python Integration

I was on the Github page and noticed python mentioned in the QC project description. Are there any plans to support this at some point?

Also can the web ide auto complete C# hints? Can't run visual studio easily as not on windows. Could go mono develop etc but web ide would be easier =).
Update Backtest








Hey Chris, sorry about the auto-complete we disabled it for the launch of the v2.0 of the IDE. Its in the plan to re-implement but second-place to live trading at the moment. If its a quick fix I'll have a look this weekend.

The python technology is completed, we haven't rolled it out mainly because we're worried supporting two languages will split user focus, double the bugs we're fixing, half the quality of support etc.

Perhaps in the next months we'll roll it out as a test and see how the adoption is and if there's overwhelming support we'll leave it installed. Choosing what not to build is half the battle with a start up :)..
0

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.


No problem. I was mostly curious about the python as I would eventually want to be able to plug into things like numpy, scipy, sklearn. When the python integration is complete on your end w. the data api would users be able to use these modules in strategy scripts?

On the IDE side I have everything building under Mono / Mono Develop so not a big deal there and certainly not weekend worthy hacking =).

-Chris
0

Just curious if there are still plans for rolling out Python support? I'd be interested to test, as almost all my past algo development has been in Python.
0

Hell yes @Gene! We're in a much better position to roll it out now too.

We can easily support python algorithm backtesting, but to do it properly we'd need syntax/error highlighting white you're coding. We ideally need a python expert to help us with a few of the technical parts of a python syntax error detector for the compiler.
0

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.


+1 for getting this implemented for Python users. I'm not happy in C# (not really that happy with much in Windows any more) and there's such depth of quant usage for Python available.
0

actually i dont understand why everyone is so fixated on python. python is good at data science, up to a point, where you dont have so much to backtest. When you have a lot of data, it is painfully slow, and when you want to do serious trading, python just couldnt be an option, because if speed of execution is not the most important thing in real trading, at least it is very very important. I think C# is pretty much the best language for the job, it is just a little bit harder to learn compare to python, it is highly expressive and elegant(with so much sugar added by MS, it looks more and more like python), and with C# 6.0, the compiler is even open up as a service so you can compile you C# strategy on the fly (I am not sure if this feature is implemented here). And more, MS open sourced .Net end of last year, the expectation is it will be fully functional on linux soon.

I would say this project is the first serious one for the so called online quant trading, because the engine is fast, so my advise is pick up C# to embrace the full power of this project.
0

Well, tisn't really a fixation as much as a bandwidth issue. I'm new to systematic trading, have full time jobs outside of this, have some good Python (and zero C#) experience, and I can find loads of good quant samples and models and blogs using Python, but not so much in C#. I'm not doing intraday trading so the speed issue you mention is not an issue for me, I'm so far sticking to pretty simple models. So... given the option, I'd much prefer Python here, so i'm upvoting it. Meanwhile, I'm working through the sample algorithms and learning C# as I go. I can't say it looks much like Python :-) but the code is largely readable, yes. I'm giving C# a go, but still voting for the option.
0

Nothing wrong with C#. It certainly has its merits; however, there is a reason python is heavily used in the Qaunt/Algorithmic trading community. Python, in the right hands, allows for quick/easy development with less time spent writing code and more time to focus on your trading algorithms.

For example, the powerful Pandas library allows you to do such things as perform a rolling_apply() to an dataframe (array) with just a line of code. Shifting arrays n values left or right can be done easily with Python/Pandas with a single function call. Splicing and all manner of array operation can be done in a single line of code with Pandas. Doing the same thing in other languages often involve complicated for loops and lining up the elements of the array can be error prone especially if you are trying to perform an operation on two different sized arrays, since Pandas allows indexing by timestamp, so you rarely have to worry about alignment issues.

Furthermore, python has a plethora of powerful libraries. The scikit-learn library allows one create a classifier or regressor (ie. SVM, RandomForests, KNN, etc) and fit it to an input and output and make a forward prediction in just a few lines of code. There are so many cases where a single line of python would have to be replaced by (multiple) for loops in another language.

I could go on and on. But really, C# is also a great language, and in some cases can be quite a bit faster. To each their own, but I think Python can't be so easily dismissed.
0

How feasible would it be to combine both?

For example, using QuantConnect's architecture for handling events (e.g., data feed, orders, portfolios, etc.) should be fast and not something you modify frequently. Then for signal generation, custom filters or whatever, just send data to Python and use numpy/pandas to process it and return output to C#.

Is that too optimistic?
0

@Alexis - that is the plan! :) We see it as a broader "support all languages" push.

Python should be a special QCAlgorithm class which uses IPython to route data & events across to the python side. We're so swamped and not really python experts though so its tough finding time. Also we're not sure how well IPython will support numpy/pandas.

We can also support all the .NET languages without changing anything -- just as long as the algorithms expose the same IAlgorithm interface. This opens up VB and F# as well.

Does anyone have experience with C#-Py interop?
0

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.


F# for algo dev sounds cool!
0

by the way, for pandas replacement, there is this lib called deedle for F# and C#, which also has a series/dataframe kind data structure, I have not used myself, but I guess worth to take a look. http://bluemountaincapital.github.io/Deedle/
0

Thank you for the suggestion Shuo, I've added it to our supported library and it will be live in the next couple of days.
0

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.


F# sounds very interesting. When you say without changing anything, does that mean this is available now?
0

@Reuben I mean without changing the engine LEAN :) We'll have to update the web UI to support other project languages, and the web-compiler to support compiling F#. If you're running the open source project locally and direct LEAN to load a VB/F# IAlgorithm I think it will just work.
0

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.



Python should be a special QCAlgorithm class which uses IPython to route data & events across to the python side. We're so swamped and not really python experts though so its tough finding time. Also we're not sure how well IPython will support numpy/pandas.


The problem is, a lot of the good/fast Python numerical libraries are actually just thin Python wrappers for C modules. These simply do not work with IronPython.

You can read more about the state of this here:
NumPy and SciPy Update

While there have been some projects to bring numpy/scipy to IronPython, they seem to be mostly abandoned in various states of functionality.

Bottom line: Python support for QC would be fairly trivial, but the oodles of numerical & data analysis libraries for Python wouldn't be available -- pretty much negating the value of adding Python. :/

There may be alternate approaches, I'm not super-deep into the architecture of Lean. But IronPython is probably not the solution, right now. :(
1

Python.NET uses CPython, so it doesn't suffer from compatibility issues with NumPy, SciPy and other libraries like IronPython does. Not sure how easy/hard it would be to integrate though.
1


Python.NET uses CPython, so it doesn't suffer from compatibility issues with NumPy, SciPy and other libraries like IronPython does. Not sure how easy/hard it would be to integrate though.


Yeah, I did see that. It looks promising, but I'd be a little concerned about depending on it long term, as there doesn't seem to be a lot of active development around it.
0

Yeah, I did see that. It looks promising, but I'd be a little concerned about depending on it long term, as there doesn't seem to be a lot of active development around it.

Last commit was on Feb 2, 2015. There have been quite a few recent commits. Seems pretty active to me.
0

Last commit was on Feb 2, 2015. There have been quite a few recent commits. Seems pretty active to me.


Yeah. I see what you are saying. Having the last commit from 4 months ago and only 7 commits in the past 12 months is below my personal threshold for "active", but that's just a difference of opinion. :)
0

We just added support for F-Sharp and Visual Basic on the open source Lean Project. It will take a little longer to add but we'll eventually support them here on the web IDE as well.
1

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.


Update Backtest





0

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.


Loading...

This discussion is closed