|
1
|
|
|
# ================================================================================== # |
|
2
|
|
|
# options.py - This file is part of the yfrake package. # |
|
3
|
|
|
# ================================================================================== # |
|
4
|
|
|
# # |
|
5
|
|
|
# MIT License # |
|
6
|
|
|
# # |
|
7
|
|
|
# Copyright (c) 2022 Mattias Aabmets # |
|
8
|
|
|
# # |
|
9
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy # |
|
10
|
|
|
# of this software and associated documentation files (the "Software"), to deal # |
|
11
|
|
|
# in the Software without restriction, including without limitation the rights # |
|
12
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # |
|
13
|
|
|
# copies of the Software, and to permit persons to whom the Software is # |
|
14
|
|
|
# furnished to do so, subject to the following conditions: # |
|
15
|
|
|
# # |
|
16
|
|
|
# The above copyright notice and this permission notice shall be included in all # |
|
17
|
|
|
# copies or substantial portions of the Software. # |
|
18
|
|
|
# # |
|
19
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # |
|
20
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # |
|
21
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # |
|
22
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # |
|
23
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # |
|
24
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # |
|
25
|
|
|
# SOFTWARE. # |
|
26
|
|
|
# # |
|
27
|
|
|
# ================================================================================== # |
|
28
|
|
|
summary = 'Options' |
|
29
|
|
|
description = 'Returns options data of a security identifier.' |
|
30
|
|
|
|
|
31
|
|
|
# ---------------------------------------------------------------------------------- # |
|
32
|
|
|
parameters = [ |
|
33
|
|
|
{ |
|
34
|
|
|
'name': 'symbol', |
|
35
|
|
|
'description': 'Any valid equity security identifier.', |
|
36
|
|
|
'required': True, |
|
37
|
|
|
'in': 'query', |
|
38
|
|
|
'schema': { |
|
39
|
|
|
'type': str |
|
40
|
|
|
} |
|
41
|
|
|
}, { |
|
42
|
|
|
'name': 'startDate', |
|
43
|
|
|
'description': 'Start date encoded as an UNIX epoch timestamp.', |
|
44
|
|
|
'required': False, |
|
45
|
|
|
'in': 'query', |
|
46
|
|
|
'schema': { |
|
47
|
|
|
'type': int |
|
48
|
|
|
} |
|
49
|
|
|
}, { |
|
50
|
|
|
'name': 'endDate', |
|
51
|
|
|
'description': 'End date encoded as an UNIX epoch timestamp.', |
|
52
|
|
|
'required': False, |
|
53
|
|
|
'in': 'query', |
|
54
|
|
|
'schema': { |
|
55
|
|
|
'type': int |
|
56
|
|
|
} |
|
57
|
|
|
}, { |
|
58
|
|
|
'name': 'strikeMin', |
|
59
|
|
|
'description': 'Minimum strike price of options.', |
|
60
|
|
|
'required': False, |
|
61
|
|
|
'in': 'query', |
|
62
|
|
|
'schema': { |
|
63
|
|
|
'type': int |
|
64
|
|
|
} |
|
65
|
|
|
}, { |
|
66
|
|
|
'name': 'strikeMax', |
|
67
|
|
|
'description': 'Maximum strike price of options.', |
|
68
|
|
|
'required': False, |
|
69
|
|
|
'in': 'query', |
|
70
|
|
|
'schema': { |
|
71
|
|
|
'type': int |
|
72
|
|
|
} |
|
73
|
|
|
}, { |
|
74
|
|
|
'name': 'straddle', |
|
75
|
|
|
'description': 'Return transactions in straddles.', |
|
76
|
|
|
'required': False, |
|
77
|
|
|
'in': 'query', |
|
78
|
|
|
'schema': { |
|
79
|
|
|
'type': bool |
|
80
|
|
|
} |
|
81
|
|
|
}, { |
|
82
|
|
|
'name': 'getAllData', |
|
83
|
|
|
'description': 'Return all options data.', |
|
84
|
|
|
'required': False, |
|
85
|
|
|
'in': 'query', |
|
86
|
|
|
'schema': { |
|
87
|
|
|
'type': bool |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
] |
|
91
|
|
|
|
|
92
|
|
|
# ---------------------------------------------------------------------------------- # |
|
93
|
|
|
response = { |
|
94
|
|
|
'underlyingSymbol': str, |
|
95
|
|
|
'expirationDates': list, |
|
96
|
|
|
'strikes': list, |
|
97
|
|
|
'hasMiniOptions': bool, |
|
98
|
|
|
'quote': { |
|
99
|
|
|
'language': str, |
|
100
|
|
|
'region': str, |
|
101
|
|
|
'quoteType': str, |
|
102
|
|
|
'quoteSourceName': str, |
|
103
|
|
|
'triggerable': bool, |
|
104
|
|
|
'currency': str, |
|
105
|
|
|
'preMarketChange': float, |
|
106
|
|
|
'preMarketChangePercent': float, |
|
107
|
|
|
'preMarketTime': int, |
|
108
|
|
|
'preMarketPrice': float, |
|
109
|
|
|
'regularMarketChange': float, |
|
110
|
|
|
'regularMarketChangePercent': float, |
|
111
|
|
|
'regularMarketTime': int, |
|
112
|
|
|
'regularMarketPrice': float, |
|
113
|
|
|
'regularMarketDayHigh': float, |
|
114
|
|
|
'regularMarketDayRange': str, |
|
115
|
|
|
'regularMarketDayLow': float, |
|
116
|
|
|
'regularMarketVolume': int, |
|
117
|
|
|
'regularMarketPreviousClose': float, |
|
118
|
|
|
'bid': float, |
|
119
|
|
|
'ask': float, |
|
120
|
|
|
'bidSize': int, |
|
121
|
|
|
'askSize': int, |
|
122
|
|
|
'fullExchangeName': str, |
|
123
|
|
|
'financialCurrency': str, |
|
124
|
|
|
'regularMarketOpen': float, |
|
125
|
|
|
'averageDailyVolume3Month': int, |
|
126
|
|
|
'averageDailyVolume10Day': int, |
|
127
|
|
|
'fiftyTwoWeekLowChange': float, |
|
128
|
|
|
'fiftyTwoWeekLowChangePercent': float, |
|
129
|
|
|
'fiftyTwoWeekRange': str, |
|
130
|
|
|
'fiftyTwoWeekHighChange': float, |
|
131
|
|
|
'fiftyTwoWeekHighChangePercent': float, |
|
132
|
|
|
'fiftyTwoWeekLow': float, |
|
133
|
|
|
'fiftyTwoWeekHigh': float, |
|
134
|
|
|
'dividendDate': int, |
|
135
|
|
|
'exchange': str, |
|
136
|
|
|
'shortName': str, |
|
137
|
|
|
'longName': str, |
|
138
|
|
|
'messageBoardId': str, |
|
139
|
|
|
'exchangeTimezoneName': str, |
|
140
|
|
|
'exchangeTimezoneShortName': str, |
|
141
|
|
|
'gmtOffSetMilliseconds': int, |
|
142
|
|
|
'market': str, |
|
143
|
|
|
'esgPopulated': bool, |
|
144
|
|
|
'firstTradeDateMilliseconds': int, |
|
145
|
|
|
'priceHint': int, |
|
146
|
|
|
'earningsTimestamp': int, |
|
147
|
|
|
'earningsTimestampStart': int, |
|
148
|
|
|
'earningsTimestampEnd': int, |
|
149
|
|
|
'trailingAnnualDividendRate': float, |
|
150
|
|
|
'trailingPE': float, |
|
151
|
|
|
'trailingAnnualDividendYield': float, |
|
152
|
|
|
'epsTrailingTwelveMonths': float, |
|
153
|
|
|
'epsForward': float, |
|
154
|
|
|
'epsCurrentYear': float, |
|
155
|
|
|
'priceEpsCurrentYear': float, |
|
156
|
|
|
'sharesOutstanding': int, |
|
157
|
|
|
'bookValue': float, |
|
158
|
|
|
'fiftyDayAverage': float, |
|
159
|
|
|
'fiftyDayAverageChange': float, |
|
160
|
|
|
'fiftyDayAverageChangePercent': float, |
|
161
|
|
|
'twoHundredDayAverage': float, |
|
162
|
|
|
'twoHundredDayAverageChange': float, |
|
163
|
|
|
'twoHundredDayAverageChangePercent': float, |
|
164
|
|
|
'marketCap': int, |
|
165
|
|
|
'forwardPE': float, |
|
166
|
|
|
'priceToBook': float, |
|
167
|
|
|
'sourceInterval': int, |
|
168
|
|
|
'exchangeDataDelayedBy': int, |
|
169
|
|
|
'pageViewGrowthWeekly': float, |
|
170
|
|
|
'averageAnalystRating': str, |
|
171
|
|
|
'tradeable': bool, |
|
172
|
|
|
'marketState': str, |
|
173
|
|
|
'displayName': str, |
|
174
|
|
|
'symbol': str |
|
175
|
|
|
}, |
|
176
|
|
|
'options': [ |
|
177
|
|
|
{ |
|
178
|
|
|
'expirationDate': int, |
|
179
|
|
|
'hasMiniOptions': bool, |
|
180
|
|
|
'straddles': list, |
|
181
|
|
|
'calls': [ |
|
182
|
|
|
{ |
|
183
|
|
|
'contractSymbol': str, |
|
184
|
|
|
'strike': float, |
|
185
|
|
|
'currency': str, |
|
186
|
|
|
'lastPrice': float, |
|
187
|
|
|
'change': float, |
|
188
|
|
|
'percentChange': float, |
|
189
|
|
|
'volume': int, |
|
190
|
|
|
'openInterest': int, |
|
191
|
|
|
'bid': float, |
|
192
|
|
|
'ask': float, |
|
193
|
|
|
'contractSize': str, |
|
194
|
|
|
'expiration': int, |
|
195
|
|
|
'lastTradeDate': int, |
|
196
|
|
|
'impliedVolatility': float, |
|
197
|
|
|
'inTheMoney': bool |
|
198
|
|
|
} |
|
199
|
|
|
], |
|
200
|
|
|
'puts': [ |
|
201
|
|
|
{ |
|
202
|
|
|
'contractSymbol': str, |
|
203
|
|
|
'strike': float, |
|
204
|
|
|
'currency': str, |
|
205
|
|
|
'lastPrice': float, |
|
206
|
|
|
'change': float, |
|
207
|
|
|
'percentChange': float, |
|
208
|
|
|
'volume': int, |
|
209
|
|
|
'openInterest': int, |
|
210
|
|
|
'bid': float, |
|
211
|
|
|
'ask': float, |
|
212
|
|
|
'contractSize': str, |
|
213
|
|
|
'expiration': int, |
|
214
|
|
|
'lastTradeDate': int, |
|
215
|
|
|
'impliedVolatility': float, |
|
216
|
|
|
'inTheMoney': bool |
|
217
|
|
|
} |
|
218
|
|
|
] |
|
219
|
|
|
} |
|
220
|
|
|
] |
|
221
|
|
|
} |
|
222
|
|
|
|