-
Notifications
You must be signed in to change notification settings - Fork 2k
Three strategies have been coded to the best of my ability. + Lightning Fast Threading #709
Conversation
Trendline: Buy when trend exceeds > 1 sell when trend is < 1 (down) where 1 is no trend at all. Standard Deviation: Buys when the mean of the last short trades exceeds the standard deviation and mean of the last long trades. Neural: Uses neural regression learning to predict the next price. Can be resource intensive. Be careful. Based on weather prediction sliding max/minimum. Buys when the mean of the last two periods prediction price exceeds the mean of the last 3 periods actual prices. I call it sliding 2/3rds averaging prediciton signal. Also: I attempted a fix for zenbot's single-thread node limitation by incuding cluster npm module, the whole zenbot instance is clustered from the master instance for neural and other processor-resource intensive strategy simulation. Be careful, it can be prone to a memory leak with: cluster.setMaxListeners(0). The cluster worker processes, if killed, should exit with: cluster.on('exit', function(worker, code, signal) { console.log('worker ' + worker.process.pid + ' died'); ----------------------------------------------------- The entire code for clustering: ----------------------------------------------------- var cluster = require('cluster'); cluster.setMaxListeners(0) var numCPUs = require('os').cpus().length; if (cluster.isMaster) { // Fork workers. for (var i = 0; i < numCPUs; i++) { cluster.fork(); } cluster.on('exit', function(worker, code, signal) { console.log('worker ' + worker.process.pid + ' died'); }); } else { ////////////////////////zenbot.js code/////////////////////// } -----------------------------------------------------
brb need to update package-lock.json to add node-prowl |
Ok, I pushed in new package lock and node-prowl. This thing is way too fast. |
"micro-request": "^666.0.10", | ||
"mime": "^1.4.0", | ||
"minimist": "^1.2.0", | ||
"moment": "^2.18.1", | ||
"mongodb": "^2.2.31", | ||
"node-prowl": "^0.1.7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have absolutely no clue how this was missing from my zenbot pull because I pulled literally straight from zenbot.git on carlos8f repo. Either way, I re-added it.
Just a suggestion; You may want to also update the README.md with your new strategies otherwise they may be lost after the pull. (I.E. no documentation people may think they don't exist) Pulled and testing in paper mode |
I noticed that list-strategies will output a bunch of times, but my speed sim was blazing fast. I mean FAST. If anyone has any suggestions, I'm open. Or if I need code edits please let me know. Or if this threading code can be dropped somewhere else, that would be amazing too. I'm mainly worried about the simulations, but not sure completely how the clustering code comes into place with say, mongodb and the nodejs code execution and the sim/trade commands. Dev testing please!!!!! Please comment any code edits I should make, but I think threading is absolutely needed for this type of speed. |
I'm going to try and move the threading code back into the strategy since it did not function as desired. |
Threading code did not work correctly at all. Thinking of solutions. Not sure where to go with this. I need actual professional node advice. ``` if (s.lookback[s.options.min_periods]) { for (let i = 0; i < s.options.min_periods; i++) { tll.push(s.lookback[i].close) } for (let i = 0; i < s.options.min_predict; i++) { tlp.push(s.lookback[i].close) } s.my_data = tll.reverse() var learn = function (s) { s.done = 0 for(var j = 0; j < s.trains; j++) { if (cluster.isMaster) { cluster.fork(); } else { for (var i = 0; i < s.my_data.length - s.neural.neuralDepth; i++); var data = s.my_data.slice(i, i + s.neural.neuralDepth); var real_value = [s.my_data[i + s.neural.neuralDepth]]; var x = new convnetjs.Vol(data); s.neural.trainer.train(x, real_value); var predicted_values = s.neural.net.forward(x); if (i === s.my_data.length - s.neural.neuralDepth) { s.done = j } if (i === s.my_data.length - s.neural.neuralDepth) { calculating === 'False' } } } } } var predict = function(data){ x = new convnetjs.Vol(data); predicted_value = s.neural.net.forward(x); return predicted_value.w[0]; } if (s.lookback[s.options.min_periods] && calculating === 'False') { calculating = 'True' learn(s); } if (s.done === s.trains) { var item = tlp.reverse(); s.prediction = predict(item) s.mean = math.mean(tll[0], tll[1], tll[2]) s.meanp = math.mean(s.prediction, oldmean) s.sig0 = s.meanp > s.mean oldmean = s.prediction } ``` The above is why. How can I drop that into a new clustered function?
Had to roll back to node 7.x. But added napa/napajs microsoft threading npm module to package.json for future use. Updated package-lock.json Install goes smoothly. Included install log in install.sh for diagnostics.
Hit:3 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial InRelease | ||
Hit:4 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease | ||
Get:5 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB] | ||
Hit:6 https://deb.nodesource.com/node_7.x xenial InRelease |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can add *.log
to the .gitignore
to ignore these kind of files
@@ -1,3199 +0,0 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you removed the entire package-lock.json
?
Trendline: Buy when trend exceeds > 1 sell when trend is < 1 (down) where 1 is no trend at all.
Standard Deviation: Buys when the mean of the last short trades exceeds the standard deviation and mean of the last long trades.
Neural: Uses neural regression learning to predict the next price. Can be resource intensive. Be careful. Based on weather prediction sliding max/minimum. Buys when the mean of the last two periods prediction price exceeds the mean of the last 3 periods actual prices. I call it sliding 2/3rds averaging prediciton signal.
Also:
I attempted a fix for zenbot's single-thread node limitation by incuding cluster npm module, the whole zenbot instance is clustered from the master instance for neural and other processor-resource intensive strategy simulation. Be careful, it can be prone to a memory leak with: cluster.setMaxListeners(0).
The cluster worker processes, if killed, should exit with:
cluster.on('exit', function(worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
The entire code for clustering:
var cluster = require('cluster');
cluster.setMaxListeners(0)
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function(worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
});
} else {
////////////////////////zenbot.js code///////////////////////
}