DeviaVir / zenbot

Zenbot is a command-line cryptocurrency trading bot using Node.js and MongoDB.
MIT License
8.23k stars 2.03k forks source link

Neural Strategy #840

Open KryptoNova opened 6 years ago

KryptoNova commented 6 years ago

I'm very interested in the new neural strategy that was created. However, I cannot seem to configure it to be profitable. It is a complicated concept and there doesn't seem to be too much documentation outlining what the parameters are actually doing. It also seems to want to buy and sell quite a bit when a buy/hold would be three times as profitable.

Is there any key setting that should be reviewed to make the strategy a little more selective in trading? Also, has anyone had any success using this strategy? Just want to make sure that I'm not spinning my wheels on parameter tweaking.

Thanks in advance!

erulabs commented 6 years ago

Been working on it a bit, without much success, but then, I haven't used convnetjs before. The convnetjs project itself doesn't seem to be maintained anymore, so I wonder if we shouldn't just look for another library. In any case, the key arguments here are neurons_1, learns, depth, and min_periods (and of course the period)

I also am not convinced the code should be "training" on every onPeriod: https://github.com/carlos8f/zenbot/blob/master/extensions/strategies/neural/strategy.js#L59

In any case, I cant get it to be profitable, and am actively looking for other NN libraries - would be happy to collaborate!

KryptoNova commented 6 years ago

@erulabs, based on my understanding of machine learning, I think you maybe on to something with the constant learning. I would suspect that learning should only occur when something in the underlying data set has changed or the model that was derived is actually incorrect. The network needs to relearn some up-to-date truths. However, this does seem to represent a change every time a period fires.

I'm not sure if I am the best person for this as I am just starting to scratch the surface of machine learning. I will keep plugging away and tweaking the neural strategy to see if I can figure out a way to get it profitable and to hedge against downturns. It almost seems that price action should be playing more of a role in the pattern recognition rather than comparison of averages. Still trying to make a good price action strategy without machine learning first though.

slashafk commented 6 years ago

Hello, If you wan't to test visually what's actually predicting that AI, I made a small web page that execute the neural strategy : https://github.com/slashafk/StockExchange-Prediction/blob/master/index.html with different depth.

So far for me that AI isn't a real one. On the paper it looks great, prices can be predicted from afar, buts it's a SGD (it's using backpropagation so it's kind of cheating).

Technically it's just extrapolating the trend (by making it learn latests prices on each period the AI will just extrapolate an up or down trend, if last price > current price it's buying else it's selling).

Some way of improvment would be to train a classification AI (with 3 status : BUY, HOLD,SELL) instead of a regression, and use indicator like RSI, CCI, VMA, ... to make a real choice based on the market because so far, it's just a blind guessing AI. That AI could also use candlestick patterns (https://www.investopedia.com/articles/active-trading/092315/5-most-powerful-candlestick-patterns.asp). Those patterns are already in the TALIB so there is only the learning to care about.

As a replacement of convnetjs, you could use deeplearn.js which is developped by google.

Another way of improvment would be to use QLearning (an AI that learn from mistakes) using the current % of earning as a learning score.

(I'm still learning AI so i'm not sure about the results, but could be fun to do)