| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Finance::CampBX; |
|
2
|
|
|
|
|
|
|
$Finance::CampBX::VERSION = '0.1'; # TRIAL |
|
3
|
1
|
|
|
1
|
|
21301
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
46
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
37
|
|
|
5
|
1
|
|
|
1
|
|
764
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
42007
|
|
|
|
1
|
|
|
|
|
35
|
|
|
6
|
1
|
|
|
1
|
|
551
|
use JSON -support_by_pp; |
|
|
1
|
|
|
|
|
8055
|
|
|
|
1
|
|
|
|
|
5
|
|
|
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
|
|
|
|
|
|
|
sub sendtoaccount(){ |
|
59
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
60
|
0
|
|
|
|
|
|
my ($userid, $password, $recepientid, $btcamount) = @_; |
|
61
|
0
|
|
|
|
|
|
return sendrequest('https://campbx.com/api/sendinstant.php', { 'user'=>$userid, 'pass'=>$password, 'CBXCode'=>$recepientid, 'BTCAmt'=>$btcamount }); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub sendrequest(){ |
|
65
|
0
|
|
|
0
|
1
|
|
my ( $url, $options ) = @_; |
|
66
|
0
|
|
|
|
|
|
my $response; |
|
67
|
0
|
|
|
|
|
|
my $browser = LWP::UserAgent->new( agent => "Perl-Finance-CampBX" ); |
|
68
|
0
|
0
|
|
|
|
|
if ($options){ |
|
69
|
0
|
|
|
|
|
|
$response = $browser->post( $url, $options ); |
|
70
|
|
|
|
|
|
|
}else{ |
|
71
|
0
|
|
|
|
|
|
$response = $browser->post( $url ); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
0
|
0
|
|
|
|
|
if ($response->is_success) { |
|
74
|
0
|
|
|
|
|
|
my $content = $response->content; |
|
75
|
0
|
|
|
|
|
|
my $json = new JSON; |
|
76
|
0
|
|
|
|
|
|
return $json->utf8->decode($content); |
|
77
|
|
|
|
|
|
|
} else { |
|
78
|
0
|
|
|
|
|
|
return 0; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub new { |
|
83
|
0
|
|
|
0
|
1
|
|
my $package = shift; |
|
84
|
0
|
|
|
|
|
|
return bless({}, $package); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
|
88
|
|
|
|
|
|
|
__END__ |