|
1
|
|
|
# ================================================================================== # |
|
2
|
|
|
# historical_prices.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 = 'Historical Prices' |
|
29
|
|
|
description = 'Returns historical prices 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': 'interval', |
|
43
|
|
|
'description': 'Time granularity of the returned data points.', |
|
44
|
|
|
'required': True, |
|
45
|
|
|
'in': 'query', |
|
46
|
|
|
'schema': { |
|
47
|
|
|
'type': str, |
|
48
|
|
|
'enum': ['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo'] |
|
49
|
|
|
} |
|
50
|
|
|
}, { |
|
51
|
|
|
'name': 'range', |
|
52
|
|
|
'description': 'Time span of the returned data points.', |
|
53
|
|
|
'required': False, |
|
54
|
|
|
'in': 'query', |
|
55
|
|
|
'schema': { |
|
56
|
|
|
'type': str, |
|
57
|
|
|
'enum': ['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max'] |
|
58
|
|
|
} |
|
59
|
|
|
}, { |
|
60
|
|
|
'name': 'startDate', |
|
61
|
|
|
'description': 'Start date encoded as an UNIX epoch timestamp.', |
|
62
|
|
|
'required': False, |
|
63
|
|
|
'in': 'query', |
|
64
|
|
|
'schema': { |
|
65
|
|
|
'type': int |
|
66
|
|
|
} |
|
67
|
|
|
}, { |
|
68
|
|
|
'name': 'endDate', |
|
69
|
|
|
'description': 'End date encoded as an UNIX epoch timestamp.', |
|
70
|
|
|
'required': False, |
|
71
|
|
|
'in': 'query', |
|
72
|
|
|
'schema': { |
|
73
|
|
|
'type': int |
|
74
|
|
|
} |
|
75
|
|
|
}, { |
|
76
|
|
|
'name': 'numberOfPoints', |
|
77
|
|
|
'description': 'Quantity of data points from start date.', |
|
78
|
|
|
'required': False, |
|
79
|
|
|
'in': 'query', |
|
80
|
|
|
'schema': { |
|
81
|
|
|
'type': int |
|
82
|
|
|
} |
|
83
|
|
|
}, { |
|
84
|
|
|
'name': 'events', |
|
85
|
|
|
'description': 'Option to include dividends and splits.', |
|
86
|
|
|
'required': False, |
|
87
|
|
|
'in': 'query', |
|
88
|
|
|
'schema': { |
|
89
|
|
|
'type': bool |
|
90
|
|
|
} |
|
91
|
|
|
}, { |
|
92
|
|
|
'name': 'extHours', |
|
93
|
|
|
'description': 'Option to include extended hours prices.', |
|
94
|
|
|
'required': False, |
|
95
|
|
|
'in': 'query', |
|
96
|
|
|
'schema': { |
|
97
|
|
|
'type': bool |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
] |
|
101
|
|
|
|
|
102
|
|
|
# ---------------------------------------------------------------------------------- # |
|
103
|
|
|
response = { |
|
104
|
|
|
'meta': { |
|
105
|
|
|
'currency': str, |
|
106
|
|
|
'symbol': str, |
|
107
|
|
|
'exchangeName': str, |
|
108
|
|
|
'instrumentType': str, |
|
109
|
|
|
'firstTradeDate': int, |
|
110
|
|
|
'regularMarketTime': int, |
|
111
|
|
|
'gmtoffset': int, |
|
112
|
|
|
'timezone': str, |
|
113
|
|
|
'exchangeTimezoneName': str, |
|
114
|
|
|
'regularMarketPrice': float, |
|
115
|
|
|
'chartPreviousClose': float, |
|
116
|
|
|
'priceHint': int, |
|
117
|
|
|
'currentTradingPeriod': { |
|
118
|
|
|
'pre': { |
|
119
|
|
|
'timezone': str, |
|
120
|
|
|
'start': int, |
|
121
|
|
|
'end': int, |
|
122
|
|
|
'gmtoffset': int |
|
123
|
|
|
}, |
|
124
|
|
|
'regular': { |
|
125
|
|
|
'timezone': str, |
|
126
|
|
|
'start': int, |
|
127
|
|
|
'end': int, |
|
128
|
|
|
'gmtoffset': int |
|
129
|
|
|
}, |
|
130
|
|
|
"post": { |
|
131
|
|
|
"timezone": str, |
|
132
|
|
|
"start": int, |
|
133
|
|
|
"end": int, |
|
134
|
|
|
"gmtoffset": int |
|
135
|
|
|
} |
|
136
|
|
|
}, |
|
137
|
|
|
'dataGranularity': str, |
|
138
|
|
|
'range': str, |
|
139
|
|
|
'validRanges': list |
|
140
|
|
|
}, |
|
141
|
|
|
'events': { |
|
142
|
|
|
'dividends': dict, |
|
143
|
|
|
'splits': dict |
|
144
|
|
|
}, |
|
145
|
|
|
'quotes': { |
|
146
|
|
|
'timestamp': list, |
|
147
|
|
|
'volume': list, |
|
148
|
|
|
'open': list, |
|
149
|
|
|
'high': list, |
|
150
|
|
|
'low': list, |
|
151
|
|
|
'close': list, |
|
152
|
|
|
'adjclose': list |
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
|