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