siat 3.5.11__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.
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
 
@@ -2571,12 +2626,23 @@ if __name__ =="__main__":
2571
2626
  fromdate="2021-1-1"
2572
2627
  todate="2022-9-26"
2573
2628
 
2574
- def stock_dividend(ticker,start,end,facecolor='whitesmoke',fontcolor='black'):
2629
+
2630
+ def security_dividend(ticker,start="L3Y",end="today",facecolor='whitesmoke',fontcolor='black'):
2631
+ """
2632
+ 功能:套壳函数stock_dividend
2633
+ """
2634
+ df=stock_dividend(ticker,start,end,facecolor,fontcolor)
2635
+ return df
2636
+
2637
+
2638
+ def stock_dividend(ticker,start="L3Y",end="today",facecolor='whitesmoke',fontcolor='black'):
2575
2639
  """
2576
2640
  功能:显示股票的分红历史
2577
2641
  输入:单一股票代码
2578
2642
  输出:分红历史
2579
2643
  """
2644
+ start,end=start_end_preprocess(start,end)
2645
+
2580
2646
  fromdate,todate=start,end
2581
2647
 
2582
2648
  print(" Searching for the dividend info of stock",ticker,"... ...")
@@ -2649,24 +2715,24 @@ def stock_dividend(ticker,start,end,facecolor='whitesmoke',fontcolor='black'):
2649
2715
 
2650
2716
  lang=check_language()
2651
2717
  tname=ticker_name(ticker,'stock')
2652
- fromdatey2md=startdt.strftime('%y/%m/%d')
2653
- todatey2md=enddt.strftime('%y/%m/%d')
2718
+ fromdatey2md=startdt.strftime('%Y/%m/%d')
2719
+ todatey2md=enddt.strftime('%Y/%m/%d')
2654
2720
 
2655
- titletxt=text_lang("股票分红历史","Stock Dividend")+': '+tname
2656
- periodtxt=text_lang("历史期间:","Period:")+' '+fromdatey2md+"-"+todatey2md
2721
+ titletxt=text_lang("证券分红","Stock Dividend")+': '+tname
2722
+ periodtxt=text_lang("期间:","Period:")+' '+fromdatey2md+"-"+todatey2md
2657
2723
  #sourcetxt=text_lang("数据来源: 雅虎财经,","Data source: Yahoo Finance,")
2658
- sourcetxt=text_lang("数据来源: 雅虎财经","Data source: Yahoo Finance")
2724
+ sourcetxt=text_lang("数据来源: Yahoo/Sina","Data source: Yahoo/Sina")
2659
2725
  footnote=periodtxt+'\n'+sourcetxt
2660
2726
 
2661
2727
  #修改列命为英文
2662
- divprt.columns = [text_lang('序号','No.'),text_lang('日期','Date'),text_lang('星期','Weekday'),text_lang('每股股息','Dividend/share')]
2728
+ divprt.columns = [text_lang('序号','No.'),text_lang('日期','Date'),text_lang('星期','Weekday'),text_lang('每股(份)红利','Dividend/share')]
2663
2729
 
2664
2730
  """
2665
2731
  print(divprt.to_string(index=False))
2666
2732
  """
2667
2733
  #print('') #空一行
2668
2734
 
