line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::GDAX::API::Quote; |
2
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
3
|
1
|
|
|
1
|
|
44575
|
use 5.20.0; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
474
|
use Moose; |
|
1
|
|
|
|
|
463937
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
6833
|
use JSON; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
7
|
1
|
|
|
1
|
|
795
|
use REST::Client; |
|
1
|
|
|
|
|
35787
|
|
|
1
|
|
|
|
|
31
|
|
8
|
1
|
|
|
1
|
|
342
|
use Finance::GDAX::API::URL; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
59
|
|
9
|
1
|
|
|
1
|
|
646
|
use namespace::autoclean; |
|
1
|
|
|
|
|
6941
|
|
|
1
|
|
|
|
|
4
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Finance::GDAX::API::Quote - Get a quote from the GDAX |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use Finanace::GDAX::API::Quote; |
19
|
|
|
|
|
|
|
my $quote = Finance::GDAX::API::Quote->new(product => 'BTC-USD')->get; |
20
|
|
|
|
|
|
|
say $$quote{price}; |
21
|
|
|
|
|
|
|
say $$quote{bid}; |
22
|
|
|
|
|
|
|
say $$quote{ask}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Gets a quote from the GDAX for the specified "product". These quotes |
27
|
|
|
|
|
|
|
do not require GDAX API keys, but they suggesting keeping traffic low. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
More detailed information can be retrieve about products and history |
30
|
|
|
|
|
|
|
using API keys with other classes like Finance::GDAX::API::Product |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Currently, the supported products are: |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
BTC-USD |
35
|
|
|
|
|
|
|
BTC-GBP |
36
|
|
|
|
|
|
|
BTC-EUR |
37
|
|
|
|
|
|
|
ETH-BTC |
38
|
|
|
|
|
|
|
ETH-USD |
39
|
|
|
|
|
|
|
LTC-BTC |
40
|
|
|
|
|
|
|
LTC-USD |
41
|
|
|
|
|
|
|
ETH-EUR |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
These are not hard-coded, but the default is BTC-USD, so if any are |
44
|
|
|
|
|
|
|
added by GDAX in the future, it should work find if you can find the |
45
|
|
|
|
|
|
|
product code. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Quote is returned as a hashref with the (currently) following keys: |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
trade_id |
50
|
|
|
|
|
|
|
price |
51
|
|
|
|
|
|
|
size |
52
|
|
|
|
|
|
|
bid |
53
|
|
|
|
|
|
|
ask |
54
|
|
|
|
|
|
|
volume |
55
|
|
|
|
|
|
|
time |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 C<debug> (default: 1) |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Bool that sets debug mode (will use sandbox). Defaults to true |
62
|
|
|
|
|
|
|
(1). Debug mode does not seem to give real quotes. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 C<product> (default: "BTC-USD") |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
The product code for which to return the quote. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
has 'product' => (is => 'rw', |
71
|
|
|
|
|
|
|
isa => 'Str', |
72
|
|
|
|
|
|
|
default => 'BTC-USD', |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
has 'debug' => (is => 'rw', |
75
|
|
|
|
|
|
|
isa => 'Bool', |
76
|
|
|
|
|
|
|
default => 1, |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 METHODS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 C<get> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Returns a quote for the desired product. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub get { |
88
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
89
|
1
|
|
|
|
|
43
|
my $url = Finance::GDAX::API::URL->new; |
90
|
1
|
|
|
|
|
39
|
$url->debug($self->debug); |
91
|
1
|
|
|
|
|
6
|
$url->add('products'); |
92
|
1
|
|
|
|
|
27
|
$url->add($self->product); |
93
|
1
|
|
|
|
|
6
|
$url->add('ticker'); |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
13
|
my $client = REST::Client->new; |
96
|
1
|
|
|
|
|
5741
|
$client->GET($url->get); |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
822116
|
my $json = JSON->new; |
99
|
1
|
|
|
|
|
9
|
return $json->decode($client->responseContent); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Mark Rushing <mark@orbislumen.net> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Home Grown Systems, SPC. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
115
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|