siat 3.10.132__py3-none-any.whl → 3.11.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.
Files changed (221) hide show
  1. siat/__init__.py +0 -0
  2. siat/allin.py +8 -0
  3. siat/assets_liquidity.py +0 -0
  4. siat/beta_adjustment.py +0 -0
  5. siat/beta_adjustment_china.py +0 -0
  6. siat/blockchain.py +0 -0
  7. siat/bond.py +0 -0
  8. siat/bond_base.py +0 -0
  9. siat/bond_china.py +0 -0
  10. siat/bond_zh_sina.py +0 -0
  11. siat/capm_beta.py +0 -0
  12. siat/capm_beta2.py +4 -4
  13. siat/common.py +9 -6
  14. siat/compare_cross.py +0 -0
  15. siat/copyrights.py +0 -0
  16. siat/cryptocurrency.py +0 -0
  17. siat/economy.py +0 -0
  18. siat/economy2.py +0 -0
  19. siat/esg.py +0 -0
  20. siat/event_study.py +0 -0
  21. siat/exchange_bond_china.pickle +0 -0
  22. siat/fama_french.py +0 -0
  23. siat/fin_stmt2_yahoo.py +0 -0
  24. siat/financial_base.py +0 -0
  25. siat/financial_statements.py +0 -0
  26. siat/financials.py +0 -0
  27. siat/financials2.py +0 -0
  28. siat/financials_china.py +0 -0
  29. siat/financials_china2.py +0 -0
  30. siat/fund.py +0 -0
  31. siat/fund_china.pickle +0 -0
  32. siat/fund_china.py +0 -0
  33. siat/future_china.py +0 -0
  34. siat/google_authenticator.py +0 -0
  35. siat/grafix.py +55 -4
  36. siat/holding_risk.py +0 -0
  37. siat/luchy_draw.py +0 -0
  38. siat/market_china.py +0 -0
  39. siat/markowitz.py +0 -0
  40. siat/markowitz2.py +1 -0
  41. siat/markowitz2_20250704.py +0 -0
  42. siat/markowitz2_20250705.py +0 -0
  43. siat/markowitz_simple.py +0 -0
  44. siat/ml_cases.py +0 -0
  45. siat/ml_cases_example.py +0 -0
  46. siat/option_china.py +0 -0
  47. siat/option_pricing.py +0 -0
  48. siat/other_indexes.py +0 -0
  49. siat/risk_adjusted_return.py +0 -0
  50. siat/risk_adjusted_return2.py +8 -4
  51. siat/risk_evaluation.py +0 -0
  52. siat/risk_free_rate.py +0 -0
  53. siat/save2docx.py +345 -0
  54. siat/save2pdf.py +145 -0
  55. siat/sector_china.py +0 -0
  56. siat/security_price2.py +0 -0
  57. siat/security_prices.py +168 -6
  58. siat/security_trend.py +0 -0
  59. siat/security_trend2.py +2 -2
  60. siat/stock.py +11 -1
  61. siat/stock_advice_linear.py +0 -0
  62. siat/stock_base.py +0 -0
  63. siat/stock_china.py +0 -0
  64. siat/stock_info.pickle +0 -0
  65. siat/stock_prices_kneighbors.py +0 -0
  66. siat/stock_prices_linear.py +0 -0
  67. siat/stock_profile.py +0 -0
  68. siat/stock_technical.py +0 -0
  69. siat/stooq.py +0 -0
  70. siat/transaction.py +0 -0
  71. siat/translate.py +0 -0
  72. siat/valuation.py +0 -0
  73. siat/valuation_china.py +0 -0
  74. siat/var_model_validation.py +0 -0
  75. siat/yf_name.py +0 -0
  76. {siat-3.10.132.dist-info/licenses → siat-3.11.1.dist-info}/LICENSE +0 -0
  77. {siat-3.10.132.dist-info → siat-3.11.1.dist-info}/METADATA +234 -235
  78. siat-3.11.1.dist-info/RECORD +80 -0
  79. {siat-3.10.132.dist-info → siat-3.11.1.dist-info}/WHEEL +1 -1
  80. {siat-3.10.132.dist-info → siat-3.11.1.dist-info}/top_level.txt +0 -1
  81. build/lib/build/lib/siat/__init__.py +0 -75
  82. build/lib/build/lib/siat/allin.py +0 -137
  83. build/lib/build/lib/siat/assets_liquidity.py +0 -915
  84. build/lib/build/lib/siat/beta_adjustment.py +0 -1058
  85. build/lib/build/lib/siat/beta_adjustment_china.py +0 -548
  86. build/lib/build/lib/siat/blockchain.py +0 -143
  87. build/lib/build/lib/siat/bond.py +0 -2900
  88. build/lib/build/lib/siat/bond_base.py +0 -992
  89. build/lib/build/lib/siat/bond_china.py +0 -100
  90. build/lib/build/lib/siat/bond_zh_sina.py +0 -143
  91. build/lib/build/lib/siat/capm_beta.py +0 -783
  92. build/lib/build/lib/siat/capm_beta2.py +0 -887
  93. build/lib/build/lib/siat/common.py +0 -5360
  94. build/lib/build/lib/siat/compare_cross.py +0 -642
  95. build/lib/build/lib/siat/copyrights.py +0 -18
  96. build/lib/build/lib/siat/cryptocurrency.py +0 -667
  97. build/lib/build/lib/siat/economy.py +0 -1471
  98. build/lib/build/lib/siat/economy2.py +0 -1853
  99. build/lib/build/lib/siat/esg.py +0 -536
  100. build/lib/build/lib/siat/event_study.py +0 -815
  101. build/lib/build/lib/siat/fama_french.py +0 -1521
  102. build/lib/build/lib/siat/fin_stmt2_yahoo.py +0 -982
  103. build/lib/build/lib/siat/financial_base.py +0 -1160
  104. build/lib/build/lib/siat/financial_statements.py +0 -598
  105. build/lib/build/lib/siat/financials.py +0 -2339
  106. build/lib/build/lib/siat/financials2.py +0 -1278
  107. build/lib/build/lib/siat/financials_china.py +0 -4433
  108. build/lib/build/lib/siat/financials_china2.py +0 -2212
  109. build/lib/build/lib/siat/fund.py +0 -629
  110. build/lib/build/lib/siat/fund_china.py +0 -3307
  111. build/lib/build/lib/siat/future_china.py +0 -551
  112. build/lib/build/lib/siat/google_authenticator.py +0 -47
  113. build/lib/build/lib/siat/grafix.py +0 -3636
  114. build/lib/build/lib/siat/holding_risk.py +0 -867
  115. build/lib/build/lib/siat/luchy_draw.py +0 -638
  116. build/lib/build/lib/siat/market_china.py +0 -1168
  117. build/lib/build/lib/siat/markowitz.py +0 -2363
  118. build/lib/build/lib/siat/markowitz2.py +0 -3150
  119. build/lib/build/lib/siat/markowitz2_20250704.py +0 -2969
  120. build/lib/build/lib/siat/markowitz2_20250705.py +0 -3158
  121. build/lib/build/lib/siat/markowitz_simple.py +0 -373
  122. build/lib/build/lib/siat/ml_cases.py +0 -2291
  123. build/lib/build/lib/siat/ml_cases_example.py +0 -60
  124. build/lib/build/lib/siat/option_china.py +0 -3069
  125. build/lib/build/lib/siat/option_pricing.py +0 -1925
  126. build/lib/build/lib/siat/other_indexes.py +0 -409
  127. build/lib/build/lib/siat/risk_adjusted_return.py +0 -1576
  128. build/lib/build/lib/siat/risk_adjusted_return2.py +0 -1900
  129. build/lib/build/lib/siat/risk_evaluation.py +0 -2218
  130. build/lib/build/lib/siat/risk_free_rate.py +0 -351
  131. build/lib/build/lib/siat/sector_china.py +0 -4140
  132. build/lib/build/lib/siat/security_price2.py +0 -727
  133. build/lib/build/lib/siat/security_prices.py +0 -3408
  134. build/lib/build/lib/siat/security_trend.py +0 -402
  135. build/lib/build/lib/siat/security_trend2.py +0 -646
  136. build/lib/build/lib/siat/stock.py +0 -4284
  137. build/lib/build/lib/siat/stock_advice_linear.py +0 -934
  138. build/lib/build/lib/siat/stock_base.py +0 -26
  139. build/lib/build/lib/siat/stock_china.py +0 -2095
  140. build/lib/build/lib/siat/stock_prices_kneighbors.py +0 -910
  141. build/lib/build/lib/siat/stock_prices_linear.py +0 -386
  142. build/lib/build/lib/siat/stock_profile.py +0 -707
  143. build/lib/build/lib/siat/stock_technical.py +0 -3305
  144. build/lib/build/lib/siat/stooq.py +0 -74
  145. build/lib/build/lib/siat/transaction.py +0 -347
  146. build/lib/build/lib/siat/translate.py +0 -5183
  147. build/lib/build/lib/siat/valuation.py +0 -1378
  148. build/lib/build/lib/siat/valuation_china.py +0 -2076
  149. build/lib/build/lib/siat/var_model_validation.py +0 -444
  150. build/lib/build/lib/siat/yf_name.py +0 -811
  151. build/lib/siat/__init__.py +0 -75
  152. build/lib/siat/allin.py +0 -137
  153. build/lib/siat/assets_liquidity.py +0 -915
  154. build/lib/siat/beta_adjustment.py +0 -1058
  155. build/lib/siat/beta_adjustment_china.py +0 -548
  156. build/lib/siat/blockchain.py +0 -143
  157. build/lib/siat/bond.py +0 -2900
  158. build/lib/siat/bond_base.py +0 -992
  159. build/lib/siat/bond_china.py +0 -100
  160. build/lib/siat/bond_zh_sina.py +0 -143
  161. build/lib/siat/capm_beta.py +0 -783
  162. build/lib/siat/capm_beta2.py +0 -887
  163. build/lib/siat/common.py +0 -5360
  164. build/lib/siat/compare_cross.py +0 -642
  165. build/lib/siat/copyrights.py +0 -18
  166. build/lib/siat/cryptocurrency.py +0 -667
  167. build/lib/siat/economy.py +0 -1471
  168. build/lib/siat/economy2.py +0 -1853
  169. build/lib/siat/esg.py +0 -536
  170. build/lib/siat/event_study.py +0 -815
  171. build/lib/siat/fama_french.py +0 -1521
  172. build/lib/siat/fin_stmt2_yahoo.py +0 -982
  173. build/lib/siat/financial_base.py +0 -1160
  174. build/lib/siat/financial_statements.py +0 -598
  175. build/lib/siat/financials.py +0 -2339
  176. build/lib/siat/financials2.py +0 -1278
  177. build/lib/siat/financials_china.py +0 -4433
  178. build/lib/siat/financials_china2.py +0 -2212
  179. build/lib/siat/fund.py +0 -629
  180. build/lib/siat/fund_china.py +0 -3307
  181. build/lib/siat/future_china.py +0 -551
  182. build/lib/siat/google_authenticator.py +0 -47
  183. build/lib/siat/grafix.py +0 -3636
  184. build/lib/siat/holding_risk.py +0 -867
  185. build/lib/siat/luchy_draw.py +0 -638
  186. build/lib/siat/market_china.py +0 -1168
  187. build/lib/siat/markowitz.py +0 -2363
  188. build/lib/siat/markowitz2.py +0 -3150
  189. build/lib/siat/markowitz2_20250704.py +0 -2969
  190. build/lib/siat/markowitz2_20250705.py +0 -3158
  191. build/lib/siat/markowitz_simple.py +0 -373
  192. build/lib/siat/ml_cases.py +0 -2291
  193. build/lib/siat/ml_cases_example.py +0 -60
  194. build/lib/siat/option_china.py +0 -3069
  195. build/lib/siat/option_pricing.py +0 -1925
  196. build/lib/siat/other_indexes.py +0 -409
  197. build/lib/siat/risk_adjusted_return.py +0 -1576
  198. build/lib/siat/risk_adjusted_return2.py +0 -1900
  199. build/lib/siat/risk_evaluation.py +0 -2218
  200. build/lib/siat/risk_free_rate.py +0 -351
  201. build/lib/siat/sector_china.py +0 -4140
  202. build/lib/siat/security_price2.py +0 -727
  203. build/lib/siat/security_prices.py +0 -3408
  204. build/lib/siat/security_trend.py +0 -402
  205. build/lib/siat/security_trend2.py +0 -646
  206. build/lib/siat/stock.py +0 -4284
  207. build/lib/siat/stock_advice_linear.py +0 -934
  208. build/lib/siat/stock_base.py +0 -26
  209. build/lib/siat/stock_china.py +0 -2095
  210. build/lib/siat/stock_prices_kneighbors.py +0 -910
  211. build/lib/siat/stock_prices_linear.py +0 -386
  212. build/lib/siat/stock_profile.py +0 -707
  213. build/lib/siat/stock_technical.py +0 -3305
  214. build/lib/siat/stooq.py +0 -74
  215. build/lib/siat/transaction.py +0 -347
  216. build/lib/siat/translate.py +0 -5183
  217. build/lib/siat/valuation.py +0 -1378
  218. build/lib/siat/valuation_china.py +0 -2076
  219. build/lib/siat/var_model_validation.py +0 -444
  220. build/lib/siat/yf_name.py +0 -811
  221. siat-3.10.132.dist-info/RECORD +0 -218
