rquote 0.3.1__tar.gz → 0.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rquote-0.3.1 → rquote-0.3.4}/PKG-INFO +1 -1
- {rquote-0.3.1 → rquote-0.3.4}/pyproject.toml +1 -1
- {rquote-0.3.1 → rquote-0.3.4}/rquote/main.py +38 -10
- {rquote-0.3.1 → rquote-0.3.4}/rquote.egg-info/PKG-INFO +1 -1
- {rquote-0.3.1 → rquote-0.3.4}/README.md +0 -0
- {rquote-0.3.1 → rquote-0.3.4}/rquote/__init__.py +0 -0
- {rquote-0.3.1 → rquote-0.3.4}/rquote/plots.py +0 -0
- {rquote-0.3.1 → rquote-0.3.4}/rquote/utils.py +0 -0
- {rquote-0.3.1 → rquote-0.3.4}/rquote.egg-info/SOURCES.txt +0 -0
- {rquote-0.3.1 → rquote-0.3.4}/rquote.egg-info/dependency_links.txt +0 -0
- {rquote-0.3.1 → rquote-0.3.4}/rquote.egg-info/requires.txt +0 -0
- {rquote-0.3.1 → rquote-0.3.4}/rquote.egg-info/top_level.txt +0 -0
- {rquote-0.3.1 → rquote-0.3.4}/setup.cfg +0 -0
|
@@ -137,6 +137,13 @@ def _check_date_format(date_str):
|
|
|
137
137
|
return date_str
|
|
138
138
|
|
|
139
139
|
|
|
140
|
+
def load_js_var_json(url):
|
|
141
|
+
a = hget(url)
|
|
142
|
+
if a:
|
|
143
|
+
a = json.loads(a.text.split('(')[1].split(')')[0])
|
|
144
|
+
return a
|
|
145
|
+
|
|
146
|
+
|
|
140
147
|
def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
|
|
141
148
|
dd=None) -> (str, str, pd.DataFrame):
|
|
142
149
|
'''
|
|
@@ -170,6 +177,8 @@ def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
|
|
|
170
177
|
'_var=min_data_{}&code={}'
|
|
171
178
|
sina_future_d = 'https://stock2.finance.sina.com.cn/futures/api/jsonp.php/' + \
|
|
172
179
|
'var%20t1nf_{}=/InnerFuturesNewService.getDailyKLine?symbol={}'
|
|
180
|
+
sina_future_min = 'https://stock2.finance.sina.com.cn/futures/api/jsonp.php/' + \
|
|
181
|
+
'var%20t1nf_{}=/InnerFuturesNewService.getMinLine?symbol={}'
|
|
173
182
|
sina_btc = 'https://quotes.sina.cn/fx/api/openapi.php/BtcService.getDayKLine?' + \
|
|
174
183
|
'symbol=btcbtcusd'
|
|
175
184
|
|
|
@@ -209,11 +218,28 @@ def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
|
|
|
209
218
|
d = json.loads(hget(url).text)['result']['data'].split('|')
|
|
210
219
|
d = pd.DataFrame([i.split(',') for i in d],
|
|
211
220
|
columns=['date', 'open', 'high', 'low', 'close', 'vol', 'amount'])
|
|
221
|
+
for col in ['open','high','low','close','vol','amount']:
|
|
222
|
+
d[col] = pd.to_numeric(d[col], errors='coerce')
|
|
212
223
|
return i, 'BTC', d
|
|
213
224
|
else:
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
225
|
+
ix = i[2:]
|
|
226
|
+
if freq in ('min', '1min', 'minute'):
|
|
227
|
+
url = sina_future_min.format(ix, ix)
|
|
228
|
+
# rtext = hget(url).text
|
|
229
|
+
# d = pd.DataFrame(json.loads(rtext.split(i[2:])[1][2:-2]))
|
|
230
|
+
d = pd.DataFrame(load_js_var_json(url))
|
|
231
|
+
d.columns = ['dtime', 'close', 'avg', 'vol', 'hold','last_close','cur_date']
|
|
232
|
+
for col in ['close','avg','vol','hold']:
|
|
233
|
+
d[col] = pd.to_numeric(d[col], errors='coerce')
|
|
234
|
+
d = d.set_index(['dtime'])
|
|
235
|
+
return i[2:], i[2:], d
|
|
236
|
+
else:
|
|
237
|
+
# d = pd.DataFrame(json.loads(hget(sina_future_d.format(
|
|
238
|
+
# ix, ix)).text.split('(')[1][:-2]))
|
|
239
|
+
d = pd.DataFrame(load_js_var_json(sina_future_d.format(ix, ix)))
|
|
240
|
+
d.columns = ['date', 'open', 'high', 'low', 'close', 'vol', 'p', 's']
|
|
241
|
+
for col in ['open','high','low','close','vol','p','s']:
|
|
242
|
+
d[col] = pd.to_numeric(d[col], errors='coerce')
|
|
217
243
|
d = d.set_index(['date']).astype(float)
|
|
218
244
|
# d.index = pd.DatetimeIndex(d.index)
|
|
219
245
|
return i, ix, d
|
|
@@ -240,7 +266,9 @@ def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
|
|
|
240
266
|
a = json.loads(a.text.split('=')[1])['data'][i]
|
|
241
267
|
nm = a['qt'][i][1]
|
|
242
268
|
b = pd.DataFrame([i.split() for i in a['data']['data']],
|
|
243
|
-
|
|
269
|
+
columns=['minute','price','volume']).set_index(['minute'])
|
|
270
|
+
for col in ['price','volume']:
|
|
271
|
+
b[col] = pd.to_numeric(b[col], errors='coerce')
|
|
244
272
|
return i, nm, b
|
|
245
273
|
a = json.loads(a.text)['data'][i]
|
|
246
274
|
name = ''
|
|
@@ -251,12 +279,10 @@ def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
|
|
|
251
279
|
tk = tkt
|
|
252
280
|
break
|
|
253
281
|
b = pd.DataFrame([j[:6] for j in a[tk]],
|
|
254
|
-
columns=['date',
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
'low',
|
|
259
|
-
'vol']).set_index(['date']).astype(float)
|
|
282
|
+
columns=['date','open','close','high','low','vol']
|
|
283
|
+
).set_index(['date'])
|
|
284
|
+
for col in ['open','high','low','close','vol']:
|
|
285
|
+
b[col] = pd.to_numeric(b[col], errors='coerce')
|
|
260
286
|
if 'qt' in a:
|
|
261
287
|
name = a['qt'][i][1]
|
|
262
288
|
except Exception as e:
|
|
@@ -470,6 +496,8 @@ def get_hk_stocks_hsi():
|
|
|
470
496
|
if __name__ == "__main__":
|
|
471
497
|
# print(get_cn_stock_list())
|
|
472
498
|
# print(get_price('fuBTC',sdate='20250101'))
|
|
499
|
+
# print(get_price('fuM2601',sdate='20250101', freq='min'))
|
|
500
|
+
# print(get_price('fuM2601',sdate='2025-01-01'))
|
|
473
501
|
# print(get_price('sz000001', sdate='20240101', edate='20250101'))
|
|
474
502
|
print(get_price('usAMZN.OQ', sdate='20250101', edate='20250101', freq='min'))
|
|
475
503
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|