-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFuturesAPI.py
More file actions
43 lines (35 loc) · 1.81 KB
/
Copy pathFuturesAPI.py
File metadata and controls
43 lines (35 loc) · 1.81 KB
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
43
import requests
import pandas as pd
# Function to get coin symbols from Binance
def get_binance_symbols():
binance_api_url = "https://fapi.binance.com/fapi/v1/exchangeInfo"
response = requests.get(binance_api_url)
symbols = [symbol['symbol'][:-4] for symbol in response.json()['symbols'] if symbol['symbol'].endswith("USDT")]
return pd.DataFrame(symbols, columns=['Symbol'])
# Function to get coin symbols from OKX
def get_okx_symbols():
okx_api_url = "https://www.okx.com/api/v5/public/instruments?instType=SWAP"
response = requests.get(okx_api_url)
symbols = [entry['instId'].split('-')[0] for entry in response.json()['data']]
return pd.DataFrame(symbols, columns=['Symbol'])
# Function to get coin symbols from Bybit
def get_bybit_symbols():
bybit_api_url = "https://api.bybit.com/v2/public/symbols"
response = requests.get(bybit_api_url)
symbols = [symbol['base_currency'] for symbol in response.json()['result'] if symbol['quote_currency'] == 'USDT']
return pd.DataFrame(symbols, columns=['Symbol'])
# Get data
binance_df = get_binance_symbols()
okx_df = get_okx_symbols()
bybit_df = get_bybit_symbols()
# Find coins on Binance
in_binance = binance_df
# Find coins on Bybit but not on Binance
in_bybit_not_binance = bybit_df[~bybit_df['Symbol'].isin(binance_df['Symbol'])]
# Find coins on OKX but not on Binance or Bybit
in_okx_not_binance_bybit = okx_df[~okx_df['Symbol'].isin(binance_df['Symbol']) & ~okx_df['Symbol'].isin(bybit_df['Symbol'])]
# Write results to Excel
with pd.ExcelWriter('exchange_comparison.xlsx') as writer:
in_binance.to_excel(writer, sheet_name='In Binance', index=False)
in_bybit_not_binance.to_excel(writer, sheet_name='In Bybit Not Binance', index=False)
in_okx_not_binance_bybit.to_excel(writer, sheet_name='In OKX Not Binance Bybit', index=False)