2669
- df_display_CSS(divprt,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=2, \
2735
+ df_display_CSS(divprt,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=4, \
2670
2736
  first_col_align='center',second_col_align='center', \
2671
2737
  last_col_align='right',other_col_align='center')
2672
2738
 
@@ -2701,13 +2767,23 @@ if __name__ =="__main__":
2701
2767
  fromdate='2019-1-1'
2702
2768
  todate='2020-6-30'
2703
2769
 
2704
- #==============================================================================
2705
- def stock_split(ticker,start,end,facecolor='whitesmoke',fontcolor='black'):
2770
+ #==============================================================================
2771
+ def security_split(ticker,start="L10Y",end="today",facecolor='whitesmoke',fontcolor='black'):
2772
+ """
2773
+ 功能:套壳函数stock_split
2774
+ """
2775
+ df=stock_split(ticker,start,end,facecolor,fontcolor)
2776
+ return df
2777
+
2778
+
2779
+ def stock_split(ticker,start="L10Y",end="today",facecolor='whitesmoke',fontcolor='black'):
2706
2780
  """
2707
2781
  功能:显示股票的分拆历史
2708
2782
  输入:单一股票代码
2709
2783
  输出:分拆历史
2710
2784
  """
2785
+ start,end=start_end_preprocess(start,end)
2786
+
2711
2787
  fromdate,todate=start,end
2712
2788
 
2713
2789
  print(" Searching for the split info of stock",ticker,"... ...")
@@ -2803,15 +2879,15 @@ def stock_split(ticker,start,end,facecolor='whitesmoke',fontcolor='black'):
2803
2879
  today = datetime.date.today()
2804
2880
  print('\n*** '+sourcetxt,today)
2805
2881
  """
2806
- fromdatey2md=startdt.strftime('%y/%m/%d')
2807
- todatey2md=enddt.strftime('%y/%m/%d')
2882
+ fromdatey2md=startdt.strftime('%Y/%m/%d')
2883
+ todatey2md=enddt.strftime('%Y/%m/%d')
2808
2884
 
2809
- titletxt=text_lang("股票分拆历史","Stock Split")+': '+tname
2810
- periodtxt=text_lang("历史期间:","Period:")+' '+fromdatey2md+"-"+todatey2md
2885
+ titletxt=text_lang("证券分拆","Stock Split")+': '+tname
2886
+ periodtxt=text_lang("期间:","Period:")+' '+fromdatey2md+"-"+todatey2md
2811
2887
 
2812
2888
  import datetime; todaydt=datetime.date.today(); todayy2md=str(todaydt.strftime('%y/%m/%d'))
2813
2889
  #sourcetxt=text_lang("数据来源: 雅虎财经, ","Data source: Yahoo Finance, ")+todayy2md
2814
- sourcetxt=text_lang("数据来源: 雅虎财经","Data source: Yahoo Finance")
2890
+ sourcetxt=text_lang("数据来源: Yahoo/Sina","Data source: Yahoo Finance")
2815
2891
  footnote=periodtxt+'\n'+ sourcetxt
2816
2892
 
2817
2893
  #修改列命为英文
siat/stooq.py CHANGED
@@ -46,9 +46,10 @@ class StooqDailyReader(_DailyBaseReader):
46
46
  pass
47
47
  #symbol = ".".join([symbol, country])
48
48
  elif symbol_parts[1].lower() == "pl": #后缀为波兰
49
+ #pass
49
50
  symbol = symbol_parts[0]
50
51
  else:
51
- pass
52
+ #pass
52
53
  if symbol_parts[1].lower() not in [
53
54
  "de",
54
55
  "hk",
siat/translate.py CHANGED
@@ -819,7 +819,7 @@ def codetranslate0(code):
819
819
  ['VIPS','唯品会'],['Vipshop','唯品会'],
820
820
  ['PDD','拼多多'],['Pinduoduo','拼多多'],
821
821
  ['BABA','阿里巴巴美股'],['Alibaba','阿里巴巴美股'],
822
- ['JD','京东美股'],
822
+ ['JD','京东美股'],['MPNGY','美团美股'],
823
823
  ['SINA','新浪网'],['BIDU','百度'],['NTES','网易'],
824
824
 
825
825
  ['00700.HK','腾讯港股'],['TENCENT','腾讯控股'],
@@ -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指数'],
@@ -1083,7 +1083,8 @@ def codetranslate0(code):
1083
1083
  ['^OMXS','瑞典斯德哥尔摩指数'],['^DKDOW','道琼斯丹麦指数'],
1084
1084
  ['^HEX','芬兰赫尔辛基指数'],['^OMXV','立陶宛维尔纽斯指数'],
1085
1085
  ['^OMXR','拉脱维亚里加指数'],['^OMXT','爱沙尼亚塔林指数'],
1086
- ['^ICEX','冰岛综合指数'],['^FMIB','富时意大利米兰指数'],
1086
+ ['^ICEX','冰岛综合指数'],['^OMXC25','丹麦哥本哈根25指数'],
1087
+ ['^FMIB','富时意大利指数'],
1087
1088
  ['^IBEX','西班牙IBEX指数'],['^OSEAX','挪威奥斯陆指数'],
1088
1089
  ['^SMI','瑞士SMI指数'],['^MOEX','俄罗斯莫斯科指数(卢布计价)'],
1089
1090
  ['^UX','乌克兰UX指数'],['^RTS','俄罗斯市值加权指数(美元计价)'],
@@ -1129,6 +1130,7 @@ def codetranslate0(code):
1129
1130
  ['^BSESN','孟买敏感指数'],['^SNX','孟买敏感指数'],['^NSEI','印度国交50指数'],
1130
1131
  ['^FCHI','法国CAC40指数'],['^GDAXI','德国DAX指数'],
1131
1132
  ['^CAC','法国CAC40指数'],['^DAX','德国DAX指数'],
1133
+ ['^ATX','奥地利ATX指数'],
1132
1134
  ['IMOEX.ME','俄罗斯MOEX指数'],['^MOEX','俄罗斯MOEX指数'],
1133
1135
  ['^RTS','俄罗斯RTS指数(美元标价)'],
1134
1136
  ['^TASI','沙特TASI指数'],
siat/valuation.py CHANGED
@@ -942,6 +942,8 @@ def security_valuation(tickers,indicators,start,end, \
942
942
  preprocess='none',scaling_option='start', \
943
943
  twinx=False,loc1='best',loc2='best', \
944
944
  graph=True,facecolor='whitesmoke', \
945
+ attention_value='', \
946
+ attention_point='', \
945
947
  annotate=False,annotate_value=False, \
946
948
  mark_top=False,mark_bottom=False,mark_end=False):
947
949
  """
@@ -992,7 +994,7 @@ def security_valuation(tickers,indicators,start,end, \
992
994
  footnote1=""
993
995
  if i=='MV':
994
996
  if preprocess=='none':
995
- footnote1="注:市值金额:十亿,当地货币单位\n"
997
+ footnote1="注:市值金额:十亿,本币单位\n"
996
998
 
997
999
  todaydt = datetime.date.today()
998
1000
  footnote9="数据来源: Baidu/Stooq/FundDB/SWHY,"+str(todaydt)
@@ -1001,7 +1003,10 @@ def security_valuation(tickers,indicators,start,end, \
1001
1003
  draw_lines(df2,y_label=ylabeltxt,x_label=footnote, \
1002
1004
  axhline_value=0,axhline_label='', \
1003
1005
  title_txt=titletxt,data_label=False, \
1004
- resample_freq='D',loc=loc1,facecolor=facecolor,
1006
+ resample_freq='D',loc=loc1,facecolor=facecolor, \
1007
+ attention_value=attention_value, \
1008
+ attention_point=attention_point, \
1009
+ annotate=annotate,annotate_value=annotate_value, \
1005
1010
  mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end)
1006
1011
 
1007
1012
  return df
@@ -1015,12 +1020,12 @@ def security_valuation(tickers,indicators,start,end, \
1015
1020
  df2_1.rename(columns={t:i1},inplace=True)
1016
1021
  df2_2.rename(columns={t:i2},inplace=True)
1017
1022
 
1018
- titletxt="证券估值走势对比:"+t
1023
+ titletxt="证券估值走势:"+t
1019
1024
 
1020
1025
  footnote1=""
1021
1026
  if i1=='MV' or i2=='MV':
1022
1027
  if preprocess=='none':
1023
- footnote1="注:市值金额:十亿,当地货币单位\n"
1028
+ footnote1="注:市值金额:十亿,本币单位\n"
1024
1029
 
1025
1030
  todaydt = datetime.date.today()
1026
1031
  footnote9="数据来源: Baidu/Stooq/FundDB/SWHY,"+str(todaydt)
@@ -1037,7 +1042,11 @@ def security_valuation(tickers,indicators,start,end, \
1037
1042
  ylabeltxt='',titletxt=titletxt,footnote=footnote, \
1038
1043
  twinx=twinx, \
1039
1044
  resample_freq='D',loc1=loc1,loc2=loc2, \
1040
- color1='red',color2='blue',facecolor=facecolor)
1045
+ color1='red',color2='blue',facecolor=facecolor, \
1046
+ yline=attention_value, \
1047
+ xline=attention_point
1048
+ )
1049
+
1041
1050
  return df
1042
1051
 
1043
1052
  # 绘制双线: 两只证券,一个指标。twinx双轴绘图
@@ -1048,13 +1057,13 @@ def security_valuation(tickers,indicators,start,end, \
1048
1057
  df2_1.rename(columns={t1:i},inplace=True)
1049
1058
  df2_2.rename(columns={t2:i},inplace=True)
1050
1059
 
1051
- #titletxt="证券估值走势对比:"+i
1052
- titletxt="证券估值走势对比:"+ectranslate(i)
1060
+ #titletxt="证券估值走势:"+i
1061
+ titletxt="证券估值走势:"+ectranslate(i)
1053
1062
 
1054
1063
  footnote1=""
1055
1064
  if i=='MV':
1056
1065
  if preprocess=='none':
1057
- footnote1="注:市值金额:十亿,当地货币单位\n"
1066
+ footnote1="注:市值金额:十亿,本币单位\n"
1058
1067
 
1059
1068
  todaydt = datetime.date.today()
1060
1069
  footnote9="数据来源: Baidu/Stooq/FundDB/SWHY,"+str(todaydt)
@@ -1074,7 +1083,10 @@ def security_valuation(tickers,indicators,start,end, \
1074
1083
  ylabeltxt=ylabeltxt,titletxt=titletxt,footnote=footnote, \
1075
1084
  twinx=twinx, \
1076
1085
  resample_freq='D',loc1=loc1,loc2=loc2, \
1077
- color1='red',color2='blue',facecolor=facecolor)
1086
+ color1='red',color2='blue',facecolor=facecolor, \
1087
+ yline=attention_value, \
1088
+ xline=attention_point
1089
+ )
1078
1090
 
1079
1091
  return df
1080
1092
 
@@ -1089,7 +1101,7 @@ def security_valuation(tickers,indicators,start,end, \
1089
1101
  footnote1=""
1090
1102
  if i=='MV':
1091
1103
  if preprocess=='none':
1092
- footnote1="注:市值金额:十亿,当地货币单位\n"
1104
+ footnote1="注:市值金额:十亿,本币单位\n"
1093
1105
 
1094
1106
  todaydt = datetime.date.today()
1095
1107
  footnote9="数据来源: Baidu/Stooq/FundDB/SWHY,"+str(todaydt)
@@ -1110,11 +1122,13 @@ def security_valuation(tickers,indicators,start,end, \
1110
1122
  annotate=annotate,annotate_value=annotate_value, \
1111
1123
  plus_sign=plus_sign, \
1112
1124
  facecolor=facecolor, \
1125
+ attention_value=attention_value, \
1126
+ attention_point=attention_point, \
1113
1127
  mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end)
1114
1128
 
1115
1129
  return df
1116
1130
 
1117
- # 绘制多线:一只证券,多个指标。简单多线绘图
1131
+ # 绘制多线:一只证券,多个指标。简单多线绘图。可能数量级差异较大,意义有限
1118
1132
  if name_num == 1 and indicator_num >= 2 and not twinx:
1119
1133
  t=names1[0]
1120
1134
  df2=None
@@ -1134,7 +1148,7 @@ def security_valuation(tickers,indicators,start,end, \
1134
1148
  footnote1=''
1135
1149
  if 'MV' in indicators1:
1136
1150
  if preprocess=='none':
1137
- footnote1="注:市值金额:十亿,当地货币单位\n"
1151
+ footnote1="注:市值金额:十亿,本币单位\n"
1138
1152
 
1139
1153
  todaydt = datetime.date.today()
1140
1154
  footnote9="数据来源: Baidu/Stooq/FundDB/SWHY,"+str(todaydt)
@@ -1154,6 +1168,9 @@ def security_valuation(tickers,indicators,start,end, \
1154
1168
  resample_freq='D',loc=loc1,plus_sign=plus_sign, \
1155
1169
  annotate=annotate,annotate_value=annotate_value, \
1156
1170
  facecolor=facecolor, \
1171
+ attention_value=attention_value, \
1172
+ attention_point=attention_point, \
1173
+
1157
1174
  mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end)
1158
1175
 
1159
1176
  return df
siat/yf_name.py CHANGED
@@ -94,6 +94,7 @@ if __name__=='__main__':
94
94
  ticker='600333.ss'
95
95
  ticker='600444.ss'
96
96
  ticker='600777.ss'
97
+ ticker='GC=F'
97
98
 
98
99
  yahoo_name1(ticker)
99
100
 
@@ -242,12 +243,129 @@ if __name__=='__main__':
242
243
 
243
244
  #发现问题后单独测试
244
245
  ticker='600088.SS'
246
+ ticker="ALI=F"
247
+ ticker="ZS=F"
248
+ ticker="ES=F"
249
+
250
+ ticker_info(ticker)
251
+
245
252
  yahoo_name1(ticker)
246
253
  yahoo_name2(ticker)
247
254
 
248
255
  yahoo_name2(ticker,short_name=True)
249
256
 
250
257
  ticker_name(ticker)
258
+
259
+ numeric_to_date(1734652800)
260
+
261
+ def numeric_to_date(numeric):
262
+ # 数值转日期
263
+ from datetime import datetime, timedelta
264
+ epoch = datetime(1970, 1, 1)
265
+ return (epoch + timedelta(seconds=numeric)).strftime('%Y-%m-%d')
266
+
267
+ if __name__=='__main__':
268
+ ticker="ES=F" #期货
269
+ ticker="VIX241120C00035000" #期权
270
+
271
+ ticker_info(ticker, info="interest")
272
+ ticker_info(ticker, info="open interest")
273
+ ticker_info(ticker, info="volume")
274
+ ticker_info(ticker, info="average volume")
275
+ ticker_info(ticker, info="REGULAR CLOSE")
276
+ ticker_info(ticker, info="day average")
277
+
278
+ ticker_info(ticker, info=["regular close","fifty day average","two hundred day average"])
279
+
280
+ def ticker_info(ticker,info="all"):
281
+ """
282
+
283
+ 功能:显示yahoo证券代码的信息,可多个信息类型
284
+ """
285
+ if isinstance(info,str):
286
+ infos=[info]
287
+ elif isinstance(info,list):
288
+ infos=info
289
+ else:
290
+ print(" Sorry, unsupported info type:",info)
291
+ return
292
+
293
+ first_time=True
294
+ for i in infos:
295
+ if first_time:
296
+ ticker_info1(ticker,info=i,test_access=True,print_title=True)
297
+ first_time=False
298
+ else:
299
+ ticker_info1(ticker,info=i,test_access=False,print_title=False)
300
+
301
+ return
302
+
303
+ if __name__=='__main__':
304
+ ticker="TSLA260618C00330000"
305
+
306
+ ticker_info1(ticker)
307
+ ticker_info1(ticker, info="open interest")
308
+
309
+ def ticker_info1(ticker,info="all",test_access=True,print_title=True):
310
+ """
311
+
312
+ 功能:显示yahoo证券代码的信息,1个信息类型
313
+ """
314
+ #测试雅虎
315
+ if test_access:
316
+ if not test_yahoo_access():
317
+ print(" Sorry, data source Yahoo is currently not reachable")
318
+ return
319
+
320
+ #去掉ticker中的.US后缀
321
+ ticker=ticker.upper()
322
+ ticker1=ticker.replace('.US', "")
323
+
324
+ import yfinance as yf
325
+ ticker_info = yf.Ticker(ticker1)
326
+
327
+ import datetime
328
+ stoday = datetime.date.today().strftime("%Y-%m-%d")
329
+
330
+ info_list=info.split(); found=False
331
+ """
332
+ info_yahoo=(info_list[0]).lower()
333
+ for i in info_list[1:]:
334
+ info_yahoo=info_yahoo+(i.lower()).capitalize()
335
+ """
336
+
337
+ try:
338
+ t_info=ticker_info.info
339
+
340
+ if print_title:
341
+ print("*** Ticker",ticker,'Information @'+stoday)
342
+
343
+ if ('all' in info) or ('All' in info) or ('ALL' in info):
344
+ for k in t_info.keys():
345
+ if not 'Date' in k:
346
+ print(' '+k+':',t_info[k])
347
+ else:
348
+ print(' '+k+':',numeric_to_date(t_info[k]))
349
+ #display(t_info)
350
+ else:
351
+ for k in t_info.keys():
352
+ for i in info_list:
353
+ if (not i.lower() in k) and (not (i.lower()).capitalize() in k):
354
+ found=False; break
355
+ else:
356
+ found=True
357
+ if not found: continue
358
+
359
+ if not 'Date' in k:
360
+ print(' '+k+':',t_info[k])
361
+ else:
362
+ print(' '+k+':',numeric_to_date(t_info[k]))
363
+
364
+ except:
365
+ print(" Sorry, ticker",ticker,"is not found in data source Yahoo")
366
+
367
+ return
368
+
251
369
 
252
370
  def yahoo_name1(ticker,short_name=False,add_suffix=True,maxlen=80):
253
371
  """
@@ -256,7 +374,6 @@ def yahoo_name1(ticker,short_name=False,add_suffix=True,maxlen=80):
256
374
  现存问题:需要访问雅虎,且耗时稍长
257
375
  """
258
376
 
259
-
260
377
  #测试雅虎
261
378
  if not test_yahoo_access():
262
379
  return ticker
@@ -276,9 +393,16 @@ def yahoo_name1(ticker,short_name=False,add_suffix=True,maxlen=80):
276
393
 
277
394
  try:
278
395
  if short_name:
279
- t_name0=t_info['shortName']
396
+ try:
397
+ t_name0=t_info['shortName']
398
+ except:
399
+ t_name0=t_info['longName']
280
400
  else:
281
- t_name0=t_info['longName']
401
+ try:
402
+ t_name0=t_info['longName']
403
+ except:
404
+ t_name0=t_info['shortName']
405
+
282
406
  if len(t_name0) > maxlen:
283
407
  t_name0=t_info['shortName']
284
408
  except:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siat
3
- Version: 3.5.11
3
+ Version: 3.6.1
4
4
  Summary: Securities Investment Analysis Tools (siat)
5
5
  Home-page: https://pypi.org/project/siat/
6
6
  Author: Prof. WANG Dehong, International Business School, Beijing Foreign Studies University