benjamin icon indicating copy to clipboard operation
benjamin copied to clipboard

Simple simulation doesn't work

Open MaxBareiss opened this issue 12 years ago • 0 comments

I'm using the latest version of the library, with node 0.10.17 . With this code, it downloads the latest trades, and then does nothing. What am I doing wrong? This is a really great idea for a library, and I'd like to help it succeed:

var Benjamin = require("benjamin");
var options = {
    client:{
        api_key:"BLAH",
        api_secret:"SEEKRIT"
    }
};
var benjamin = new Benjamin(options);

var strategy = {
    name:"Max-strategy",
    initialize:function(){
        console.log("Init!");
    },
    tick:function(Trades,currentSuggestion,callback){
        console.log("Here!");
        callback(0);
    },
    shouldExit:function(){
        return false;
    }
};

benjamin.use(strategy);

var start = Math.floor(Date.now()/1000)-31*24*60*60;
var end = Math.floor(Date.now()/1000);
benjamin.simulate({
    start: start, // UNIX-timestamps
    end: end,
    interval:15
});

MaxBareiss avatar Dec 25 '13 02:12 MaxBareiss