Skip to content

Commit 4dc96b9

Browse files
authored
Merge pull request #11 from PhantomResearch/support-data-system
Add cached last price function for Polygon API
2 parents 84f1944 + 6127f36 commit 4dc96b9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

phantom_core/polygon.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from .constants import DATA_TIME_ZONE, PERIOD_CNAME
1313
from .ohlcv import clean_ohlcv
1414
from .market_dataframe import MarketDataFrame
15+
from .cache import ttl_cached
1516

1617

1718
def _response_empty(resp: Any) -> bool:
@@ -275,4 +276,9 @@ def get_last_price(ticker: str) -> float:
275276
assert isinstance(last_trade, LastTrade)
276277
assert last_trade.price is not None
277278
last_price = float(last_trade.price)
278-
return last_price
279+
return last_price
280+
281+
282+
@ttl_cached(20)
283+
def get_last_price_cached(ticker: str) -> float:
284+
return get_last_price(ticker)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "phantom-core"
3-
version = "0.0.10"
3+
version = "0.0.11"
44
description = "Phantom Core"
55
authors = ["Adam Lineberry <ablineberry@gmail.com>"]
66
license = "MIT"

0 commit comments

Comments
 (0)