#include "RandomSellStrategy.h" #include #include "Stock.h" RandomSellStrategy::RandomSellStrategy( double probability, double fluctuation, double maxSell ) : probability_( probability ), fluctuation_( fluctuation ), maxSell_( maxSell ) { } RandomSellStrategy::~RandomSellStrategy() { } long RandomSellStrategy::buy( Stock* stock, double capitalAvailable, double buyPrice, long amount ) { if ( drand48() > probability_ ) return 0; amount = (long)( drand48() * amount * maxSell_ ); double fluct = ( fluctuation_* (drand48() - 0.5) + 1.0 ); price_ = stock->price() * fluct; return - amount; }