siat 2.14.2__py3-none-any.whl → 3.0.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.
- siat/allin.py +1 -0
- siat/assets_liquidity.py +16 -16
- siat/beta_adjustment.py +6 -6
- siat/beta_adjustment_china.py +9 -9
- siat/bond.py +71 -67
- siat/capm_beta.py +11 -11
- siat/capm_beta2.py +49 -23
- siat/common.py +427 -60
- siat/compare_cross.py +15 -82
- siat/exchange_bond_china.pickle +0 -0
- siat/fama_french.py +3 -3
- siat/financials.py +15 -15
- siat/financials2.py +8 -8
- siat/financials_china.py +20 -20
- siat/financials_china2.py +25 -25
- siat/fund_china.pickle +0 -0
- siat/fund_china.py +5 -4
- siat/grafix.py +195 -132
- siat/markowitz.py +6 -5
- siat/option_china.py +1 -1
- siat/option_pricing.py +6 -6
- siat/risk_adjusted_return.py +14 -14
- siat/risk_adjusted_return2.py +64 -42
- siat/risk_evaluation.py +32 -32
- siat/risk_free_rate.py +0 -0
- siat/sector_china.py +3 -195
- siat/security_price2.py +616 -0
- siat/security_prices.py +935 -308
- siat/security_trend2.py +28 -47
- siat/stock.py +225 -437
- siat/stock_china.py +19 -19
- siat/stock_info.pickle +0 -0
- siat/stock_technical.py +547 -144
- siat/transaction.py +3 -3
- siat/translate.py +781 -24
- siat/valuation.py +6 -6
- siat/var_model_validation.py +2 -2
- {siat-2.14.2.dist-info → siat-3.0.0.dist-info}/METADATA +1 -1
- {siat-2.14.2.dist-info → siat-3.0.0.dist-info}/RECORD +41 -40
- {siat-2.14.2.dist-info → siat-3.0.0.dist-info}/WHEEL +0 -0
- {siat-2.14.2.dist-info → siat-3.0.0.dist-info}/top_level.txt +0 -0
siat/security_trend2.py
CHANGED
@@ -68,6 +68,7 @@ if __name__=='__main__':
|
|
68
68
|
loc1='upper left'
|
69
69
|
loc2='lower right'
|
70
70
|
source='auto'
|
71
|
+
ticker_type='auto'
|
71
72
|
|
72
73
|
df=security_trend(ticker,indicator=indicator)
|
73
74
|
|
@@ -78,7 +79,6 @@ if __name__=='__main__':
|
|
78
79
|
end="2020-6-30"
|
79
80
|
|
80
81
|
|
81
|
-
|
82
82
|
def security_trend(ticker,indicator='Close', \
|
83
83
|
start='default',end='default', \
|
84
84
|
|
@@ -97,7 +97,8 @@ def security_trend(ticker,indicator='Close', \
|
|
97
97
|
preprocess='none',scaling_option='start', \
|
98
98
|
annotate=False,annotate_value=False, \
|
99
99
|
printout=False,source='auto', \
|
100
|
-
mark_top=
|
100
|
+
mark_top=True,mark_bottom=True,mark_end=False, \
|
101
|
+
ticker_type='auto'):
|
101
102
|
|
102
103
|
"""
|
103
104
|
功能:组合指令,分析证券指标走势,支持多个证券、多个指标和多种绘图方式。
|
@@ -164,6 +165,7 @@ def security_trend(ticker,indicator='Close', \
|
|
164
165
|
若指定雅虎财经数据源,需要拥有访问该网站的权限。
|
165
166
|
"""
|
166
167
|
portfolio_flag=False #标志:ticker中是否含有投资组合
|
168
|
+
ticker=tickers_cvt2yahoo(ticker) #支持多种形式证券代码格式
|
167
169
|
|
168
170
|
# 检查证券代码
|
169
171
|
if isinstance(ticker,str):
|
@@ -193,7 +195,7 @@ def security_trend(ticker,indicator='Close', \
|
|
193
195
|
# 处理K线图=================================================================
|
194
196
|
if kline and not kline_demo:
|
195
197
|
if portfolio_flag:
|
196
|
-
print(" #
|
198
|
+
print(" #Warning(security_trend): ticker of or with portfolio does not support for K line")
|
197
199
|
return None
|
198
200
|
|
199
201
|
# 跟踪
|
@@ -202,24 +204,24 @@ def security_trend(ticker,indicator='Close', \
|
|
202
204
|
fromdate=date_adjust(todate,adjust=-60)
|
203
205
|
if not isinstance(mav,list):
|
204
206
|
mav=[mav]
|
205
|
-
df=candlestick(stkcd=tickers[0],fromdate=fromdate,todate=todate,mav=mav)
|
207
|
+
df=candlestick(stkcd=tickers[0],fromdate=fromdate,todate=todate,mav=mav,ticker_type=ticker_type)
|
206
208
|
return df
|
207
209
|
|
208
210
|
if kline and kline_demo:
|
209
211
|
if portfolio_flag:
|
210
|
-
print(" #
|
212
|
+
print(" #Warning(security_trend): ticker of or with portfolio does not support for K line")
|
211
213
|
return None
|
212
214
|
|
213
215
|
if start in ['default']:
|
214
216
|
fromdate=date_adjust(todate,adjust=-7)
|
215
217
|
|
216
|
-
df=candlestick_demo(tickers[0],fromdate=fromdate,todate=todate)
|
218
|
+
df=candlestick_demo(tickers[0],fromdate=fromdate,todate=todate,ticker_type=ticker_type)
|
217
219
|
return df
|
218
220
|
|
219
221
|
# 处理股票分红和股票分拆:需要访问雅虎财经=====================================
|
220
222
|
if stock_dividend:
|
221
223
|
if portfolio_flag:
|
222
|
-
print(" #
|
224
|
+
print(" #Warning(security_trend): ticker of or with portfolio does not support for stock dividend")
|
223
225
|
return None
|
224
226
|
|
225
227
|
if start in ['default']:
|
@@ -230,7 +232,7 @@ def security_trend(ticker,indicator='Close', \
|
|
230
232
|
|
231
233
|
if stock_split:
|
232
234
|
if portfolio_flag:
|
233
|
-
print(" #
|
235
|
+
print(" #Warning(security_trend): ticker of or with portfolio does not support for stock split")
|
234
236
|
return None
|
235
237
|
|
236
238
|
if start in ['default']:
|
@@ -331,10 +333,11 @@ def security_trend(ticker,indicator='Close', \
|
|
331
333
|
return None
|
332
334
|
|
333
335
|
#检查指标是否支持投资组合:暂不支持组1/3的指标
|
336
|
+
"""
|
334
337
|
if portfolio_flag and (indicator_group1 or indicator_group3):
|
335
|
-
print(" #
|
338
|
+
print(" #Warning(security_trend): ticker of or with portfolio does not support indicator",list2str(measures))
|
336
339
|
return None
|
337
|
-
|
340
|
+
"""
|
338
341
|
# 情形1:单个证券,单个普通指标===============================================
|
339
342
|
# 绘制横线
|
340
343
|
zeroline=False
|
@@ -348,15 +351,17 @@ def security_trend(ticker,indicator='Close', \
|
|
348
351
|
zeroline=zeroline, \
|
349
352
|
average_value=average_value, \
|
350
353
|
datatag=datatag,power=power,graph=graph, \
|
351
|
-
source=source,
|
352
|
-
mark_top=mark_top,mark_bottom=mark_bottom,
|
354
|
+
source=source, \
|
355
|
+
mark_top=mark_top,mark_bottom=mark_bottom, \
|
356
|
+
mark_end=mark_end,ticker_type=ticker_type)
|
353
357
|
return df
|
354
358
|
|
355
359
|
# 情形2:单个证券,两个普通指标,twinx==True =================================
|
356
360
|
if ticker_num==1 and indicator_num == 2 and indicator_group1 and twinx:
|
357
361
|
df=compare_security(tickers=tickers[0],measures=measures[:2], \
|
358
362
|
fromdate=fromdate,todate=todate,twinx=twinx, \
|
359
|
-
loc1=loc1,loc2=loc2,graph=graph,source=source
|
363
|
+
loc1=loc1,loc2=loc2,graph=graph,source=source, \
|
364
|
+
ticker_type=ticker_type)
|
360
365
|
return df
|
361
366
|
|
362
367
|
# 情形3:单个证券,两个及以上普通指标=========================================
|
@@ -367,14 +372,16 @@ def security_trend(ticker,indicator='Close', \
|
|
367
372
|
date_range=date_range,date_freq=date_freq, \
|
368
373
|
annotate=annotate,annotate_value=annotate_value, \
|
369
374
|
source=source,
|
370
|
-
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end
|
375
|
+
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
376
|
+
ticker_type=ticker_type)
|
371
377
|
return df
|
372
378
|
|
373
379
|
# 情形4:两个证券,取第一个普通指标,twinx==True =============================
|
374
380
|
if ticker_num==2 and indicator_group1 and twinx:
|
375
381
|
df=compare_security(tickers=tickers,measures=measures[0], \
|
376
382
|
fromdate=fromdate,todate=todate,twinx=twinx, \
|
377
|
-
loc1=loc1,loc2=loc2,graph=graph,source=source
|
383
|
+
loc1=loc1,loc2=loc2,graph=graph,source=source, \
|
384
|
+
ticker_type=ticker_type)
|
378
385
|
return df
|
379
386
|
|
380
387
|
# 情形5:两个及以上证券,取第一个普通指标=====================================
|
@@ -403,7 +410,8 @@ def security_trend(ticker,indicator='Close', \
|
|
403
410
|
annotate=annotate,annotate_value=annotate_value, \
|
404
411
|
smooth=smooth, \
|
405
412
|
source=source, \
|
406
|
-
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end
|
413
|
+
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
414
|
+
ticker_type=ticker_type)
|
407
415
|
return df
|
408
416
|
|
409
417
|
# 情形6:单个或多个证券,单个或多个RAR指标,支持投资组合=======================
|
@@ -414,48 +422,21 @@ def security_trend(ticker,indicator='Close', \
|
|
414
422
|
graph=graph,axhline_value=0,axhline_label='', \
|
415
423
|
printout=printout, \
|
416
424
|
sortby=sortby,trailing=trailing,trend_threshhold=trend_threshhold, \
|
417
|
-
annotate=annotate,mktidx=market_index,source=source
|
418
|
-
|
419
|
-
df=compare_1security_mrar(ticker=tickers[0],rar_names=measures, \
|
420
|
-
start=fromdate,end=todate, \
|
421
|
-
market=market,market_index=market_index,RF=RF,window=window, \
|
422
|
-
axhline_value=0,axhline_label='零线',graph=graph,printout=printout, \
|
423
|
-
sortby=sortby,source=source,trailing=trailing,trend_threshhold=trend_threshhold, \
|
424
|
-
annotate=annotate)
|
425
|
-
"""
|
425
|
+
annotate=annotate,mktidx=market_index,source=source, \
|
426
|
+
ticker_type=ticker_type)
|
426
427
|
return df
|
427
428
|
|
428
|
-
"""
|
429
|
-
# 情形7:多个证券,取第一个RAR指标===========================================
|
430
|
-
# 特别注意:与收益率对比时若使用扩展收益率可能导致矛盾,要使用滚动收益率
|
431
|
-
if indicator_group2 and ticker_num > 1:
|
432
|
-
df=compare_mrar(tickers=tickers,rar_name=measures[0], \
|
433
|
-
start=fromdate,end=todate, \
|
434
|
-
market=market,market_index=market_index,RF=RF,window=window, \
|
435
|
-
axhline_value=0,axhline_label='零线',graph=graph,printout=printout, \
|
436
|
-
sortby=sortby,source=source,trailing=trailing,trend_threshhold=trend_threshhold, \
|
437
|
-
annotate=annotate)
|
438
|
-
return df
|
439
|
-
"""
|
440
429
|
# 情形7:单个或多个证券,CAPM贝塔系数=========================================
|
441
430
|
if indicator_group4:
|
442
431
|
df=compare_beta_security(ticker=tickers,start=fromdate,end=todate, \
|
443
432
|
RF=RF,regression_period=regression_period, \
|
444
433
|
graph=graph,annotate=annotate, \
|
445
|
-
mktidx=market_index,source=source)
|
434
|
+
mktidx=market_index,source=source,ticker_type=ticker_type)
|
446
435
|
|
447
|
-
"""
|
448
|
-
df=compare_mrar(tickers=tickers,rar_name=measures[0], \
|
449
|
-
start=fromdate,end=todate, \
|
450
|
-
market=market,market_index=market_index,RF=RF,window=window, \
|
451
|
-
axhline_value=0,axhline_label='零线',graph=graph,printout=printout, \
|
452
|
-
sortby=sortby,source=source,trailing=trailing,trend_threshhold=trend_threshhold, \
|
453
|
-
annotate=annotate)
|
454
|
-
"""
|
455
436
|
return df
|
456
437
|
|
457
438
|
|
458
|
-
# 情形8:估值指标PE/PB/MV/ROE
|
439
|
+
# 情形8:估值指标PE/PB/MV/ROE,仅针对股票,无需ticker_type====================
|
459
440
|
if indicator_group3:
|
460
441
|
df=security_valuation(tickers=tickers,indicators=measures,start=fromdate,end=todate, \
|
461
442
|
preprocess=preprocess,scaling_option=scaling_option, \
|