Found in tensorflow-js what you need for the first steps in ML and trading.
This is dqn training where rewards and penalties are given to the agent for actions.
https://github.com/tensorflow/tfjs-examples/tree/master/snake-dqn
https://storage.googleapis.com/tfjs-examples/snake-dqn/index.html
It turns out we have a snake that learns from its own experience to move. She has a certain number of moves (turn or continue) and her task is to get to the fruit. Initially, the snake does not know how, but in the course of training, it gains the ability to find fruits and dodge. It’s very similar to trading, isn’t it?
Well, at least for our task, when we have data running, and the robot needs to make a decision to buy or sell.
The minus of the snake is that it is written for node.js, and we need to be able to train in the browser (so that any user can do it). Therefore, the same had to be done on the client.
I dragged the snake as it is to my page with a chart and tried to launch it. It wasn’t there!
The snake fought back
packages first,
then arguments. (by the way, I also made a pull request next to the fix https://github.com/tensorflow/tfjs-examples/pull/353),
then %%Unhandled Rejection (TypeError): Cannot call a class as a function%%. Which is being repaired here https://github.com/tensorflow/tfjs/pull/3906/files, but since There is no release yet, so I had to substitute it with my hands. Here, by the way, many people have a problem https://github.com/tensorflow/tfjs/issues/3384.
Minors have already gone further, like replacing work from fs with indexeddb. Work with which I spied here, by the way. Well, in general, cart-pole initially inspired me to do everything on the client.
https://github.com/tensorflow/tfjs-examples/tree/master/cart-pole
https://storage.googleapis.com/tfjs-examples/cart-pole/dist/index.html
in the end, this is what happened:
https://github.com/pskucherov/opexflow/pull/16/files
Well, actually, the next step will be:
- Fit to charts
- Visualization
- Train the robot on known data to show the maximum result
Below is a video demo of the work-training of robots on the client. Someday they will also trade Sberbank futures instead of me.