Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quandl price handler #53

Closed

Conversation

moonlight16
Copy link
Contributor

Okay I was able to get a quandl price handler working with Futures data. Although its currently using Equity pricing. The next step is to fix up QSTrader to recognize if the Ticker should be priced using Futures pricing or Equities pricing.

Note: this PR also included my previous PR to ignore Textmate files. Please suggest if there's a better workflow to handle all of this. I am pushing these from non-master branches. But I wanted to work off the same code base as the previous PR (because i wanted git to ignore Textmate files). Also, I noticed each one of my commits is showing up. Should I being squashing these? or if you accept this PR will you be able to squash? (sorry for the newbie questions. still getting used to the workflows in GitHub)

@moonlight16
Copy link
Contributor Author

After thought:
I suppose normally one would split PRs into separate branches. So that each PR could be accepted independently. So I guess with the approach that I've chosen @mhallsmoore is forced to look at accepting the first PR before the 2nd PR (an ordered PR chain if you will). Am I understanding this correctly?

@femtotrader
Copy link
Contributor

femtotrader commented Jun 24, 2016

My opinion is that a more general price handler with Pandas DataFrame (or Pandas Panel when several tickers are given) as input will be better.
Because it will work what ever your data source is.
It could be Pandas-DataReader, Quandl or any other data source

An example with Pandas DataReader

In [1]: import pandas_datareader as pdr
In [12]: pdr.DataReader(["GOOG", "IBM"], "yahoo")
Out[2]:
<class 'pandas.core.panel.Panel'>
Dimensions: 6 (items) x 1630 (major_axis) x 2 (minor_axis)
Items axis: Open to Adj Close
Major_axis axis: 2010-01-04 00:00:00 to 2016-06-23 00:00:00
Minor_axis axis: GOOG to IBM

I'm just wondering if Quandl Python client support 3D datastructure...
quandl/quandl-python#74

@moonlight16
Copy link
Contributor Author

Quandl does return data already in Pandas DataFrame format. The only problem with pandas_datareader is that they don't support Quandl as a data source. This change was specifically to leverage the databases provided by Quandl; in particular futures data and other hard to find economic data.

As to your suggestion about a more general handler. I guess what we have is price handlers that are starting with data in some format (i.e. CSV), and the price handler is written to recognize the format. i.e. YahooPriceHandler isn't getting the data from Yahoo (someone/something already downloaded that data into CSV format), rather its built to just recognize the format of data in a CSV file.

I guess I did something a bit different here. I could have downloaded the CSV file from Quandl, and then had my price handler read the CSV file and load it into a DataFrame data structure. But I found the Python Quandl API already returns a Pandas DataFrame. So I just kept that. The downside is that it goes across the wire for each backtest, which I was originally concerned about, but I found the execution to be surprisingly fast (100Mbps network) - even on a daily bar /ES eminis going back to 1982 or whatever it was. But of course we'll need something that's more friendly when running "1000 backtests".

One ideaI that I was tossing. If it retrieved the data, then store it as CSV (or I prefer sqlite db) as sort of a cache. Then basically use this as a data cache when deciding if it needs to go to Quandl or get it locally.

Stepping back a bit. I feel like this is over engineering the price handler.
I'm thinking we really need a separate data source tool (rather than manually downloading the CSVs). Especially if your running continuous backtests daily or weekly and you want to be testing against the latest datasets.

Some other considerations. How does this affect a live trader. Do brokerages (i.e. IB) already give you historical data in their APIs? or does a live trader need also use this local db for strategy analysis? I just downloaded IBs API to learn more.

Sorry for the long post. Just trying to flush this out some more.

@femtotrader
Copy link
Contributor

femtotrader commented Jun 24, 2016

I understand perfectly that pandas_datareader doesn't have Quandl source... it's just an example to show what Panels are and how they can be an interesting datastructure to create a price handler (for several tickers)

About caching, you might have a look at quandl/quandl-python#30
Idea was to use requests-cache with SQLite as backend.

See http://pandas-datareader.readthedocs.io/en/latest/cache.html

@moonlight16
Copy link
Contributor Author

Sorry, thanks for clarifying. Let me digest it some more.

Very interesting links on the caching mechanism, thanks for sharing!

@femtotrader
Copy link
Contributor

@jacohn16 You should have a look at quandl/quandl-python#74

@juliettejames
Copy link
Collaborator

Closed due to deprecation of Quandl data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants