Back to Community
Experienced economist seeking advice

Hello everyone!

I'm an economist with a lot of trading experience, but I'm a total novice at coding. Going forward I'm looking to make a shift from my existing qualitative analysis to quantitative analysis so I basically need to convert my knowledge into code.

Currently I'm trying to find a platform where I can manipulate economic and market data, and use it to create trading strategies. For example, if I wanted to create a trading strategy where I buy the S&P 500 every time the VIX is over 20 and the Unemployment Rate is >6%, how would that be possible?

Most of the data I need is at FRED, but ideally I'd like to be able to add in more data sources. I'm looking for something object oriented and not too difficult to learn. Does anyone have any suggestions for a good platform for what I'm attempting to accomplish?

Thank you in advance.

6 responses

Hello Xavier,

For tools, see:

Looks like data are available, as well:

You'll face a learning curve (both Python and the Quantopian API). However, my sense is that at least for Python, your time will not be wasted. As I understand, it is becoming the de facto standard in data science, which would include fiddling around with economic data.

Note, however, that Quantopian is hyper-focused on their hedge fund, and so if you are interested in anything tangential (e.g. market timing of long-only SPY), it may not be a good long-term fit. Presumably, they'll keep their platform open and free at some level, but it is not entirely clear, in my opinion, that the offering will continue indefinitely. Recently, retail trading was dropped suddenly, and so it doesn't bode well for long-term support of activities not in direct support of harvesting algos and authors for the hedge fund (although perhaps the specific cost of retail trading was too high relative to the return, whereas the cost of maintaining a free platform for simulations is bearing fruit). I'm just cautioning you, since if you are looking for a tool that will still be available in 10 years, you might want to consider other options, as well. Quantopian is not software-as-a-service; it is a hedge fund (I think...few actual, verifiable details are available).

Hello Xavier,

Constructing a strategy like you're considering is definitely possible on Quantopian.

I agree with Grant that Python and Quantopian have a learning curve, but that it is time well-invested. I particularly suggest you invest in learning the research platform (Notebooks). You'll find it to be immensely powerful and will save you a lot of cycles of work if you do the analysis before you write the strategy itself.

As you learn the Quantopian platform, you may come up with ideas on how to construct a strategy this is eligible to receive an allocation.

I do have a quibble with Grant's characterization of Quantopian. We are an investment management firm, and that is indeed verifiable with the standard registration databases.


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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.

I hadn't kept up with the times. I see now that Q no longer calls itself a hedge fund but rather an investment management firm.

Hi Xavier, welcome to Quantopian. Based on your description, I'd say you came to the right place. I am an experienced programmer, but before learning about Quantopian I didn't know much about capital markets. It has been an awesome learning tool for me. It sounds like you're in the opposite scenario.

My advice to you is to find a Python tutorial and work your way through it while looking at the Quantopian tutorials in parallel. That way you'll get the introduction to Python that you need, while also getting a chance to try it out. You can use the Quantopian Research environment to follow along with any Python tutorial you find on the internet: you don't need to install anything to learn Python, if you do it this way. If you struggle, don't worry about it. In my opinion, the real learning in programming is done by struggling with examples of increasing difficulty.

To get started, click Research, Notebooks, + (New Notebook). Then, in the line that pops up starting with "In [ ]:", type this, then click the play button:
print('Hello, World!')

There, you've written your first Python program. With regards to your original example, of how to write an algorithm that longs the market when the unemployment rate is over 6% and the VIX is over 20, I have done this for you as an example. I must admit that even this simple example seems complicated to me. There are a few different APIs (application programming interfaces) you have to learn before you can expect to implement things like this first try. Besides basic Python, there are the Quantopian basics, pipeline, and at the minimum you have to be able to manipulate Pandas DataFrame objects. So if you have trouble, don't worry, a software engineer would expect to take a while before things seem easy when working with a new API. That being said, if you have something kind-of like what you want, you can start from there and try to put the puzzle pieces together.

So, with that caveat, the example code is attached to this backtest, click 'Clone Algorithm' to create a copy, modify it, and run your own backtests.

Clone Algorithm
Backtest from to with initial capital
Total Returns
Max Drawdown
Benchmark Returns
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 59c854e4ae62bb54b8ab2d2c
There was a runtime error.

Thank you all so much for your help. I'm glad to hear Python + Quantopian will be suitable for what I'm trying to accomplish. :)

I've been going through a Python tutorial all weekend and so far I've thoroughly enjoyed it. It will be awhile before I'm genuinely proficient, but I can tell it is going to be well worth the time invested.

Douglas, thanks a lot for spending the time to create that algorithm. I've cloned it as you suggested and reviewed the code. I can tell I'm going to learn a lot tinkering around with this code sample. :D

I'll begin familiarizing myself more with Quantopian this week. This is a very interesting place and I look forward to contributing to the forums going forward.

Hi Douglas,

Thanks again for sharing this example. I'm trying to pick up python and quantopian at the same time and it's proving a little challenging for me. Are you able to possibly share how one might access both the VIX open and close from a previous day?

I'm guessing that I could create another custom factor for the close and access it similar to how you have (context.results.Vix[context.spy][1]) however i was hoping you may suggest a "cleaner" way.