rquote 0.3.1__tar.gz → 0.3.3__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.3}/PKG-INFO +1 -1
- {rquote-0.3.1 → rquote-0.3.3}/pyproject.toml +1 -1
- {rquote-0.3.1 → rquote-0.3.3}/rquote/main.py +25 -3
- {rquote-0.3.1 → rquote-0.3.3}/rquote.egg-info/PKG-INFO +1 -1
- {rquote-0.3.1 → rquote-0.3.3}/README.md +0 -0
- {rquote-0.3.1 → rquote-0.3.3}/rquote/__init__.py +0 -0
- {rquote-0.3.1 → rquote-0.3.3}/rquote/plots.py +0 -0
- {rquote-0.3.1 → rquote-0.3.3}/rquote/utils.py +0 -0
- {rquote-0.3.1 → rquote-0.3.3}/rquote.egg-info/SOURCES.txt +0 -0
- {rquote-0.3.1 → rquote-0.3.3}/rquote.egg-info/dependency_links.txt +0 -0
- {rquote-0.3.1 → rquote-0.3.3}/rquote.egg-info/requires.txt +0 -0
- {rquote-0.3.1 → rquote-0.3.3}/rquote.egg-info/top_level.txt +0 -0
- {rquote-0.3.1 → rquote-0.3.3}/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
|
|
|
@@ -211,9 +220,20 @@ def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
|
|
|
211
220
|
columns=['date', 'open', 'high', 'low', 'close', 'vol', 'amount'])
|
|
212
221
|
return i, 'BTC', d
|
|
213
222
|
else:
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
223
|
+
ix = i[2:]
|
|
224
|
+
if freq in ('min', '1min', 'minute'):
|
|
225
|
+
url = sina_future_min.format(ix, ix)
|
|
226
|
+
# rtext = hget(url).text
|
|
227
|
+
# d = pd.DataFrame(json.loads(rtext.split(i[2:])[1][2:-2]))
|
|
228
|
+
d = pd.DataFrame(load_js_var_json(url))
|
|
229
|
+
d.columns = ['dtime', 'close', 'avg', 'vol', 'hold','last_close','cur_date']
|
|
230
|
+
d = d.set_index(['dtime'])
|
|
231
|
+
return i[2:], i[2:], d
|
|
232
|
+
else:
|
|
233
|
+
# d = pd.DataFrame(json.loads(hget(sina_future_d.format(
|
|
234
|
+
# ix, ix)).text.split('(')[1][:-2]))
|
|
235
|
+
d = pd.DataFrame(load_js_var_json(sina_future_d.format(ix, ix)))
|
|
236
|
+
d.columns = ['date', 'open', 'high', 'low', 'close', 'vol', 'p', 's']
|
|
217
237
|
d = d.set_index(['date']).astype(float)
|
|
218
238
|
# d.index = pd.DatetimeIndex(d.index)
|
|
219
239
|
return i, ix, d
|
|
@@ -470,6 +490,8 @@ def get_hk_stocks_hsi():
|
|
|
470
490
|
if __name__ == "__main__":
|
|
471
491
|
# print(get_cn_stock_list())
|
|
472
492
|
# print(get_price('fuBTC',sdate='20250101'))
|
|
493
|
+
# print(get_price('fuM2601',sdate='20250101', freq='min'))
|
|
494
|
+
# print(get_price('fuM2601',sdate='2025-01-01'))
|
|
473
495
|
# print(get_price('sz000001', sdate='20240101', edate='20250101'))
|
|
474
496
|
print(get_price('usAMZN.OQ', sdate='20250101', edate='20250101', freq='min'))
|
|
475
497
|
|
|
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
|