Update api.py
This function receive a date in this format DDMMMYY and returns timestamps intmax_pain_deribit
parent
f2f7855e54
commit
7b02df9b49
|
@ -112,6 +112,10 @@ def deribit_timestamp(when: datetime) -> int:
|
|||
)
|
||||
|
||||
|
||||
def get_timestamp_int(expiry_date: str) -> int:
|
||||
return int(time.mktime(time.strptime(expiry_date, '%d%b%y')))
|
||||
|
||||
|
||||
def str_to_cb_sym(name: str) -> Symbol:
|
||||
base, strike_price, expiry_date, option_type = name.split('-')
|
||||
|
||||
|
@ -124,8 +128,9 @@ def str_to_cb_sym(name: str) -> Symbol:
|
|||
else:
|
||||
raise Exception("Couldn\'t parse option type")
|
||||
|
||||
new_expiry_date = get_values_from_cb_normalized_date(expiry_date)
|
||||
|
||||
new_expiry_date: int = get_timestamp_int(
|
||||
get_values_from_cb_normalized_date(expiry_date)
|
||||
)
|
||||
return Symbol(
|
||||
base=base,
|
||||
quote=quote,
|
||||
|
@ -145,6 +150,7 @@ def piker_sym_to_cb_sym(name: str) -> Symbol:
|
|||
)= tuple(
|
||||
name.upper().split('-'))
|
||||
|
||||
new_expiry_date = get_timestamp_int(expiry_date)
|
||||
quote: str = base
|
||||
|
||||
if option_type == 'P':
|
||||
|
@ -160,7 +166,7 @@ def piker_sym_to_cb_sym(name: str) -> Symbol:
|
|||
type=OPTION,
|
||||
strike_price=strike_price,
|
||||
option_type=option_type,
|
||||
expiry_date=expiry_date
|
||||
expiry_date=new_expiry_date
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue