Back

Help debugging an algorithm in Python

   I'm new in QC and I write to ask some help. I come from Q platform and I see this project such interesting. I have several live-trade algorithms in Q and I want to start developing here. 

   My objective is to develop in Python and I need to have debugger support, otherwise is very hard for me to develop. I write my story after one week and half of research and fight against QC. I know that Python is still on beta and there is lack of documentation, for that reason I am asking here.

   First I started developing with the web interface, using Python. The problem was that despite the backtest build successfully, there were runtime exceptions and the output doesn't clarify properly where the error is. I tried to debug using the web, but I saw it is not possible. 

Question 1: Can you confirm that is not possible to debug using the web interface in Python?

   As for me the debugger is very important, I tried to install QC locally, as the documentation says. I created a Windows VM, install Visual Studio Community, Lean the requirements and I started with a C# test project (just to test). I was able to run a backtest in C# and also run a  debugger. In C# the debugger worked as I expected. Then I realized that the quotes are stored locally, in the data directory. Nevertheless, my idea is to work with the 14 TB data that QC has.

Question 2: It is possible to run a backtests, in Visual Studio, with debugger, using QC database? 

Question 3: If it is not possible, something that I fully understand, how does people  use QC data? Develop locally and then copy/paste the code into the web interface? 

   Then, I tried to move to Python, which is my objective. I configured IronPython and I was able to run a local backtest using Python. The problem was that the debugger didn't work. I mean, I set breakpoints, and the backtests didn't stop in the breakpoint. 

Question 4: Is there a way to use the Visual Stuio Debugger with Python, to debug a backtests?

   I guess the debuger didn't work because Python code runs under IronPython, so I tried to run ipdb or pdb (Python debuger). My idea was, instead of using Visual Studio debuger, I can use Python debuger, which is ok for me. Nevertheless, QC raised an error importing ipdb or pdb

Question 5: If Visual Studio debuger is not possible in Python, is possible to use Python pdb or ipdb? I only needed localy, just to debug. 

I read that NumPy, Pandas and SciPy are not available. 

Question 5: I wonder what are the math libraries I can use to replace, when I have to create my own Indicators, or combination of indicators? I usually use Pandas.DataFrame and Pandas.Series.

I am very thankful with some help. I am looking forward to start coding in QC.

Update Backtest








Currently Lean/QuantConnect supports python with IronPython. However, we have been moving to pythonnet, since a known issue with IronPython is that it does not support 3rd party libraries. With the new framework, we have been able to use numpy with Lean.

Debugging python scripts within a C# framework is challenge because it depends on the available tools. It is not straight forward how it can be done with Visual Studio. One of beta tester managed to debug locally.

It is not possible to debug in the web IDE in python nor C#. It is definitely an item in our TODO list.
 

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.


Hello,
Found this via google, sorry for resurrecting such an old thread.

Has there been any progress on integrating debugging possibilities for python either offline or online?

+ Is there a way to run LEAN using python on OS X via Mono?

Best,J

0

Try following this tutorial for Lean Mac.

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.


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