feat: Add MT5 trading bot project files
This commit includes the initial project files for the MT5 trading bot. It includes: - MQL5 scripts for exporting data and for the trading EAs. - Python scripts for model development and for creating a benchmark model. - ONNX models for the trading EAs. - A file with all the code concatenated. - A directory with the separate code files.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import pandas as pd
|
||||
from sklearn.linear_model import LogisticRegression
|
||||
import skl2onnx
|
||||
from skl2onnx.common.data_types import FloatTensorType
|
||||
|
||||
# Load the data
|
||||
raw_price_df = pd.read_csv("raw_price_data.csv")
|
||||
|
||||
# Feature Engineering
|
||||
raw_price_df["feature_price_change"] = raw_price_df["Close"].diff()
|
||||
|
||||
# Target Engineering
|
||||
raw_price_df["y_target_direction"] = (raw_price_df["Close"].shift(-1) > raw_price_df["Close"]).astype(int)
|
||||
|
||||
# Drop rows with NaN values
|
||||
raw_price_df.dropna(inplace=True)
|
||||
|
||||
# Separate features and target
|
||||
X = raw_price_df[['feature_price_change']]
|
||||
y = raw_price_df['y_target_direction']
|
||||
|
||||
# Create and train the logistic regression model
|
||||
log_reg_model = LogisticRegression()
|
||||
log_reg_model.fit(X, y)
|
||||
|
||||
# Convert the model to ONNX format
|
||||
initial_type = [('float_input', FloatTensorType([None, 1]))]
|
||||
onnx_model = skl2onnx.convert_sklearn(log_reg_model, initial_types=initial_type)
|
||||
|
||||
# Save the ONNX model
|
||||
with open("benchmark_logistic_model.onnx", "wb") as f:
|
||||
f.write(onnx_model.SerializeToString())
|
||||
|
||||
print("Model successfully exported to benchmark_logistic_model.onnx")
|
||||
Reference in New Issue
Block a user