27 lines
591 B
Python
27 lines
591 B
Python
from binance.spot import Spot
|
|
from binance.cm_futures import CMFutures
|
|
|
|
cm = CMFutures()
|
|
|
|
# Get klines
|
|
def klines(symbol, interval, limit=1000):
|
|
lines = cm.klines(symbol,interval, limit=limit)
|
|
return lines
|
|
|
|
def ticker_price(symbol):
|
|
try:
|
|
prices = cm.ticker_price(symbol)
|
|
return prices[0]['price'] if len(prices)>0 else 0
|
|
except:
|
|
return 0
|
|
|
|
# Get Symbols
|
|
def symbols():
|
|
info = cm.exchange_info()
|
|
|
|
symbols = []
|
|
for s in info['symbols']:
|
|
if s['symbol'].endswith('_PERP'):
|
|
symbols.append(s['symbol'])
|
|
|
|
return symbols |