autotrade::Market::MtGox::rcfile: New attribute
[autotrade.git] / autotrade.pl
bloba4d4f3a23c2b97167e8ebf7204aa08170874f45f
1 #!/usr/bin/perl
3 # Automated Bitcoin Trader - Low-High
4 # (c) Petr Baudis <pasky@ucw.cz> 2011
6 # The automated trader maintains no persistent data except in MtGox
7 # order book. We still expect periodical user inspections; if you want
8 # to withdraw k USD, place a buy order on k BTC @ 1 USD.
10 use warnings;
11 use strict;
13 my $interval = 15; # [s] trade cycle period
16 use autotrade::SQL;
17 use autotrade::RateHistory;
18 use autotrade::Market::MtGox;
19 use autotrade::Trader::LowHigh;
21 my $dbh = autotrade::SQL::db_connect();
22 my $rh = autotrade::RateHistory->new(dbh => $dbh);
23 my $m = autotrade::Market::MtGox->new();
24 my $t = autotrade::Trader::LowHigh->new(m => $m);
27 while (1) {
28 print "... ".localtime." check\n";
29 my $md;
30 my $time;
31 do {
32 $md = $m->market_data();
33 $time = time;
34 } while ($t->beat($md));
35 $rh->record($time, $md->rate_buybtc(), $md->rate_sellbtc());
36 print "... ".localtime." check finished.\n\n";
37 sleep $interval;