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

Generate Lines in chart.html Using Default Data #29

Closed
wants to merge 1 commit into from
Closed

Generate Lines in chart.html Using Default Data #29

wants to merge 1 commit into from

Conversation

11
Copy link

@11 11 commented Dec 17, 2020

Description

No lines were rendered inside chart.html after running backtest.chart() on your example backtest algorithm and BTCUSD data

I'm not exactly sure if the issue I'm running into is an error, or if just the example data included in this repo requires updating - but as mentioned here in your README:

"If you have your own data that has/hasn't been processed, you should conform to the following structure. Basically, load your data into a Pandas dataframe object and be sure to convert the dates to datetime format"

it could just be that the data was formatted incorrectly

Github Issue

this open issue

Changes

The pandas dates that were stored inside the self.data['date'] object needed to be converted from strings to datetime objects using pd.to_datetime(self.data['date'])

How to Replicate

This was the guide I was following:
https://gemini-docs.readthedocs.io/en/latest/using-gemini.html#basic

This was the data I used:
https://github.com/anfederico/gemini/blob/master/examples/data/BTC_USD.csv

This is the HTML that was generated into chart.html:
https://gist.github.com/11/159820cdf0a7b8dd69bd928add991acd

Screenshots

Broken version of backtest.charts()
image

Updated version
image

@11 11 mentioned this pull request Dec 17, 2020
p.line(self.data['date'], self.account.equity, color='#49516F', legend='Strategy')
base_equity = [price*shares for price in self.data['open']]
p.line(pd.to_datetime(self.data['date']), base_equity, color='#CAD8DE', legend='Buy and Hold')
p.line(pd.to_datetime(self.data['date']), self.account.equity, color='#49516F', legend='Strategy')
Copy link
Author

@11 11 Dec 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anfederico I removed some unwanted whitespace in this file -- but line 129 & 130 is the main hack I used to get your example data to work

@11 11 changed the title Fixing Line Plotting Issue when Generating Graphs Generate Lines in chart.html Using Default Data Dec 17, 2020
@anfederico anfederico closed this Jun 1, 2021
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.

2 participants