Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ import numpy as np
|
|
| 7 |
from sklearn.preprocessing import MinMaxScaler
|
| 8 |
from sklearn.impute import SimpleImputer
|
| 9 |
from scipy import stats
|
|
|
|
| 10 |
|
| 11 |
# Fetch data
|
| 12 |
def fetch_binance_data(symbol, timeframe, limit=2000):
|
|
@@ -86,7 +87,7 @@ def create_features_and_labels_with_advanced_features(btc, eth):
|
|
| 86 |
features = np.vstack((btc_features, eth_features))
|
| 87 |
return features, labels
|
| 88 |
|
| 89 |
-
def get_data_predict(btc_ori, eth_ori, symbol='
|
| 90 |
btc_data_ = fetch_binance_data('BTC/USDT', timeframe, limit=limit)
|
| 91 |
eth_data_ = fetch_binance_data(symbol, timeframe, limit=limit)
|
| 92 |
btc_data_ = remove_outliers(btc_data_, epsilon)
|
|
@@ -133,7 +134,7 @@ with open('model_n4h_cat.pkl','rb') as f:
|
|
| 133 |
|
| 134 |
def predict_and_plot(timeframe, limit, epsilon, n_steps, ma):
|
| 135 |
btc_ori = yf.download('BTC-USD', period=f'{limit}d', interval=timeframe)
|
| 136 |
-
eth_ori = yf.download('
|
| 137 |
btc_data, eth_data, label = get_data_predict(btc_ori, eth_ori, symbol='ETH/USDT', timeframe=timeframe, epsilon=epsilon, normalized=True, limit=limit)
|
| 138 |
model = model_n1d_cat if timeframe=='1d' else model_n4h_cat
|
| 139 |
preds = predictions(model, btc_data, eth_data, name=timeframe, n_steps=n_steps)
|
|
|
|
| 7 |
from sklearn.preprocessing import MinMaxScaler
|
| 8 |
from sklearn.impute import SimpleImputer
|
| 9 |
from scipy import stats
|
| 10 |
+
import yfinance as yf
|
| 11 |
|
| 12 |
# Fetch data
|
| 13 |
def fetch_binance_data(symbol, timeframe, limit=2000):
|
|
|
|
| 87 |
features = np.vstack((btc_features, eth_features))
|
| 88 |
return features, labels
|
| 89 |
|
| 90 |
+
def get_data_predict(btc_ori, eth_ori, symbol='BCH/USDT', timeframe='4h', epsilon=2, normalized=False, limit=50):
|
| 91 |
btc_data_ = fetch_binance_data('BTC/USDT', timeframe, limit=limit)
|
| 92 |
eth_data_ = fetch_binance_data(symbol, timeframe, limit=limit)
|
| 93 |
btc_data_ = remove_outliers(btc_data_, epsilon)
|
|
|
|
| 134 |
|
| 135 |
def predict_and_plot(timeframe, limit, epsilon, n_steps, ma):
|
| 136 |
btc_ori = yf.download('BTC-USD', period=f'{limit}d', interval=timeframe)
|
| 137 |
+
eth_ori = yf.download('BCH-USD', period=f'{limit}d', interval=timeframe)
|
| 138 |
btc_data, eth_data, label = get_data_predict(btc_ori, eth_ori, symbol='ETH/USDT', timeframe=timeframe, epsilon=epsilon, normalized=True, limit=limit)
|
| 139 |
model = model_n1d_cat if timeframe=='1d' else model_n4h_cat
|
| 140 |
preds = predictions(model, btc_data, eth_data, name=timeframe, n_steps=n_steps)
|