Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Latest commit

 

History

History

realtime-agent

How-to, this model based on evolution-strategy

  1. You can check realtime-evolution-strategy.ipynb for to train an evolution strategy to do realtime trading.

I trained the model to learn trading on different stocks,

['TWTR.csv',
 'GOOG.csv',
 'FB.csv',
 'LB.csv',
 'MTDR.csv',
 'CPRT.csv',
 'FSV.csv',
 'TSLA.csv',
 'SINA.csv',
 'GWR.csv']

You might want to add more to cover more stochastic patterns.

  1. Run app.py to serve the checkpoint model using Flask,
python3 app.py
* Serving Flask app "app" (lazy loading)
* Environment: production
  WARNING: This is a development server. Do not use it in a production deployment.
  Use a production WSGI server instead.
* Debug mode: off
* Running on http://0.0.0.0:8005/ (Press CTRL+C to quit)
  1. You can check requests example in request.ipynb to get a kickstart.
curl http://localhost:8005/trade?data=[13.1, 13407500]
{'action': 'sell', 'balance': 971.1199990000001, 'investment': '10.224268 %', 'status': 'sell 1 unit, price 16.709999', 'timestamp': '2019-05-26 01:12:10.370206'}
{'action': 'nothing', 'balance': 971.1199990000001, 'status': 'do nothing', 'timestamp': '2019-05-26 01:12:10.376245'}
{'action': 'sell', 'balance': 987.7799990000001, 'investment': '11.066667 %', 'status': 'sell 1 unit, price 16.660000', 'timestamp': '2019-05-26 01:12:10.382282'}
{'action': 'nothing', 'balance': 987.7799990000001, 'status': 'do nothing', 'timestamp': '2019-05-26 01:12:10.388330'}
{'action': 'nothing', 'balance': 987.7799990000001, 'status': 'do nothing', 'timestamp': '2019-05-26 01:12:10.394324'}
{'action': 'sell', 'balance': 1006.1299990000001, 'investment': '18.387097 %', 'status': 'sell 1 unit, price 18.350000', 'timestamp': '2019-05-26 01:12:10.400104'}
{'action': 'nothing', 'balance': 1006.1299990000001, 'status': 'do nothing', 'timestamp': '2019-05-26 01:12:10.405804'}
{'action': 'nothing', 'balance': 1006.1299990000001, 'status': 'do nothing', 'timestamp': '2019-05-26 01:12:10.411531'}

Notes

  1. You can use this code to integrate with realtime socket, or any APIs you wanted, imagination is your limit now.