File Coverage

lib/Finance/Robinhood/Forex/Currency.pm
Criterion Covered Total %
statement 16 39 41.0
branch n/a
condition 3 6 50.0
subroutine 8 11 72.7
pod 2 2 100.0
total 29 58 50.0


line stmt bran cond sub pod time code
1             package Finance::Robinhood::Forex::Currency;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls
6              
7             =head1 NAME
8              
9             Finance::Robinhood::Forex::Currency - Represents a Single Forex Currency
10             Watchlist
11              
12             =head1 SYNOPSIS
13              
14             use Finance::Robinhood;
15             my $rh = Finance::Robinhood->new;
16              
17             # TODO
18              
19             =cut
20              
21             our $VERSION = '0.92_003';
22 1     1   7 use Mojo::Base-base, -signatures;
  1         2  
  1         7  
23 1     1   193 use Mojo::URL;
  1         2  
  1         6  
24 1     1   436 use Finance::Robinhood::Forex::Quote;
  1         2  
  1         10  
25              
26             sub _test__init {
27 1     1   12034 my $rh = t::Utility::rh_instance(1);
28 0         0 my $btc
29             = $rh->forex_currency_by_id('d674efea-e623-4396-9026-39574b92b093')
30             ; # BTC
31 0         0 isa_ok($btc, __PACKAGE__);
32 0         0 t::Utility::stash('CURRENCY', $btc); # Store it for later
33             }
34 1     1   150 use overload '""' => sub ($s, @) { $s->{id} }, fallback => 1;
  1     0   3  
  1         14  
  0         0  
  0         0  
  0         0  
  0         0  
35              
36             sub _test_stringify {
37 1   50 1   1900 t::Utility::stash('CURRENCY') // skip_all();
38 0         0 like(+t::Utility::stash('CURRENCY'),
39             qr'^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'i
40             );
41             }
42             #
43             has _rh => undef => weak => 1;
44              
45             =head1 METHODS
46              
47             =head2 C
48              
49             If defined, this returns a hex color code used for display.
50              
51             =head2 C
52              
53             Short code used to represent this currency for display. 'USD', for example.
54              
55             =head2 C
56              
57             Returns a UUID.
58              
59             =head2 C
60              
61             The increment used as a minimum for display, etc. For example, USD would return
62             C<0.01> to prevent sub-penny price display.
63              
64             =head2 C
65              
66             Returns a string suited for display. And example would be 'US Dollar'.
67              
68             =head2 C
69              
70             This is the asset type. Currently, C or C.
71              
72             =cut
73              
74             has ['brand_color', 'code', 'id', 'increment', 'name', 'type'];
75              
76             =head2 C
77              
78             my $news = $currency->news;
79              
80             Returns an iterator containing Finance::Robinhood::News elements.
81              
82             =cut
83              
84 0     0 1 0 sub news ($s) { $s->_rh->news($s->id) }
  0         0  
  0         0  
  0         0  
85              
86             sub _test_news {
87 1   50 1   2115 t::Utility::stash('CURRENCY') // skip_all();
88 0         0 my $news = t::Utility::stash('CURRENCY')->news;
89 0         0 isa_ok($news, 'Finance::Robinhood::Utilities::Iterator');
90 0         0 isa_ok($news->current, 'Finance::Robinhood::News');
91             }
92              
93             =head2 C
94              
95             my $pair = $currency->pair;
96              
97             Returns a Finance::Robinhood::Forex::Pair object.
98              
99             =cut
100              
101 0     0 1 0 sub pair ($s) {
  0         0  
  0         0  
102             my ($retval)
103 0         0 = grep { $_->asset_currency->id eq $s->id } $s->_rh->forex_pairs->all;
  0         0  
104 0         0 $retval;
105             }
106              
107             sub _test_pairs {
108 1   50 1   1855 t::Utility::stash('CURRENCY') // skip_all();
109 0           my $pair = t::Utility::stash('CURRENCY')->pair;
110 0           isa_ok($pair, 'Finance::Robinhood::Forex::Pair');
111             }
112              
113             =head1 LEGAL
114              
115             This is a simple wrapper around the API used in the official apps. The author
116             provides no investment, legal, or tax advice and is not responsible for any
117             damages incurred while using this software. This software is not affiliated
118             with Robinhood Financial LLC in any way.
119              
120             For Robinhood's terms and disclosures, please see their website at
121             https://robinhood.com/legal/
122              
123             =head1 LICENSE
124              
125             Copyright (C) Sanko Robinson.
126              
127             This library is free software; you can redistribute it and/or modify it under
128             the terms found in the Artistic License 2. Other copyrights, terms, and
129             conditions may apply to data transmitted through this module. Please refer to
130             the L section.
131              
132             =head1 AUTHOR
133              
134             Sanko Robinson Esanko@cpan.orgE
135              
136             =cut
137              
138             1;