| 1 | package Finance::CoinbasePro::API::CLI::Account; | ||||||||||
| 2 | # this knows about Finance::GDAX::Fill objects and can display them | ||||||||||
| 3 | 1 | ▶ | use Mouse; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use Data::Dump qw(dump); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Finance::CoinbasePro::API::CLI::Util::CurrencyUtil qw(format_usd format_currency ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | has 'balance' => ( is=>'rw', isa=>"Num", required=>1 ); | |||||||||
| 8 | 1 | has 'currency' => ( is=>'rw', isa=>"Str", required=>1 ); | |||||||||
| 9 | 1 | has 'available' => ( is=>'rw', isa=>"Num", required=>1 ); | |||||||||
| 10 | 1 | has 'hold' => ( is=>'rw', isa=>"Num", required=>1 ); | |||||||||
| 11 | 1 | has 'id' => ( is=>'rw', isa=>"Str", default=>'' ); | |||||||||
| 12 | 1 | has 'profile_id' => ( is=>'rw', isa=>"Str", default=>'' ); | |||||||||
| 13 | |||||||||||
| 14 | sub balance { | ||||||||||
| 15 | my $self = shift; | ||||||||||
| 16 | return Finance::CoinbasePro::API::CLI::Value->new( num => $self->{balance}, currency => $self->{currency} ); | ||||||||||
| 17 | } | ||||||||||
| 18 | sub hold { | ||||||||||
| 19 | my $self = shift; | ||||||||||
| 20 | return $self->{hold} || 0; | ||||||||||
| 21 | } | ||||||||||
| 22 | sub to_str { | ||||||||||
| 23 | 2 | ▶ | my $self = shift; | ||||||||
|
Subroutine
to_str: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||
| 24 | 2 | my $balance = $self->balance(); | |||||||||
| 25 | 2 | my $str = format_currency( $self->balance, $self->currency ); | |||||||||
| 26 | # available => "3468.65944081011515", balance => "3468.6594408101151500", currency => "USD", hold => "0.0000000000000000", | ||||||||||
| 27 | # id => "2b81d28b-249b-416d-9ade-720301443d82", # profile_id => "18f975e3-6d43-4127-aca5-7d2c13b2ea31", | ||||||||||
| 28 | 2 | ▶ | if ((my $hold = $self->hold()) > 0) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 0 | $str .= " ($hold held)"; # should be a J:D:Value | |||||||||
| 30 | } | ||||||||||
| 31 | 2 | return $str; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | sub to_str_with_usd { | ||||||||||
| 35 | 1 | ▶ | my ($self, $per_usd) = @_; | ||||||||
|
Subroutine
to_str_with_usd: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||
| 36 | 1 | my $str = $self->to_str(); | |||||||||
| 37 | 1 | ▶ | if ($self->{currency} ne "USD") { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 0 | $str .= " " . format_usd( $self->{balance}, $self->{currency}. $per_usd ); | |||||||||
| 39 | } | ||||||||||
| 40 | 1 | return $str; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 1 | 1; | |||||||||
| 44 | |||||||||||
| 45 | |||||||||||
| 46 | |||||||||||
| 47 | |||||||||||
| 48 | #################### pod generated by Pod::Autopod - keep this line to make pod updates possible #################### | ||||||||||
| 49 | |||||||||||
| 50 | =head1 NAME | ||||||||||
| 51 | |||||||||||
| 52 | Finance::CoinbasePro::API::CLI::Account | ||||||||||
| 53 | |||||||||||
| 54 | |||||||||||
| 55 | =head1 DESCRIPTION | ||||||||||
| 56 | |||||||||||
| 57 | this knows about Finance::GDAX::Fill objects and can display them | ||||||||||
| 58 | |||||||||||
| 59 | |||||||||||
| 60 | =head1 REQUIRES | ||||||||||
| 61 | |||||||||||
| 62 | L<Finance::CoinbasePro::API::CLI::Util::CurrencyUtil> | ||||||||||
| 63 | |||||||||||
| 64 | L<Data::Dump> | ||||||||||
| 65 | |||||||||||
| 66 | L<Mouse> | ||||||||||
| 67 | |||||||||||
| 68 | |||||||||||
| 69 | =head1 METHODS | ||||||||||
| 70 | |||||||||||
| 71 | =head2 balance | ||||||||||
| 72 | |||||||||||
| 73 | balance(); | ||||||||||
| 74 | |||||||||||
| 75 | =head2 hold | ||||||||||
| 76 | |||||||||||
| 77 | hold(); | ||||||||||
| 78 | |||||||||||
| 79 | =head2 to_str | ||||||||||
| 80 | |||||||||||
| 81 | to_str(); | ||||||||||
| 82 | |||||||||||
| 83 | =head2 to_str_with_usd | ||||||||||
| 84 | |||||||||||
| 85 | to_str_with_usd(); | ||||||||||
| 86 | |||||||||||
| 87 | =cut | ||||||||||
| 88 | |||||||||||