line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::CampBX; |
2
|
|
|
|
|
|
|
$Finance::CampBX::VERSION = '0.2'; |
3
|
1
|
|
|
1
|
|
24687
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
1255
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
82317
|
|
|
1
|
|
|
|
|
52
|
|
6
|
1
|
|
|
1
|
|
1834
|
use JSON -support_by_pp; |
|
1
|
|
|
|
|
22926
|
|
|
1
|
|
|
|
|
8
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub ticker(){ |
9
|
0
|
|
|
0
|
1
|
|
return sendrequest("http://campbx.com/api/xticker.php"); |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub depth(){ |
13
|
0
|
|
|
0
|
1
|
|
return sendrequest("http://campbx.com/api/xdepth.php"); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub balance(){ |
17
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
18
|
0
|
|
|
|
|
|
my ($userid, $password) = @_; |
19
|
0
|
|
|
|
|
|
return sendrequest('https://campbx.com/api/myfunds.php', {'user'=>$userid, 'pass'=>$password }); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub orders(){ |
23
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
24
|
0
|
|
|
|
|
|
my ($userid, $password) = @_; |
25
|
0
|
|
|
|
|
|
return sendrequest('https://campbx.com/api/myorders.php', {'user'=>$userid, 'pass'=>$password }); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub margins(){ |
29
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
30
|
0
|
|
|
|
|
|
my ($userid, $password) = @_; |
31
|
0
|
|
|
|
|
|
return sendrequest('https://campbx.com/api/mymargins.php', {'user'=>$userid, 'pass'=>$password }); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub getbtcaddress(){ |
35
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
36
|
0
|
|
|
|
|
|
my ($userid, $password) = @_; |
37
|
0
|
|
|
|
|
|
return sendrequest('https://campbx.com/api/getbtcaddr.php', {'user'=>$userid, 'pass'=>$password }); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub quicktrade(){ |
41
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
42
|
0
|
|
|
|
|
|
my ($userid, $password, $trademode, $quantity, $price) = @_; |
43
|
0
|
|
|
|
|
|
return sendrequest('https://campbx.com/api/tradeenter.php', { 'user'=>$userid, 'pass'=>$password, 'TradeMode'=>$trademode, 'Quantity'=> $quantity, 'Price'=>$price }); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub cancelorder(){ |
47
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
48
|
0
|
|
|
|
|
|
my ($userid, $password, $type, $orderid) = @_; |
49
|
0
|
|
|
|
|
|
return sendrequest('https://campbx.com/api/tradecancel.php', { 'user'=>$userid, 'pass'=>$password, 'Type'=>$type, 'OrderID'=>$orderid }); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub sendtobtc(){ |
53
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
54
|
0
|
|
|
|
|
|
my ($userid, $password, $btcaddress, $btcamount) = @_; |
55
|
0
|
|
|
|
|
|
return sendrequest('https://campbx.com/api/sendbtc.php', { 'user'=>$userid, 'pass'=>$password, 'BTCTo'=>$btcaddress, 'BTCAmt'=>$btcamount }); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub sendrequest(){ |
60
|
0
|
|
|
0
|
1
|
|
my ( $url, $options ) = @_; |
61
|
0
|
|
|
|
|
|
my $response; |
62
|
0
|
|
|
|
|
|
my $browser = LWP::UserAgent->new( agent => "Perl-Finance-CampBX" ); |
63
|
0
|
0
|
|
|
|
|
if ($options){ |
64
|
0
|
|
|
|
|
|
$response = $browser->post( $url, $options ); |
65
|
|
|
|
|
|
|
}else{ |
66
|
0
|
|
|
|
|
|
$response = $browser->post( $url ); |
67
|
|
|
|
|
|
|
} |
68
|
0
|
0
|
|
|
|
|
if ($response->is_success) { |
69
|
0
|
|
|
|
|
|
my $content = $response->content; |
70
|
0
|
|
|
|
|
|
my $json = new JSON; |
71
|
0
|
|
|
|
|
|
return $json->utf8->decode($content); |
72
|
|
|
|
|
|
|
} else { |
73
|
0
|
|
|
|
|
|
return 0; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub new { |
78
|
0
|
|
|
0
|
1
|
|
my $package = shift; |
79
|
0
|
|
|
|
|
|
return bless({}, $package); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
__END__ |