| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Finance::Robinhood::Options::Instrument; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | =encoding utf-8 | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | =for stopwords watchlist watchlists untradable urls | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | =head1 NAME | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | Finance::Robinhood::Options::Instrument - Represents a Single Options | 
| 10 |  |  |  |  |  |  | Instrument | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | use Finance::Robinhood; | 
| 15 |  |  |  |  |  |  | my $rh = Finance::Robinhood->new; | 
| 16 |  |  |  |  |  |  | my $instruments = $rh->options_instruments(); | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | for my $instrument ($instruments->all) { | 
| 19 |  |  |  |  |  |  | CORE::say $instrument->chain_symbol; | 
| 20 |  |  |  |  |  |  | } | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | =cut | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | our $VERSION = '0.92_001'; | 
| 25 | 1 |  |  | 1 |  | 7 | use Mojo::Base-base, -signatures; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 12 |  | 
| 26 | 1 |  |  | 1 |  | 307 | use Mojo::URL; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 11 |  | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | sub _test__init { | 
| 29 | 1 |  |  | 1 |  | 11311 | my $rh         = t::Utility::rh_instance(1); | 
| 30 | 0 |  |  |  |  | 0 | my $instrument = $rh->options_instruments( | 
| 31 |  |  |  |  |  |  | chain_id    => $rh->equity_instrument_by_symbol('MSFT')->tradable_chain_id, | 
| 32 |  |  |  |  |  |  | tradability => 'tradable' | 
| 33 |  |  |  |  |  |  | )->current; | 
| 34 | 0 |  |  |  |  | 0 | isa_ok( $instrument, __PACKAGE__ ); | 
| 35 | 0 |  |  |  |  | 0 | t::Utility::stash( 'INSTRUMENT', $instrument );    #  Store it for later | 
| 36 |  |  |  |  |  |  | } | 
| 37 | 1 |  |  | 1 |  | 164 | use overload '""' => sub ( $s, @ ) { $s->{url} }, fallback => 1; | 
|  | 1 |  |  | 0 |  | 3 |  | 
|  | 1 |  |  |  |  | 12 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | sub _test_stringify { | 
| 40 | 1 |  | 50 | 1 |  | 1893 | t::Utility::stash('INSTRUMENT') // skip_all(); | 
| 41 | 0 |  |  |  |  | 0 | is( | 
| 42 |  |  |  |  |  |  | +t::Utility::stash('INSTRUMENT'), | 
| 43 |  |  |  |  |  |  | 'https://api.robinhood.com/options/instruments/' | 
| 44 |  |  |  |  |  |  | . t::Utility::stash('INSTRUMENT')->id . '/' | 
| 45 |  |  |  |  |  |  | ); | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  | # | 
| 48 |  |  |  |  |  |  | has _rh => undef => weak => 1; | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | =head1 METHODS | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | =head2 C | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | =head2 C | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | =head2 C | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | UUID used to identify this instrument. | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | =head2 C | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | Returns a hash reference with the following keys: | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | =over | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | =item C - Minimum tick size when applicable. | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | =item C - Minimum tick size when applicable. | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =item C - At this price or more, the C will apply. Below this price, the C is required. | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | =back | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | =head2 C | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | Exposes whether or not this instrument can be traded on Robinhood. Either | 
| 79 |  |  |  |  |  |  | C or C. | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | =head2 C | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | =head2 C | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | The strike of this particular instrument. | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | =head2 C | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | Indicates whether this instrument is being traded in general. | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | =head2 C | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | Indicated whether this is a C or C. | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | =cut | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | has [ | 
| 100 |  |  |  |  |  |  | 'chain_id',        'chain_symbol', 'id',           'min_ticks', | 
| 101 |  |  |  |  |  |  | 'rhs_tradability', 'state',        'strike_price', 'tradability', | 
| 102 |  |  |  |  |  |  | 'type', | 
| 103 |  |  |  |  |  |  | ]; | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | =head2 C | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | Returns a Time::Moment object. | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | =cut | 
| 110 |  |  |  |  |  |  |  | 
| 111 | 0 |  |  | 0 | 1 | 0 | sub expiration_date ($s) { | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 112 | 0 |  |  |  |  | 0 | Time::Moment->from_string( $s->{expiration_date} . 'T00:00:00Z' ); | 
| 113 |  |  |  |  |  |  | } | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | sub _test_expiration_date { | 
| 116 | 1 |  | 50 | 1 |  | 1864 | t::Utility::stash('INSTRUMENT') // skip_all(); | 
| 117 | 0 |  |  |  |  | 0 | isa_ok( t::Utility::stash('INSTRUMENT')->expiration_date, 'Time::Moment' ); | 
| 118 |  |  |  |  |  |  | } | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | =head2 C | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | Returns a Time::Moment object. | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | =cut | 
| 125 |  |  |  |  |  |  |  | 
| 126 | 0 |  |  | 0 | 1 | 0 | sub issue_date ($s) { | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 127 | 0 |  |  |  |  | 0 | Time::Moment->from_string( $s->{issue_date} . 'T00:00:00Z' ); | 
| 128 |  |  |  |  |  |  | } | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | sub _test_issue_date { | 
| 131 | 1 |  | 50 | 1 |  | 1877 | t::Utility::stash('INSTRUMENT') // skip_all(); | 
| 132 | 0 |  |  |  |  | 0 | isa_ok( t::Utility::stash('INSTRUMENT')->issue_date, 'Time::Moment' ); | 
| 133 |  |  |  |  |  |  | } | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | =head2 C | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | Returns a Time::Moment object. | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | =cut | 
| 140 |  |  |  |  |  |  |  | 
| 141 | 0 |  |  | 0 | 1 | 0 | sub created_at ($s) { | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 142 | 0 |  |  |  |  | 0 | Time::Moment->from_string( $s->{created_at} ); | 
| 143 |  |  |  |  |  |  | } | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | sub _test_created_at { | 
| 146 | 1 |  | 50 | 1 |  | 1992 | t::Utility::stash('INSTRUMENT') // skip_all(); | 
| 147 | 0 |  |  |  |  | 0 | isa_ok( t::Utility::stash('INSTRUMENT')->created_at, 'Time::Moment' ); | 
| 148 |  |  |  |  |  |  | } | 
| 149 |  |  |  |  |  |  |  | 
| 150 |  |  |  |  |  |  | =head2 C | 
| 151 |  |  |  |  |  |  |  | 
| 152 |  |  |  |  |  |  | Returns a Time::Moment object. | 
| 153 |  |  |  |  |  |  |  | 
| 154 |  |  |  |  |  |  | =cut | 
| 155 |  |  |  |  |  |  |  | 
| 156 | 0 |  |  | 0 | 1 | 0 | sub updated_at ($s) { | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 157 | 0 |  |  |  |  | 0 | Time::Moment->from_string( $s->{updated_at} ); | 
| 158 |  |  |  |  |  |  | } | 
| 159 |  |  |  |  |  |  |  | 
| 160 |  |  |  |  |  |  | sub _test_updated_at { | 
| 161 | 1 |  | 50 | 1 |  | 1867 | t::Utility::stash('INSTRUMENT') // skip_all(); | 
| 162 | 0 |  |  |  |  |  | isa_ok( t::Utility::stash('INSTRUMENT')->updated_at, 'Time::Moment' ); | 
| 163 |  |  |  |  |  |  | } | 
| 164 |  |  |  |  |  |  |  | 
| 165 |  |  |  |  |  |  | =head1 LEGAL | 
| 166 |  |  |  |  |  |  |  | 
| 167 |  |  |  |  |  |  | This is a simple wrapper around the API used in the official apps. The author | 
| 168 |  |  |  |  |  |  | provides no investment, legal, or tax advice and is not responsible for any | 
| 169 |  |  |  |  |  |  | damages incurred while using this software. This software is not affiliated | 
| 170 |  |  |  |  |  |  | with Robinhood Financial LLC in any way. | 
| 171 |  |  |  |  |  |  |  | 
| 172 |  |  |  |  |  |  | For Robinhood's terms and disclosures, please see their website at | 
| 173 |  |  |  |  |  |  | https://robinhood.com/legal/ | 
| 174 |  |  |  |  |  |  |  | 
| 175 |  |  |  |  |  |  | =head1 LICENSE | 
| 176 |  |  |  |  |  |  |  | 
| 177 |  |  |  |  |  |  | Copyright (C) Sanko Robinson. | 
| 178 |  |  |  |  |  |  |  | 
| 179 |  |  |  |  |  |  | This library is free software; you can redistribute it and/or modify it under | 
| 180 |  |  |  |  |  |  | the terms found in the Artistic License 2. Other copyrights, terms, and | 
| 181 |  |  |  |  |  |  | conditions may apply to data transmitted through this module. Please refer to | 
| 182 |  |  |  |  |  |  | the L section. | 
| 183 |  |  |  |  |  |  |  | 
| 184 |  |  |  |  |  |  | =head1 AUTHOR | 
| 185 |  |  |  |  |  |  |  | 
| 186 |  |  |  |  |  |  | Sanko Robinson Esanko@cpan.orgE | 
| 187 |  |  |  |  |  |  |  | 
| 188 |  |  |  |  |  |  | =cut | 
| 189 |  |  |  |  |  |  |  | 
| 190 |  |  |  |  |  |  | 1; |