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