Machine Learning model forecasting on real time data in python
Machine Learning model forecasting on real time data in python
Loading saved threads...
Federico Juvara · External communityPost link
External question — Quantitative Finance Stack Exchange
Author: Federico Juvara
Original post: https://quant.stackexchange.com/questions/59419
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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!
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Quantitative Finance Stack Exchange Author: Federico Juvara Source score (net votes, not local likes): 1 Original post: https://quant.stackexchange.com/questions/59419 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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!
Checking account access…