Я нашел этот код в Интернете, но некоторые его части отсутствовали.Я добавил statsmodels.api
import requests # for making http requests to binance
import json # for parsing what binance sends back to us
import pandas as pd # for storing and manipulating the data we get back
import numpy as np # numerical python, i usually need this somewhere
# and so i import by habit nowadays
import statsmodels.api as sm
import matplotlib.pyplot as plt # for charts and such
import datetime as dt # for dealing with times
def get_bars(symbol, interval = '1h'):
root_url = 'https://api.binance.com/api/v1/klines'
url = root_url + '?symbol=' + symbol + '&interval=' + interval
data = json.loads(requests.get(url).text)
df = pd.DataFrame(data)
df.columns = ['open_time',
'o', 'h', 'l', 'c', 'v',
'close_time', 'qav', 'num_trades',
'taker_base_vol', 'taker_quote_vol', 'ignore']
df.index = [dt.datetime.fromtimestamp(x/1000.0) for x in df.close_time]
return df
symbols =
json.loads(requests.get("https://api.binance.com/api/v1/exchangeInfo").text)
symbols = [symbol['symbol'] for symbol in symbols['symbols'] if
symbol['quoteAsset'] == 'ETH']
ethusdt = get_bars('ETHUSDT')
price_data = []
new_symbols = []
for symbol in symbols:
print(symbol)
data = get_bars(symbol)
new_symbols.append(symbol.replace('ETH','USDT'))
price_data.append(data['c'].astype('float') *
ethusdt['c'].astype('float'))
combo = pd.concat(price_data, axis = 1)
combo.columns = new_symbols
mst = sm.MinimumSpanningTree(dataset = np.log(combo).diff().T)
При запуске кода я получаю эту ошибку.В чем здесь проблема?
mst = sm.MinimumSpanningTree(dataset = np.log(combo).diff().T)
AttributeError: module 'statsmodels.api' has no attribute 'MinimumSpanningTree'