-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Add EIA Daily Spot Prices Data via FRED (#6677)
* add EIA daily spot prices data via FRED * line too long * comment out the test skipped test * fix test? * delete commented out sections * unused argument * name things like Minh says --------- Co-authored-by: Igor Radovanovic <[email protected]>
- Loading branch information
1 parent
c786852
commit b9de848
Showing
17 changed files
with
1,274 additions
and
519 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
openbb_platform/core/openbb_core/provider/standard_models/commodity_spot_prices.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"""Commodity Spot Prices Standard Model.""" | ||
|
||
from datetime import ( | ||
date as dateType, | ||
) | ||
from typing import Optional | ||
|
||
from pydantic import Field | ||
|
||
from openbb_core.provider.abstract.data import Data | ||
from openbb_core.provider.abstract.query_params import QueryParams | ||
from openbb_core.provider.utils.descriptions import ( | ||
DATA_DESCRIPTIONS, | ||
QUERY_DESCRIPTIONS, | ||
) | ||
|
||
|
||
class CommoditySpotPricesQueryParams(QueryParams): | ||
"""Commodity Spot Prices Query.""" | ||
|
||
start_date: Optional[dateType] = Field( | ||
default=None, | ||
description=QUERY_DESCRIPTIONS.get("start_date", ""), | ||
) | ||
end_date: Optional[dateType] = Field( | ||
default=None, | ||
description=QUERY_DESCRIPTIONS.get("end_date", ""), | ||
) | ||
|
||
|
||
class CommoditySpotPricesData(Data): | ||
"""Commodity Spot Prices Data.""" | ||
|
||
date: dateType = Field( | ||
description=DATA_DESCRIPTIONS.get("date", ""), | ||
) | ||
symbol: Optional[str] = Field( | ||
default=None, | ||
description=DATA_DESCRIPTIONS.get("symbol", ""), | ||
) | ||
commodity: Optional[str] = Field( | ||
default=None, | ||
description="Commodity name.", | ||
) | ||
price: float = Field( | ||
description="Price of the commodity.", | ||
json_schema_extra={"x-unit_measurement": "currency"}, | ||
) | ||
unit: Optional[str] = Field( | ||
default=None, | ||
description="Unit of the commodity price.", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
openbb_platform/extensions/commodity/openbb_commodity/price/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Commodity Price.""" |
33 changes: 33 additions & 0 deletions
33
openbb_platform/extensions/commodity/openbb_commodity/price/price_router.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Price Router.""" | ||
|
||
# pylint: disable=unused-argument | ||
|
||
from openbb_core.app.model.command_context import CommandContext | ||
from openbb_core.app.model.example import APIEx | ||
from openbb_core.app.model.obbject import OBBject | ||
from openbb_core.app.provider_interface import ( | ||
ExtraParams, | ||
ProviderChoices, | ||
StandardParams, | ||
) | ||
from openbb_core.app.query import Query | ||
from openbb_core.app.router import Router | ||
|
||
router = Router(prefix="/price") | ||
|
||
|
||
@router.command( | ||
model="CommoditySpotPrices", | ||
examples=[ | ||
APIEx(parameters={"provider": "fred"}), | ||
APIEx(parameters={"provider": "fred", "commodity": "wti"}), | ||
], | ||
) | ||
async def spot( | ||
cc: CommandContext, | ||
provider_choices: ProviderChoices, | ||
standard_params: StandardParams, | ||
extra_params: ExtraParams, | ||
) -> OBBject: | ||
"""Commodity Spot Prices.""" | ||
return await OBBject.from_query(Query(**locals())) |
Oops, something went wrong.