-
-
Notifications
You must be signed in to change notification settings - Fork 782
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
Futures Data (CME, EUREX, etc) #313
Comments
Hi @jortiz12, Yes this is possible. I would also recommend you have a look at alternatives that could be used as a substitute to make life a bit easier (e.g. there might be ETFs that track the same instruments?). However, if you are after a higher level of accuracy you can simply download the data for the timeframe you are after (direct from CME, EUREX, etc), save it to .csv or .xlsx format (example below uses csv), place this file in the same folder as your python script, import that into your script and use import quantstats as qs
import pandas as pd
instrument_daily_close_price = pd.read_csv("instrument_daily_close_price.csv")
instrument_daily_close_price['Date'] = pd.to_datetime(instrument_daily_close_price['Date'], format='%d/%m/%Y')
instrument_daily_close_price['pct_change'] = instrument_daily_close_price['Price'].pct_change()
instrument_daily_close_price = instrument_daily_close_price[['Date','pct_change']] # Drop out all unrequired columns
instrument_daily_close_price = instrument_daily_close_price.set_index('Date')
instrument_daily_close_price_series = instrument_daily_close_price.squeeze() # Convert to pandas series
instrument_daily_close_price_series.index = instrument_daily_close_price_series.index.tz_localize(None)
comparison_instrument = qs.utils.download_returns('SPY') # Download historical prices for benchmark.
comparison_instrument.index = comparison_instrument.index.tz_localize(None)
qs.reports.html(instrument_daily_close_price_series, comparison_instrument, output=1, download_filename="output.html") Let me know if this answers your question? Kind regards, |
Dear Community,
Is it possible to supply QuantStats with external futures data saved in .csv or .xlsx format.
Typical data providers (e.g. YFinance) don´t have data I'm looking for (mostly bond futures at CME, EUREX).
Kind Regards
Jose
The text was updated successfully, but these errors were encountered: