line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypto::Exchange::API; |
2
|
|
|
|
|
|
|
$Crypto::Exchange::API::VERSION = '0.01'; |
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Crypto::Exchange::API - API module for Crypto Exchanges |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 USAGE |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Use this class as parent for the exchanges API. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
It defines the key, secret which evey crypto exchnages are requried. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
The base_currencies is for the exchanges is useful to help to separate the coin and the base token |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
ie. Binance |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
XRPUSDT |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
OR XRPGBP |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
In the sub class define all the base tokens e.g. ['USDT', 'GBP', etc...] |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
And you can use the below example method to separate them in request and response |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub response_attr_pair { |
26
|
|
|
|
|
|
|
my ($self, $pair) = @_; |
27
|
|
|
|
|
|
|
my $bases = $self->base_currencies; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
foreach my $base(keys %$bases) { |
30
|
|
|
|
|
|
|
if ($pair =~ m/^$base(.+)/ || $pair =~ m/(.+)$base$/) { |
31
|
|
|
|
|
|
|
return { base => $base, coin => $1 }, |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
die "Pair [$pair] couldnn't find base currency"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
1
|
|
1369
|
use Moo; |
|
1
|
|
|
|
|
12034
|
|
|
1
|
|
|
|
|
5
|
|
41
|
1
|
|
|
1
|
|
2081
|
use Crypto::API; |
|
1
|
|
|
|
|
125393
|
|
|
1
|
|
|
|
|
118
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
extends 'Crypto::API'; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has key => ( |
46
|
|
|
|
|
|
|
is => 'ro', |
47
|
|
|
|
|
|
|
lazy => 1, |
48
|
|
|
|
|
|
|
builder => 1, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has secret => ( |
52
|
|
|
|
|
|
|
is => 'ro', |
53
|
|
|
|
|
|
|
lazy => 1, |
54
|
|
|
|
|
|
|
builder => 1, |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has phrase => ( |
58
|
|
|
|
|
|
|
is => 'ro', |
59
|
|
|
|
|
|
|
lazy => 1, |
60
|
|
|
|
|
|
|
builder => 1, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has base_currencies => ( |
64
|
|
|
|
|
|
|
is => 'ro', |
65
|
|
|
|
|
|
|
lazy => 1, |
66
|
|
|
|
|
|
|
builder => 1, |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
## leave the builders to the sub class |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
1
|
|
10
|
no Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |