Nadex/Order.pm

filter: Statementstmt 71.8% 46 / 64 Branchbran 41.6% 10 / 24 Conditioncond 21.2% 10 / 47 MC/DCmcdc 0.0% 0 / 25 Subroutinesub 100% 12 / 12 Podpod 100% 8 / 8 totaltotal 47.7% 86 / 180 CC 34 SCAR 44.3
CC
34
Cov
49%
_new
165.4
direction
16.7
id
2.1
CRAP 83.8
« Nadex/Position.pm ↑ Summary Nadex.pm »
1 package Finance::Nadex::Order;
2  
3 14 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 14 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub id {
Subroutine id: called CC=2 SCAR=7.6
Pod documented
8  
9 1 my $self = shift;
10  
11 1 ▶ if ( exists $self->{id} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"id"}) 1 0 1
12 1 return $self->{id};
13 }
14  
15 0 return;
16 }
17  
18 1 ▶sub bid {
Subroutine bid: called CC=2 SCAR=7.6
Pod documented
19  
20 1 my $self = shift;
21  
22 1 ▶ if ( exists $self->{bid} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"bid"}) 1 0 1
23 1 return $self->{bid};
24 }
25  
26 0 return;
27 }
28  
29 1 ▶sub contract {
Subroutine contract: called CC=2 SCAR=7.6
Pod documented
30  
31 1 my $self = shift;
32  
33 1 ▶ if ( exists $self->{contract} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"contract"}) 1 0 1
34 1 return $self->{contract};
35 }
36  
37 0 return;
38 }
39  
40 1 ▶sub direction {
Subroutine direction: called CC=6 SCAR=28.1
Pod documented
41  
42 1 my $self = shift;
43  
44 1 ▶ if ( exists $self->{direction} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"direction"}) 1 0 1
45 return 'buy'
46 1 ▶ if $self->{direction} eq '+' || $self->{direction} eq 'buy';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"direction"} eq "+" or $self->{"direction"} eq "buy" 1 0 1
Condition33%1/3
$self->{"direction"} eq "+" or $self->{"direction"} eq "buy"
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->{"direction"} eq "+" or $self->{"direction"} eq "buy"
$self->{"direction"} eq "+" $self->{"direction"} eq "buy"
Truth table33%1/3
A or B
A= $self->{"direction"} eq "+"B= $self->{"direction"} eq "buy"
ABresult
1X1
011
000
47 return 'sell'
48 0 ▶ if $self->{direction} eq '-' || $self->{direction} eq 'sell';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"direction"} eq "-" or $self->{"direction"} eq "sell" 0 0 0
Condition0%0/3
$self->{"direction"} eq "-" or $self->{"direction"} eq "sell"
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"direction"} eq "-" or $self->{"direction"} eq "sell"
$self->{"direction"} eq "-" $self->{"direction"} eq "sell"
Truth table0%0/3
A or B
A= $self->{"direction"} eq "-"B= $self->{"direction"} eq "sell"
ABresult
1X1
011
000
49 0 return;
50 }
51  
52 0 return;
53 }
54  
55 1 ▶sub epic {
Subroutine epic: called CC=2 SCAR=7.6
Pod documented
56  
57 1 my $self = shift;
58  
59 1 ▶ if ( exists $self->{epic} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"epic"}) 1 0 1
60 1 return $self->{epic};
61 }
62  
63 0 return;
64  
65 }
66  
67 1 ▶sub offer {
Subroutine offer: called CC=2 SCAR=7.6
Pod documented
68  
69 1 my $self = shift;
70  
71 1 ▶ if ( exists $self->{offer} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"offer"}) 1 0 1
72 1 return $self->{offer};
73 }
74  
75 0 return;
76 }
77  
78 1 ▶sub price {
Subroutine price: called CC=2 SCAR=7.6
Pod documented
79  
80 1 my $self = shift;
81  
82 1 ▶ if ( exists $self->{price} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"price"}) 1 0 1
83 1 return $self->{price};
84 }
85  
86 0 return;
87  
88 }
89  
90 1 ▶sub size {
Subroutine size: called CC=2 SCAR=7.1
Pod documented
91  
92 1 my $self = shift;
93  
94 1 ▶ if ( exists $self->{size} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"size"}) 1 0 1
95 1 return $self->{size};
96 }
97 }
98  
99 2 ▶sub _new {
Subroutine _new: called CC=22 SCAR=51.1
100  
101 2 my $hashref = shift;
102  
103 2 my $self = {};
104  
105 2 ▶ if ( exists $hashref->{'market'} && exists $hashref->{'workingOrder'} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $hashref->{'market'} and exists $hashref->{'workingOrder'}) { } 2 0 2
elsif (exists $hashref->{'order'} and exists $hashref->{'instrument'} and $hashref->{'marketSnapshot'}) { } 0 0 0
Condition33%1/3
exists $hashref->{"market"} and exists $hashref->{"workingOrder"}
!ll&&!rl&&r
002
MC/DC0%0/2
exists $hashref->{"market"} and exists $hashref->{"workingOrder"}
exists $hashref->{"market"} exists $hashref->{"workingOrder"}
Truth table33%1/3
A and B
A= exists $hashref->{"market"}B= exists $hashref->{"workingOrder"}
ABresult
0X0
100
111
106 2 ▶ $self->{direction} = $hashref->{'workingOrder'}->{'direction'} || undef;
Condition50%1/2
$hashref->{'workingOrder'}{'direction'} || undef
l!l
20
MC/DC0%0/1
$hashref->{'workingOrder'}{'direction'} || undef
$hashref->{'workingOrder'}{'direction'}
Truth table50%1/2
A
A= $hashref->{'workingOrder'}{'direction'}
Aresult
11
00
107 2 ▶ $self->{price} = $hashref->{'workingOrder'}->{'level'} || undef;
Condition50%1/2
$hashref->{'workingOrder'}{'level'} || undef
l!l
20
MC/DC0%0/1
$hashref->{'workingOrder'}{'level'} || undef
$hashref->{'workingOrder'}{'level'}
Truth table50%1/2
A
A= $hashref->{'workingOrder'}{'level'}
Aresult
11
00
108 2 ▶ $self->{id} = $hashref->{'workingOrder'}->{'dealId'} || undef;
Condition50%1/2
$hashref->{'workingOrder'}{'dealId'} || undef
l!l
20
MC/DC0%0/1
$hashref->{'workingOrder'}{'dealId'} || undef
$hashref->{'workingOrder'}{'dealId'}
Truth table50%1/2
A
A= $hashref->{'workingOrder'}{'dealId'}
Aresult
11
00
109 2 ▶ $self->{epic} = $hashref->{'workingOrder'}->{'epic'} || undef;
Condition50%1/2
$hashref->{'workingOrder'}{'epic'} || undef
l!l
20
MC/DC0%0/1
$hashref->{'workingOrder'}{'epic'} || undef
$hashref->{'workingOrder'}{'epic'}
Truth table50%1/2
A
A= $hashref->{'workingOrder'}{'epic'}
Aresult
11
00
110 2 ▶ $self->{contract} = $hashref->{'market'}->{'instrumentName'} || undef;
Condition50%1/2
$hashref->{'market'}{'instrumentName'} || undef
l!l
20
MC/DC0%0/1
$hashref->{'market'}{'instrumentName'} || undef
$hashref->{'market'}{'instrumentName'}
Truth table50%1/2
A
A= $hashref->{'market'}{'instrumentName'}
Aresult
11
00
111 2 ▶ $self->{bid} = $hashref->{'market'}->{'displayBid'} || 'NoBid';
Condition50%1/2
$hashref->{'market'}{'displayBid'} || 'NoBid'
l!l
20
MC/DC0%0/1
$hashref->{'market'}{'displayBid'} || 'NoBid'
$hashref->{'market'}{'displayBid'}
Truth table50%1/2
A
A= $hashref->{'market'}{'displayBid'}
Aresult
11
00
112 2 ▶ $self->{offer} = $hashref->{'market'}->{'displayOffer'} || 'NoOffer';
Condition50%1/2
$hashref->{'market'}{'displayOffer'} || 'NoOffer'
l!l
20
MC/DC0%0/1
$hashref->{'market'}{'displayOffer'} || 'NoOffer'
$hashref->{'market'}{'displayOffer'}
Truth table50%1/2
A
A= $hashref->{'market'}{'displayOffer'}
Aresult
11
00
113 2 ▶ $self->{size} = $hashref->{'workingOrder'}->{'size'} || undef;
Condition50%1/2
$hashref->{'workingOrder'}{'size'} || undef
l!l
20
MC/DC0%0/1
$hashref->{'workingOrder'}{'size'} || undef
$hashref->{'workingOrder'}{'size'}
Truth table50%1/2
A
A= $hashref->{'workingOrder'}{'size'}
Aresult
11
00
114 }
115 ▶ elsif (exists $hashref->{'order'}
Condition0%0/6
exists $hashref->{"order"} and exists $hashref->{"instrument"} and $hashref->{"marketSnapshot"}
!ll&&!rl&&r
000
exists $hashref->{"order"} and exists $hashref->{"instrument"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $hashref->{"order"} and exists $hashref->{"instrument"} and $hashref->{"marketSnapshot"}
exists $hashref->{"order"} exists $hashref->{"instrument"} $hashref->{"marketSnapshot"}
Truth table0%0/4
A and B and C
A= exists $hashref->{"order"}B= exists $hashref->{"instrument"}C= $hashref->{"marketSnapshot"}
ABCresult
0XX0
10X0
1100
1111
116 && exists $hashref->{'instrument'}
117 && $hashref->{'marketSnapshot'} )
118 {
119 0 ▶ $self->{direction} = $hashref->{'order'}->{'direction'} || undef;
Condition0%0/2
$hashref->{'order'}{'direction'} || undef
l!l
00
MC/DC0%0/1
$hashref->{'order'}{'direction'} || undef
$hashref->{'order'}{'direction'}
Truth table0%0/2
A
A= $hashref->{'order'}{'direction'}
Aresult
11
00
120 0 ▶ $self->{price} = $hashref->{'order'}->{'triggerLevel'} || undef;
Condition0%0/2
$hashref->{'order'}{'triggerLevel'} || undef
l!l
00
MC/DC0%0/1
$hashref->{'order'}{'triggerLevel'} || undef
$hashref->{'order'}{'triggerLevel'}
Truth table0%0/2
A
A= $hashref->{'order'}{'triggerLevel'}
Aresult
11
00
121 0 ▶ $self->{id} = $hashref->{'order'}->{'id'} || undef;
Condition0%0/2
$hashref->{'order'}{'id'} || undef
l!l
00
MC/DC0%0/1
$hashref->{'order'}{'id'} || undef
$hashref->{'order'}{'id'}
Truth table0%0/2
A
A= $hashref->{'order'}{'id'}
Aresult
11
00
122 0 ▶ $self->{epic} = $hashref->{'instrument'}->{'epic'} || undef;
Condition0%0/2
$hashref->{'instrument'}{'epic'} || undef
l!l
00
MC/DC0%0/1
$hashref->{'instrument'}{'epic'} || undef
$hashref->{'instrument'}{'epic'}
Truth table0%0/2
A
A= $hashref->{'instrument'}{'epic'}
Aresult
11
00
123 0 ▶ $self->{contract} = $hashref->{'instrument'}->{'marketName'} || undef;
Condition0%0/2
$hashref->{'instrument'}{'marketName'} || undef
l!l
00
MC/DC0%0/1
$hashref->{'instrument'}{'marketName'} || undef
$hashref->{'instrument'}{'marketName'}
Truth table0%0/2
A
A= $hashref->{'instrument'}{'marketName'}
Aresult
11
00
124 0 ▶ $self->{bid} = $hashref->{'marketSnapshot'}->{'displayBid'} || 'NoBid';
Condition0%0/2
$hashref->{'marketSnapshot'}{'displayBid'} || 'NoBid'
l!l
00
MC/DC0%0/1
$hashref->{'marketSnapshot'}{'displayBid'} || 'NoBid'
$hashref->{'marketSnapshot'}{'displayBid'}
Truth table0%0/2
A
A= $hashref->{'marketSnapshot'}{'displayBid'}
Aresult
11
00
125 $self->{offer} =
126 0 ▶ $hashref->{'marketSnapshot'}->{'displayOffer'} || 'NoOffer';
Condition0%0/2
$hashref->{'marketSnapshot'}{'displayOffer'} || 'NoOffer'
l!l
00
MC/DC0%0/1
$hashref->{'marketSnapshot'}{'displayOffer'} || 'NoOffer'
$hashref->{'marketSnapshot'}{'displayOffer'}
Truth table0%0/2
A
A= $hashref->{'marketSnapshot'}{'displayOffer'}
Aresult
11
00
127 0 ▶ $self->{size} = $hashref->{'order'}->{'size'} || undef;
Condition0%0/2
$hashref->{'order'}{'size'} || undef
l!l
00
MC/DC0%0/1
$hashref->{'order'}{'size'} || undef
$hashref->{'order'}{'size'}
Truth table0%0/2
A
A= $hashref->{'order'}{'size'}
Aresult
11
00
128 }
129 0 else { return }
130  
131 2 return bless $self, __PACKAGE__;
132 }
133  
134 =head1 NAME
135  
136 Finance::Nadex::Order - Provides information about an order on the North American Derivatives Exchange
137  
138 =head1 VERSION
139  
140 Version 0.01
141  
142 =cut
143  
144 14 our $VERSION = '0.01';
145  
146 =head1 SYNOPSIS
147  
148 Container for information about orders; used by L<Finance::Nadex>; not meant to be instantiated
149 directly in client code; certain methods in L<Finance::Nadex> return a Finance::Nadex::Order or a list
150 of Finance::Nadex::Order objects; given an instance or a list of instances, the accessor methods
151 below can be used to retrieve information about the order;
152 see L<Finance::Nadex> for information on how to retrieve an order
153  
154 =head1 ACCESSORS
155  
156 =head2 bid
157  
158 Retrieves the current high bid for the contract (example: "34.50")
159  
160 =head2 contract
161  
162 Retrieves the name of the contract (example: "GBP/USD >1.5120 (3PM)")
163  
164 =head2 direction
165  
166 Retrieves the direction of the order instance; either 'buy' or 'sell'
167  
168 =head2 epic
169  
170 Retrieves the unique identifier for the contract created by the exchange (example: "NB.D.OPT-GBP-USD-1-20-12Jan15")
171  
172 =head2 id
173  
174 Retrieves the order id for the order instance (example: "NZ34DE908QZASW")
175  
176 =head2 offer
177  
178 Retrieves the current low offer for the contract (example: "50.00")
179  
180 =head2 price
181  
182 Retrieves the price at which the contract is to be bought or sold (example: "30.00")
183  
184 =head2 size
185  
186 Retrieves the number of contracts to be bought or sold (example: "2")
187  
188 =head1 AUTHOR
189  
190 mhandisi, C<< <mhandisi at cpan.org> >>
191  
192 =head1 BUGS
193  
194 Please report any bugs or feature requests to C<bug-nadex-api at rt.cpan.org>, or through
195 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Nadex-API>. I will be notified, and then you'll
196 automatically be notified of progress on your bug as I make changes.
197  
198  
199  
200  
201 =head1 SUPPORT
202  
203 You can find documentation for this module with the perldoc command.
204  
205 perldoc Finance::Nadex::Order
206  
207  
208 You can also look for information at:
209  
210 =over 4
211  
212 =item * RT: CPAN's request tracker (report bugs here)
213  
214 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Nadex-API>
215  
216 =item * AnnoCPAN: Annotated CPAN documentation
217  
218 L<http://annocpan.org/dist/Nadex-API>
219  
220 =item * CPAN Ratings
221  
222 L<http://cpanratings.perl.org/d/Nadex-API>
223  
224 =item * Search CPAN
225  
226 L<http://search.cpan.org/dist/Nadex-API/>
227  
228 =back
229  
230  
231 =head1 ACKNOWLEDGEMENTS
232  
233  
234 =head1 LICENSE AND COPYRIGHT
235  
236 Copyright 2015 mhandisi.
237  
238 This program is free software; you can redistribute it and/or modify it
239 under the terms of the the Artistic License (2.0). You may obtain a
240 copy of the full license at:
241  
242 L<http://www.perlfoundation.org/artistic_license_2_0>
243  
244 Any use, modification, and distribution of the Standard or Modified
245 Versions is governed by this Artistic License. By using, modifying or
246 distributing the Package, you accept this license. Do not use, modify,
247 or distribute the Package, if you do not accept this license.
248  
249 If your Modified Version has been derived from a Modified Version made
250 by someone other than you, you are nevertheless required to ensure that
251 your Modified Version complies with the requirements of this license.
252  
253 This license does not grant you the right to use any trademark, service
254 mark, tradename, or logo of the Copyright Holder.
255  
256 This license includes the non-exclusive, worldwide, free-of-charge
257 patent license to make, have made, use, offer to sell, sell, import and
258 otherwise transfer the Package with respect to any patent claims
259 licensable by the Copyright Holder that are necessarily infringed by the
260 Package. If you institute patent litigation (including a cross-claim or
261 counterclaim) against any party alleging that the Package constitutes
262 direct or contributory patent infringement, then this Artistic License
263 to you shall terminate on the date that such litigation is filed.
264  
265 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
266 AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
267 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
268 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
269 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
270 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
271 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
272 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
273  
274  
275 =cut
276  
277 14 42; # End of Finance::Nadex::Order
« Nadex/Position.pm ↑ Summary Nadex.pm »