-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathderibit.py
42 lines (33 loc) · 1.3 KB
/
deribit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import requests
import ccxt
import matplotlib.pyplot as plt
class DeribitAPI:
def __init__(self):
self.exchange = ccxt.deribit({
'apiKey': '0KAFcKks',
'secret': 'MTviEm1EAYUhmOq9MFx6gBXuYiTifgJ82lpKTMLQiOQ',
})
def fetch_option_instruments(self):
params = {'currency': 'BTC'} # Cambiar a 'ETH' si deseas instrumentos de Ethereum
return self.exchange.publicGetGetInstruments(params=params)
def fetch_ticker(self, symbol):
return self.exchange.publicGetTicker({'instrument_name': symbol})
def fetch_order_book(self, symbol):
return self.exchange.publicGetGetOrderBook({'instrument_name': symbol})
class DeribitDraw:
def __init__(self):
self.exchange = ccxt.deribit({
'rateLimit': 6000,
'enableRateLimit': True,
})
def fetch_option_prices(self, symbol):
return self.exchange.fetch_ticker(symbol)
def plot_option_prices(self, option_prices):
last_price = option_prices['last']
bid_price = option_prices['bid']
ask_price = option_prices['ask']
plt.figure(figsize=(10, 6))
plt.plot(['Last', 'Bid', 'Ask'], [last_price, bid_price, ask_price], marker='o')
plt.ylabel('Price')
plt.title('Option Prices')
plt.show()