siat 3.5.12__py3-none-any.whl → 3.6.1__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.
@@ -114,7 +114,12 @@ def get_rolling_sharpe_sortino(ticker,start,end,rar_name="sharpe", \
114
114
  RF_period=RF
115
115
 
116
116
  #收益率减去一个常数其实不影响其标准差的数值,即std(ret-RF)=std(ret)
117
- rardf2[ret_type]=rardf2[ret_type] - RF_period
117
+ try:
118
+ rardf2[ret_type]=rardf2[ret_type] - RF_period
119
+ except:
120
+ print(" #Warning(get_rolling_sharpe_sortino): unsupported ret_type",ret_type)
121
+ return None
122
+
118
123
  rardf3=rolling_ret_volatility(rardf2, period=ret_period)
119
124
  rardf4=rolling_ret_lpsd(rardf3, period=ret_period)
120
125
 
@@ -269,7 +274,7 @@ if __name__=='__main__':
269
274
  alpha2y=get_rolling_treynor_alpha(ticker,start,end,rar_name="alpha",ret_type="Annual Ret%",RF=0.01759)
270
275
 
271
276
  def get_rolling_treynor_alpha(ticker,start,end,rar_name="alpha", \
272
- ret_type="Monthly Ret%",RF=0, \
277
+ ret_type="Monthly Adj Ret%",RF=0, \
273
278
  regression_period=365,mktidx='auto',source='auto',ticker_type='auto'):
274
279
  """
275
280
  功能:获取一只股票的特雷诺比率或阿尔法指数,基于给定的滚动收益率类型,在指定期间内
@@ -804,6 +809,9 @@ if __name__=='__main__':
804
809
 
805
810
  def compare_1ticker_mrar(ticker,start,end,rar=['sharpe','sortino','treynor','alpha'], \
806
811
  ret_type="Annual Adj Ret%",RF=0,regression_period=365, \
812
+ attention_value='', \
813
+ attention_point='', \
814
+
807
815
  graph=True,loc1='best', \
808
816
  axhline_value=0,axhline_label='',facecolor='whitesmoke', \
809
817
  printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
@@ -904,6 +912,9 @@ def compare_1ticker_mrar(ticker,start,end,rar=['sharpe','sortino','treynor','alp
904
912
  draw_lines(df1,y_label,x_label=footnotex, \
905
913
  axhline_value=axhline_value,axhline_label=axhline_label, \
906
914
  title_txt=title_txt,data_label=False, \
915
+ attention_value=attention_value, \
916
+ attention_point=attention_point, \
917
+
907
918
  annotate=annotate,annotate_value=annotate, \
908
919
  mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
909
920
  facecolor=facecolor,loc=loc1)
@@ -962,7 +973,9 @@ if __name__=='__main__':
962
973
  rars=compare_mticker_1rar(ticker=["600519.SS","000858.SZ"],start="2024-1-1",end="2024-6-16",rar='sharpe',printout=True)
963
974
 
964
975
  def compare_mticker_1rar(ticker,start,end,rar='sharpe', \
965
- ret_type="Annual Ret%",RF=0,regression_period=365, \
976
+ ret_type="Annual Adj Ret%",RF=0,regression_period=365, \
977
+ attention_value='', \
978
+ attention_point='', \
966
979
  graph=True,loc1='best', \
967
980
  axhline_value=0,axhline_label='', \
968
981
  printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
@@ -1084,6 +1097,9 @@ def compare_mticker_1rar(ticker,start,end,rar='sharpe', \
1084
1097
  draw_lines(df1,y_label,x_label=footnotex, \
1085
1098
  axhline_value=axhline_value,axhline_label=axhline_label, \
1086
1099
  title_txt=title_txt,data_label=False, \
1100
+ attention_value=attention_value, \
1101
+ attention_point=attention_point, \
1102
+
1087
1103
  annotate=annotate,annotate_value=annotate, \
1088
1104
  mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
1089
1105
  facecolor=facecolor,loc=loc1)
@@ -1138,7 +1154,9 @@ if __name__=='__main__':
1138
1154
  rars=compare_mticker_mrar(ticker,start,end,rar,graph=False,printout=True)
1139
1155
 
1140
1156
  def compare_mticker_mrar(ticker,start,end,rar=['sharpe','alpha','sortino','treynor'], \
1141
- ret_type="Annual Ret%",RF=0,regression_period=365, \
1157
+ ret_type="Annual Adj Ret%",RF=0,regression_period=365, \
1158
+ attention_value='', \
1159
+ attention_point='', \
1142
1160
  graph=True,loc1='best', \
1143
1161
  axhline_value=0,axhline_label='', \
1144
1162
  printout=True,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
@@ -1167,6 +1185,8 @@ def compare_mticker_mrar(ticker,start,end,rar=['sharpe','alpha','sortino','treyn
1167
1185
  #with HiddenPrints(): #此项将压制所有print输出,造成表头脚注不显示
1168
1186
  _,df_tmp=compare_mticker_1rar(ticker=ticker,start=start,end=end,rar=r, \
1169
1187
  ret_type=ret_type,RF=RF,regression_period=regression_period, \
1188
+ attention_value=attention_value, \
1189
+ attention_point=attention_point, \
1170
1190
  graph=graph,facecolor=facecolor, \
1171
1191
  axhline_value=axhline_value,axhline_label=axhline_label, \
1172
1192
  printout=printout,sortby=sortby, \
@@ -1340,8 +1360,10 @@ if __name__=='__main__':
1340
1360
  rars=compare_1ticker_1rar_mret(ticker,start,end,rar,ret_type,printout=True)
1341
1361
 
1342
1362
  def compare_1ticker_1rar_mret(ticker,start,end,rar='sharpe', \
1343
- ret_type=["Annual Ret%","Monthly Ret%"], \
1363
+ ret_type=["Annual Adj Ret%","Monthly Adj Ret%"], \
1344
1364
  RF=0,regression_period=365, \
1365
+ attention_value='', \
1366
+ attention_point='', \
1345
1367
  graph=True,loc1='best', \
1346
1368
  axhline_value=0,axhline_label='',facecolor='whitesmoke', \
1347
1369
  printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
@@ -1373,7 +1395,7 @@ def compare_1ticker_1rar_mret(ticker,start,end,rar='sharpe', \
1373
1395
  RF=RF[0]
1374
1396
  if isinstance(regression_period,list):
1375
1397
  regression_period=regression_period[0]
1376
- print(" Starting to retrieve and calculate",rar,"for",ticker_name(ticker,ticker_type),"on different types of return, please wait ......\n")
1398
+ print(" Working on",rar,"for",ticker_name(ticker,ticker_type),"in different returns, please wait ......\n")
1377
1399
 
1378
1400
  df=pd.DataFrame()
1379
1401
  for t in ret_type:
@@ -1435,6 +1457,8 @@ def compare_1ticker_1rar_mret(ticker,start,end,rar='sharpe', \
1435
1457
  draw_lines(df1,y_label,x_label=footnotex, \
1436
1458
  axhline_value=axhline_value,axhline_label=axhline_label, \
1437
1459
  title_txt=title_txt,data_label=False, \
1460
+ attention_value=attention_value, \
1461
+ attention_point=attention_point, \
1438
1462
  annotate=annotate,annotate_value=annotate, \
1439
1463
  mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
1440
1464
  facecolor=facecolor,loc=loc1)
@@ -1490,7 +1514,9 @@ if __name__=='__main__':
1490
1514
  rars=compare_1ticker_1rar_1ret_mRF(ticker,start,end,rar,ret_type,RF)
1491
1515
 
1492
1516
  def compare_1ticker_1rar_1ret_mRF(ticker,start,end,rar='sharpe', \
1493
- ret_type="Annual Ret%",RF=[0,0.02,0.05],regression_period=365, \
1517
+ ret_type="Annual Adj Ret%",RF=[0,0.02,0.05],regression_period=365, \
1518
+ attention_value='', \
1519
+ attention_point='', \
1494
1520
  graph=True,loc1='best', \
1495
1521
  axhline_value=0,axhline_label='',facecolor='whitesmoke', \
1496
1522
  printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
@@ -1579,6 +1605,8 @@ def compare_1ticker_1rar_1ret_mRF(ticker,start,end,rar='sharpe', \
1579
1605
  draw_lines(df1,y_label,x_label=footnotex, \
1580
1606
  axhline_value=axhline_value,axhline_label=axhline_label, \
1581
1607
  title_txt=title_txt,data_label=False, \
1608
+ attention_value=attention_value, \
1609
+ attention_point=attention_point, \
1582
1610
  annotate=annotate,annotate_value=annotate, \
1583
1611
  mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
1584
1612
  facecolor=facecolor,loc=loc1)
@@ -1652,6 +1680,8 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
1652
1680
  ret_type="Annual Adj Ret%", \
1653
1681
  RF=0, \
1654
1682
  regression_period=365, \
1683
+ attention_value='', \
1684
+ attention_point='', \
1655
1685
  graph=True,loc1='best', \
1656
1686
  axhline_value=0,axhline_label='',facecolor='whitesmoke', \
1657
1687
  printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.05, \
@@ -1683,6 +1713,9 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
1683
1713
  if rar_num ==1: #一个RAR
1684
1714
  df=compare_mticker_1rar(ticker=ticker,start=start,end=end,rar=rar, \
1685
1715
  ret_type=ret_type,RF=RF,regression_period=regression_period, \
1716
+ attention_value=attention_value, \
1717
+ attention_point=attention_point, \
1718
+
1686
1719
  graph=graph,loc1=loc1, \
1687
1720
  axhline_value=axhline_value,axhline_label=axhline_label, \
1688
1721
  printout=printout, \
@@ -1697,6 +1730,9 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
1697
1730
  printout=True #否则无法运行descriptive_statistics2函数
1698
1731
  df=compare_mticker_mrar(ticker=ticker,start=start,end=end,rar=rar, \
1699
1732
  ret_type=ret_type,RF=RF,regression_period=regression_period, \
1733
+ attention_value=attention_value, \
1734
+ attention_point=attention_point, \
1735
+
1700
1736
  graph=graph,loc1=loc1, \
1701
1737
  axhline_value=axhline_value,axhline_label=axhline_label, \
1702
1738
  printout=printout, \
@@ -1720,6 +1756,9 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
1720
1756
 
1721
1757
  df=compare_1ticker_mrar(ticker=ticker,start=start,end=end,rar=rar, \
1722
1758
  ret_type=ret_type,RF=RF,regression_period=regression_period, \
1759
+ attention_value=attention_value, \
1760
+ attention_point=attention_point, \
1761
+
1723
1762
  graph=graph,loc1=loc1, \
1724
1763
  axhline_value=axhline_value,axhline_label=axhline_label, \
1725
1764
  printout=printout,facecolor=facecolor, \
@@ -1741,6 +1780,9 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
1741
1780
 
1742
1781
  df=compare_1ticker_1rar_mret(ticker=ticker,start=start,end=end,rar=rar, \
1743
1782
  ret_type=ret_type,RF=RF,regression_period=regression_period, \
1783
+ attention_value=attention_value, \
1784
+ attention_point=attention_point, \
1785
+
1744
1786
  graph=graph,loc1=loc1, \
1745
1787
  axhline_value=axhline_value,axhline_label=axhline_label, \
1746
1788
  printout=printout, \
@@ -1760,6 +1802,9 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
1760
1802
 
1761
1803
  df=compare_1ticker_1rar_1ret_mRF(ticker=ticker,start=start,end=end,rar=rar, \
1762
1804
  ret_type=ret_type,RF=RF,regression_period=regression_period, \
1805
+ attention_value=attention_value, \
1806
+ attention_point=attention_point, \
1807
+
1763
1808
  graph=graph,loc1=loc1, \
1764
1809
  axhline_value=axhline_value,axhline_label=axhline_label, \
1765
1810
  printout=printout,facecolor=facecolor, \
@@ -1776,6 +1821,9 @@ def compare_rar_security(ticker,start,end,rar='sharpe', \
1776
1821
  #情形5:1只证券,1个RAR,1个收益率类型,1个RF
1777
1822
  df=compare_1ticker_mrar(ticker=ticker,start=start,end=end,rar=rar, \
1778
1823
  ret_type=ret_type,RF=RF,regression_period=regression_period, \
1824
+ attention_value=attention_value, \
1825
+ attention_point=attention_point, \
1826
+
1779
1827
  graph=graph,loc1=loc1, \
1780
1828
  axhline_value=axhline_value,axhline_label=axhline_label, \
1781
1829
  printout=printout,sortby=sortby, \
siat/security_trend2.py CHANGED
@@ -123,21 +123,28 @@ if __name__=='__main__':
123
123
 
124
124
  def security_trend(ticker,indicator='Close',adjust='', \
125
125
  start='default',end='default', \
126
-
126
+ #纵轴水平线
127
127
  attention_value='',average_value=False, \
128
+ #横轴垂直线
129
+ attention_point='', \
128
130
 
129
- kline=False,kline_demo=False,mav=[5,10,20], \
131
+ kline=False,kline_demo=False,mav=[5,20], \
130
132
 
131
133
  dividend=False,split=False, \
132
-
134
+
135
+ #计算RAR和贝塔系数的基础参数
133
136
  ret_type='Annual Adj Ret%',RF=0,regression_period=365,market_index="auto", \
134
137
  sortby='tpw_mean',trailing=7,trend_threshhold=0.05, \
135
-
138
+
139
+ #绘制河流图的上下边界
136
140
  band_area='', \
141
+
142
+
137
143
  graph=True,twinx=False,loc1='best',loc2='best', \
138
144
  datatag=False,power=0, \
139
145
  smooth=True,date_range=False,date_freq=False, \
140
-
146
+
147
+ #数据预处理
141
148
  preprocess='none',scaling_option='change%', \
142
149
 
143
150
  annotate=False,annotate_value=False, \
@@ -211,7 +218,9 @@ def security_trend(ticker,indicator='Close',adjust='', \
211
218
  source参数:指定证券基础数据来源,默认由系统决定。当系统找到的数据不理想时,可手动指定。
212
219
  若指定雅虎财经数据源,需要拥有访问该网站的权限。
213
220
  """
214
- critical_value=attention_value
221
+ DEBUG=False
222
+
223
+ #critical_value=attention_value
215
224
 
216
225
  portfolio_flag=False #标志:ticker中是否含有投资组合
217
226
  ticker=tickers_cvt2yahoo(ticker) #支持多种形式证券代码格式
@@ -307,8 +316,9 @@ def security_trend(ticker,indicator='Close',adjust='', \
307
316
  # 检查趋势指标
308
317
  indicator_list1=['Open','Close','Adj Close','High','Low',
309
318
  'Daily Ret','Daily Ret%','Daily Adj Ret','Daily Adj Ret%',
310
- 'log(Daily Ret)','log(Daily Adj Ret)','Weekly Ret','Weekly Ret%',
311
- 'Weekly Adj Ret','Weekly Adj Ret%','Monthly Ret','Monthly Ret%',
319
+ 'log(Daily Ret)','log(Daily Adj Ret)',
320
+ 'Weekly Ret','Weekly Ret%','Weekly Adj Ret','Weekly Adj Ret%',
321
+ 'Monthly Ret','Monthly Ret%',
312
322
  'Monthly Adj Ret','Monthly Adj Ret%','Quarterly Ret','Quarterly Ret%',
313
323
  'Quarterly Adj Ret','Quarterly Adj Ret%','Annual Ret','Annual Ret%',
314
324
  'Annual Adj Ret','Annual Adj Ret%','Exp Ret','Exp Ret%','Exp Adj Ret',
@@ -327,7 +337,8 @@ def security_trend(ticker,indicator='Close',adjust='', \
327
337
  'Annual Adj Ret Volatility', 'Annual Adj Ret Volatility%',
328
338
  'Exp Ret Volatility', 'Exp Ret Volatility%', 'Exp Adj Ret Volatility',
329
339
  'Exp Adj Ret Volatility%', 'Weekly Ret LPSD', 'Weekly Ret LPSD%',
330
- 'Weekly Adj Ret LPSD', 'Weekly Adj Ret LPSD%', 'Monthly Ret LPSD',
340
+ 'Weekly Adj Ret LPSD', 'Weekly Adj Ret LPSD%',
341
+ 'Monthly Ret LPSD',
331
342
  'Monthly Ret LPSD%', 'Monthly Adj Ret LPSD', 'Monthly Adj Ret LPSD%',
332
343
  'Quarterly Ret LPSD', 'Quarterly Ret LPSD%', 'Quarterly Adj Ret LPSD',
333
344
  'Quarterly Adj Ret LPSD%', 'Annual Ret LPSD', 'Annual Ret LPSD%',
@@ -390,17 +401,20 @@ def security_trend(ticker,indicator='Close',adjust='', \
390
401
  return None
391
402
  """
392
403
  # 情形1:单个证券,单个普通指标===============================================
393
- # 绘制横线
404
+ # 绘制零线:由绘图函数自动判断
394
405
  zeroline=False
406
+ """
395
407
  if (critical_value != ''):
396
408
  if isinstance(critical_value,float) or isinstance(critical_value,int):
397
409
  zeroline=critical_value
398
-
410
+ """
399
411
  if ticker_num==1 and indicator_num==1 and indicator_group1:
400
412
  df=security_indicator(ticker=tickers[0],indicator=measures[0],adjust=adjust, \
401
413
  fromdate=fromdate,todate=todate, \
402
414
  zeroline=zeroline, \
415
+ attention_value=attention_value, \
403
416
  average_value=average_value, \
417
+ attention_point=attention_point, \
404
418
  datatag=datatag,power=power,graph=graph, \
405
419
  source=source, \
406
420
  mark_top=mark_top,mark_bottom=mark_bottom, \
@@ -410,18 +424,32 @@ def security_trend(ticker,indicator='Close',adjust='', \
410
424
 
411
425
  # 情形2:单个证券,两个普通指标,twinx==True =================================
412
426
  if ticker_num==1 and indicator_num == 2 and indicator_group1 and twinx:
427
+ if DEBUG:
428
+ print("Scenario 2: ticker_num==1 and indicator_num == 2 and indicator_group1 and twinx")
429
+ print("attention_value=",attention_value)
430
+ print("attention_point=",attention_point)
431
+
413
432
  df=compare_security(tickers=tickers[0],measures=measures[:2], \
414
433
  adjust=adjust, \
415
434
  fromdate=fromdate,todate=todate,twinx=twinx, \
435
+ attention_value=attention_value, \
436
+ attention_point=attention_point, \
416
437
  loc1=loc1,loc2=loc2,graph=graph,source=source, \
417
438
  ticker_type=ticker_type,facecolor=facecolor)
418
439
  return df
419
440
 
420
441
  # 情形3:单个证券,两个及以上普通指标,twinx==False ==========================
421
442
  if ticker_num==1 and indicator_num >= 2 and indicator_group1 and not twinx:
443
+ if DEBUG:
444
+ print("Scenario 3: ticker_num==1 and indicator_num >= 2 and indicator_group1 and not twinx")
445
+ print("attention_value=",attention_value)
446
+ print("attention_point=",attention_point)
447
+
422
448
  df=security_mindicators(ticker=tickers[0],measures=measures, \
423
449
  adjust=adjust, \
424
450
  fromdate=fromdate,todate=todate, \
451
+ attention_value=attention_value, \
452
+ attention_point=attention_point, \
425
453
  graph=graph,smooth=smooth,band_area=band_area,loc=loc1, \
426
454
  date_range=date_range,date_freq=date_freq, \
427
455
  annotate=annotate,annotate_value=annotate_value, \
@@ -432,9 +460,16 @@ def security_trend(ticker,indicator='Close',adjust='', \
432
460
 
433
461
  # 情形4:两个证券,取第一个普通指标,twinx==True =============================
434
462
  if ticker_num==2 and indicator_group1 and twinx:
463
+ if DEBUG:
464
+ print("Scenario 4: ticker_num==2 and indicator_group1 and twinx")
465
+ print("attention_value=",attention_value)
466
+ print("attention_point=",attention_point)
467
+
435
468
  df=compare_security(tickers=tickers,measures=measures[0], \
436
469
  adjust=adjust, \
437
470
  fromdate=fromdate,todate=todate,twinx=twinx, \
471
+ attention_value=attention_value, \
472
+ attention_point=attention_point, \
438
473
  loc1=loc1,loc2=loc2,graph=graph,source=source, \
439
474
  ticker_type=ticker_type,facecolor=facecolor)
440
475
  return df
@@ -450,14 +485,22 @@ def security_trend(ticker,indicator='Close',adjust='', \
450
485
  # 绘制横线
451
486
  axhline_value=0
452
487
  axhline_label=''
488
+ """
453
489
  if (critical_value != ''):
454
490
  if isinstance(critical_value,float) or isinstance(critical_value,int):
455
491
  axhline_value=critical_value
456
492
  axhline_label='零线'
457
-
493
+ """
458
494
  if ((ticker_num == 2 and not twinx) or ticker_num > 2) and indicator_group1:
495
+ if DEBUG:
496
+ print("Scenario 5: ((ticker_num == 2 and not twinx) or ticker_num > 2) and indicator_group1")
497
+ print("attention_value=",attention_value)
498
+ print("attention_point=",attention_point)
499
+
459
500
  df=compare_msecurity(tickers=tickers,measure=measures[0], \
460
501
  start=fromdate,end=todate, \
502
+ attention_value=attention_value, \
503
+ attention_point=attention_point, \
461
504
  adjust=adjust, \
462
505
  axhline_value=axhline_value,axhline_label=axhline_label, \
463
506
  preprocess=preprocess,linewidth=linewidth, \
@@ -474,8 +517,15 @@ def security_trend(ticker,indicator='Close',adjust='', \
474
517
  # 注意:收益率类型支持滚动收益率和扩展收益率,但不建议混合使用,因为难以解释结果
475
518
  # 复权价:使用ret_type为xx Adj Ret%即可
476
519
  if indicator_group2:
520
+ if DEBUG:
521
+ print("Scenario 6: indicator_group2 RAR")
522
+ print("attention_value=",attention_value)
523
+ print("attention_point=",attention_point)
524
+
477
525
  df=compare_rar_security(ticker=tickers,start=fromdate,end=todate,rar=measures, \
478
526
  ret_type=ret_type,RF=RF,regression_period=regression_period, \
527
+ attention_value=attention_value, \
528
+ attention_point=attention_point, \
479
529
  graph=graph,axhline_value=0,axhline_label='', \
480
530
  loc1=loc1, \
481
531
  printout=printout, \
@@ -491,7 +541,10 @@ def security_trend(ticker,indicator='Close',adjust='', \
491
541
  df=compare_beta_security(ticker=tickers,start=fromdate,end=todate, \
492
542
  adjust=adjust, \
493
543
  RF=RF,regression_period=regression_period, \
494
- graph=graph,facecolor=facecolor, \
544
+ attention_value=attention_value, \
545
+ attention_point=attention_point, \
546
+
547
+ graph=graph,facecolor=facecolor,loc=loc1, \
495
548
  annotate=annotate,annotate_value=annotate_value, \
496
549
  mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
497
550
  mktidx=market_index,source=source, \
@@ -506,12 +559,15 @@ def security_trend(ticker,indicator='Close',adjust='', \
506
559
  preprocess=preprocess,scaling_option=scaling_option, \
507
560
  twinx=twinx,loc1=loc1,loc2=loc2, \
508
561
  graph=graph,facecolor=facecolor, \
562
+ attention_value=attention_value, \
563
+ attention_point=attention_point, \
564
+
509
565
  annotate=annotate,annotate_value=annotate_value, \
510
566
  mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end)
511
567
  return df
512
568
 
513
569
  # 其他未预料情形
514
- print(" #Error(security_trend): unsupported combination of security(ies) and indicator(s):-(")
570
+ print(" #Warning(security_trend): unexpected combination of security(ies) and indicator(s):-(")
515
571
 
516
572
  return None
517
573
 
siat/stock.py CHANGED
@@ -630,7 +630,9 @@ if __name__ =="__main__":
630
630
  def security_indicator(ticker,indicator, \
631
631
  fromdate,todate,adjust='', \
632
632
  zeroline=False, \
633
+ attention_value='', \
633
634
  average_value=False, \
635
+ attention_point='', \
634
636
  datatag=False,power=0,graph=True,source='auto', \
635
637
  mark_top=True,mark_bottom=True,mark_end=True, \
636
638
  ticker_type='auto',facecolor='whitesmoke'):
@@ -739,7 +741,10 @@ def security_indicator(ticker,indicator, \
739
741
  zeroline=True
740
742
 
741
743
  plot_line(erdf3,indicator,collabel,ylabeltxt,titletxt,footnote,datatag=datatag, \
742
- power=power,zeroline=zeroline,average_value=average_value, \
744
+ power=power,zeroline=zeroline, \
745
+ attention_value=attention_value, \
746
+ average_value=average_value, \
747
+ attention_point=attention_point, \
743
748
  mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
744
749
  facecolor=facecolor)
745
750
 
@@ -860,6 +865,8 @@ if __name__ =="__main__":
860
865
 
861
866
  def security_mindicators(ticker,measures,
862
867
  fromdate,todate, \
868
+ attention_value='', \
869
+ attention_point='', \
863
870
  adjust='', \
864
871
  band_area='', \
865
872
  graph=True,smooth=True,loc='best',facecolor='whitesmoke', \
@@ -969,6 +976,8 @@ def security_mindicators(ticker,measures,
969
976
  draw_lines2(df,y_label,x_label,axhline_value,axhline_label,titletxt, \
970
977
  data_label=False,resample_freq='6H',smooth=smooth, \
971
978
  date_range=date_range,date_freq=date_freq,date_fmt='%Y-%m-%d', \
979
+ attention_value=attention_value, \
980
+ attention_point=attention_point, \
972
981
  annotate=annotate,annotate_value=annotate_value, \
973
982
  mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end,facecolor=facecolor, \
974
983
  band_area=band_area,loc=loc)
@@ -1337,6 +1346,8 @@ if __name__ =="__main__":
1337
1346
  pv=price_lpsd2(df,"000002.SZ","2019-1-1","2020-3-16","Annual Exp Price Volatility")
1338
1347
  #==============================================================================
1339
1348
  def comp_1security_2measures(df,measure1,measure2,twinx=False, \
1349
+ attention_value='', \
1350
+ attention_point='', \
1340
1351
  loc1='upper left',loc2='lower left', \
1341
1352
  graph=True,facecolor='whitesmoke', \
1342
1353
  ticker_type='auto'):
@@ -1346,6 +1357,8 @@ def comp_1security_2measures(df,measure1,measure2,twinx=False, \
1346
1357
  输出:绘制证券行情双折线图,基于twinx判断使用单轴或双轴坐标
1347
1358
  返回:无
1348
1359
  """
1360
+ DEBUG=False
1361
+
1349
1362
  #筛选证券指标,检验是否支持指标
1350
1363
  dfcols=list(df)
1351
1364
  #nouselist=['date','Weekday','ticker']
@@ -1382,8 +1395,15 @@ def comp_1security_2measures(df,measure1,measure2,twinx=False, \
1382
1395
  footnote=footnote1+str(todaydt)
1383
1396
 
1384
1397
  #绘图
1398
+ if DEBUG:
1399
+ print("plot_line2")
1400
+ print("attention_value=",attention_value)
1401
+ print("attention_point=",attention_point)
1402
+
1385
1403
  plot_line2(df,ticker,measure1,label1,df,ticker,measure2,label2, \
1386
1404
  ylabeltxt,titletxt,footnote,zeroline=zeroline,twinx=twinx, \
1405
+ yline=attention_value, \
1406
+ xline=attention_point, \
1387
1407
  loc1=loc1,loc2=loc2,facecolor=facecolor)
1388
1408
 
1389
1409
  return
@@ -1398,6 +1418,8 @@ if __name__ =="__main__":
1398
1418
  comp_1security_2measures(df,measure1,measure2)
1399
1419
  #==============================================================================
1400
1420
  def comp_2securities_1measure(df1,df2,measure,twinx=False, \
1421
+ attention_value='', \
1422
+ attention_point='', \
1401
1423
  loc1='best',loc2='best',graph=True, \
1402
1424
  ticker_type=['auto','auto'],facecolor='whitesmoke'):
1403
1425
  """
@@ -1459,6 +1481,8 @@ def comp_2securities_1measure(df1,df2,measure,twinx=False, \
1459
1481
 
1460
1482
  plot_line2(df1,ticker1,measure,label,df2,ticker2,measure,label, \
1461
1483
  ylabeltxt,titletxt,footnote,zeroline=zeroline,twinx=twinx, \
1484
+ yline=attention_value, \
1485
+ xline=attention_point, \
1462
1486
  loc1=loc1,loc2=loc2,facecolor=facecolor)
1463
1487
 
1464
1488
  return
@@ -1498,6 +1522,8 @@ if __name__ =="__main__":
1498
1522
  def compare_security(tickers,measures,fromdate,todate, \
1499
1523
  adjust='', \
1500
1524
  twinx=False, \
1525
+ attention_value='', \
1526
+ attention_point='', \
1501
1527
  loc1='best',loc2='lower left',graph=True,source='auto', \
1502
1528
  ticker_type='auto',facecolor='whitesmoke'):
1503
1529
  """
@@ -1519,6 +1545,7 @@ def compare_security(tickers,measures,fromdate,todate, \
1519
1545
  """
1520
1546
  #调试开关
1521
1547
  DEBUG=False
1548
+
1522
1549
  # 应对导入失灵的函数
1523
1550
  from siat.common import upper_ticker
1524
1551
  tickers=upper_ticker(tickers)
@@ -1589,6 +1616,8 @@ def compare_security(tickers,measures,fromdate,todate, \
1589
1616
  #security_indicator未能做到同时获得Close和Adj Close
1590
1617
  df1tmp=security_indicator(ticker=ticker1,indicator=measure1,adjust=adjust1, \
1591
1618
  fromdate=fromdate,todate=todate, \
1619
+ attention_value=attention_value, \
1620
+ attention_point=attention_point, \
1592
1621
  source=source, \
1593
1622
  ticker_type=ticker_type, \
1594
1623
  graph=False)
@@ -1608,6 +1637,8 @@ def compare_security(tickers,measures,fromdate,todate, \
1608
1637
  #security_indicator未能做到同时获得Close和Adj Close
1609
1638
  df2tmp=security_indicator(ticker=ticker1,indicator=measure2,adjust=adjust2, \
1610
1639
  fromdate=fromdate,todate=todate, \
1640
+ attention_value=attention_value, \
1641
+ attention_point=attention_point, \
1611
1642
  source=source, \
1612
1643
  ticker_type=ticker_type, \
1613
1644
  graph=False)
@@ -1623,7 +1654,15 @@ def compare_security(tickers,measures,fromdate,todate, \
1623
1654
 
1624
1655
  #绘制单个证券的双指标对比图
1625
1656
  if graph:
1657
+ if DEBUG:
1658
+ print("In compare_security:")
1659
+ print("Going to comp_1security_2measures ...")
1660
+ print("attention_value=",attention_value)
1661
+ print("attention_point=",attention_point)
1662
+
1626
1663
  comp_1security_2measures(pltdf,measure1,measure2,twinx=twinx, \
1664
+ attention_value=attention_value, \
1665
+ attention_point=attention_point, \
1627
1666
  loc1=loc1,loc2=loc2,graph=graph, \
1628
1667
  ticker_type=ticker_type[0],facecolor=facecolor)
1629
1668
 
@@ -1644,6 +1683,8 @@ def compare_security(tickers,measures,fromdate,todate, \
1644
1683
 
1645
1684
  df1tmp=security_indicator(ticker=ticker1,indicator=measure1,adjust=adjust, \
1646
1685
  fromdate=fromdate,todate=todate, \
1686
+ attention_value=attention_value, \
1687
+ attention_point=attention_point, \
1647
1688
  source=source, \
1648
1689
  ticker_type=ticker_type, \
1649
1690
  graph=False)
@@ -1655,6 +1696,8 @@ def compare_security(tickers,measures,fromdate,todate, \
1655
1696
 
1656
1697
  df2tmp=security_indicator(ticker=ticker2,indicator=measure1,adjust=adjust, \
1657
1698
  fromdate=fromdate,todate=todate, \
1699
+ attention_value=attention_value, \
1700
+ attention_point=attention_point, \
1658
1701
  source=source, \
1659
1702
  ticker_type=ticker_type, \
1660
1703
  graph=False)
@@ -1666,7 +1709,15 @@ def compare_security(tickers,measures,fromdate,todate, \
1666
1709
 
1667
1710
  #绘制双证券单指标对比图
1668
1711
  if graph:
1712
+ if DEBUG:
1713
+ print("In compare_security ...")
1714
+ print("Going to comp_2securities_1measure")
1715
+ print("attention_value=",attention_value)
1716
+ print("attention_point=",attention_point)
1717
+
1669
1718
  comp_2securities_1measure(pltdf1,pltdf2,measure1,twinx=twinx, \
1719
+ attention_value=attention_value, \
1720
+ attention_point=attention_point, \
1670
1721
  loc1=loc1,loc2=loc2,graph=graph, \
1671
1722
  ticker_type=ticker_type_list,facecolor=facecolor)
1672
1723
 
@@ -1683,7 +1734,7 @@ def compare_security(tickers,measures,fromdate,todate, \
1683
1734
  return result1,result2
1684
1735
 
1685
1736
  else:
1686
- print(" #Warning(compare_secuirty):only support the situations of 1 ticker + 2 measures or 2 tickers + 1 measure.")
1737
+ print(" #Warning(compare_secuirty):only support 1 ticker + 2 measures or 2 tickers + 1 measure.")
1687
1738
  return None,None
1688
1739
 
1689
1740
 
@@ -1899,6 +1950,8 @@ if __name__ =="__main__":
1899
1950
 
1900
1951
 
1901
1952
  def compare_msecurity(tickers,measure,start,end, \
1953
+ attention_value='', \
1954
+ attention_point='', \
1902
1955
  adjust='', \
1903
1956
  axhline_value=0,axhline_label='', \
1904
1957
  preprocess='none',linewidth=1.5, \
@@ -1925,7 +1978,7 @@ def compare_msecurity(tickers,measure,start,end, \
1925
1978
  scaling:缩放处理,五种选项scaling_option
1926
1979
  (mean均值,min最小值,start开始值,percentage相对每条曲线起点值的百分比,
1927
1980
  change%相对每条曲线起点值变化的百分比)
1928
- start方式的图形更接近于持有收益率(Exp Ret%),设为默认的缩放方式。
1981
+ change%方式的图形更接近于持有收益率(Exp Ret%),设为默认的缩放方式。
1929
1982
 
1930
1983
  """
1931
1984
  DEBUG=False
@@ -2078,6 +2131,8 @@ def compare_msecurity(tickers,measure,start,end, \
2078
2131
 
2079
2132
  draw_lines(dfs2,y_label,x_label,axhline_value,axhline_label,title_txt, \
2080
2133
  data_label=False,resample_freq='H',smooth=smooth,linewidth=linewidth,loc=loc, \
2134
+ attention_value=attention_value, \
2135
+ attention_point=attention_point, \
2081
2136
  annotate=annotate,annotate_value=annotate_value,plus_sign=plus_sign, \
2082
2137
  mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end,facecolor=facecolor)
2083
2138
 
siat/translate.py CHANGED
@@ -1072,7 +1072,7 @@ def codetranslate0(code):
1072
1072
  ['^FTSE','英国富时100指数'],['^FTM','英国富时250指数'],
1073
1073
  ['^NKX','日经225指数'],['^N100','泛欧100指数'],
1074
1074
  ['^FMIB','富时意大利指数'],
1075
- ['^TSX','多伦多综合指数'],['^MXX','墨西哥IPC指数'],
1075
+ ['^GSPTSE','多伦多综合指数'],['^MXX','墨西哥IPC指数'],
1076
1076
  ['^NDX','纳斯达克100指数'],['^NDQ','纳斯达克综合指数'],
1077
1077
  ['^BET','罗马尼亚布加勒斯特指数'],
1078
1078
  ['^BUX','匈牙利布达佩斯指数'],['^PX','捷克布拉格PX指数'],