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:
|
def str_to_cb_sym(name: str) -> Symbol:
|
||||||
base, strike_price, expiry_date, option_type = name.split('-')
|
base, strike_price, expiry_date, option_type = name.split('-')
|
||||||
|
|
||||||
|
@ -124,8 +128,9 @@ def str_to_cb_sym(name: str) -> Symbol:
|
||||||
else:
|
else:
|
||||||
raise Exception("Couldn\'t parse option type")
|
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(
|
return Symbol(
|
||||||
base=base,
|
base=base,
|
||||||
quote=quote,
|
quote=quote,
|
||||||
|
@ -145,6 +150,7 @@ def piker_sym_to_cb_sym(name: str) -> Symbol:
|
||||||
)= tuple(
|
)= tuple(
|
||||||
name.upper().split('-'))
|
name.upper().split('-'))
|
||||||
|
|
||||||
|
new_expiry_date = get_timestamp_int(expiry_date)
|
||||||
quote: str = base
|
quote: str = base
|
||||||
|
|
||||||
if option_type == 'P':
|
if option_type == 'P':
|
||||||
|
@ -160,7 +166,7 @@ def piker_sym_to_cb_sym(name: str) -> Symbol:
|
||||||
type=OPTION,
|
type=OPTION,
|
||||||
strike_price=strike_price,
|
strike_price=strike_price,
|
||||||
option_type=option_type,
|
option_type=option_type,
|
||||||
expiry_date=expiry_date
|
expiry_date=new_expiry_date
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue