line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Crypto::Exchange::Kraken::REST::Public; |
2
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
3
|
1
|
|
|
1
|
|
1423
|
use Moose::Role; |
|
1
|
|
|
|
|
6201
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Role for Kraken "public" API calls |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
requires qw(call); |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6447
|
use HTTP::Request::Common qw(POST); |
|
1
|
|
|
|
|
2368
|
|
|
1
|
|
|
|
|
73
|
|
10
|
1
|
|
|
1
|
|
573
|
use Types::Standard qw( Int Str Enum); |
|
1
|
|
|
|
|
81367
|
|
|
1
|
|
|
|
|
12
|
|
11
|
1
|
|
|
1
|
|
1804
|
use Params::ValidationCompiler qw(validation_for); |
|
1
|
|
|
|
|
22167
|
|
|
1
|
|
|
|
|
806
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _public { |
14
|
11
|
|
|
11
|
|
48
|
my ($self, $call, %payload) = @_; |
15
|
|
|
|
|
|
|
|
16
|
11
|
|
|
|
|
436
|
my $uri = $self->_uri->clone; |
17
|
11
|
|
|
|
|
191
|
$uri->path_segments(0, 'public', $call); |
18
|
|
|
|
|
|
|
|
19
|
11
|
100
|
|
|
|
897
|
return POST( |
20
|
|
|
|
|
|
|
$uri, |
21
|
|
|
|
|
|
|
%payload ? (Content => [%payload]) : (), |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub get_server_time { |
26
|
1
|
|
|
1
|
1
|
7255
|
my $self = shift; |
27
|
1
|
|
|
|
|
6
|
my $req = $self->_public('Time'); |
28
|
1
|
|
|
|
|
244
|
return $self->call($req); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
my $validator = validation_for( |
34
|
|
|
|
|
|
|
name => 'get_asset_info', |
35
|
|
|
|
|
|
|
params => { |
36
|
|
|
|
|
|
|
info => { |
37
|
|
|
|
|
|
|
type => Enum [qw(info)], |
38
|
|
|
|
|
|
|
optional => 1, |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
aclass => { |
41
|
|
|
|
|
|
|
type => Enum [qw(currency)], |
42
|
|
|
|
|
|
|
optional => 1, |
43
|
|
|
|
|
|
|
}, |
44
|
|
|
|
|
|
|
asset => { |
45
|
|
|
|
|
|
|
type => Str, |
46
|
|
|
|
|
|
|
optional => 1, |
47
|
|
|
|
|
|
|
}, |
48
|
|
|
|
|
|
|
}, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub get_asset_info { |
52
|
2
|
|
|
2
|
1
|
21916
|
my $self = shift; |
53
|
2
|
|
|
|
|
61
|
my %args = $validator->(@_); |
54
|
2
|
|
|
|
|
95
|
my $req = $self->_public('Assets', %args); |
55
|
2
|
|
|
|
|
1092
|
return $self->call($req); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
{ |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $validator = validation_for( |
62
|
|
|
|
|
|
|
name => 'get_tradable_asset_pairs', |
63
|
|
|
|
|
|
|
params => { |
64
|
|
|
|
|
|
|
info => { |
65
|
|
|
|
|
|
|
type => Enum [qw(info leverage fees margin)], |
66
|
|
|
|
|
|
|
optional => 1, |
67
|
|
|
|
|
|
|
}, |
68
|
|
|
|
|
|
|
pair => { |
69
|
|
|
|
|
|
|
type => Str, |
70
|
|
|
|
|
|
|
optional => 1, |
71
|
|
|
|
|
|
|
}, |
72
|
|
|
|
|
|
|
}, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub get_tradable_asset_pairs { |
76
|
2
|
|
|
2
|
1
|
14696
|
my $self = shift; |
77
|
2
|
|
|
|
|
58
|
my %args = $validator->(@_); |
78
|
2
|
|
|
|
|
73
|
my $req = $self->_public('AssetPairs', %args); |
79
|
2
|
|
|
|
|
652
|
return $self->call($req); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
{ |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $validator = validation_for( |
87
|
|
|
|
|
|
|
name => 'get_ticker_information', |
88
|
|
|
|
|
|
|
params => { pair => { type => Str, }, }, |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub get_ticker_information { |
92
|
1
|
|
|
1
|
1
|
7182
|
my $self = shift; |
93
|
1
|
|
|
|
|
30
|
my %args = $validator->(@_); |
94
|
1
|
|
|
|
|
41
|
my $req = $self->_public('Ticker', %args); |
95
|
1
|
|
|
|
|
406
|
return $self->call($req); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
{ |
100
|
|
|
|
|
|
|
my $validator = validation_for( |
101
|
|
|
|
|
|
|
name => 'get_ohlc_data', |
102
|
|
|
|
|
|
|
params => { |
103
|
|
|
|
|
|
|
pair => { type => Str, }, |
104
|
|
|
|
|
|
|
interval => { |
105
|
|
|
|
|
|
|
optional => 1, |
106
|
|
|
|
|
|
|
type => Enum [qw(1 5 15 30 60 240 1440 10080 21600)] |
107
|
|
|
|
|
|
|
}, |
108
|
|
|
|
|
|
|
since => { optional => 1, } |
109
|
|
|
|
|
|
|
}, |
110
|
|
|
|
|
|
|
); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub get_ohlc_data { |
113
|
1
|
|
|
1
|
1
|
7998
|
my $self = shift; |
114
|
1
|
|
|
|
|
42
|
my %args = $validator->(@_); |
115
|
1
|
|
|
|
|
62
|
my $req = $self->_public('OHLC', %args); |
116
|
1
|
|
|
|
|
428
|
return $self->call($req); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
{ |
121
|
|
|
|
|
|
|
my $validator = validation_for( |
122
|
|
|
|
|
|
|
name => 'get_order_book', |
123
|
|
|
|
|
|
|
params => { |
124
|
|
|
|
|
|
|
pair => { type => Str, }, |
125
|
|
|
|
|
|
|
count => { |
126
|
|
|
|
|
|
|
optional => 1, |
127
|
|
|
|
|
|
|
type => Int, |
128
|
|
|
|
|
|
|
}, |
129
|
|
|
|
|
|
|
}, |
130
|
|
|
|
|
|
|
); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub get_order_book { |
133
|
2
|
|
|
2
|
1
|
14880
|
my $self = shift; |
134
|
2
|
|
|
|
|
61
|
my %args = $validator->(@_); |
135
|
2
|
|
|
|
|
94
|
my $req = $self->_public('Depth', %args); |
136
|
2
|
|
|
|
|
857
|
return $self->call($req); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
{ |
141
|
|
|
|
|
|
|
my $validator = validation_for( |
142
|
|
|
|
|
|
|
name => 'get_recent_trades', |
143
|
|
|
|
|
|
|
params => { |
144
|
|
|
|
|
|
|
pair => { type => Str, }, |
145
|
|
|
|
|
|
|
since => { optional => 1, }, |
146
|
|
|
|
|
|
|
}, |
147
|
|
|
|
|
|
|
); |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub get_recent_trades { |
150
|
1
|
|
|
1
|
1
|
7642
|
my $self = shift; |
151
|
1
|
|
|
|
|
64
|
my %args = $validator->(@_); |
152
|
1
|
|
|
|
|
44
|
my $req = $self->_public('Trades', %args); |
153
|
1
|
|
|
|
|
399
|
return $self->call($req); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
{ |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
my $validator = validation_for( |
160
|
|
|
|
|
|
|
name => 'get_recent_spread_data', |
161
|
|
|
|
|
|
|
params => { |
162
|
|
|
|
|
|
|
pair => { type => Str, }, |
163
|
|
|
|
|
|
|
since => { optional => 1, }, |
164
|
|
|
|
|
|
|
}, |
165
|
|
|
|
|
|
|
); |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub get_recent_spread_data { |
168
|
1
|
|
|
1
|
1
|
7338
|
my $self = shift; |
169
|
1
|
|
|
|
|
30
|
my %args = $validator->(@_); |
170
|
1
|
|
|
|
|
38
|
my $req = $self->_public('Spread', %args); |
171
|
1
|
|
|
|
|
422
|
return $self->call($req); |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
1; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
__END__ |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=pod |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=encoding UTF-8 |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 NAME |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Finance::Crypto::Exchange::Kraken::REST::Public - Role for Kraken "public" API calls |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 VERSION |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
version 0.002 |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 SYNOPSIS |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
package Foo; |
195
|
|
|
|
|
|
|
use Moose; |
196
|
|
|
|
|
|
|
with qw(Finance::Crypto::Exchange::Kraken::REST::Public); |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 DESCRIPTION |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This role introduces all the public API calls Kraken supports. For extensive |
201
|
|
|
|
|
|
|
information please have a look at the |
202
|
|
|
|
|
|
|
L<Kraken API manual|https://www.kraken.com/features/api#public-market-data> |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 METHODS |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head2 get_server_time |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
L<https://api.kraken.com/0/public/Time> |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 get_asset_info |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
L<https://api.kraken.com/0/public/Asset> |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head3 Accepted parameters |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=over |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=item info (optional) |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
C<info> all info (default) |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=item aclass (optional) |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
C<currency> (default) |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item asset (optional) |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
C<all> (default) |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=back |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head2 get_tradable_asset_pairs |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
L<https://api.kraken.com/0/public/AssetPairs> |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 get_ticker_information |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
L<https://api.kraken.com/0/public/Ticker> |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 get_ohlc_data |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
L<https://api.kraken.com/0/public/OHLC> |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head2 get_order_book |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
L<https://api.kraken.com/0/public/Depth> |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head2 get_recent_trades |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
L<https://api.kraken.com/0/public/Trades> |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head2 get_recent_spread_data |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
L<https://api.kraken.com/0/public/Spread> |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 AUTHOR |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Wesley Schwengle <waterkip@cpan.org> |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Wesley Schwengle. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
This is free software, licensed under: |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
The (three-clause) BSD License |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=cut |