rquote 0.2.9__py3-none-any.whl → 0.3.0__py3-none-any.whl

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/main.py CHANGED
@@ -166,6 +166,8 @@ def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
166
166
  'param={},{},{},{},{},{}'
167
167
  qtimg_stock_us = 'http://web.ifzq.gtimg.cn/appstock/app/usfqkline/get?' + \
168
168
  'param={},{},{},{},{},{}'
169
+ qtimg_stock_us_min = 'https://web.ifzq.gtimg.cn/appstock/app/UsMinute/query?' + \
170
+ '_var=min_data_{}&code={}'
169
171
  sina_future_d = 'https://stock2.finance.sina.com.cn/futures/api/jsonp.php/' + \
170
172
  'var%20t1nf_{}=/InnerFuturesNewService.getDailyKLine?symbol={}'
171
173
  sina_btc = 'https://quotes.sina.cn/fx/api/openapi.php/BtcService.getDayKLine?' + \
@@ -226,11 +228,20 @@ def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
226
228
  elif i[:2] == 'hk':
227
229
  url = qtimg_stock_hk.format(i, freq, sdate, edate, days, fq)
228
230
  elif i[:2] == 'us':
229
- url = qtimg_stock_us.format(i, freq, sdate, edate, days, fq)
231
+ if freq in ('min', '1min', 'minute'):
232
+ url = qtimg_stock_us_min.format(i.replace('.', ''), i)
233
+ else:
234
+ url = qtimg_stock_us.format(i, freq, sdate, edate, days, fq)
230
235
  else:
231
236
  raise ValueError(f'target market not supported: {i}')
232
237
  a = hget(url)
233
238
  #a = json.loads(a.text.replace('kline_dayqfq=', ''))['data'][i]
239
+ if i[:2] == 'us' and freq in ('min', '1min', 'minute'):
240
+ a = json.loads(a.text.split('=')[1])['data'][i]
241
+ nm = a['qt']['usAMZN.OQ'][1]
242
+ b = pd.DataFrame([i.split() for i in a['data']['data']],
243
+ columns=['minute','price','volume']).set_index(['minute']).astype(str)
244
+ return i, nm, b
234
245
  a = json.loads(a.text)['data'][i]
235
246
  name = ''
236
247
  try:
@@ -249,7 +260,7 @@ def get_price(i, sdate='', edate='', freq='day', days=320, fq='qfq',
249
260
  if 'qt' in a:
250
261
  name = a['qt'][i][1]
251
262
  except Exception as e:
252
- logger.warning('error fetching {}, err: {}'.format(i, e))
263
+ raise ValueError('error fetching {}, err: {}'.format(i, e))
253
264
  return i, name, b
254
265
 
255
266
 
@@ -288,14 +299,13 @@ def get_tick(tgts=[]):
288
299
 
289
300
  a = hget(sina_tick + ','.join(tgts))
290
301
  if not a:
291
- logger.warning('hget failed {}'.format(tgts))
292
- return []
302
+ raise ValueError('hget failed {}'.format(tgts))
293
303
 
294
304
  try:
295
305
  dat = [i.split('"')[1].split(',') for i in a.text.split(';\n') if ',' in i]
296
306
  dat_trim = [{k:i[j] for j,k in enumerate(head_row) if k!='_'} for i in dat]
297
307
  except Exception as e:
298
- logger.warming('data not complete, check tgt be code str or list without'+
308
+ raise ValueError('data not complete, check tgt be code str or list without'+
299
309
  ' prefix, your given: {}'.format(tgts))
300
310
  return dat_trim
301
311
 
@@ -313,8 +323,7 @@ def get_stock_concepts(i) -> []:
313
323
  concepts = json.loads(hget(url).text)[
314
324
  'hxtc'][0]['ydnr'].split()
315
325
  except Exception as e:
316
- logger.error(str(e))
317
- concepts = ['']
326
+ raise ValueError(f'error fetching concepts of {i}, err: {e}')
318
327
  #concepts = [i for i in concepts if i not in drop_cons]
319
328
  #concepts = [i for i in concepts if i[-2:] not in drop_tails]
320
329
  #concepts = [i for i in concepts if '股' not in i]
@@ -460,6 +469,7 @@ def get_hk_stocks_hsi():
460
469
 
461
470
  if __name__ == "__main__":
462
471
  # print(get_cn_stock_list())
463
- # print(get_price('fuBTC'))
464
- print(get_price('sz000001', sdate='20240101', edate='20250101'))
472
+ # print(get_price('fuBTC',sdate='20250101'))
473
+ # print(get_price('sz000001', sdate='20240101', edate='20250101'))
474
+ print(get_price('usAMZN.OQ', sdate='20250101', edate='20250101', freq='min'))
465
475
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rquote
3
- Version: 0.2.9
3
+ Version: 0.3.0
4
4
  Summary: Mostly day quotes of cn/hk/us/fund/future markets, side with quote list fetch
5
5
  Requires-Python: >=3.6.1
6
6
  Description-Content-Type: text/markdown
@@ -0,0 +1,8 @@
1
+ rquote/__init__.py,sha256=PB620yEq2QZyfDweKY_8qMEsZMKhskGfhmfDkch_0j0,462
2
+ rquote/main.py,sha256=8_-JjaoMWt66SrEzKmSh30-VPMKidOTNOd2qCYDy1R0,18955
3
+ rquote/plots.py,sha256=N8uvD6ju9tow0DllPQiXiM7EoPC2bK8X7QF6NQainKs,2342
4
+ rquote/utils.py,sha256=4Neb9_R-EKAd6s1Qj4O_vs9jXWyvroxEEhdqH35vxVE,6808
5
+ rquote-0.3.0.dist-info/METADATA,sha256=p11Jj4lQO9C2jBwrPUvLR76IEMwmtzsfp0GwJqvU9Xw,7273
6
+ rquote-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ rquote-0.3.0.dist-info/top_level.txt,sha256=CehAiaZx7Fo8HGoV2zd5GhILUW1jQEN8YS-cWMlrK9Y,7
8
+ rquote-0.3.0.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- rquote/__init__.py,sha256=PB620yEq2QZyfDweKY_8qMEsZMKhskGfhmfDkch_0j0,462
2
- rquote/main.py,sha256=SiMpjcs9zvcRzvSMPByX_ZpLQuYRyx2AUEeHJnj8uE4,18272
3
- rquote/plots.py,sha256=N8uvD6ju9tow0DllPQiXiM7EoPC2bK8X7QF6NQainKs,2342
4
- rquote/utils.py,sha256=4Neb9_R-EKAd6s1Qj4O_vs9jXWyvroxEEhdqH35vxVE,6808
5
- rquote-0.2.9.dist-info/METADATA,sha256=QG0nVFxI0ePdTK7894Ajq8H4R2X-PbiRoLMG-h75Q3M,7273
6
- rquote-0.2.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- rquote-0.2.9.dist-info/top_level.txt,sha256=CehAiaZx7Fo8HGoV2zd5GhILUW1jQEN8YS-cWMlrK9Y,7
8
- rquote-0.2.9.dist-info/RECORD,,
File without changes