asavinov / intelligent-trading-bot

Intelligent Trading Bot: Automatically generating signals and trading based on machine learning and feature engineering
https://t.me/intelligent_trading_signals
MIT License
1.02k stars 217 forks source link

error during SIGNAL run. dividing to ZERO #30

Open cebbot opened 1 year ago

cebbot commented 1 year ago

Dobriy Den Alexander,

I ınstalled all files. worked TRAINING SIGNAL also. python -m scripts.features -c config.json after this comment giving ERROR. it is can not divide to ZERO with row 186, 182 etc.

how can ı work with this bot.

Have a nice day

cebbot commented 1 year ago

PS C:\intelligent-trading-bot-master> python -m service.server -c config.json Initializing server. Trade pair: BTCUSDT. Finished health check (connection, server status etc.) Finished initial data collection. Scheduler started. C:\intelligent-trading-bot-master\common\feature_generation_rolling_agg.py:159: RuntimeWarning: invalid value encountered in scalar divide ratio = pos / b # in [0,1] C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:182: RuntimeWarning: invalid value encountered in scalar divide slope = ssxym / ssxm C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:196: RuntimeWarning: invalid value encountered in sqrt t = r np.sqrt(df / ((1.0 - r + TINY)(1.0 + r + TINY))) C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:199: RuntimeWarning: invalid value encountered in scalar divide slope_stderr = np.sqrt((1 - r*2) ssym / ssxm / df) C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:182: RuntimeWarning: invalid value encountered in scalar divide slope = ssxym / ssxm C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:196: RuntimeWarning: invalid value encountered in sqrt t = r np.sqrt(df / ((1.0 - r + TINY)(1.0 + r + TINY))) C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:199: RuntimeWarning: invalid value encountered in scalar divide slope_stderr = np.sqrt((1 - r*2) ssym / ssxm / df)

cebbot commented 1 year ago

FYI Epoch 200, change: 0.00080476 max_iter reached after 60 seconds C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\linear_model_sag.py:350: ConvergenceWarning: The maxiter was reached which means the coef did not converge warnings.warn( LABELS: 100%|██████████████████████████████████████████████████████████████████████████| 10/10 [08:16<00:00, 49.62s/it] Models stored in path: C:\intelligent-trading-bot-master\data\btcusdt\MODELS Metrics stored in path: C:\intelligent-trading-bot-master\data\btcusdt\prediction-metrics.txt Storing output file... Predictions stored in file: C:\intelligent-trading-bot-master\data\BTCUSDT\predictions. Length: 262618. Columns: 27 Finished training models in 0:08:58 PS C:\intelligent-trading-bot-master> python -m scripts.signals -c config.json

Loading predictions from input file: C:\intelligent-trading-bot-master\data\BTCUSDT\predictions.csv Predictions loaded. Length: 262618. Width: 27 Metrics stored in path: C:\intelligent-trading-bot-master\data\btcusdt\signal-metrics.txt Storing output file... Signals stored in file: C:\intelligent-trading-bot-master\data\BTCUSDT\signals. Length: 262618. Columns: 24 Finished signal generation in 0:00:06 PS C:\intelligent-trading-bot-master> python -m scripts.train_signals -c config.json

Loading signals from input file: C:\intelligent-trading-bot-master\data\BTCUSDT\signals.csv C:\intelligent-trading-bot-master\scripts\train_signals.py:96: DtypeWarning: Columns (20) have mixed types. Specify dtype option on import or set low_memory=False. df = pd.read_csv(file_path, parse_dates=[time_column], nrows=P.in_nrows) Signals loaded. Length: 262618. Width: 24 MODELS: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:01<00:00, 5.67it/s] Simulation results stored in: C:\intelligent-trading-bot-master\data\btcusdt\signal_models.txt. Lines: 9. Finished simulation in 0:00:02

cebbot commented 1 year ago

I download all files from Github. add my binance API open C:\DATA_ITB\BTCUSDT run all command on power shell last command is not working properly PS C:\intelligent-trading-bot-master> python -m service.server -c config.json Initializing server. Trade pair: BTCUSDT. Finished health check (connection, server status etc.) Finished initial data collection. Scheduler started. C:\intelligent-trading-bot-master\common\feature_generation_rolling_agg.py:159: RuntimeWarning: invalid value encountered in scalar divide ratio = pos / b # in [0,1] C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:182: RuntimeWarning: invalid value encountered in scalar divide slope = ssxym / ssxm C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:196: RuntimeWarning: invalid value encountered in sqrt t = r np.sqrt(df / ((1.0 - r + TINY)(1.0 + r + TINY))) C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:199: RuntimeWarning: invalid value encountered in scalar divide slope_stderr = np.sqrt((1 - r*2) ssym / ssxm / df) C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:182: RuntimeWarning: invalid value encountered in scalar divide slope = ssxym / ssxm C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:196: RuntimeWarning: invalid value encountered in sqrt t = r np.sqrt(df / ((1.0 - r + TINY)(1.0 + r + TINY))) C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:199: RuntimeWarning: invalid value encountered in scalar divide slope_stderr = np.sqrt((1 - r*2) ssym / ssxm / df) C:\intelligent-trading-bot-master\common\feature_generation_rolling_agg.py:159: RuntimeWarning: invalid value encountered in scalar divide ratio = pos / b # in [0,1]

asavinov commented 1 year ago

Hi, as far as I understood you have division by zero in feature generation. There could be multiple reasons for that. If you provide more information about what features you generate then probably we find where is the problem. What is in your config?

cebbot commented 1 year ago

Hi Alexander, I am happy to get answer my question. Thank you ! I want to explain shortly what ı did. 1- I am using Win 10 Home 2-I installed Python 3.11 (64bit) 3-I am using config.json which you put in github config-sample-v0.6.dev.json. 4-I add only my binance API key and secret. 5- open folder C:\DATA_ITB\BTCUSDT 6- using all below command at power shell in C:\intelligent-trading-bot-master pip install -r requirements.txt python -m scripts.download_binance -c config.json python -m scripts.merge -c config.json python -m scripts.features -c config.json python -m scripts.labels -c config.json python -m scripts.train -c config.json python -m scripts.signals -c config.json python -m scripts.train_signals -c config.json python -m service.server -c config.json

all abowe command working properly except 'python -m service.server -c config.json'. 7-after latst command can see below warning: PS C:\intelligent-trading-bot-master> python -m service.server -c config.json Initializing server. Trade pair: BTCUSDT. Finished health check (connection, server status etc.) Finished initial data collection. Scheduler started. C:\intelligent-trading-bot-master\common\feature_generation_rolling_agg.py:159: RuntimeWarning: invalid value encountered in scalar divide ratio = pos / b # in [0,1] C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:182: RuntimeWarning: invalid value encountered in scalar divide slope = ssxym / ssxm C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:196: RuntimeWarning: invalid value encountered in sqrt t = r * np.sqrt(df / ((1.0 - r + TINY)(1.0 + r + TINY))) C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:199: RuntimeWarning: invalid value encountered in scalar divide slope_stderr = np.sqrt((1 - r2) ssym / ssxm / df) C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:182: RuntimeWarning: invalid value encountered in scalar divide slope = ssxym / ssxm C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:196: RuntimeWarning: invalid value encountered in sqrt t = r np.sqrt(df / ((1.0 - r + TINY)(1.0 + r + TINY))) C:\Users\PC2\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy\stats_stats_mstats_common.py:199: RuntimeWarning: invalid value encountered in scalar divide slope_stderr = np.sqrt((1 - r2) * ssym / ssxm / df) C:\intelligent-trading-bot-master\common\feature_generation_rolling_agg.py:159: RuntimeWarning: invalid value encountered in scalar divide ratio = pos / b # in [0,1]

image image

some files very large in C:\DATA_ITB\BTCUSDT folder, I can send link if you want. other all files dowloaded from github.

Please, text me where is my mistake

Thank you in advance,

Cebrail

asavinov commented 1 year ago

Is it the latest version? If not then could you please update your installation and execute all steps again. The reason is that I did many fixes and now it should run without problems.

cebbot commented 1 year ago

I cannot install TA-LIB propely. trying to install to python on Win 10 based OS. ı will text to you when I am installing this library. Thanks agin

cebbot commented 1 year ago

Hello Alexander,

it is STARTED to work. :)

now I am trying it at Binance.

I will text you result of bot.

Thank you for your help!

image

cebbot commented 1 year ago
  Hello Alexander,

Still Ta-lib has some problem


build\lib.win-amd64-cpython-39\talib_ta_lib.cp39-win_amd64.pyd : fatal error LNK1120: 339 ‡”z\x81mlenmemiŸ d\x8dŸlar error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\bin\HostX86\x64\link.exe' failed with exit code 1120 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for ta-lib Failed to build ta-lib ERROR: Could not build wheels for ta-lib, which is required to install pyproject.toml-based projects PS C:\intelligent-trading-bot-master>

asavinov commented 1 year ago

You can install it using conda conda install -c conda-forge ta-lib which includes Windows binary library.

If you do not want to use conda for your porject then just do it one time (install miniconda and then ta-ib), get the binary from this installation, and copy this lib to your normal environment (without conda). It did not try it but it should work.

cebbot commented 1 year ago

Hello Alexander, I install now Ananconda. ı used powershell as administrator. image still can not install ta-lib. good night

asavinov commented 1 year ago

It seems that the package is not available for Python 3.11. Try Python 3.10:

conda create -n itb python=3.10
conda activate itb
conda install -c conda-forge ta-lib

Then start python and execute line by line:

import talib
import numpy as np
talib.SMA(np.array([1.0,2,3,4,5]), 2)

If it prints something then it works.