Price prediction using machine learning

Moderator: Moderator

Price prediction using machine learning

Postby JuliaS » Wed Oct 03, 2018 5:37 pm

You can use ForexConnect API in machine learning models.

The following sample scripts are available at github:

PricePredictionMLregressionMA.py
This sample script shows how to use Machine Learning in Python and how to predict prices by using Linear Regression.
The input of the regression model is three Moving Averages calculated based on close prices. The algorithm uses a linear model to minimize the residual sum of squares between the observed responses in the dataset and the responses predicted by the linear approximation.

PricePredictionMLregressionPrevious.py
This sample script shows how to use Machine Learning in Python and how to predict prices by using Linear Regression.
The input of the regression model is close prices of previous bars. The algorithm uses a linear model to minimize the residual sum of squares between the observed responses in the dataset and the responses predicted by the linear approximation.

PricePredictionMLClassification.py
This sample script shows how to use Machine Learning in Python and how to predict prices
by using Support Vector Classification.
The model divides objects into two groups: "the price will grow on the next bar" and "the price will fall on the next bar".
The input data for the model are Open-Close and High-Low. The model tries to define whether the price is growing or falling on the basis of the input data.
JuliaS
 
Posts: 16
Joined: Wed Jan 25, 2017 11:19 am

Re: Price prediction using machine learning

Postby SANTOSH » Tue Oct 30, 2018 2:17 pm

Hello Julias ,

I am not able to log in .
Can u give the sample of how to write the arguments after SAMPLE.PY.


I am talking about this :
Need to know how to write the arguments .

If Python is added to the PATH Environmental Variable,
to run the sample script, execute the following command in a console:
python <Sample.py> <Arguments>

I write like this following the above :
C:\Users\abc>PricePredictionMLRegressionMA.py -l D291033620, -p 9173, -u https:/
/tradingstation.fxcm.com/, -c DEMO


May be the fxcm server url is wrong .
I use the server -u https://tradingstation.fxcm.com/

u] Can u get me the exact fxcm server url to add to the arguments. [/u]



I get the following error as attached .


C:\Users\abc>PricePredictionMLRegressionMA.py -l D291033620, -p 9173, -u https:/
/tradingstation.fxcm.com/, -c DEMO
C:\Users\abc\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\ex
ternals\joblib\externals\cloudpickle\cloudpickle.py:47: DeprecationWarning: the
imp module is deprecated in favour of importlib; see the module's documentation
for alternative uses
import imp
Status: CONNECTING
Status: DISCONNECTED
Traceback (most recent call last):
File "C:\Users\abc\AppData\Local\Programs\Python\Python37\PricePredictionMLReg
ressionMA.py", line 120, in <module>
main()
File "C:\Users\abc\AppData\Local\Programs\Python\Python37\PricePredictionMLReg
ressionMA.py", line 64, in main
common_samples.session_status_changed)
File "C:\Users\abc\AppData\Local\Programs\Python\Python37\lib\site-packages\fo
rexconnect\ForexConnect.py", line 205, in login
use_table_manager, table_manager_callback)
File "C:\Users\abc\AppData\Local\Programs\Python\Python37\lib\site-packages\fo
rexconnect\ForexConnect.py", line 152, in _login
raise LoginFailedError(self._status_listener.last_error)
forexconnect.errors.LoginFailedError: Unable to parse descriptor data


Kindly help,
Regards,
Santosh Sahu.
Email - sahusantosh30@gmail.com
SANTOSH
FXCodeBase: Graduate
 
Posts: 238
Joined: Tue Apr 21, 2015 12:21 am

Re: Price prediction using machine learning

Postby Alexander.Gettinger » Wed Oct 31, 2018 11:37 am

FXCM server url: fxcorporate.com/Hosts.jsp

What version of Python do you have?
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Price prediction using machine learning

Postby SANTOSH » Wed Oct 31, 2018 2:56 pm

Thanks Alexander .
I will use the above fxcm server and give a try .

I use python 3.7 with all the forex connect requirements on it .

Regards ,
Santosh .
SANTOSH
FXCodeBase: Graduate
 
Posts: 238
Joined: Tue Apr 21, 2015 12:21 am

Re: Price prediction using machine learning

Postby SANTOSH » Thu Nov 01, 2018 4:54 am

