1 package autotrade
::Trader
;
5 has
'm' => ( isa
=> 'autotrade::Market', is
=> 'ro', required
=> 1 );
7 has
'buy_lifetime' => ( isa
=> 'Int', is
=> 'rw', default => 9999999 );
8 has
'sell_lifetime' => ( isa
=> 'Int', is
=> 'rw', default => 9999999 );
10 # Single frame; analyze market data and make buys/sells.
11 # Takes parameters: autotrade::MarketData
12 # Returns 1 if we should try to make more buys/sells right away.
17 # The default implementation will just prune old orders.
18 # In theory - default lifetimes actually prevent that.
22 and $_->time() < $now - ($_->otype() eq 'buy' ?
$self->buy_lifetime() : $self->sell_lifetime())
25 printf "\tCancelling too old order %d (%d): %s %s BTC @ %s USD\n",
26 $o->oid(), $o->time(), $o->otype(), $o->amount(), $o->rate();
27 $self->m()->cancel($o);