File Coverage

lib/Finance/Robinhood/Equity/PriceMovement.pm
Criterion Covered Total %
statement 11 19 57.8
branch n/a
condition 1 2 50.0
subroutine 5 6 83.3
pod n/a
total 17 27 62.9


line stmt bran cond sub pod time code
1             package Finance::Robinhood::Equity::PriceMovement;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls
6              
7             =head1 NAME
8              
9             Finance::Robinhood::Equity::PriceMovement - Represents How Much a Top Moving
10             Equity Instrument has Moved
11              
12             =head1 SYNOPSIS
13              
14             use Text::Wrap qw[wrap];
15             use Finance::Robinhood;
16             my $rh = Finance::Robinhood->new;
17             my $movers = $rh->top_movers(direction => 'up');
18              
19             for my $mover ($movers->all) {
20             CORE::say $mover->instrument->name . ' has increased by ' . $mover->price_movement->market_hours_last_movement_pct . '%' ;
21             }
22              
23             =head1 METHODS
24              
25             =cut
26              
27             our $VERSION = '0.92_002';
28              
29 1     1   7 use Mojo::Base-base, -signatures;
  1         2  
  1         7  
30 1     1   184 use Mojo::URL;
  1         2  
  1         6  
31              
32             sub _test__init {
33 1     1   12428 my $rh = t::Utility::rh_instance(1);
34 0         0 my $top = $rh->top_movers( direction => 'up' )->current->price_movement;
35 0         0 isa_ok( $top, __PACKAGE__ );
36 0         0 t::Utility::stash( 'MOVEMENT', $top ); # Store it for later
37             }
38              
39 1     1   152 use overload '""' => sub ( $s, @ ) { $s->{market_hours_last_movement_pct} }, fallback => 1;
  1     0   2  
  1         8  
  0         0  
  0         0  
  0         0  
  0         0  
40              
41             sub _test_stringify {
42 1   50 1   2056 t::Utility::stash('MOVEMENT') // skip_all();
43 0           like(
44             +t::Utility::stash('MOVEMENT'),
45             qr[^\-?\d+\.\d+$],
46             );
47             }
48             #
49             has _rh => undef => weak => 1;
50              
51             =head2 C
52              
53             Returns a number of positive of negative percentage points.
54              
55             =head2 C
56              
57             Returns the actual price.
58              
59             =cut
60              
61             has [
62             'market_hours_last_movement_pct',
63             'market_hours_last_price'
64             ];
65              
66             =head1 LEGAL
67              
68             This is a simple wrapper around the API used in the official apps. The author
69             provides no investment, legal, or tax advice and is not responsible for any
70             damages incurred while using this software. This software is not affiliated
71             with Robinhood Financial LLC in any way.
72              
73             For Robinhood's terms and disclosures, please see their website at
74             https://robinhood.com/legal/
75              
76             =head1 LICENSE
77              
78             Copyright (C) Sanko Robinson.
79              
80             This library is free software; you can redistribute it and/or modify it under
81             the terms found in the Artistic License 2. Other copyrights, terms, and
82             conditions may apply to data transmitted through this module. Please refer to
83             the L section.
84              
85             =head1 AUTHOR
86              
87             Sanko Robinson Esanko@cpan.orgE
88              
89             =cut
90              
91             1;