-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathoptions_api.py
More file actions
3756 lines (3230 loc) · 184 KB
/
options_api.py
File metadata and controls
3756 lines (3230 loc) · 184 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# coding: utf-8
"""
Intrinio API
Welcome to the Intrinio API! Through our Financial Data Marketplace, we offer a wide selection of financial data feed APIs sourced by our own proprietary processes as well as from many data vendors. For a complete API request / response reference please view the [Intrinio API documentation](https://docs.intrinio.com/documentation/api_v2). If you need additional help in using the API, please visit the [Intrinio website](https://intrinio.com) and click on the chat icon in the lower right corner. # noqa: E501
OpenAPI spec version: 2.123.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import re # noqa: F401
# python 2 and python 3 compatibility library
import six
from intrinio_sdk.api_client import ApiClient
class OptionsApi(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
"""
def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client
def get_all_options_tickers(self, **kwargs): # noqa: E501
"""Options Tickers # noqa: E501
Returns all tickers that have existing options contracts. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_all_options_tickers(_async=True)
>>> result = thread.get()
:param async bool
:param bool use_underlying_symbols: Use underlying symbol vs contract symbol
:return: ApiResponseOptionsTickers
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
return self.get_all_options_tickers_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_all_options_tickers_with_http_info(**kwargs) # noqa: E501
return data
def get_all_options_tickers_with_http_info(self, **kwargs): # noqa: E501
"""Options Tickers # noqa: E501
Returns all tickers that have existing options contracts. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_all_options_tickers_with_http_info(_async=True)
>>> result = thread.get()
:param async bool
:param bool use_underlying_symbols: Use underlying symbol vs contract symbol
:return: ApiResponseOptionsTickers
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['use_underlying_symbols'] # noqa: E501
all_params.append('async')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method get_all_options_tickers" % key
)
params[key] = val
del params['kwargs']
collection_formats = {}
path_params = {}
query_params = []
if 'use_underlying_symbols' in params:
query_params.append(('use_underlying_symbols', params['use_underlying_symbols'])) # noqa: E501
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# Authentication setting
auth_settings = ['ApiKeyAuth'] # noqa: E501
return self.api_client.call_api(
'/options/tickers', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='ApiResponseOptionsTickers', # noqa: E501
auth_settings=auth_settings,
_async=params.get('async'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def get_option_aggregates(self, **kwargs): # noqa: E501
"""Total open interest and volume aggregated by ticker # noqa: E501
Returns total open interest and volume by ticker # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_option_aggregates(_async=True)
>>> result = thread.get()
:param async bool
:param object date: Return aggregated data for this date
:param int page_size: The number of results to return
:param str next_page: Gets the next page of data from a previous API call
:return: ApiResponseOptionsAggregates
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
return self.get_option_aggregates_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_option_aggregates_with_http_info(**kwargs) # noqa: E501
return data
def get_option_aggregates_with_http_info(self, **kwargs): # noqa: E501
"""Total open interest and volume aggregated by ticker # noqa: E501
Returns total open interest and volume by ticker # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_option_aggregates_with_http_info(_async=True)
>>> result = thread.get()
:param async bool
:param object date: Return aggregated data for this date
:param int page_size: The number of results to return
:param str next_page: Gets the next page of data from a previous API call
:return: ApiResponseOptionsAggregates
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['date', 'page_size', 'next_page'] # noqa: E501
all_params.append('async')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method get_option_aggregates" % key
)
params[key] = val
del params['kwargs']
collection_formats = {}
path_params = {}
query_params = []
if 'date' in params:
query_params.append(('date', params['date'])) # noqa: E501
if 'page_size' in params:
query_params.append(('page_size', params['page_size'])) # noqa: E501
if 'next_page' in params:
query_params.append(('next_page', params['next_page'])) # noqa: E501
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# Authentication setting
auth_settings = ['ApiKeyAuth'] # noqa: E501
return self.api_client.call_api(
'/options/aggregates', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='ApiResponseOptionsAggregates', # noqa: E501
auth_settings=auth_settings,
_async=params.get('async'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def get_option_expirations_realtime(self, symbol, **kwargs): # noqa: E501
"""Options Expirations # noqa: E501
Returns a list of all current and upcoming option contract expiration dates for a particular symbol. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_option_expirations_realtime(symbol, _async=True)
>>> result = thread.get()
:param async bool
:param str symbol: The option symbol, corresponding to the underlying security. (required)
:param str after: Return option contract expiration dates after this date.
:param str before: Return option contract expiration dates before this date.
:param str source: Realtime or 15-minute delayed contracts.
:param bool include_related_symbols: Include related symbols that end in a 1 or 2 because of a corporate action.
:return: ApiResponseOptionsExpirations
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
return self.get_option_expirations_realtime_with_http_info(symbol, **kwargs) # noqa: E501
else:
(data) = self.get_option_expirations_realtime_with_http_info(symbol, **kwargs) # noqa: E501
return data
def get_option_expirations_realtime_with_http_info(self, symbol, **kwargs): # noqa: E501
"""Options Expirations # noqa: E501
Returns a list of all current and upcoming option contract expiration dates for a particular symbol. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_option_expirations_realtime_with_http_info(symbol, _async=True)
>>> result = thread.get()
:param async bool
:param str symbol: The option symbol, corresponding to the underlying security. (required)
:param str after: Return option contract expiration dates after this date.
:param str before: Return option contract expiration dates before this date.
:param str source: Realtime or 15-minute delayed contracts.
:param bool include_related_symbols: Include related symbols that end in a 1 or 2 because of a corporate action.
:return: ApiResponseOptionsExpirations
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['symbol', 'after', 'before', 'source', 'include_related_symbols'] # noqa: E501
all_params.append('async')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method get_option_expirations_realtime" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'symbol' is set
if ('symbol' not in params or
params['symbol'] is None):
raise ValueError("Missing the required parameter `symbol` when calling `get_option_expirations_realtime`") # noqa: E501
collection_formats = {}
path_params = {}
if 'symbol' in params:
path_params['symbol'] = params['symbol'] # noqa: E501
query_params = []
if 'after' in params:
query_params.append(('after', params['after'])) # noqa: E501
if 'before' in params:
query_params.append(('before', params['before'])) # noqa: E501
if 'source' in params:
query_params.append(('source', params['source'])) # noqa: E501
if 'include_related_symbols' in params:
query_params.append(('include_related_symbols', params['include_related_symbols'])) # noqa: E501
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# Authentication setting
auth_settings = ['ApiKeyAuth'] # noqa: E501
return self.api_client.call_api(
'/options/expirations/{symbol}/realtime', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='ApiResponseOptionsExpirations', # noqa: E501
auth_settings=auth_settings,
_async=params.get('async'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def get_option_strikes_realtime(self, symbol, strike, **kwargs): # noqa: E501
"""Option Strikes Realtime # noqa: E501
Returns a list of the latest top of the order book size and premium (bid / ask), the latest trade size and premium as well as the greeks and implied volatility for all call/put contracts that match the strike and symbol specified. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_option_strikes_realtime(symbol, strike, _async=True)
>>> result = thread.get()
:param async bool
:param str symbol: The option symbol, corresponding to the underlying security. (required)
:param float strike: The strike price of the option contract. This will return options contracts with strike price equal to this price. (required)
:param str source: Realtime or delayed.
:param str stock_price_source: Source for underlying price for calculating Greeks.
:param str model: Model for calculating Greek values. Default is black_scholes.
:param bool show_extended_price: Whether to include open close high low type fields.
:param bool include_related_symbols: Include related symbols that end in a 1 or 2 because of a corporate action.
:return: ApiResponseOptionsChainRealtime
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
return self.get_option_strikes_realtime_with_http_info(symbol, strike, **kwargs) # noqa: E501
else:
(data) = self.get_option_strikes_realtime_with_http_info(symbol, strike, **kwargs) # noqa: E501
return data
def get_option_strikes_realtime_with_http_info(self, symbol, strike, **kwargs): # noqa: E501
"""Option Strikes Realtime # noqa: E501
Returns a list of the latest top of the order book size and premium (bid / ask), the latest trade size and premium as well as the greeks and implied volatility for all call/put contracts that match the strike and symbol specified. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_option_strikes_realtime_with_http_info(symbol, strike, _async=True)
>>> result = thread.get()
:param async bool
:param str symbol: The option symbol, corresponding to the underlying security. (required)
:param float strike: The strike price of the option contract. This will return options contracts with strike price equal to this price. (required)
:param str source: Realtime or delayed.
:param str stock_price_source: Source for underlying price for calculating Greeks.
:param str model: Model for calculating Greek values. Default is black_scholes.
:param bool show_extended_price: Whether to include open close high low type fields.
:param bool include_related_symbols: Include related symbols that end in a 1 or 2 because of a corporate action.
:return: ApiResponseOptionsChainRealtime
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['symbol', 'strike', 'source', 'stock_price_source', 'model', 'show_extended_price', 'include_related_symbols'] # noqa: E501
all_params.append('async')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method get_option_strikes_realtime" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'symbol' is set
if ('symbol' not in params or
params['symbol'] is None):
raise ValueError("Missing the required parameter `symbol` when calling `get_option_strikes_realtime`") # noqa: E501
# verify the required parameter 'strike' is set
if ('strike' not in params or
params['strike'] is None):
raise ValueError("Missing the required parameter `strike` when calling `get_option_strikes_realtime`") # noqa: E501
collection_formats = {}
path_params = {}
if 'symbol' in params:
path_params['symbol'] = params['symbol'] # noqa: E501
if 'strike' in params:
path_params['strike'] = params['strike'] # noqa: E501
query_params = []
if 'source' in params:
query_params.append(('source', params['source'])) # noqa: E501
if 'stock_price_source' in params:
query_params.append(('stock_price_source', params['stock_price_source'])) # noqa: E501
if 'model' in params:
query_params.append(('model', params['model'])) # noqa: E501
if 'show_extended_price' in params:
query_params.append(('show_extended_price', params['show_extended_price'])) # noqa: E501
if 'include_related_symbols' in params:
query_params.append(('include_related_symbols', params['include_related_symbols'])) # noqa: E501
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# Authentication setting
auth_settings = ['ApiKeyAuth'] # noqa: E501
return self.api_client.call_api(
'/options/strikes/{symbol}/{strike}/realtime', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='ApiResponseOptionsChainRealtime', # noqa: E501
auth_settings=auth_settings,
_async=params.get('async'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def get_option_trades(self, **kwargs): # noqa: E501
"""Option Trades # noqa: E501
Returns all trades between start time and end time, up to seven days ago for the specified source. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_option_trades(_async=True)
>>> result = thread.get()
:param async bool
:param str source: The specific source of the data being requested.
:param date start_date: The start date for the data being requested.
:param str start_time: The start time for the data being requested.
:param date end_date: The end date for the data being requested.
:param str end_time: The end time for the data being requested.
:param str timezone: The timezone the start and end date/times use.
:param int page_size: The maximum number of results to return per page.
:param int min_size: Trades must be larger or equal to this size.
:param str security: The ticker symbol for which trades are being requested.
:param str next_page: Gets the next page of data from a previous API call
:return: OptionTradesResult
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
return self.get_option_trades_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_option_trades_with_http_info(**kwargs) # noqa: E501
return data
def get_option_trades_with_http_info(self, **kwargs): # noqa: E501
"""Option Trades # noqa: E501
Returns all trades between start time and end time, up to seven days ago for the specified source. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_option_trades_with_http_info(_async=True)
>>> result = thread.get()
:param async bool
:param str source: The specific source of the data being requested.
:param date start_date: The start date for the data being requested.
:param str start_time: The start time for the data being requested.
:param date end_date: The end date for the data being requested.
:param str end_time: The end time for the data being requested.
:param str timezone: The timezone the start and end date/times use.
:param int page_size: The maximum number of results to return per page.
:param int min_size: Trades must be larger or equal to this size.
:param str security: The ticker symbol for which trades are being requested.
:param str next_page: Gets the next page of data from a previous API call
:return: OptionTradesResult
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['source', 'start_date', 'start_time', 'end_date', 'end_time', 'timezone', 'page_size', 'min_size', 'security', 'next_page'] # noqa: E501
all_params.append('async')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method get_option_trades" % key
)
params[key] = val
del params['kwargs']
if 'page_size' in params and params['page_size'] > 10000: # noqa: E501
raise ValueError("Invalid value for parameter `page_size` when calling `get_option_trades`, must be a value less than or equal to `10000`") # noqa: E501
collection_formats = {}
path_params = {}
query_params = []
if 'source' in params:
query_params.append(('source', params['source'])) # noqa: E501
if 'start_date' in params:
query_params.append(('start_date', params['start_date'])) # noqa: E501
if 'start_time' in params:
query_params.append(('start_time', params['start_time'])) # noqa: E501
if 'end_date' in params:
query_params.append(('end_date', params['end_date'])) # noqa: E501
if 'end_time' in params:
query_params.append(('end_time', params['end_time'])) # noqa: E501
if 'timezone' in params:
query_params.append(('timezone', params['timezone'])) # noqa: E501
if 'page_size' in params:
query_params.append(('page_size', params['page_size'])) # noqa: E501
if 'min_size' in params:
query_params.append(('min_size', params['min_size'])) # noqa: E501
if 'security' in params:
query_params.append(('security', params['security'])) # noqa: E501
if 'next_page' in params:
query_params.append(('next_page', params['next_page'])) # noqa: E501
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# Authentication setting
auth_settings = ['ApiKeyAuth'] # noqa: E501
return self.api_client.call_api(
'/options/trades', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='OptionTradesResult', # noqa: E501
auth_settings=auth_settings,
_async=params.get('async'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def get_option_trades_by_contract(self, identifier, **kwargs): # noqa: E501
"""Option Trades By Contract # noqa: E501
Returns all trades for a contract between start time and end time, up to seven days ago for the specified source. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_option_trades_by_contract(identifier, _async=True)
>>> result = thread.get()
:param async bool
:param str identifier: The option contract for which trades are being requested. (required)
:param str source: The specific source of the data being requested.
:param date start_date: The start date for the data being requested.
:param str start_time: The start time for the data being requested.
:param date end_date: The end date for the data being requested.
:param str end_time: The end time for the data being requested.
:param str timezone: The timezone the start and end date/times use.
:param int page_size: The maximum number of results to return per page.
:param int min_size: Trades must be larger or equal to this size.
:param str next_page: Gets the next page of data from a previous API call
:return: OptionTradesResult
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
return self.get_option_trades_by_contract_with_http_info(identifier, **kwargs) # noqa: E501
else:
(data) = self.get_option_trades_by_contract_with_http_info(identifier, **kwargs) # noqa: E501
return data
def get_option_trades_by_contract_with_http_info(self, identifier, **kwargs): # noqa: E501
"""Option Trades By Contract # noqa: E501
Returns all trades for a contract between start time and end time, up to seven days ago for the specified source. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_option_trades_by_contract_with_http_info(identifier, _async=True)
>>> result = thread.get()
:param async bool
:param str identifier: The option contract for which trades are being requested. (required)
:param str source: The specific source of the data being requested.
:param date start_date: The start date for the data being requested.
:param str start_time: The start time for the data being requested.
:param date end_date: The end date for the data being requested.
:param str end_time: The end time for the data being requested.
:param str timezone: The timezone the start and end date/times use.
:param int page_size: The maximum number of results to return per page.
:param int min_size: Trades must be larger or equal to this size.
:param str next_page: Gets the next page of data from a previous API call
:return: OptionTradesResult
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['identifier', 'source', 'start_date', 'start_time', 'end_date', 'end_time', 'timezone', 'page_size', 'min_size', 'next_page'] # noqa: E501
all_params.append('async')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method get_option_trades_by_contract" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'identifier' is set
if ('identifier' not in params or
params['identifier'] is None):
raise ValueError("Missing the required parameter `identifier` when calling `get_option_trades_by_contract`") # noqa: E501
if 'page_size' in params and params['page_size'] > 10000: # noqa: E501
raise ValueError("Invalid value for parameter `page_size` when calling `get_option_trades_by_contract`, must be a value less than or equal to `10000`") # noqa: E501
collection_formats = {}
path_params = {}
if 'identifier' in params:
path_params['identifier'] = params['identifier'] # noqa: E501
query_params = []
if 'source' in params:
query_params.append(('source', params['source'])) # noqa: E501
if 'start_date' in params:
query_params.append(('start_date', params['start_date'])) # noqa: E501
if 'start_time' in params:
query_params.append(('start_time', params['start_time'])) # noqa: E501
if 'end_date' in params:
query_params.append(('end_date', params['end_date'])) # noqa: E501
if 'end_time' in params:
query_params.append(('end_time', params['end_time'])) # noqa: E501
if 'timezone' in params:
query_params.append(('timezone', params['timezone'])) # noqa: E501
if 'page_size' in params:
query_params.append(('page_size', params['page_size'])) # noqa: E501
if 'min_size' in params:
query_params.append(('min_size', params['min_size'])) # noqa: E501
if 'next_page' in params:
query_params.append(('next_page', params['next_page'])) # noqa: E501
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# Authentication setting
auth_settings = ['ApiKeyAuth'] # noqa: E501
return self.api_client.call_api(
'/options/{identifier}/trades', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='OptionTradesResult', # noqa: E501
auth_settings=auth_settings,
_async=params.get('async'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def get_options(self, symbol, **kwargs): # noqa: E501
"""Options # noqa: E501
Returns a list of all securities that have options listed and are tradable on a US market exchange. Useful to retrieve the entire universe. Available via a 3rd party, contact sales for a trial. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_options(symbol, _async=True)
>>> result = thread.get()
:param async bool
:param str symbol: The option symbol, corresponding to the underlying security. (required)
:param str type: The option contract type.
:param float strike: The strike price of the option contract. This will return options contracts with strike price equal to this price.
:param float strike_greater_than: The strike price of the option contract. This will return options contracts with strike prices greater than this price.
:param float strike_less_than: The strike price of the option contract. This will return options contracts with strike prices less than this price.
:param str expiration: The expiration date of the option contract. This will return options contracts with expiration dates on this date.
:param str expiration_after: The expiration date of the option contract. This will return options contracts with expiration dates after this date.
:param str expiration_before: The expiration date of the option contract. This will return options contracts with expiration dates before this date.
:param int page_size: The number of results to return
:param str next_page: Gets the next page of data from a previous API call
:return: ApiResponseOptions
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
return self.get_options_with_http_info(symbol, **kwargs) # noqa: E501
else:
(data) = self.get_options_with_http_info(symbol, **kwargs) # noqa: E501
return data
def get_options_with_http_info(self, symbol, **kwargs): # noqa: E501
"""Options # noqa: E501
Returns a list of all securities that have options listed and are tradable on a US market exchange. Useful to retrieve the entire universe. Available via a 3rd party, contact sales for a trial. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_options_with_http_info(symbol, _async=True)
>>> result = thread.get()
:param async bool
:param str symbol: The option symbol, corresponding to the underlying security. (required)
:param str type: The option contract type.
:param float strike: The strike price of the option contract. This will return options contracts with strike price equal to this price.
:param float strike_greater_than: The strike price of the option contract. This will return options contracts with strike prices greater than this price.
:param float strike_less_than: The strike price of the option contract. This will return options contracts with strike prices less than this price.
:param str expiration: The expiration date of the option contract. This will return options contracts with expiration dates on this date.
:param str expiration_after: The expiration date of the option contract. This will return options contracts with expiration dates after this date.
:param str expiration_before: The expiration date of the option contract. This will return options contracts with expiration dates before this date.
:param int page_size: The number of results to return
:param str next_page: Gets the next page of data from a previous API call
:return: ApiResponseOptions
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['symbol', 'type', 'strike', 'strike_greater_than', 'strike_less_than', 'expiration', 'expiration_after', 'expiration_before', 'page_size', 'next_page'] # noqa: E501
all_params.append('async')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method get_options" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'symbol' is set
if ('symbol' not in params or
params['symbol'] is None):
raise ValueError("Missing the required parameter `symbol` when calling `get_options`") # noqa: E501
if 'page_size' in params and params['page_size'] > 10000: # noqa: E501
raise ValueError("Invalid value for parameter `page_size` when calling `get_options`, must be a value less than or equal to `10000`") # noqa: E501
collection_formats = {}
path_params = {}
if 'symbol' in params:
path_params['symbol'] = params['symbol'] # noqa: E501
query_params = []
if 'type' in params:
query_params.append(('type', params['type'])) # noqa: E501
if 'strike' in params:
query_params.append(('strike', params['strike'])) # noqa: E501
if 'strike_greater_than' in params:
query_params.append(('strike_greater_than', params['strike_greater_than'])) # noqa: E501
if 'strike_less_than' in params:
query_params.append(('strike_less_than', params['strike_less_than'])) # noqa: E501
if 'expiration' in params:
query_params.append(('expiration', params['expiration'])) # noqa: E501
if 'expiration_after' in params:
query_params.append(('expiration_after', params['expiration_after'])) # noqa: E501
if 'expiration_before' in params:
query_params.append(('expiration_before', params['expiration_before'])) # noqa: E501
if 'page_size' in params:
query_params.append(('page_size', params['page_size'])) # noqa: E501
if 'next_page' in params:
query_params.append(('next_page', params['next_page'])) # noqa: E501
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# Authentication setting
auth_settings = ['ApiKeyAuth'] # noqa: E501
return self.api_client.call_api(
'/options/{symbol}', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='ApiResponseOptions', # noqa: E501
auth_settings=auth_settings,
_async=params.get('async'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def get_options_by_symbol_realtime(self, symbol, **kwargs): # noqa: E501
"""Options by Symbol Realtime # noqa: E501
Returns a list of all securities that have options listed and are tradable on a US market exchange. Useful to retrieve the entire universe. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_options_by_symbol_realtime(symbol, _async=True)
>>> result = thread.get()
:param async bool
:param str symbol: The option symbol, corresponding to the underlying security. (required)
:param str type: The option contract type.
:param float strike: The strike price of the option contract. This will return options contracts with strike price equal to this price.
:param float strike_greater_than: The strike price of the option contract. This will return options contracts with strike prices greater than this price.
:param float strike_less_than: The strike price of the option contract. This will return options contracts with strike prices less than this price.
:param str expiration: The expiration date of the option contract. This will return options contracts with expiration dates on this date.
:param str expiration_after: The expiration date of the option contract. This will return options contracts with expiration dates after this date.
:param str expiration_before: The expiration date of the option contract. This will return options contracts with expiration dates before this date.
:param str source: Realtime or 15-minute delayed contracts.
:param bool include_related_symbols: Include related symbols that end in a 1 or 2 because of a corporate action.
:return: ApiResponseOptionsRealtime
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
return self.get_options_by_symbol_realtime_with_http_info(symbol, **kwargs) # noqa: E501
else:
(data) = self.get_options_by_symbol_realtime_with_http_info(symbol, **kwargs) # noqa: E501
return data
def get_options_by_symbol_realtime_with_http_info(self, symbol, **kwargs): # noqa: E501
"""Options by Symbol Realtime # noqa: E501
Returns a list of all securities that have options listed and are tradable on a US market exchange. Useful to retrieve the entire universe. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_options_by_symbol_realtime_with_http_info(symbol, _async=True)
>>> result = thread.get()
:param async bool
:param str symbol: The option symbol, corresponding to the underlying security. (required)
:param str type: The option contract type.
:param float strike: The strike price of the option contract. This will return options contracts with strike price equal to this price.
:param float strike_greater_than: The strike price of the option contract. This will return options contracts with strike prices greater than this price.
:param float strike_less_than: The strike price of the option contract. This will return options contracts with strike prices less than this price.
:param str expiration: The expiration date of the option contract. This will return options contracts with expiration dates on this date.
:param str expiration_after: The expiration date of the option contract. This will return options contracts with expiration dates after this date.
:param str expiration_before: The expiration date of the option contract. This will return options contracts with expiration dates before this date.
:param str source: Realtime or 15-minute delayed contracts.
:param bool include_related_symbols: Include related symbols that end in a 1 or 2 because of a corporate action.
:return: ApiResponseOptionsRealtime
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['symbol', 'type', 'strike', 'strike_greater_than', 'strike_less_than', 'expiration', 'expiration_after', 'expiration_before', 'source', 'include_related_symbols'] # noqa: E501
all_params.append('async')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method get_options_by_symbol_realtime" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'symbol' is set
if ('symbol' not in params or
params['symbol'] is None):
raise ValueError("Missing the required parameter `symbol` when calling `get_options_by_symbol_realtime`") # noqa: E501
collection_formats = {}
path_params = {}
if 'symbol' in params:
path_params['symbol'] = params['symbol'] # noqa: E501
query_params = []
if 'type' in params:
query_params.append(('type', params['type'])) # noqa: E501
if 'strike' in params:
query_params.append(('strike', params['strike'])) # noqa: E501
if 'strike_greater_than' in params:
query_params.append(('strike_greater_than', params['strike_greater_than'])) # noqa: E501
if 'strike_less_than' in params:
query_params.append(('strike_less_than', params['strike_less_than'])) # noqa: E501
if 'expiration' in params:
query_params.append(('expiration', params['expiration'])) # noqa: E501
if 'expiration_after' in params:
query_params.append(('expiration_after', params['expiration_after'])) # noqa: E501
if 'expiration_before' in params:
query_params.append(('expiration_before', params['expiration_before'])) # noqa: E501
if 'source' in params:
query_params.append(('source', params['source'])) # noqa: E501
if 'include_related_symbols' in params:
query_params.append(('include_related_symbols', params['include_related_symbols'])) # noqa: E501
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# Authentication setting
auth_settings = ['ApiKeyAuth'] # noqa: E501
return self.api_client.call_api(
'/options/{symbol}/realtime', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='ApiResponseOptionsRealtime', # noqa: E501
auth_settings=auth_settings,
_async=params.get('async'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def get_options_chain(self, symbol, expiration, **kwargs): # noqa: E501
"""Options Chain # noqa: E501
Returns a list of the historical end-of-day top of the order book size and premium (bid / ask), the latest trade size and premium as well as the greeks and implied volatility for all option contracts currently associated with the option chain. Available via a 3rd party, contact sales for a trial. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get_options_chain(symbol, expiration, _async=True)
>>> result = thread.get()
:param async bool
:param str symbol: The option symbol, corresponding to the underlying security. (required)
:param str expiration: The expiration date of the options contract (required)
:param date date: The date of the option price. Returns option prices on this date.
:param str type: The option contract type.
:param float strike: The strike price of the option contract. This will return options contracts with strike price equal to this price.