chinadata 0.3.8__py3-none-any.whl → 0.3.9__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.
- chinadata/ca_data.py +0 -60
- {chinadata-0.3.8.dist-info → chinadata-0.3.9.dist-info}/METADATA +1 -1
- chinadata-0.3.9.dist-info/RECORD +7 -0
- chinadata-0.3.8.dist-info/RECORD +0 -7
- {chinadata-0.3.8.dist-info → chinadata-0.3.9.dist-info}/WHEEL +0 -0
- {chinadata-0.3.8.dist-info → chinadata-0.3.9.dist-info}/top_level.txt +0 -0
chinadata/ca_data.py
CHANGED
|
@@ -753,66 +753,6 @@ class pro_api:
|
|
|
753
753
|
return self.query(token=self.token, api_name=api_name, **kwargs)
|
|
754
754
|
def ft_limit(self, api_name='ft_limit', **kwargs):
|
|
755
755
|
return self.query(token=self.token, api_name=api_name, **kwargs)
|
|
756
|
-
|
|
757
|
-
def request_with_retry(self,url, max_retries,):
|
|
758
|
-
for attempt in range(max_retries):
|
|
759
|
-
try:
|
|
760
|
-
response = requests.get(url=url, timeout=100, )
|
|
761
|
-
response.raise_for_status()
|
|
762
|
-
return response
|
|
763
|
-
except Exception as e:
|
|
764
|
-
# print(f"尝试 {attempt + 1} 失败: {e}")
|
|
765
|
-
if attempt < max_retries - 1:
|
|
766
|
-
wait_time = 1 * (2 ** attempt) # 指数退避
|
|
767
|
-
# print(f"等待 {wait_time} 秒后重试...")
|
|
768
|
-
time.sleep(wait_time)
|
|
769
|
-
# print(f"请求失败,已重试 {max_retries} 次")
|
|
770
|
-
return None
|
|
771
|
-
|
|
772
|
-
def rt_min(self,ts_code,freq,max_retries=3):
|
|
773
|
-
url = f"http://39.105.209.102:9002/csi/stock/min/rt_min/{ts_code}/{freq}/{self.token}"
|
|
774
|
-
r=self.request_with_retry(url, max_retries=max_retries)
|
|
775
|
-
df=pd.DataFrame(r.json())
|
|
776
|
-
df['time'] = pd.to_datetime(df['time'])
|
|
777
|
-
if freq == '60min':
|
|
778
|
-
periods = {
|
|
779
|
-
'09:15-10:30': ('09:15:00', '10:30:00'),
|
|
780
|
-
'10:31-11:30': ('10:31:00', '11:30:00'),
|
|
781
|
-
'13:01-14:00': ('13:01:00', '14:00:00'),
|
|
782
|
-
'14:01-15:00': ('14:01:00', '15:00:00')
|
|
783
|
-
}
|
|
784
|
-
result = []
|
|
785
|
-
for name, (start, end) in periods.items():
|
|
786
|
-
mask = (df['time'].dt.strftime('%H:%M:%S') >= start) & \
|
|
787
|
-
(df['time'].dt.strftime('%H:%M:%S') <= end)
|
|
788
|
-
data = df[mask]
|
|
789
|
-
if len(data) > 0:
|
|
790
|
-
result.append({
|
|
791
|
-
'ts_code': df.iloc[0]['ts_code'],
|
|
792
|
-
'time': end,
|
|
793
|
-
'open': data.iloc[0]['open'],
|
|
794
|
-
'high': data['high'].max(),
|
|
795
|
-
'low': data['low'].min(),
|
|
796
|
-
'close': data.iloc[-1]['close'],
|
|
797
|
-
'vol': data['vol'].sum(),
|
|
798
|
-
'amount': data['amount'].sum()
|
|
799
|
-
})
|
|
800
|
-
df = pd.DataFrame(result)
|
|
801
|
-
|
|
802
|
-
else:
|
|
803
|
-
# 设置为索引
|
|
804
|
-
df.set_index('time', inplace=True)
|
|
805
|
-
df = df.resample(freq, label='right', closed='right').agg({
|
|
806
|
-
'ts_code': 'first',
|
|
807
|
-
'open': 'first',
|
|
808
|
-
'high': 'max',
|
|
809
|
-
'low': 'min',
|
|
810
|
-
'close': 'last',
|
|
811
|
-
'vol': 'sum',
|
|
812
|
-
'amount': 'sum',
|
|
813
|
-
}).dropna().reset_index()[[ 'ts_code','time','open','high','low','close','vol','amount']]
|
|
814
|
-
|
|
815
|
-
return df
|
|
816
756
|
def irm_qa_sh(self, api_name='irm_qa_sh', **kwargs):
|
|
817
757
|
return self.query(token=self.token, api_name=api_name, **kwargs)
|
|
818
758
|
def irm_qa_sz(self, api_name='irm_qa_sz', **kwargs):
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
chinadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
chinadata/ca_data.py,sha256=CfEWR1Awl7iJk_nfP5QtEMKsaLY9i6UYJhiNlZjUDaw,37514
|
|
3
|
+
chinadata/example.py,sha256=eKj2Hl5KVq9EJGWVY2ZoRJOqZ-p4yiSoFI-xVzdf8LA,575
|
|
4
|
+
chinadata-0.3.9.dist-info/METADATA,sha256=cMWEdKwVDUpmKugFrsZG-RyE52FvwB-G7GYeX4CGFF0,161
|
|
5
|
+
chinadata-0.3.9.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
6
|
+
chinadata-0.3.9.dist-info/top_level.txt,sha256=Ptxvu9uzRHP4kVGRf413KuwSvsY2mk_KgQJ6ssWwisU,10
|
|
7
|
+
chinadata-0.3.9.dist-info/RECORD,,
|
chinadata-0.3.8.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
chinadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
chinadata/ca_data.py,sha256=sFzL91lw0_AF8wnFozU_Iu7KPvCzkepK2JlPdBPtOqg,40118
|
|
3
|
-
chinadata/example.py,sha256=eKj2Hl5KVq9EJGWVY2ZoRJOqZ-p4yiSoFI-xVzdf8LA,575
|
|
4
|
-
chinadata-0.3.8.dist-info/METADATA,sha256=bKGFgc537irq0w9PH2N9AAUpOeRtwvZyAfTXzDEee6w,161
|
|
5
|
-
chinadata-0.3.8.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
6
|
-
chinadata-0.3.8.dist-info/top_level.txt,sha256=Ptxvu9uzRHP4kVGRf413KuwSvsY2mk_KgQJ6ssWwisU,10
|
|
7
|
-
chinadata-0.3.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|