Thanks Alexander ,
I get it to working .
Can log in and use the machine leaarning .py samples which are in fxcodebase .

=========================================================================
I tried the following and got success .
PricePredictionMLClassification.py
The model divides objects into two groups: "the price will grow on the next bar" and "the price will fall on the next bar".


C:\Users\abc>PricePredictionMLC.py -l D291033620 -p 9173 -u fxcorporate.com/Hos
ts.jsp -c DEMO
C:\Users\abc\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\ex
ternals\joblib\externals\cloudpickle\cloudpickle.py:47: DeprecationWarning: the
imp module is deprecated in favour of importlib; see the module's documentation
for alternative uses
import imp
Status: CONNECTING
Status: CONNECTED
C:\Users\abc\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\sv
m\base.py:196: FutureWarning: The default value of gamma will change from 'auto'
to 'scale' in version 0.22 to account better for unscaled features. Set gamma e
xplicitly to 'auto' or 'scale' to avoid this warning.
"avoid this warning.", FutureWarning)
Train Accuracy: 54.17%
Test Accuracy: 48.33%
Status: DISCONNECTING
Status: DISCONNECTED

=========================================================================
Have a question :
How can we use the above python script in live market to predict the next bar , meaning whats the way to use it in the live market ?


Regards ,
Santosh .
SANTOSH
FXCodeBase: Graduate
 
Posts: 238
Joined: Tue Apr 21, 2015 12:21 am

Re: Price prediction using machine learning

Postby Konstantin.Toporov » Fri Nov 02, 2018 1:46 pm

Similar sample is in our development queue.
Konstantin.Toporov
FXCodeBase: Initiate
 
Posts: 113
Joined: Mon Aug 31, 2015 10:16 am

Re: Price prediction using machine learning

Postby SANTOSH » Sat Nov 03, 2018 2:03 am

You mean to say ,
Python machine learning is only for back testing ?
Cannot apply it for alerts ?

Regards ,
Santosh.
SANTOSH
FXCodeBase: Graduate
 
Posts: 238
Joined: Tue Apr 21, 2015 12:21 am

Re: Price prediction using machine learning

Postby SANTOSH » Wed Nov 14, 2018 10:47 pm

Hello Everyone ,

Is there any way to use Machine Learning for Live market alerting or signalling ?

Regards,
Santosh Sahu.
SANTOSH
FXCodeBase: Graduate
 
Posts: 238
Joined: Tue Apr 21, 2015 12:21 am

Re: Price prediction using machine learning

Postby SANTOSH » Fri May 31, 2019 11:18 pm

JuliaS wrote:You can use ForexConnect API in machine learning models.

The following sample scripts are available at github:

PricePredictionMLregressionMA.py
This sample script shows how to use Machine Learning in Python and how to predict prices by using Linear Regression.
The input of the regression model is three Moving Averages calculated based on close prices. The algorithm uses a linear model to minimize the residual sum of squares between the observed responses in the dataset and the responses predicted by the linear approximation.

PricePredictionMLregressionPrevious.py
This sample script shows how to use Machine Learning in Python and how to predict prices by using Linear Regression.
The input of the regression model is close prices of previous bars. The algorithm uses a linear model to minimize the residual sum of squares between the observed responses in the dataset and the responses predicted by the linear approximation.

PricePredictionMLClassification.py
This sample script shows how to use Machine Learning in Python and how to predict prices
by using Support Vector Classification.
The model divides objects into two groups: "the price will grow on the next bar" and "the price will fall on the next bar".
The input data for the model are Open-Close and High-Low. The model tries to define whether the price is growing or falling on the basis of the input data.



Can a lua strategy be machine learned ?


Regards ,
Santosh .
SANTOSH
FXCodeBase: Graduate
 
Posts: 238
Joined: Tue Apr 21, 2015 12:21 am

Re: Price prediction using machine learning

Postby SANTOSH » Wed Mar 04, 2020 10:00 am

Hi All
Can a lua strategy be machine learned?

Regards,
Santosh.
SANTOSH
FXCodeBase: Graduate
 
Posts: 238
Joined: Tue Apr 21, 2015 12:21 am

Next

Return to ForexConnect-Python API

Who is online

Users browsing this forum: No registered users and 0 guests