forked from OpenBB-finance/OpenBB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Add Direction Of Trade Statistics From IMF (OpenBB-finance#…
…6683) * add direction of trade statistics from IMF * update readme * linting * linting
- Loading branch information
1 parent
39e30e8
commit 12b4863
Showing
15 changed files
with
2,515 additions
and
1,783 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
openbb_platform/core/openbb_core/provider/standard_models/direction_of_trade.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,66 @@ | ||
"""Direction Of Trade Standard Model.""" | ||
|
||
from datetime import date as dateType | ||
from typing import Literal, 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 DirectionOfTradeQueryParams(QueryParams): | ||
"""Direction Of Trade Query.""" | ||
|
||
__json_schema_extra__ = { | ||
"direction": { | ||
"choices": ["exports", "imports", "balance", "all"], | ||
}, | ||
"frequency": { | ||
"choices": ["month", "quarter", "annual"], | ||
}, | ||
} | ||
|
||
country: Optional[str] = Field( | ||
default=None, | ||
description=QUERY_DESCRIPTIONS.get("country", "") | ||
+ " None is an equiavlent to 'all'. If 'all' is used, the counterpart field cannot be 'all'.", | ||
) | ||
counterpart: Optional[str] = Field( | ||
default=None, | ||
description="Counterpart country to the trade. None is an equiavlent to 'all'." | ||
+ " If 'all' is used, the country field cannot be 'all'.", | ||
) | ||
direction: Literal["exports", "imports", "balance", "all"] = Field( | ||
default="balance", | ||
description="Trade direction. Use 'all' to get all data for this dimension.", | ||
) | ||
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", "") | ||
) | ||
frequency: Literal["month", "quarter", "annual"] = Field( | ||
default="month", description=QUERY_DESCRIPTIONS.get("frequency", "") | ||
) | ||
|
||
|
||
class DirectionOfTradeData(Data): | ||
"""Direction Of Trade Data.""" | ||
|
||
date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", "")) | ||
symbol: Optional[str] = Field( | ||
default=None, description=DATA_DESCRIPTIONS.get("symbol", "") | ||
) | ||
country: str = Field(description=DATA_DESCRIPTIONS.get("country", "")) | ||
counterpart: str = Field(description="Counterpart country or region to the trade.") | ||
title: Optional[str] = Field( | ||
default=None, description="Title corresponding to the symbol." | ||
) | ||
value: float = Field(description="Trade value.") | ||
scale: Optional[str] = Field(default=None, description="Scale of the value.") |
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
Oops, something went wrong.