Skip to content

Commit

Permalink
add currency snapshots from polygon (#6333)
Browse files Browse the repository at this point in the history
  • Loading branch information
deeleeramone authored Apr 23, 2024
1 parent 2ccf39d commit 6b3d6fb
Show file tree
Hide file tree
Showing 8 changed files with 2,766 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ def test_currency_reference_rates(params, headers):
"quote_type": "indirect",
}
),
(
{
"provider": "polygon",
"base": "USD,XAU",
"counter_currencies": "EUR,JPY,GBP",
"quote_type": "indirect",
}
),
],
)
@pytest.mark.integration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ def test_currency_reference_rates(params, obb):
"quote_type": "indirect",
}
),
(
{
"provider": "polygon",
"base": "USD,XAU",
"counter_currencies": "EUR,JPY,GBP",
"quote_type": "indirect",
}
),
],
)
@pytest.mark.integration
Expand Down
151 changes: 147 additions & 4 deletions openbb_platform/openbb/assets/reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@
{
"name": "base",
"type": "Union[str, List[str]]",
"description": "The base currency symbol. Multiple items allowed for provider(s): fmp.",
"description": "The base currency symbol. Multiple items allowed for provider(s): fmp, polygon.",
"default": "usd",
"optional": true
},
Expand All @@ -826,13 +826,14 @@
},
{
"name": "provider",
"type": "Literal['fmp']",
"type": "Literal['fmp', 'polygon']",
"description": "The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default.",
"default": "fmp",
"optional": true
}
],
"fmp": []
"fmp": [],
"polygon": []
},
"returns": {
"OBBject": [
Expand All @@ -843,7 +844,7 @@
},
{
"name": "provider",
"type": "Optional[Literal['fmp']]",
"type": "Optional[Literal['fmp', 'polygon']]",
"description": "Provider name."
},
{
Expand Down Expand Up @@ -979,6 +980,148 @@
"default": null,
"optional": true
}
],
"polygon": [
{
"name": "vwap",
"type": "float",
"description": "The volume-weighted average price.",
"default": null,
"optional": true
},
{
"name": "change",
"type": "float",
"description": "The change in price from the previous day.",
"default": null,
"optional": true
},
{
"name": "change_percent",
"type": "float",
"description": "The percentage change in price from the previous day.",
"default": null,
"optional": true
},
{
"name": "prev_open",
"type": "float",
"description": "The previous day's opening price.",
"default": null,
"optional": true
},
{
"name": "prev_high",
"type": "float",
"description": "The previous day's high price.",
"default": null,
"optional": true
},
{
"name": "prev_low",
"type": "float",
"description": "The previous day's low price.",
"default": null,
"optional": true
},
{
"name": "prev_volume",
"type": "float",
"description": "The previous day's volume.",
"default": null,
"optional": true
},
{
"name": "prev_vwap",
"type": "float",
"description": "The previous day's VWAP.",
"default": null,
"optional": true
},
{
"name": "bid",
"type": "float",
"description": "The current bid price.",
"default": null,
"optional": true
},
{
"name": "ask",
"type": "float",
"description": "The current ask price.",
"default": null,
"optional": true
},
{
"name": "minute_open",
"type": "float",
"description": "The open price from the most recent minute bar.",
"default": null,
"optional": true
},
{
"name": "minute_high",
"type": "float",
"description": "The high price from the most recent minute bar.",
"default": null,
"optional": true
},
{
"name": "minute_low",
"type": "float",
"description": "The low price from the most recent minute bar.",
"default": null,
"optional": true
},
{
"name": "minute_close",
"type": "float",
"description": "The close price from the most recent minute bar.",
"default": null,
"optional": true
},
{
"name": "minute_volume",
"type": "float",
"description": "The volume from the most recent minute bar.",
"default": null,
"optional": true
},
{
"name": "minute_vwap",
"type": "float",
"description": "The VWAP from the most recent minute bar.",
"default": null,
"optional": true
},
{
"name": "minute_transactions",
"type": "float",
"description": "The number of transactions in the most recent minute bar.",
"default": null,
"optional": true
},
{
"name": "quote_timestamp",
"type": "datetime",
"description": "The timestamp of the last quote.",
"default": null,
"optional": true
},
{
"name": "minute_timestamp",
"type": "datetime",
"description": "The timestamp for the start of the most recent minute bar.",
"default": null,
"optional": true
},
{
"name": "last_updated",
"type": "datetime",
"description": "The last time the data was updated.",
"default": "",
"optional": false
}
]
},
"model": "CurrencySnapshots"
Expand Down
55 changes: 46 additions & 9 deletions openbb_platform/openbb/package/currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def snapshots(
base: Annotated[
Union[str, List[str]],
OpenBBField(
description="The base currency symbol. Multiple comma separated items allowed for provider(s): fmp."
description="The base currency symbol. Multiple comma separated items allowed for provider(s): fmp, polygon."
),
] = "usd",
quote_type: Annotated[
Expand All @@ -170,7 +170,7 @@ def snapshots(
),
] = None,
provider: Annotated[
Optional[Literal["fmp"]],
Optional[Literal["fmp", "polygon"]],
OpenBBField(
description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default."
),
Expand All @@ -182,12 +182,12 @@ def snapshots(
Parameters
----------
base : Union[str, List[str]]
The base currency symbol. Multiple comma separated items allowed for provider(s): fmp.
The base currency symbol. Multiple comma separated items allowed for provider(s): fmp, polygon.
quote_type : Literal['direct', 'indirect']
Whether the quote is direct or indirect. Selecting 'direct' will return the exchange rate as the amount of domestic currency required to buy one unit of the foreign currency. Selecting 'indirect' (default) will return the exchange rate as the amount of foreign currency required to buy one unit of the domestic currency.
counter_currencies : Union[List[str], str, None]
An optional list of counter currency symbols to filter for. None returns all.
provider : Optional[Literal['fmp']]
provider : Optional[Literal['fmp', 'polygon']]
The provider to use for the query, by default None.
If None, the provider specified in defaults is selected or 'fmp' if there is
no default.
Expand All @@ -197,7 +197,7 @@ def snapshots(
OBBject
results : List[CurrencySnapshots]
Serializable results.
provider : Optional[Literal['fmp']]
provider : Optional[Literal['fmp', 'polygon']]
Provider name.
warnings : Optional[List[Warning_]]
List of warnings.
Expand Down Expand Up @@ -227,9 +227,10 @@ def snapshots(
prev_close : Optional[float]
The previous close price.
change : Optional[float]
The change in the price from the previous close. (provider: fmp)
The change in the price from the previous close. (provider: fmp, polygon)
change_percent : Optional[float]
The change in the price from the previous close, as a normalized percent. (provider: fmp)
The change in the price from the previous close, as a normalized percent. (provider: fmp);
The percentage change in price from the previous day. (provider: polygon)
ma50 : Optional[float]
The 50-day moving average. (provider: fmp)
ma200 : Optional[float]
Expand All @@ -240,6 +241,42 @@ def snapshots(
The 52-week low. (provider: fmp)
last_rate_timestamp : Optional[datetime]
The timestamp of the last rate. (provider: fmp)
vwap : Optional[float]
The volume-weighted average price. (provider: polygon)
prev_open : Optional[float]
The previous day's opening price. (provider: polygon)
prev_high : Optional[float]
The previous day's high price. (provider: polygon)
prev_low : Optional[float]
The previous day's low price. (provider: polygon)
prev_volume : Optional[float]
The previous day's volume. (provider: polygon)
prev_vwap : Optional[float]
The previous day's VWAP. (provider: polygon)
bid : Optional[float]
The current bid price. (provider: polygon)
ask : Optional[float]
The current ask price. (provider: polygon)
minute_open : Optional[float]
The open price from the most recent minute bar. (provider: polygon)
minute_high : Optional[float]
The high price from the most recent minute bar. (provider: polygon)
minute_low : Optional[float]
The low price from the most recent minute bar. (provider: polygon)
minute_close : Optional[float]
The close price from the most recent minute bar. (provider: polygon)
minute_volume : Optional[float]
The volume from the most recent minute bar. (provider: polygon)
minute_vwap : Optional[float]
The VWAP from the most recent minute bar. (provider: polygon)
minute_transactions : Optional[float]
The number of transactions in the most recent minute bar. (provider: polygon)
quote_timestamp : Optional[datetime]
The timestamp of the last quote. (provider: polygon)
minute_timestamp : Optional[datetime]
The timestamp for the start of the most recent minute bar. (provider: polygon)
last_updated : Optional[datetime]
The last time the data was updated. (provider: polygon)
Examples
--------
Expand All @@ -256,7 +293,7 @@ def snapshots(
"provider": self._get_provider(
provider,
"/currency/snapshots",
("fmp",),
("fmp", "polygon"),
)
},
standard_params={
Expand All @@ -265,6 +302,6 @@ def snapshots(
"counter_currencies": counter_currencies,
},
extra_params=kwargs,
info={"base": {"multiple_items_allowed": ["fmp"]}},
info={"base": {"multiple_items_allowed": ["fmp", "polygon"]}},
)
)
2 changes: 2 additions & 0 deletions openbb_platform/providers/polygon/openbb_polygon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from openbb_polygon.models.crypto_historical import PolygonCryptoHistoricalFetcher
from openbb_polygon.models.currency_historical import PolygonCurrencyHistoricalFetcher
from openbb_polygon.models.currency_pairs import PolygonCurrencyPairsFetcher
from openbb_polygon.models.currency_snapshots import PolygonCurrencySnapshotsFetcher
from openbb_polygon.models.equity_historical import PolygonEquityHistoricalFetcher
from openbb_polygon.models.equity_nbbo import PolygonEquityNBBOFetcher
from openbb_polygon.models.income_statement import PolygonIncomeStatementFetcher
Expand All @@ -29,6 +30,7 @@
"CryptoHistorical": PolygonCryptoHistoricalFetcher,
"CurrencyHistorical": PolygonCurrencyHistoricalFetcher,
"CurrencyPairs": PolygonCurrencyPairsFetcher,
"CurrencySnapshots": PolygonCurrencySnapshotsFetcher,
"EquityHistorical": PolygonEquityHistoricalFetcher,
"EquityNBBO": PolygonEquityNBBOFetcher,
"EtfHistorical": PolygonEquityHistoricalFetcher,
Expand Down
Loading

0 comments on commit 6b3d6fb

Please sign in to comment.