siat 1.7.46__py3-none-any.whl → 1.7.48__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.
- siat/common.py +13 -0
- siat/economy.py +2 -2
- siat/markowitz.py +182 -44
- siat/security_prices.py +70 -0
- siat/stock.py +1 -1
- siat/translate.py +3 -0
- {siat-1.7.46.dist-info → siat-1.7.48.dist-info}/METADATA +1 -1
- {siat-1.7.46.dist-info → siat-1.7.48.dist-info}/RECORD +10 -10
- {siat-1.7.46.dist-info → siat-1.7.48.dist-info}/WHEEL +0 -0
- {siat-1.7.46.dist-info → siat-1.7.48.dist-info}/top_level.txt +0 -0
siat/common.py
CHANGED
@@ -1854,7 +1854,20 @@ def print_list(alist,leading_blanks=1):
|
|
1854
1854
|
|
1855
1855
|
return
|
1856
1856
|
#==============================================================================
|
1857
|
+
# FUNCTION TO REMOVE TIMEZONE
|
1858
|
+
def remove_timezone(dt):
|
1859
|
+
|
1860
|
+
# HERE `dt` is a python datetime
|
1861
|
+
# object that used .replace() method
|
1862
|
+
return dt.replace(tzinfo=None)
|
1857
1863
|
#==============================================================================
|
1864
|
+
def remove_df_index_timezone(df):
|
1865
|
+
df['timestamp']=df.index
|
1866
|
+
df['timestamp'] = df['timestamp'].apply(remove_timezone)
|
1867
|
+
df.index=df['timestamp']
|
1868
|
+
del df['timestamp']
|
1869
|
+
|
1870
|
+
return df
|
1858
1871
|
#==============================================================================
|
1859
1872
|
#==============================================================================
|
1860
1873
|
|
siat/economy.py
CHANGED
@@ -191,7 +191,7 @@ if __name__=='__main__':
|
|
191
191
|
get_econ_factors('2010-1-1','2020-8-31','?','Constant GDP')
|
192
192
|
get_econ_factors('2010-1-1','2020-8-31','China','?')
|
193
193
|
#==============================================================================
|
194
|
-
def economy_trend(start,end,scope='China',factor='GDP',datatag=False,power=
|
194
|
+
def economy_trend(start,end,scope='China',factor='GDP',datatag=False,power=0,zeroline=False):
|
195
195
|
"""
|
196
196
|
功能:绘制宏观经济指标,单线,有趋势线
|
197
197
|
"""
|
@@ -209,7 +209,7 @@ def economy_trend(start,end,scope='China',factor='GDP',datatag=False,power=3,zer
|
|
209
209
|
|
210
210
|
#绘图
|
211
211
|
ylabeltxt=ectranslate(factor)
|
212
|
-
titletxt=ectranslate(list(ds['name'])[0])+'
|
212
|
+
titletxt=ectranslate(list(ds['name'])[0])+'变化趋势:'+ectranslate(scope)
|
213
213
|
|
214
214
|
import datetime
|
215
215
|
today=datetime.date.today()
|
siat/markowitz.py
CHANGED
@@ -26,6 +26,7 @@ import pandas as pd
|
|
26
26
|
import numpy as np
|
27
27
|
import datetime
|
28
28
|
#==============================================================================
|
29
|
+
import seaborn as sns
|
29
30
|
import matplotlib.pyplot as plt
|
30
31
|
#统一设定绘制的图片大小:数值为英寸,1英寸=100像素
|
31
32
|
plt.rcParams['figure.figsize']=(12.8,7.2)
|
@@ -51,14 +52,14 @@ import sys; czxt=sys.platform
|
|
51
52
|
if czxt in ['win32','win64']:
|
52
53
|
plt.rcParams['font.sans-serif'] = ['SimHei'] # 设置默认字体
|
53
54
|
mpfrc={'font.family': 'SimHei'}
|
55
|
+
sns.set_style('whitegrid',{'font.sans-serif':['simhei','Arial']})
|
54
56
|
|
55
|
-
if czxt in ['darwin']: #MacOSX
|
57
|
+
if czxt in ['darwin','linux']: #MacOSX
|
58
|
+
#plt.rcParams['font.family'] = ['Arial Unicode MS'] #用来正常显示中文标签
|
56
59
|
plt.rcParams['font.family']= ['Heiti TC']
|
57
60
|
mpfrc={'font.family': 'Heiti TC'}
|
61
|
+
sns.set_style('whitegrid',{'font.sans-serif':['Arial Unicode MS','Arial']})
|
58
62
|
|
59
|
-
if czxt in ['linux']: #website Jupyter
|
60
|
-
plt.rcParams['font.family']= ['Heiti TC']
|
61
|
-
mpfrc={'font.family':'Heiti TC'}
|
62
63
|
|
63
64
|
# 解决保存图像时'-'显示为方块的问题
|
64
65
|
plt.rcParams['axes.unicode_minus'] = False
|
@@ -232,7 +233,8 @@ if __name__=='__main__':
|
|
232
233
|
printout=True
|
233
234
|
|
234
235
|
def portfolio_cumret(portfolio,thedate,pastyears=1, \
|
235
|
-
rate_period='1Y',rate_type='shibor',RF=False,
|
236
|
+
rate_period='1Y',rate_type='shibor',RF=False, \
|
237
|
+
printout=True,graph=True):
|
236
238
|
"""
|
237
239
|
功能:绘制投资组合的累计收益率趋势图,并与等权和市值加权组合比较
|
238
240
|
注意:中国部分历史区段的treasury历史可能无法取得;
|
@@ -248,7 +250,7 @@ def portfolio_cumret(portfolio,thedate,pastyears=1, \
|
|
248
250
|
totalshares=np.sum(sharelist0)
|
249
251
|
if abs(totalshares - 1) >= 0.000001:
|
250
252
|
print("\n #Warning(portfolio_cumret): total weights is",totalshares,", it requires 1.0 here")
|
251
|
-
print("
|
253
|
+
print(" Automatically converted into total weights 1")
|
252
254
|
sharelist=list(sharelist0/totalshares)
|
253
255
|
else:
|
254
256
|
sharelist=sharelist0
|
@@ -272,7 +274,8 @@ def portfolio_cumret(portfolio,thedate,pastyears=1, \
|
|
272
274
|
|
273
275
|
#..........................................................................
|
274
276
|
# 抓取投资组合股价
|
275
|
-
prices=get_prices(tickerlist,start,thedate)
|
277
|
+
#prices=get_prices(tickerlist,start,thedate)
|
278
|
+
prices=get_prices_simple(tickerlist,start,thedate)
|
276
279
|
if prices is None:
|
277
280
|
print(" #Error(portfolio_cumret): failed to get portfolio prices",pname)
|
278
281
|
return None
|
@@ -305,43 +308,45 @@ def portfolio_cumret(portfolio,thedate,pastyears=1, \
|
|
305
308
|
#..........................................................................
|
306
309
|
|
307
310
|
# 绘制原投资组合的收益率曲线,以便使用收益率%来显示
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
311
|
+
if graph:
|
312
|
+
plotsr = StockReturns['Portfolio']
|
313
|
+
plotsr.plot(label=pname)
|
314
|
+
plt.axhline(y=0,ls=":",c="red")
|
315
|
+
|
316
|
+
if lang == 'Chinese':
|
317
|
+
title_txt="投资组合: 日收益率的变化趋势"
|
318
|
+
ylabel_txt="日收益率"
|
319
|
+
source_txt="来源: Sina/EM/stooq, "
|
320
|
+
else:
|
321
|
+
title_txt="Investment Portfolio: Daily Return"
|
322
|
+
ylabel_txt="Daily Return"
|
323
|
+
source_txt="Source: sina/eastmoney/stooq, "
|
324
|
+
|
325
|
+
plt.title(title_txt)
|
326
|
+
plt.ylabel(ylabel_txt)
|
327
|
+
|
328
|
+
stoday = datetime.date.today()
|
329
|
+
plt.xlabel(source_txt+str(stoday))
|
330
|
+
plt.legend()
|
331
|
+
plt.show()
|
328
332
|
#..........................................................................
|
329
333
|
|
330
334
|
# 计算原投资组合的持有收益率,并绘图
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
335
|
+
name_list=["Portfolio"]
|
336
|
+
label_list=[pname]
|
337
|
+
|
338
|
+
if lang == 'Chinese':
|
339
|
+
titletxt="投资组合: 持有收益率的变化趋势"
|
340
|
+
ylabeltxt="持有收益率"
|
341
|
+
xlabeltxt="来源: Sina/EM/stooq, "+str(stoday)
|
342
|
+
else:
|
343
|
+
titletxt="Investment Portfolio: Holding Return"
|
344
|
+
ylabeltxt="Holding Return"
|
345
|
+
xlabeltxt="Source: sina/eastmoney/stooq, "+str(stoday)
|
342
346
|
|
343
347
|
#绘制持有收益率曲线
|
344
|
-
|
348
|
+
if graph:
|
349
|
+
cumulative_returns_plot(StockReturns,name_list,titletxt,ylabeltxt,xlabeltxt,label_list)
|
345
350
|
#..........................................................................
|
346
351
|
|
347
352
|
# 构造等权重组合Portfolio_EW的持有收益率
|
@@ -376,7 +381,8 @@ def portfolio_cumret(portfolio,thedate,pastyears=1, \
|
|
376
381
|
titletxt=title_txt
|
377
382
|
|
378
383
|
#绘制各个投资组合的持有收益率曲线
|
379
|
-
|
384
|
+
if graph:
|
385
|
+
cumulative_returns_plot(StockReturns,name_list,titletxt,ylabeltxt,xlabeltxt,label_list)
|
380
386
|
|
381
387
|
#打印各个投资组合的持股比例
|
382
388
|
member_returns=stock_return
|
@@ -393,7 +399,8 @@ def portfolio_cumret(portfolio,thedate,pastyears=1, \
|
|
393
399
|
portfolio_returns=cvt_portfolio_name(pname,portfolio_returns)
|
394
400
|
|
395
401
|
#打印现有投资组合策略的排名
|
396
|
-
|
402
|
+
if printout:
|
403
|
+
portfolio_ranks(portfolio_returns,pname)
|
397
404
|
|
398
405
|
return [[portfolio,thedate,member_returns,rf_df,member_prices], \
|
399
406
|
[portfolio_returns,portfolio_weights,portfolio_weights_ew,portfolio_weights_lw]]
|
@@ -407,7 +414,7 @@ if __name__=='__main__':
|
|
407
414
|
#==============================================================================
|
408
415
|
|
409
416
|
def portfolio_expret(portfolio,today,pastyears=1, \
|
410
|
-
rate_period='1Y',rate_type='shibor',RF=False,printout=True):
|
417
|
+
rate_period='1Y',rate_type='shibor',RF=False,printout=True,graph=True):
|
411
418
|
"""
|
412
419
|
功能:绘制投资组合的持有期收益率趋势图,并与等权和市值加权组合比较
|
413
420
|
套壳原来的portfolio_cumret函数,以维持兼容性
|
@@ -417,7 +424,7 @@ def portfolio_expret(portfolio,today,pastyears=1, \
|
|
417
424
|
"""
|
418
425
|
#处理失败的返回值
|
419
426
|
results=portfolio_cumret(portfolio,today,pastyears, \
|
420
|
-
rate_period,rate_type,RF,printout)
|
427
|
+
rate_period,rate_type,RF,printout,graph)
|
421
428
|
if results is None: return None
|
422
429
|
|
423
430
|
[[portfolio,thedate,member_returns,rf_df,member_prices], \
|
@@ -453,7 +460,7 @@ def portfolio_corr(pf_info):
|
|
453
460
|
import seaborn as sns
|
454
461
|
# 创建热图
|
455
462
|
sns.heatmap(correlation_matrix,annot=True,cmap="YlGnBu",linewidths=0.3,
|
456
|
-
annot_kws={"size":
|
463
|
+
annot_kws={"size": 16})
|
457
464
|
plt.title(pname+": 成份股收益率之间的相关系数")
|
458
465
|
plt.ylabel("成份股票")
|
459
466
|
|
@@ -2038,7 +2045,138 @@ if __name__=='__main__':
|
|
2038
2045
|
fromdate,todate='2019-1-1','2020-8-1'
|
2039
2046
|
df=portfolio_ef(stocks,fromdate,todate)
|
2040
2047
|
|
2048
|
+
#==============================================================================
|
2049
|
+
if __name__=='__main__':
|
2050
|
+
tickers=['^GSPC','000001.SS','^HSI','^N225','^BSESN']
|
2051
|
+
start='2023-1-1'
|
2052
|
+
end='2023-3-22'
|
2053
|
+
info_type='Volume'
|
2054
|
+
df=security_correlation(tickers,start,end,info_type='Close')
|
2055
|
+
|
2056
|
+
|
2057
|
+
def cm2inch(x,y):
|
2058
|
+
return x/2.54,y/2.54
|
2059
|
+
|
2060
|
+
def security_correlation(tickers,start,end,info_type='Close'):
|
2061
|
+
"""
|
2062
|
+
功能:股票/指数收盘价之间的相关性
|
2063
|
+
info_type='Close': 默认Close, 还可为Open/High/Low/Volume
|
2064
|
+
"""
|
2065
|
+
info_types=['Close','Open','High','Low','Volume']
|
2066
|
+
info_types_cn=['收盘价','开盘价','最高价','最低价','成交量']
|
2067
|
+
if not(info_type in info_types):
|
2068
|
+
print(" #Error(security_correlation): invalid information type",info_type)
|
2069
|
+
print(" Supported information type:",info_types)
|
2070
|
+
return None
|
2071
|
+
pos=info_types.index(info_type)
|
2072
|
+
info_type_cn=info_types_cn[pos]
|
2073
|
+
|
2074
|
+
#屏蔽函数内print信息输出的类
|
2075
|
+
import os, sys
|
2076
|
+
class HiddenPrints:
|
2077
|
+
def __enter__(self):
|
2078
|
+
self._original_stdout = sys.stdout
|
2079
|
+
sys.stdout = open(os.devnull, 'w')
|
2080
|
+
|
2081
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
2082
|
+
sys.stdout.close()
|
2083
|
+
sys.stdout = self._original_stdout
|
2084
|
+
|
2085
|
+
print(" Searching for security prices, please wait ...")
|
2086
|
+
with HiddenPrints():
|
2087
|
+
prices=get_prices_simple(tickers,start,end)
|
2088
|
+
df=prices[info_type]
|
2089
|
+
df.dropna(axis=0,inplace=True)
|
2090
|
+
|
2091
|
+
# here put the import lib
|
2092
|
+
import seaborn as sns
|
2093
|
+
sns.set(font='SimHei') # 解决Seaborn中文显示问题
|
2094
|
+
#sns.set_style('whitegrid',{'font.sans-serif':['SimHei','Arial']})
|
2095
|
+
#sns.set_style('whitegrid',{'font.sans-serif':['FangSong']})
|
2096
|
+
|
2097
|
+
import numpy as np
|
2098
|
+
from scipy.stats import pearsonr
|
2099
|
+
|
2100
|
+
collist=list(df)
|
2101
|
+
for col in collist:
|
2102
|
+
df.rename(columns={col:codetranslate(col)},inplace=True)
|
2103
|
+
df_coor = df.corr()
|
2104
|
+
|
2105
|
+
|
2106
|
+
#fig = plt.figure(figsize=(cm2inch(16,12)))
|
2107
|
+
fig = plt.figure(figsize=(cm2inch(12,8)))
|
2108
|
+
ax1 = plt.gca()
|
2109
|
+
|
2110
|
+
#构造mask,去除重复数据显示
|
2111
|
+
mask = np.zeros_like(df_coor)
|
2112
|
+
mask[np.triu_indices_from(mask)] = True
|
2113
|
+
mask2 = mask
|
2114
|
+
mask = (np.flipud(mask)-1)*(-1)
|
2115
|
+
mask = np.rot90(mask,k = -1)
|
2116
|
+
|
2117
|
+
im1 = sns.heatmap(df_coor,annot=True,cmap="YlGnBu"
|
2118
|
+
, mask=mask#构造mask,去除重复数据显示
|
2119
|
+
,vmax=1,vmin=-1
|
2120
|
+
, fmt='.2f',ax = ax1,annot_kws={"size": 8})
|
2121
|
+
|
2122
|
+
ax1.tick_params(axis = 'both', length=0)
|
2123
|
+
|
2124
|
+
#计算相关性显著性并显示
|
2125
|
+
rlist = []
|
2126
|
+
plist = []
|
2127
|
+
for i in df.columns.values:
|
2128
|
+
for j in df.columns.values:
|
2129
|
+
r,p = pearsonr(df[i],df[j])
|
2130
|
+
rlist.append(r)
|
2131
|
+
plist.append(p)
|
2132
|
+
|
2133
|
+
rarr = np.asarray(rlist).reshape(len(df.columns.values),len(df.columns.values))
|
2134
|
+
parr = np.asarray(plist).reshape(len(df.columns.values),len(df.columns.values))
|
2135
|
+
xlist = ax1.get_xticks()
|
2136
|
+
ylist = ax1.get_yticks()
|
2137
|
+
|
2138
|
+
widthx = 0
|
2139
|
+
widthy = -0.15
|
2140
|
+
|
2141
|
+
for m in ax1.get_xticks():
|
2142
|
+
for n in ax1.get_yticks():
|
2143
|
+
pv = (parr[int(m),int(n)])
|
2144
|
+
rv = (rarr[int(m),int(n)])
|
2145
|
+
if mask2[int(m),int(n)]<1.:
|
2146
|
+
if abs(rv) > 0.5:
|
2147
|
+
if pv< 0.05 and pv>= 0.01:
|
2148
|
+
ax1.text(n+widthx,m+widthy,'*',ha = 'center',color = 'white')
|
2149
|
+
if pv< 0.01 and pv>= 0.001:
|
2150
|
+
ax1.text(n+widthx,m+widthy,'**',ha = 'center',color = 'white')
|
2151
|
+
if pv< 0.001:
|
2152
|
+
#print([int(m),int(n)])
|
2153
|
+
ax1.text(n+widthx,m+widthy,'***',ha = 'center',color = 'white')
|
2154
|
+
else:
|
2155
|
+
if pv< 0.05 and pv>= 0.01:
|
2156
|
+
ax1.text(n+widthx,m+widthy,'*',ha = 'center',color = 'k')
|
2157
|
+
elif pv< 0.01 and pv>= 0.001:
|
2158
|
+
ax1.text(n+widthx,m+widthy,'**',ha = 'center',color = 'k')
|
2159
|
+
elif pv< 0.001:
|
2160
|
+
ax1.text(n+widthx,m+widthy,'***',ha = 'center',color = 'k')
|
2161
|
+
|
2162
|
+
plt.title("证券"+info_type_cn+"之间的相关性")
|
2163
|
+
plt.tick_params(labelsize=8)
|
2164
|
+
|
2165
|
+
footnote1="\n显著性数值:***非常显著(<0.001),**很显著(<0.01),*显著(<0.05),其余为不显著"
|
2166
|
+
footnote2="\n系数绝对值:>=0.8极强相关,0.6-0.8强相关,0.4-0.6相关,0.2-0.4弱相关,否则为极弱(不)相关"
|
2167
|
+
|
2168
|
+
footnote3="\n观察期间: "+start+'至'+end
|
2169
|
+
import datetime as dt; stoday=dt.date.today()
|
2170
|
+
footnote4=";来源:Sina/EM/stooq/Yahoo,"+str(stoday)
|
2171
|
+
|
2172
|
+
fontxlabel={'size':7}
|
2173
|
+
plt.xlabel(footnote1+footnote2+footnote3+footnote4,fontxlabel)
|
2174
|
+
#plt.xticks(rotation=45)
|
2175
|
+
plt.show()
|
2176
|
+
|
2177
|
+
return df_coor
|
2041
2178
|
|
2179
|
+
#==============================================================================
|
2042
2180
|
|
2043
2181
|
|
2044
2182
|
|
siat/security_prices.py
CHANGED
@@ -92,6 +92,7 @@ def get_prices(ticker,fromdate,todate,adj=False,retry_count=3,pause=1):
|
|
92
92
|
print(" #Error(get_prices): invalid date period from",fromdate,'to',todate)
|
93
93
|
return None
|
94
94
|
|
95
|
+
"""
|
95
96
|
#尝试pandas_datareader+FRED(仅对部分国外市场指数有效)
|
96
97
|
if ticker[0]=='^':
|
97
98
|
print(" Trying to capture info from fred for",ticker)
|
@@ -103,6 +104,7 @@ def get_prices(ticker,fromdate,todate,adj=False,retry_count=3,pause=1):
|
|
103
104
|
print(" #Warning(get_prices): zero record found in fred for",ticker)
|
104
105
|
else:
|
105
106
|
return prices
|
107
|
+
"""
|
106
108
|
|
107
109
|
#尝试AkShare+Sina+EM(新浪,对中国内地股票、港股和美股有效,但不包括国外市场指数)
|
108
110
|
#printmsg=str(ticker)+" from "+fromdate+' to '+todate
|
@@ -822,6 +824,73 @@ if __name__=='__main__':
|
|
822
824
|
dfm2=get_prices_ak(['600519.SS','AAPL'],'2020-12-1','2021-1-31')
|
823
825
|
|
824
826
|
#==============================================================================
|
827
|
+
if __name__=='__main__':
|
828
|
+
ticker=['600519.SS','000858.SZ']
|
829
|
+
fromdate='2020-12-1'
|
830
|
+
todate='2021-1-31'
|
831
|
+
adjust='none'
|
832
|
+
|
833
|
+
def get_prices_simple(ticker,fromdate,todate,adjust='none'):
|
834
|
+
"""
|
835
|
+
功能:直接循环获取股票或指数的历史行情,多个股票
|
836
|
+
"""
|
837
|
+
#检查是否为多个股票:单个股票代码
|
838
|
+
if isinstance(ticker,str):
|
839
|
+
df=get_prices(ticker,fromdate,todate,adjust=adjust)
|
840
|
+
return df
|
841
|
+
|
842
|
+
#检查是否为多个股票:空的列表
|
843
|
+
if isinstance(ticker,list) and len(ticker) == 0:
|
844
|
+
pass
|
845
|
+
return None
|
846
|
+
|
847
|
+
#检查是否为多个股票:列表中只有一个代码
|
848
|
+
if isinstance(ticker,list) and len(ticker) == 1:
|
849
|
+
ticker1=ticker[0]
|
850
|
+
df=get_prices(ticker1,fromdate,todate,adjust=adjust)
|
851
|
+
return df
|
852
|
+
|
853
|
+
import pandas as pd
|
854
|
+
#处理列表中的第一个股票
|
855
|
+
i=0
|
856
|
+
df=None
|
857
|
+
while df is None:
|
858
|
+
t=ticker[i]
|
859
|
+
#df=get_prices(t,fromdate,todate,adjust=adjust)
|
860
|
+
df=get_prices(t,fromdate,todate)
|
861
|
+
if not (df is None):
|
862
|
+
columns=create_tuple_for_columns(df,t)
|
863
|
+
df.columns=pd.MultiIndex.from_tuples(columns)
|
864
|
+
else:
|
865
|
+
i=i+1
|
866
|
+
if (i+1) == len(ticker):
|
867
|
+
#已经到达股票代码列表末尾
|
868
|
+
return df
|
869
|
+
|
870
|
+
#对抗时区不匹配问题
|
871
|
+
df.index=pd.to_datetime(df.index)
|
872
|
+
#处理列表中的其余股票
|
873
|
+
for t in ticker[(i+1):]:
|
874
|
+
#dft=get_prices(t,fromdate,todate,adjust=adjust)
|
875
|
+
dft=get_prices(t,fromdate,todate)
|
876
|
+
if dft is None: continue
|
877
|
+
if len(dft)==0: continue
|
878
|
+
|
879
|
+
if not (dft is None):
|
880
|
+
columns=create_tuple_for_columns(dft,t)
|
881
|
+
dft.columns=pd.MultiIndex.from_tuples(columns)
|
882
|
+
|
883
|
+
dft.index=pd.to_datetime(dft.index)
|
884
|
+
df=pd.merge(df,dft,how='inner',left_index=True,right_index=True)
|
885
|
+
|
886
|
+
return df
|
887
|
+
|
888
|
+
if __name__=='__main__':
|
889
|
+
dfm=get_prices_simple(['600519.SS','000858.SZ'],'2020-12-1','2021-1-31')
|
890
|
+
dfm2=get_prices_simple(['600519.SS','AAPL'],'2020-12-1','2021-1-31')
|
891
|
+
|
892
|
+
#==============================================================================
|
893
|
+
|
825
894
|
if __name__=='__main__':
|
826
895
|
ticker='AAPL'
|
827
896
|
start='2020-12-1'
|
@@ -1886,6 +1955,7 @@ if __name__ =="__main__":
|
|
1886
1955
|
|
1887
1956
|
#==============================================================================
|
1888
1957
|
|
1958
|
+
|
1889
1959
|
#==============================================================================
|
1890
1960
|
#==============================================================================
|
1891
1961
|
#==============================================================================
|
siat/stock.py
CHANGED
@@ -1220,7 +1220,7 @@ def compare_msecurity(tickers,measure,start,end, \
|
|
1220
1220
|
axhline_value=0,axhline_label='', \
|
1221
1221
|
preprocess='none',linewidth=1.5, \
|
1222
1222
|
scaling_option='start', \
|
1223
|
-
|
1223
|
+
graph=True):
|
1224
1224
|
"""
|
1225
1225
|
功能:比较并绘制多条证券指标曲线(多于2条),个数可为双数或单数
|
1226
1226
|
注意:
|
siat/translate.py
CHANGED
@@ -761,6 +761,8 @@ def codetranslate0(code):
|
|
761
761
|
|
762
762
|
['SIVB','硅谷银行'],['WFC','富国银行'],['SBNY','签字银行'],
|
763
763
|
['FRC','第一共和银行'],['CS','瑞士信贷'],['UBS','瑞银'],
|
764
|
+
['SI','加密友好银行'],
|
765
|
+
|
764
766
|
|
765
767
|
['8306.T','三菱日联金融'],['MITSUBISHI UFJ FINANCIAL GROUP','三菱日联金融'],
|
766
768
|
['8411.T','日股瑞穗金融'],['MIZUHO FINANCIAL GROUP','瑞穗金融'],
|
@@ -1255,6 +1257,7 @@ def codetranslate1(code):
|
|
1255
1257
|
|
1256
1258
|
['SIVB','Silicon Valley Bank'],['WFC','Wells Fargo'],['SBNY','Signature Bank'],
|
1257
1259
|
['FRC','First Republic Bank'],['CS','Credit Suisse'],['UBS','UBS Group'],
|
1260
|
+
['SI','Silvergate Capital'],
|
1258
1261
|
|
1259
1262
|
['8306.T','MITSUBISHI UFJ'],['MITSUBISHI UFJ FINANCIAL GROUP','MITSUBISHI UFJ'],
|
1260
1263
|
['8411.T','MIZUHO FINANCIAL'],['MIZUHO FINANCIAL GROUP','MIZUHO FINANCIAL'],
|
@@ -14,7 +14,7 @@ siat/bond_test.py,sha256=yUOFw7ddGU-kb1rJdnsjkJWziDNgUR7OLDA7F7Ub91A,5246
|
|
14
14
|
siat/capm_beta.py,sha256=L40UbrSU4QQ5CxmEu8CpLT5WptsOUOfDRF7Pxdw6HZs,28499
|
15
15
|
siat/capm_beta_test.py,sha256=ImR0c5mc4hIl714XmHztdl7qg8v1E2lycKyiqnFj6qs,1745
|
16
16
|
siat/cmat_commons.py,sha256=Nj9Kf0alywaztVoMVeVVL_EZk5jRERJy8R8kBw88_Tg,38116
|
17
|
-
siat/common.py,sha256=
|
17
|
+
siat/common.py,sha256=F_l3c329WhviT6jwcqcL0uDL0jrZNqLxnJMmPRHTVyM,63508
|
18
18
|
siat/concepts_iwencai.py,sha256=m1YEDtECRT6FqtzlKm91pt2I9d3Z_XoP59BtWdRdu8I,3061
|
19
19
|
siat/concepts_kpl.py,sha256=SJ9UaJp5i79EXKZ3dPa_vBEoG_zgl1Ig5rZAm-ubgM4,4941
|
20
20
|
siat/copyrights.py,sha256=YMLjZb328YpFMR-s_GUu0HBgeGce3pV7DgRut8S3I7w,690
|
@@ -22,7 +22,7 @@ siat/cryptocurrency.py,sha256=SKh_S85cqd2tRgKBKls1Fpd6HdFd9JfmUTCa2e3mpsE,27351
|
|
22
22
|
siat/cryptocurrency_test.py,sha256=3AikTNJ7j-HwLGLIYEfyXZ3bLVuLeru9mwiwHQi2SdA,2669
|
23
23
|
siat/derivative.py,sha256=qV8n09799eqLc26ojR6vN5n_X-xd7rGwdYjgq-wBih8,41483
|
24
24
|
siat/economy-20230125.py,sha256=vxZZlPnLkh7SpGMVEPLwxjt0yYLSVmdZrO-s2NYLyoM,73848
|
25
|
-
siat/economy.py,sha256=
|
25
|
+
siat/economy.py,sha256=sXg0TBp9lh2Hfx5lq97Lk-Zq1OOj3llJqwYBmvoanHk,73720
|
26
26
|
siat/economy_test.py,sha256=6vjNlPz7W125pJb7simCddobSEp3jmLIMvVkLRZ7zW8,13339
|
27
27
|
siat/esg.py,sha256=Kzui78HKwnLvtxWcjjnSjME6IZKK9cR3zSZYqTtAO0k,18941
|
28
28
|
siat/esg_test.py,sha256=Z9m6GUt8O7oHZSEG9aDYpGdvvrv2AiRJdHTiU6jqmZ0,2944
|
@@ -53,7 +53,7 @@ siat/holding_risk.py,sha256=108tiI7DDl8uUZkyUiq6Y-McKeim1mxYsgqgk7CcXw8,30544
|
|
53
53
|
siat/holding_risk_test.py,sha256=FRlw_9wFG98BYcg_cSj95HX5WZ1TvkGaOUdXD7-V86s,474
|
54
54
|
siat/local_debug_test.py,sha256=CDAOffW1Rvs-TcNN5giWVvHMlch1w4dp-w5SIV9jXL0,3936
|
55
55
|
siat/market_china.py,sha256=2_ov1KQwRtHQ6PXNO1TS4-wUPhBuoWla326g0x_xUgQ,31158
|
56
|
-
siat/markowitz.py,sha256=
|
56
|
+
siat/markowitz.py,sha256=t3FDfiYK7gj7fVpOuy_MbpLCYebOsEvhotnx0LoBIkY,91175
|
57
57
|
siat/markowitz_ccb_test.py,sha256=xBkkoaNHdq9KSUrNuHGgKTdNYUvgi84kNYcf719eoyE,1593
|
58
58
|
siat/markowitz_ef_test.py,sha256=wjNlICkgRIqnonPeSIHo4Mu2GRtb9dr21wDt2kMNEcI,4032
|
59
59
|
siat/markowitz_old.py,sha256=Lf7O_4QWT8RsdkHiUyc_7kKY3eZjKDtFR89Fz3pwYnY,33046
|
@@ -76,11 +76,11 @@ siat/risk_free_rate_test.py,sha256=CpmhUf8aEAEZeNu4gvWP2Mz2dLoIgBX5bI41vfUBEr8,4
|
|
76
76
|
siat/sector_china.py,sha256=mTMspgBgd07pesdMhGm-SpTr-rcKts-kaEsIM3kXsjk,58803
|
77
77
|
siat/sector_china_test.py,sha256=tvFQYptmj7jq6H5kNaRJtcP5Wgb-eWvaoSl33Y47ZsM,4210
|
78
78
|
siat/security_price.py,sha256=ibrdUJyt_n0c8oKRbVStE1_ptmWkzy4YIHjpc_fGiPQ,29148
|
79
|
-
siat/security_prices.py,sha256=
|
79
|
+
siat/security_prices.py,sha256=Xl7EHz16qCUIzuPGpEi-g-tLGQKk3MqHmic556-Vs7U,71984
|
80
80
|
siat/security_prices_test.py,sha256=OEphoJ87NPKoNow1QA8EU_5MUYrJF-qKoWKNapVfZNI,10779
|
81
81
|
siat/setup.py,sha256=up65rQGLmTBkhtaMLowjoQXYmIsnycnm4g1SYmeQS6o,1335
|
82
82
|
siat/shenwan index history test.py,sha256=JCVAzOSEldHalhSFa3pqD8JI_8_djPMQOxpkuYU-Esg,1418
|
83
|
-
siat/stock.py,sha256=
|
83
|
+
siat/stock.py,sha256=I-FSS8jLmegIZjMPZhJ36MlZeeRgiMlE2Gt9aAO1oVk,117152
|
84
84
|
siat/stock_advice_linear.py,sha256=-twT7IGP-NEplkL1WPSACcNJjggRB2j4mlAQCkzOAuo,31655
|
85
85
|
siat/stock_base.py,sha256=uISvbRyOGy8p9QREA96CVydgflBkn5L3OXOGKl8oanc,1312
|
86
86
|
siat/stock_china.py,sha256=au0XL1DVR3e1JZdU2gxyepJMPLy0dIb-LPSAiHERnOc,68107
|
@@ -99,12 +99,12 @@ siat/transaction_test.py,sha256=Z8g1LJCN4-mnUByXMUMoFmN0t105cbmsz2QmvSuIkbU,1858
|
|
99
99
|
siat/translate-20230125.py,sha256=NPPSXhT38s5t9fzMvl_fvi4ckSB73ThLmZetVI-xGdU,117953
|
100
100
|
siat/translate-20230206.py,sha256=-vtI125WyaJhmPotOpDAmclt_XnYVaWU9ByLWZ6FyYE,118133
|
101
101
|
siat/translate-20230215.py,sha256=TJgtPE3n8IjljmZ4Pefy8dmHoNdFF-1zpML6BhA9FKE,121657
|
102
|
-
siat/translate.py,sha256=
|
102
|
+
siat/translate.py,sha256=HmVTaKxiV39BAnkidWhcXN0yNqi_WUIi8rrWyYHChyQ,124748
|
103
103
|
siat/universal_test.py,sha256=CDAOffW1Rvs-TcNN5giWVvHMlch1w4dp-w5SIV9jXL0,3936
|
104
104
|
siat/valuation_china.py,sha256=U9FQgFcbJcS-S0cwy8iJ9Z0Rf8sxCN5Pxhm1DItUUgQ,51206
|
105
105
|
siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
|
106
106
|
siat/var_model_validation.py,sha256=zB_Skk_tmzIR15l6oAW3am4HBGVIG-eZ8gJhCdXZ8Qw,14859
|
107
|
-
siat-1.7.
|
108
|
-
siat-1.7.
|
109
|
-
siat-1.7.
|
110
|
-
siat-1.7.
|
107
|
+
siat-1.7.48.dist-info/METADATA,sha256=rATsp778G1p0s_6aGlLe_DAiFIfsCfPOjg13q8uNvwU,1400
|
108
|
+
siat-1.7.48.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
109
|
+
siat-1.7.48.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
110
|
+
siat-1.7.48.dist-info/RECORD,,
|
File without changes
|
File without changes
|