Stock Algorithm JS Sandbox



Amount of money earned:
Amount of buy decisions:
Amount of sell decisions:
Amount of cheating sells:
Amount of stock left:

/* This is the space that you need to program in javascript, to create your own stock algorithm. There should be a "main" function, so that parameters can be passed in. Also, the main function should return either true for buy, false for sell, and undefined (no return) for no action. Like so: this.main = function(previousData, amountOfStock){ // Code here // Something magical happens return true; // true for buy, false for sell, undefined for no action } The amount of previous data can also be set using: this.previousDataAmt = 10; // Default 10 Note that previousData will always have a length of previousDataAmt, which means it will start at previousDataAmt from the beginning FINAL NOTE: A cheater would be like this.main=function(){return false} and get huge profits. Well... not happening here. If the program tries to sell, but doesn't have any stock to sell, it will do nothing. Good luck Simon Cheng */ this.previousDataAmt = 10; this.main = function(previousData, amountOfStock){ };