siat/__init__.py CHANGED
File without changes
siat/allin.py CHANGED
@@ -135,3 +135,11 @@ from siat.luchy_draw import *
135
135
  # 搜索全球上市公司的英文名称,需要访问雅虎
136
136
  from siat.yf_name import *
137
137
 
138
+ # Save to PDF:实验中
139
+ from siat.save2pdf import *
140
+
141
+ # Save to docx:实验中
142
+ from siat.save2docx import *
143
+
144
+
145
+
siat/assets_liquidity.py CHANGED
File without changes
siat/beta_adjustment.py CHANGED
File without changes
File without changes
siat/blockchain.py CHANGED
File without changes
siat/bond.py CHANGED
File without changes
siat/bond_base.py CHANGED
File without changes
siat/bond_china.py CHANGED
File without changes
siat/bond_zh_sina.py CHANGED
File without changes
siat/capm_beta.py CHANGED
File without changes
siat/capm_beta2.py CHANGED
@@ -341,7 +341,7 @@ def compare_mticker_1beta(ticker,start,end, \
341
341
  attention_point='',attention_point_area='', \
342
342
  axhline_value=1,axhline_label='零线', \
343
343
  band_area='', \
344
- graph=True,facecolor='whitesmoke',loc='best', \
344
+ graph=True,facecolor='whitesmoke',loc='best',power=0, \
345
345
  annotate=False,annotate_value=False, \
346
346
  mark_top=False,mark_bottom=False, \
347
347
  mark_start=False,mark_end=False, \
@@ -451,7 +451,7 @@ def compare_mticker_1beta(ticker,start,end, \
451
451
  annotate=annotate,annotate_value=annotate, \
452
452
  mark_top=mark_top,mark_bottom=mark_bottom, \
453
453
  mark_start=mark_start,mark_end=mark_end, \
454
- facecolor=facecolor,loc=loc,precision=4)
454
+ facecolor=facecolor,loc=loc,precision=4,power=power)
455
455
 
