1
$\begingroup$

I’m building a Forex trading system based on machine learning with Python and brokers API. I get price time series data + fundamental data and then i train the model on that. Model means SVM, RF, Ensemble methods, Logistic regression and ANN. The best performer emits a signal forecasting price (classification or regression depends on model). Now i'm using Random Forest.

I'm using Sklearn and i'm stuck on a point: regressor.predict(X_test)

After prediction/forecasting on test data, how could i send on live trading the trained model?

How could i predict on real time data from brokers (i know their API but i don't know how to apply the model on updated live data). At the moment i'm not interested in backtesting solutions. My intention is to build a semi automatic strategy completely in Python Jupyter notebook: research, train, test, tuning and estimates in Jupyter notebook with historical data then forecasting every day price on live data, manually executing positions arising from those predictions + manual position sizing. So my workflow is Jupyter notebook + broker platforms.

The point is: i have a model, i have a prediction on test data, then?

My plan was to get real time data in a pandas dataframe (1 row), manipulate it and finally employ the model on it instead of test data. Is it true? I really need to manipulate it (reshaping in 2d like train test split preprocessing in Sklearn) before? Without reshaping i get errors.

For example:

URL = "example api live"

params = {'currency' : 'EURUSD','interval' : 'Hourly','api_key':'api_key'}

response = requests.get("example api live", params=params)

df= pd.read_responsejson(response.text)

forecast = df.iloc[:, 0].values.reshape(-1,1)

reg = regressor.predict(forecast)

Thank you!

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.