Skip to content

Commit

Permalink
fix: method name_instruments considers float strikes now
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioVentilii committed Apr 13, 2024
1 parent 0e737a9 commit c13b006
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
3 changes: 2 additions & 1 deletion deribit_wrapper/market_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def name_instrument(currency: str, expiry: DatetimeType, strike: StrikeType = No
name = '{c}-{t}'
name = name.format(c=c, t=t)
else:
k = int(strike)
k = float(strike)
k = int(k) if k.is_integer() else k
ot = 'c' if opt_type == 'call' else 'p'
name = '{c}-{t}-{k:d}-{ot}'
name = name.format(c=c, t=t, k=k, ot=ot)
Expand Down
44 changes: 44 additions & 0 deletions dev_scripts/debug_market_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from deribit_wrapper.market_data import MarketData

# This script is used to debug the market data class.
# It doesn't require the CLIENT_ID and CLIENT_SECRET to be set in the environment since it only uses public endpoints.
# It can be used in the production environment as well.

USE_TEST_ENV = True

md_test = MarketData(env='test')
md_prod = MarketData()

if USE_TEST_ENV:
md = md_test
else:
md = md_prod

CURRENCY = 'MATIC'


def debug_get_currencies():
currencies = md.currencies
print(f'Currencies: {currencies}')


def debug_get_instruments():
currency = CURRENCY
instruments = md.get_instruments(currency, as_list=True)
print(f'Instruments for {currency}: {instruments}')


def debug_get_first_future():
currency = CURRENCY
future = md.get_first_future(currency)
print(f'First future for {currency}: {future}')


def run():
debug_get_currencies()
debug_get_instruments()
debug_get_first_future()


if __name__ == "__main__":
run()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='deribit_wrapper',
version='0.3.0',
version='0.3.1',
packages=find_packages(),
description='A Python wrapper for seamless integration with Deribit\'s trading API, offering easy access to '
'market data, account management, and trading operations.',
Expand Down

0 comments on commit c13b006

Please sign in to comment.