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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rquote
3
- Version: 0.3.1
3
+ Version: 0.3.3
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "rquote"
7
- version = "0.3.1"
7
+ version = "0.3.3"
8
8
  description = "Mostly day quotes of cn/hk/us/fund/future markets, side with quote list fetch"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.6.1"
@@ -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
- d = pd.DataFrame(json.loads(hget(sina_future_d.format(
215
- ix, ix)).text.split('(')[1][:-2]))
216
- d.columns = ['date', 'open', 'high', 'low', 'close', 'vol', 'p', 's']
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rquote
3
- Version: 0.3.1
3
+ Version: 0.3.3
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
File without changes
File without changes
File without changes
File without changes
File without changes