Skip to content

Commit

Permalink
style: improve type handling
Browse files Browse the repository at this point in the history
Signed-off-by: bossenti <[email protected]>
  • Loading branch information
bossenti committed Nov 4, 2023
1 parent ffbede5 commit 1856b2d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions vistafetch/model/asset/financial_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,29 @@ def __query_day_price_data(self, day: datetime.date) -> PriceData:
"Please use a valid financial asset class."
)

if self.market is None:
raise RuntimeError(
"No market information available - Unable to query price data."
)

response = api_session.get(
f"{ONVISTA_API_BASE_URL}instruments/{self.entity_type}/ISIN:{self.isin}/eod_history?idNotation={self.market.id_notation}&range=D1&startDate={day.year}-{day.month}-{day.day}"
# type: ignore
f"{ONVISTA_API_BASE_URL}instruments/{self.entity_type}/ISIN:{self.isin}/eod_history?idNotation="
f"{self.market.id_notation}&range=D1&startDate={day.year}-{day.month}-{day.day}"
)

price_raw = response.json()

if len(price_raw["datetimeLast"]) == 0:
return PriceData.model_construct(
currency_symbol=None, datetime_high=None, datetime_last=None, datetime_low=None,
datetime_open=None, high=None, last=None, low=None, open=None
currency_symbol=None,
datetime_high=None,
datetime_last=None,
datetime_low=None,
datetime_open=None,
high=None,
last=None,
low=None,
open=None,
)

return PriceData.model_construct(
Expand Down

0 comments on commit 1856b2d

Please sign in to comment.