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
Determine resolution for plots from data first, then from session #49
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an improvement. But I feel that what would be a better fix is to keep around the resolution from the point at which we query the db. We currently seem to lose the information when we simplify the index of the returned BeliefsDataFrame to a regular pandas DataFrame.
I didn't see a way to preserve freq during index simplification. Well, preserve is the wrong word, as it's not in the index in the first place. Maybe it's an improvement that could be done on the Pandas side, but I'm sure it's complex. Finally, we might have other ways to get data here, so I guess this safety can't hurt. |
Rather than in the index, the BeliefsDataFrame explicitly keeps track of the event resolution as a metadata property:
Here, data points are spaced 1 day apart, while each data point describes an hourly price.
Agreed. |
So is it wrong to assume that |
That's a tough question, because I believe it is posed in the form of a misconception. You're looking to determine the resolution (bar width), not the frequency (spacing). So event_resolution is a great first guess, and index frequency is a reasonable fallback. I'm preparing a commit now that makes simplify_index retain the event_resolution, so it is actually picked up by the line you added. |
Our code to create data plots relied on the session holding the resolution. However, when we use it through the API (e.g. #39) there is no session, and we should actually look to the data we got passed.
We get a pandas DataFrame which often has no
index.freq
attribute ― because the index was a BeliefsDataFrame index which was then simplified.So I added logic to infer the resolution from the data, which works pretty well.