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

[Feature] - Add Futures Curve Chart #6547

Merged
merged 20 commits into from
Jul 2, 2024
Merged

Conversation

IgorWounds
Copy link
Contributor

@IgorWounds IgorWounds commented Jun 27, 2024

  1. Why? (1-3 sentences or a bullet point list):

    • To Expand the charting coverage and provide a better UX.
  2. What? (1-3 sentences or a bullet point list):

    • Adds a chart to the futures curve endpoint.
  3. Impact (1-2 sentences or a bullet point list):

    • A new parameter chart is available on the command.
  4. Testing Done:

    • Ensured the chart worked and added tests for it.

@github-actions github-actions bot added enhancement Enhancement platform OpenBB Platform v4 PRs for v4 labels Jun 27, 2024
@deeleeramone
Copy link
Contributor

deeleeramone commented Jun 28, 2024

I have added the possibility for multiple dates, similarly to the yield_curve end point, but with a limitation on the historical data from yFinance being for active contracts only. The code isn't the prettiest, but it'll do until we can find a
better way to get the entire list of contract symbols associated with the continuation symbol.

I had to modifybasemodel_to_df to exclude None, in model_dump, so that the Optional[date] field doesn't trip to_df() when the field is not returned.

Screenshot 2024-06-27 at 9 57 40 PM

Cboe has been narrowed in scope to be just VIX futures. There is VX_AM and VX_EOD, where AM is the mid-morning trade-weighted average price level. When date(s) are requested, the VX1-VX9 symbols are supplied as identifiers to facilitate direct comparisons of the term structure.

The symbols, "vx", "vix", "^vix", are all interpreted as "VX_EOD".

Screenshot 2024-06-29 at 7 14 18 PM

@IgorWounds IgorWounds marked this pull request as ready for review July 1, 2024 12:05
@IgorWounds IgorWounds requested a review from hjoaquim July 1, 2024 14:32
@@ -133,8 +134,13 @@ def get_params(self) -> ChartParams:
).replace("/", "_")[1:]
if hasattr(ChartParams, charting_function):
return getattr(ChartParams, charting_function)()
raise ValueError(
f"Error: No chart parameters are defined for the route: {charting_function}"

Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain? if you tried to use an endpoint that doesn't have a charting function it should raise (it shouldn't also get here probably).

Copy link
Contributor

Choose a reason for hiding this comment

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

It does raise, in the lines above, if there is no route. After verifying the route exists, it checks ChartParams for that function; if it doesn't exist, then it will return the charting function's help. This allows parameters to be detailed in the code, outside of the charting extension.

@@ -139,7 +151,7 @@ def test_derivatives_futures_curve(params, headers):

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/derivatives/futures/curve?{query_str}"
result = requests.get(url, headers=headers, timeout=60)
result = requests.get(url, headers=headers, timeout=10)
Copy link
Contributor

Choose a reason for hiding this comment

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

might be a bad idea to have such a small timeout on an integration test, will probably cause a false positive.

Comment on lines +72 to +77
from openbb_charting.core.chart_style import ChartStyle
from openbb_charting.core.openbb_figure import OpenBBFigure
from openbb_charting.styles.colors import LARGE_CYCLER
from openbb_core.app.model.abstract.error import OpenBBError
from openbb_core.provider.abstract.data import Data
from pandas import DataFrame, to_datetime
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is due to import time reduction?

@IgorWounds IgorWounds added this pull request to the merge queue Jul 2, 2024
Merged via the queue into develop with commit 5c1a1ef Jul 2, 2024
8 checks passed
@IgorWounds IgorWounds deleted the feature/futures-curve-chart branch July 2, 2024 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking_change enhancement Enhancement platform OpenBB Platform v4 PRs for v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants