From 74c63ec8873abf11024eda5adbf4e04a893888fc Mon Sep 17 00:00:00 2001 From: victalejo Date: Wed, 20 May 2026 05:08:29 +0200 Subject: [PATCH 1/2] fix: restore compatibility with modern Python/pandas/TensorFlow Pinned versions were ~5 years old and the project no longer installs or runs on a fresh environment: - requirements.txt: switch git:// (deprecated by GitHub since 2022) to https://, relax pins to numpy>=1.23, pandas>=2.0, tensorflow>=2.13, scikit-learn>=1.3 so installs succeed on Python 3.10+ - iq.py: replace DataFrame.append() (removed in pandas 2.0) with pd.concat() in get_all_candles and fast_data - training.py: drop("future", 1) -> drop("future", axis=1) for pandas 2.x; Adam(lr=, decay=) -> Adam(learning_rate=) (lr kwarg removed, decay no longer a constructor arg in Keras 3); val_acc -> val_accuracy so the ModelCheckpoint actually saves the best epoch Co-Authored-By: Claude Opus 4.7 (1M context) --- iq.py | 4 ++-- requirements.txt | 11 +++++------ training.py | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/iq.py b/iq.py index 02337e0..26f3ae7 100644 --- a/iq.py +++ b/iq.py @@ -89,7 +89,7 @@ def get_data_needed(iq): #function to gather all the data for candle in current: useful_frame = pd.DataFrame(list(candle.values()),index = list(candle.keys())).T.drop(columns = ['at']) useful_frame = useful_frame.set_index(useful_frame['id']).drop(columns = ['id']) - main = main.append(useful_frame) + main = pd.concat([main, useful_frame]) main.drop_duplicates() if active == 'EURUSD': final_data = main.drop(columns = {'from','to'}) @@ -108,7 +108,7 @@ def fast_data(iq,ratio): #function to gather reduced data for the testing for candle in candles: useful_frame = pd.DataFrame(list(candle.values()),index = list(candle.keys())).T.drop(columns = ['at']) useful_frame = useful_frame.set_index(useful_frame['id']).drop(columns = ['id']) - main = main.append(useful_frame) + main = pd.concat([main, useful_frame]) return main def get_balance(iq): diff --git a/requirements.txt b/requirements.txt index eecf703..2a996ee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ -iqoptionapi @ git+git://github.com/Lu-Yi-Hsun/iqoptionapi.git@e96ba2c5b905a139a4765167b08c5df48cf57773 -numpy==1.18.0 -pandas==1.1.1 -tensorflow==2.3.1 -scikit-learn==0.23.2 -grpcio==1.24.3 \ No newline at end of file +iqoptionapi @ git+https://github.com/Lu-Yi-Hsun/iqoptionapi.git@e96ba2c5b905a139a4765167b08c5df48cf57773 +numpy>=1.23,<2.0 +pandas>=2.0,<3.0 +tensorflow>=2.13,<3.0 +scikit-learn>=1.3,<2.0 diff --git a/training.py b/training.py index 1a1479a..0230896 100644 --- a/training.py +++ b/training.py @@ -32,7 +32,7 @@ def classify(current,future): return 0 def preprocess_df(df): - df = df.drop("future", 1) + df = df.drop("future", axis=1) from sklearn.preprocessing import MinMaxScaler scaler = MinMaxScaler() @@ -204,7 +204,7 @@ def train_data(): model.add(Dense(2, activation='softmax')) - opt = tf.keras.optimizers.Adam(lr=LEARNING_RATE, decay=5e-5) + opt = tf.keras.optimizers.Adam(learning_rate=LEARNING_RATE) # Compile model model.compile( @@ -217,7 +217,7 @@ def train_data(): filepath = "LSTM-best" # unique file name that will include the epoch and the validation acc for that epoch - checkpoint = ModelCheckpoint("models/{}.model".format(filepath), monitor='val_acc', verbose=1, save_best_only=True, mode='max') # saves only the best ones + checkpoint = ModelCheckpoint("models/{}.model".format(filepath), monitor='val_accuracy', verbose=1, save_best_only=True, mode='max') # saves only the best ones # Train model history = model.fit( From 8f41d64719391f7dfdceef7d049caefc9a683e35 Mon Sep 17 00:00:00 2001 From: victalejo Date: Wed, 20 May 2026 06:03:26 +0200 Subject: [PATCH 2/2] fix: use .keras checkpoint extension for Keras 3 compatibility ModelCheckpoint in Keras 3 (bundled with TF 2.16+) rejects custom extensions like .model and requires .keras (whole model) or .weights.h5 (weights only). The previous suffix would have aborted training as soon as val_accuracy improved. - training.py:220: "models/{}.model" -> "models/{}.keras" - testing.py:125, 139: train_data() + '.model' -> + '.keras' Validated end-to-end with TF 2.16.2: ModelCheckpoint saves on val_accuracy improvement, load_model() reloads the file, and the restored model produces valid softmax predictions (339 554 params preserved). Co-Authored-By: Claude Opus 4.7 (1M context) --- testing.py | 4 ++-- training.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/testing.py b/testing.py index 7717240..d91848f 100644 --- a/testing.py +++ b/testing.py @@ -122,7 +122,7 @@ def preprocess_prediciton(iq): -NAME = train_data() + '.model' +NAME = train_data() + '.keras' model = tf.keras.models.load_model(f'models/{NAME}') iq = login() @@ -136,7 +136,7 @@ def preprocess_prediciton(iq): while(1): if i >= 10 and i % 2 == 0: - NAME = train_data() + '.model' + NAME = train_data() + '.keras' model = tf.keras.models.load_model(f'models/{NAME}') i = 0 if datetime.datetime.now().second < 30 and i % 2 == 0: #GARANTE QUE ELE VAI APOSTAR NA SEGUNDA, POIS AQUI ELE JÁ PEGA OS DADOS DE UMA NA FRENTE, diff --git a/training.py b/training.py index 0230896..78219f7 100644 --- a/training.py +++ b/training.py @@ -217,7 +217,7 @@ def train_data(): filepath = "LSTM-best" # unique file name that will include the epoch and the validation acc for that epoch - checkpoint = ModelCheckpoint("models/{}.model".format(filepath), monitor='val_accuracy', verbose=1, save_best_only=True, mode='max') # saves only the best ones + checkpoint = ModelCheckpoint("models/{}.keras".format(filepath), monitor='val_accuracy', verbose=1, save_best_only=True, mode='max') # saves only the best ones # Train model history = model.fit(