QuantConnect / Lean

Lean Algorithmic Trading Engine by QuantConnect (Python, C#)
https://lean.io
Apache License 2.0
9.97k stars 3.29k forks source link

Loading Downloaded zip data into Python Notebooks #1960

Closed facultywork closed 6 years ago

facultywork commented 6 years ago

I've downloaded zip files of CFD hourly data from OANDA via the Quantconnect site and placed them in the Data/cfd directory of the Lean repo. My directory structure looks like this:

├── cfd
│       ├── daily
│       │   └── xauusd.zip
│       ├── hour
│       │   ├── spx500usd.zip
│       │   ├── us2000usd.zip
│       │   ├── us30usd.zip
│       │   └── xauusd.zip

I tried to load the data in my notebook via

spx500 = qb.AddCfd("SPX500USD")
us30 = qb.AddCfd("US30USD")
us2000 = qb.AddCfd("US2000USD")
xauusd = qb.AddCfd("XAUUSD")

And to get a Dataframe of values

# Gets historical data from the subscribed assets, the last 360 datapoints with daily resolution
h1 = qb.History([xauusd.Symbol], datetime(2014,1,1), datetime.now(), Resolution.Daily) #Daily)
# Plot closing prices from "SPY" 
h1.index

And as a result I got nothing:

Index([], dtype='object')

What am I doing wrong?

AlexCatarino commented 6 years ago

Please define the Market:

xau = qb.AddCfd("XAUUSD", Resolution.Minute, Market.Oanda)

The default market for CFD is Market.FXCM, so Lean looks for CFD data in Lean/Data/cdf/fxcm instead of Lean/Data/cdf/oanda.