456
456
  return df
457
457
 
@@ -786,7 +786,7 @@ def compare_beta_security(ticker,start,end, \
786
786
  attention_value='',attention_value_area='', \
787
787
  attention_point='',attention_point_area='', \
788
788
  band_area='', \
789
- graph=True,facecolor='whitesmoke', \
789
+ graph=True,power=0,facecolor='whitesmoke', \
790
790
  annotate=False,annotate_value=False, \
791
791
  mark_top=False,mark_bottom=False, \
792
792
  mark_start=False,mark_end=False, \
@@ -867,7 +867,7 @@ def compare_beta_security(ticker,start,end, \
867
867
  attention_value=attention_value,attention_value_area=attention_value_area, \
868
868
  attention_point=attention_point,attention_point_area=attention_point_area, \
869
869
  band_area=band_area, \
870
- graph=graph,facecolor=facecolor,loc=loc, \
870
+ graph=graph,power=power,facecolor=facecolor,loc=loc, \
871
871
  annotate=annotate,annotate_value=annotate, \
872
872
  mark_top=mark_top,mark_bottom=mark_bottom, \
873
873
  mark_start=mark_start,mark_end=mark_end, \
siat/common.py CHANGED
@@ -5105,7 +5105,8 @@ async def jupyter2pdf3(notebook_path):
5105
5105
 
5106
5106
  # pdf文件的完整路径
5107
5107
  output_pdf_path1=notebook_dir+sep+notebook_file1+' A4.pdf'
5108
- output_pdf_path2=notebook_dir+sep+notebook_file1+' A3.pdf'
5108
+ #output_pdf_path2=notebook_dir+sep+notebook_file1+' A3.pdf'
5109
+ output_pdf_path2=notebook_dir+sep+notebook_file1+'.pdf'
5109
5110
 
5110
5111
  from nbconvert import HTMLExporter
5111
5112
 
@@ -5118,7 +5119,7 @@ async def jupyter2pdf3(notebook_path):
5118
5119
  from playwright.async_api import async_playwright
5119
5120
  #from playwright.sync_api import sync_playwright
5120
5121
  except:
5121
- print(" #Warning(jupyter2pdf2): playwright seems not fully installed yet")
5122
+ print(" #Warning(jupyter2pdf3): playwright seems not fully installed yet")
5122
5123
  print(" [Solution] execute the command before re-run: playwright install")
5123
5124
  return
5124
5125
 
@@ -5129,10 +5130,11 @@ async def jupyter2pdf3(notebook_path):
5129
5130
  html_exporter = HTMLExporter()
5130
5131
  try:
5131
5132
  html_content, _ = html_exporter.from_filename(notebook_path)
5132
- print(f"Converting {notebook_file} to pdf ...")
5133
+ #print(f"Converting {notebook_file} to pdf ...")
5134
+ print(f"Converting from {notebook_file} ...")
5133
5135
 
5134
5136
  except:
5135
- print("File not found for {}".format(notebook_path))
5137
+ print("Source file not found from {}".format(notebook_path))
5136
5138
  return
5137
5139
 
5138
5140
  # 创建临时 HTML 文件
@@ -5150,7 +5152,7 @@ async def jupyter2pdf3(notebook_path):
5150
5152
  if not sys.platform.startswith('win'):
5151
5153
  page.wait_for_selector(".jp-Notebook", state="visible", timeout=60000) # 等待笔记本主体出现
5152
5154
 
5153
- await page.pdf(path=output_pdf_path1, format='A4')
5155
+ #await page.pdf(path=output_pdf_path1, format='A4')
5154
5156
  await page.pdf(path=output_pdf_path2, format='A3')
5155
5157
 
5156
5158
  await browser.close()
@@ -5170,7 +5172,8 @@ async def jupyter2pdf3(notebook_path):
5170
5172
  browser.close()
5171
5173
  """
5172
5174
 
5173
- print(f"2 PDFs created in {notebook_dir}")
5175
+ #print(f"2 PDFs created in {notebook_dir}")
5176
+ print(f"PDF created in {notebook_dir}")
5174
5177
 
5175
5178
  except Exception as e:
5176
5179
  if str(e)=='':
siat/compare_cross.py CHANGED
File without changes
siat/copyrights.py CHANGED
File without changes
siat/cryptocurrency.py CHANGED
File without changes
siat/economy.py CHANGED
File without changes
siat/economy2.py CHANGED
File without changes
siat/esg.py CHANGED
File without changes
siat/event_study.py CHANGED
File without changes
File without changes
siat/fama_french.py CHANGED
File without changes
siat/fin_stmt2_yahoo.py CHANGED
File without changes
siat/financial_base.py CHANGED
File without changes
File without changes
siat/financials.py CHANGED
File without changes
siat/financials2.py CHANGED
File without changes
siat/financials_china.py CHANGED
File without changes
siat/financials_china2.py CHANGED
File without changes
siat/fund.py CHANGED
File without changes
siat/fund_china.pickle CHANGED
File without changes
siat/fund_china.py CHANGED
File without changes
siat/future_china.py CHANGED
File without changes
File without changes
siat/grafix.py CHANGED
@@ -276,7 +276,7 @@ def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
276
276
  plt.axhline(y=hline,ls=":",c="black",linewidth=2,label='')
277
277
  haveLegend=False
278
278
  else:
279
- #不在必要,被attention_value的逻辑替代
279
+ #不再必要,被attention_value的逻辑替代
280
280
  if isinstance(zeroline,float) or isinstance(zeroline,int):
281
281
  hline=zeroline
282
282
  plt.axhline(y=hline,ls=":",c="darkorange",linewidth=3,label=text_lang("关注值","Attention"))
@@ -373,7 +373,7 @@ def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
373
373
  #print("--Debug(plot_line): power=",power)
374
374
  if power > 0:
375
375
  trend_txt=text_lang('趋势线','Trend line')
376
-
376
+ if power > 100: power=100
377
377
  try:
378
378
  #生成行号,借此将横轴的日期数量化,以便拟合
379
379
  df['id']=range(len(df))
@@ -383,6 +383,9 @@ def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
383
383
  parameter = np.polyfit(df.id, df[colname], power)
384
384
  f = np.poly1d(parameter)
385
385
  plt.plot(df.index, f(df.id),"r--", label=trend_txt,linewidth=1)
386
+
387
+
388
+
386
389
  haveLegend=True
387
390
  except:
388
391
  print(" #Warning(plot_line): failed to converge trend line, try a smaller power.")
@@ -484,6 +487,8 @@ def plot_line2(df1,ticker1,colname1,label1, \
484
487
  print("Going to plot_line2_coaxial")
485
488
  print("yline=",yline,"; xline=",xline)
486
489
 
490
+ if power > 100: power=100
491
+
487
492
  #if not twinx:
488
493
  if twinx == True: # 双轴会图
489
494
  plot_line2_twinx(df1,ticker1,colname1,label1, \
@@ -579,6 +584,8 @@ def plot2_line2(df1,ticker1,colname1,label1, \
579
584
  if (len(df1) ==0) and (len(df2) ==0):
580
585
  return
581
586
 
587
+ if power > 100: power=100
588
+
582
589
  if not twinx:
583
590
  plot_line2_coaxial2(df1,ticker1,colname1,label1, \
584
591
  df2,ticker2,colname2,label2, \
@@ -2176,7 +2183,7 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
2176
2183
  ticker_type='auto',facecolor='whitesmoke', \
2177
2184
  maxticks_enable=True,maxticks=15, \
2178
2185
  translate=False, \
2179
- precision=2):
2186
+ precision=2,power=0):
2180
2187
  """
2181
2188
  函数功能:根据df的内容绘制折线图
2182
2189
  输入参数:
@@ -2308,8 +2315,22 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
2308
2315
  mark_end=False
2309
2316
  df_end=dfg.tail(1)
2310
2317
  # df_end[c]必须为数值类型,否则可能出错
2318
+ if DEBUG:
2319
+ print(f"=== c: {type(c)}, {c}")
2320
+ print(f"=== df_end[c]: {type(df_end[c])}, {df_end[c]}")
2321
+
2311
2322
  y_end = df_end[c].min() # 末端的y坐标
2323
+ if not isinstance(y_end,float):
2324
+ # 需要强制提取数值,因其可能为Series类型
2325
+ print(f"=== y_end: {type(y_end)}, {y_end}")
2326
+ y_end = y_end.iloc[0]
2327
+
2312
2328
  x_end = df_end[c].idxmin() # 末端值的x坐标
2329
+ import pandas as pd
2330
+ if not isinstance(x_end,pd.Timestamp):
2331
+ # 需要强制提取数值,因其可能为Series类型
2332
+ print(f"=== x_end: {type(x_end)}, {x_end}")
2333
+ x_end = x_end.iloc[0]
2313
2334
 
2314
2335
  if annotate_value: #在标记曲线名称的同时标记其末端数值
2315
2336
  #y1=str(int(y_end)) if y_end >= 100 else str(round(y_end,2))
@@ -2386,7 +2407,37 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
2386
2407
  xy=(x_end, y_end),
2387
2408
  xytext=(x_end, y_end*0.998),fontsize=annotate_size,
2388
2409
  color=last_line_color,ha='left',va='center')
2389
-
2410
+
2411
+ #绘制趋势线
2412
+ if (power > 0) and (len(list(dfg)) == 1):
2413
+ trend_txt=text_lang('趋势线','Trend line')
2414
+ if power > 100: power=100
2415
+
2416
+ try:
2417
+ #生成行号,借此将横轴的日期数量化,以便拟合
2418
+ dfg['id']=range(len(dfg))
2419
+
2420
+ #设定多项式拟合,power为多项式次数
2421
+ """
2422
+ import numpy as np
2423
+ parameter = np.polyfit(dfg.id, dfg[list(dfg)[0]], power)
2424
+ f = np.poly1d(parameter)
2425
+ plt.plot(dfg.index, f(dfg.id),"r--", label=trend_txt,linewidth=1)
2426
+ """
2427
+ from numpy.polynomial import Polynomial
2428
+ x = dfg['id']
2429
+ y = dfg[list(dfg)[0]]
2430
+ p = Polynomial.fit(x, y, deg=power)
2431
+ plt.plot(dfg.index, p(x), "r--", label=trend_txt, linewidth=1)
2432
+
2433
+ except Exception as e:
2434
+ print(f" #Warning(draw_lines): Polynomial.fit failed — {e}")
2435
+
2436
+ """
2437
+ except:
2438
+ print(f" #Warning(draw_lines): failed to converge trend line, try a smaller power.")
2439
+ """
2440
+
2390
2441
  #用于关注值的颜色列表
2391
2442
  atv_color_list=["lightgray","paleturquoise","wheat","khaki","lightsage","hotpink","mediumslateblue"]
2392
2443
  #用于关注点的颜色列表
siat/holding_risk.py CHANGED
File without changes
siat/luchy_draw.py CHANGED
File without changes
siat/market_china.py CHANGED
File without changes
siat/markowitz.py CHANGED
File without changes
siat/markowitz2.py CHANGED
@@ -21,6 +21,7 @@ from siat.common import *
21
21
  from siat.translate import *
22
22
  from siat.security_prices import *
23
23
  from siat.security_price2 import *
24
+ from siat.stock import *
24
25
  from siat.grafix import *
25
26
  #from siat.fama_french import *
26
27
 
File without changes
File without changes
siat/markowitz_simple.py CHANGED
File without changes
siat/ml_cases.py CHANGED
File without changes
siat/ml_cases_example.py CHANGED
File without changes
siat/option_china.py CHANGED
File without changes
siat/option_pricing.py CHANGED
File without changes
siat/other_indexes.py CHANGED
File without changes
File without changes
@@ -813,7 +813,7 @@ def compare_1ticker_mrar(ticker,start,end,rar=['sharpe','sortino','treynor','alp
813
813
  attention_point='',attention_point_area='', \
814
814
  band_area='', \
815
815
  graph=True,loc1='best', \
816
- axhline_value=0,axhline_label='',facecolor='whitesmoke', \
816
+ axhline_value=0,axhline_label='',power=0,facecolor='whitesmoke', \
817
817
  printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.01, \
818
818
  annotate=False,annotate_value=False, \
819
819
  mark_top=False,mark_bottom=False, \
@@ -917,6 +917,10 @@ def compare_1ticker_mrar(ticker,start,end,rar=['sharpe','sortino','treynor','alp
917
917
  x_label=text_lang("数据来源: 综合新浪/EM/Stooq/Yahoo/SWHY,","Data source: Sina/Stooq/Yahoo, ")+str(todaydt)
918
918
  title_txt=text_lang("风险调整收益:","Risk-adjusted Return: ")+tname
919
919
 
920
+ # 英文环境下将label首字母大写
921
+ for c in list(df1):
922
+ df1.rename(columns={c:c.title()},inplace=True)
923
+
920
924
  draw_lines(df1,y_label,x_label=footnotex, \
921
925
  axhline_value=axhline_value,axhline_label=axhline_label, \
922
926
  title_txt=title_txt,data_label=False, \
@@ -926,7 +930,7 @@ def compare_1ticker_mrar(ticker,start,end,rar=['sharpe','sortino','treynor','alp
926
930
  band_area=band_area, \
927
931
  mark_top=mark_top,mark_bottom=mark_bottom, \
928
932
  mark_start=mark_start,mark_end=mark_end, \
929
- facecolor=facecolor,loc=loc1)
933
+ facecolor=facecolor,loc=loc1,power=power)
930
934
 
931
935
  #制表
932
936
  recommenddf=pd.DataFrame()
@@ -1729,7 +1733,7 @@ def compare_rar_security(ticker,start,end='today',indicator='sharpe', \
1729
1733
  attention_point='',attention_point_area='', \
1730
1734
  band_area='', \
1731
1735
  graph=True,loc1='best', \
1732
- axhline_value=0,axhline_label='',facecolor='whitesmoke', \
1736
+ axhline_value=0,axhline_label='',power=0,facecolor='whitesmoke', \
1733
1737
  printout=False,sortby='tpw_mean',trailing=7,trend_threshhold=0.05, \
1734
1738
  annotate=False,annotate_value=False, \
1735
1739
  mark_top=False,mark_bottom=False, \
@@ -1878,7 +1882,7 @@ def compare_rar_security(ticker,start,end='today',indicator='sharpe', \
1878
1882
  attention_value=attention_value,attention_value_area=attention_value_area, \
1879
1883
  attention_point=attention_point,attention_point_area=attention_point_area, \
1880
1884
  graph=graph,loc1=loc1, \
1881
- axhline_value=axhline_value,axhline_label=axhline_label, \
1885
+ axhline_value=axhline_value,axhline_label=axhline_label,power=power, \
1882
1886
  printout=printout,sortby=sortby, \
1883
1887
  trailing=trailing,trend_threshhold=trend_threshhold, \
1884
1888
  annotate=annotate,annotate_value=annotate, \
siat/risk_evaluation.py CHANGED
File without changes
siat/risk_free_rate.py CHANGED
File without changes