INNER CODE UNIT · Python
_format_strike
baileydanseglio/thetadata-python · thetadata/client.py:34
def _format_strike(strike: float) -> int:
"""Round USD to the nearest tenth of a cent, acceptable by the terminal."""
return round(strike * 1000)
def _format_date(dt: date) -> str:
"""Format a date obj into a string acceptable by the terminal."""
return dt.strftime("%Y%m%d")
def ms_to_time(ms_of_day: int) -> datetime.time:
"""Converts milliseconds of day to a time object."""
return datetime(year=2000, month=1, day=1, hour=int((ms_of_day / (1000 * 60 * 60)) % 24),
minute=int(ms_of_day / (1000 * 60)) % 60, second=int((ms_of_day / 1000) % 60),
microsecond=(ms_of_day % 1000) * 1000).time()
_pt_to_price_mul = [