Skip to content

Latest commit

 

History

History
22 lines (20 loc) · 3.46 KB

README.md

File metadata and controls

22 lines (20 loc) · 3.46 KB

Allowing your Model to be Consumed by Third Party

Assuming you have a trained model and a scaler, you can run your model under Flask and you can consume it from a trading bot.

Adding an ML Model

When you have a trained model, you can copy it and add it under: ./LSTM-FX-Prediction-Server/Models

  • Add the model directory e.g. gbpusd-32-256-14
  • Add the scaler that you've used for training which has the same name as the model with a .bin extension. e.g. gbpusd-32-256-14.bin

Run the Server

From the console, make sure you changed directory to ./LSTM-FX-Prediction-Server/ and run main.py This will load Flask Python Web Server and start accepting HTTP requests on port 5000.

The server can now receive HTTP calls of this format:

/predict/<string:ticker>/<int:batch_size>/<int:window_size>/<int:ma_periods>/<float:abs_pips>/<int:pred_size>/<string:instance>/<string:series>

There is an example in the next section, you can use it also to test if the web server is working.

Test if The Server is Working

A simple way to test if the web server has loaded is to open this in a web browser:

http://localhost:5000/predict/gbpusd/32/256/14/0.0008/4/20200824000100/1.30936,1.309315,1.30932,1.309385,1.309405,1.30954,1.309615,1.30958,1.309405,1.309325,1.30944,1.30945,1.30937,1.30932,1.309325,1.30941,1.309445,1.309415,1.30953,1.30953,1.30947,1.3095,1.309425,1.30943,1.3093,1.309235,1.30919,1.309175,1.309215,1.30922,1.30922,1.30926,1.309335,1.3094,1.309405,1.30944,1.309435,1.309335,1.309245,1.30925,1.309255,1.309295,1.30922,1.30924,1.30935,1.309255,1.309195,1.30927,1.309325,1.30936,1.30941,1.30935,1.30919,1.30917,1.309205,1.309035,1.308855,1.30887,1.308825,1.30872,1.308815,1.30881,1.30888,1.3089,1.308975,1.30907,1.30926,1.30935,1.30934,1.30942,1.309435,1.309435,1.30936,1.30944,1.309455,1.3095,1.30953,1.309435,1.30934,1.30938,1.309455,1.30954,1.309605,1.30958,1.30951,1.30946,1.30949,1.309435,1.30932,1.309375,1.30929,1.30922,1.3092,1.309135,1.30911,1.309075,1.308995,1.30896,1.308975,1.30893,1.308875,1.308925,1.30885,1.3089,1.30902,1.309065,1.309005,1.30902,1.309095,1.30907,1.30897,1.30899,1.30891,1.308885,1.308975,1.30891,1.30892,1.30821,1.3082,1.30821,1.308305,1.30831,1.308275,1.30822,1.30817,1.308245,1.30837,1.308315,1.308375,1.308365,1.30887,1.308885,1.30889,1.30889,1.30889,1.30889,1.308905,1.30884,1.308835,1.3088,1.3088,1.30881,1.30887,1.30881,1.30878,1.30882,1.30883,1.30886,1.30887,1.30898,1.3093,1.30959,1.30966,1.309695,1.30967,1.30964,1.30954,1.309575,1.309675,1.309525,1.30952,1.30944,1.309425,1.3095,1.30944,1.30943,1.30942,1.309455,1.309475,1.30957,1.30959,1.309695,1.309705,1.309505,1.309495,1.30961,1.30968,1.309715,1.309625,1.309425,1.309345,1.309345,1.309465,1.309545,1.309455,1.309355,1.309325,1.30936,1.30936,1.309415,1.309595,1.309575,1.30955,1.309545,1.30949,1.309485,1.30948,1.309475,1.3094,1.309415,1.309415,1.30941,1.30944,1.309585,1.309745,1.30974,1.30982,1.30983,1.309765,1.30962,1.30961,1.30966,1.309725,1.30972,1.30984,1.309815,1.309865,1.30987,1.30977,1.3098,1.30984,1.309865,1.3099,1.309965,1.30996,1.310005,1.309975,1.309915,1.30987,1.309765,1.30977,1.30982,1.30988,1.310025,1.310015,1.31005,1.310045,1.31003,1.30995,1.30998,1.31003,1.310055,1.31001,1.30999,1.309985,1.30996,1.309995,1.310055,1.31,1.310015,1.310035,1.31002,1.310035,1.309885,1.309895,1.309885,1.309845,1.309855,1.30982,1.30976,1.309695,1.30962,1.30966,1.30953,1.30936,1.309365,1.30925,1.309195,1.3092,1.30912

This will return "0", "1" or "-1". If this doesn't work then you will get a HTTP 500 error.