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.
- siat/__init__.py +0 -0
- siat/allin.py +8 -0
- siat/assets_liquidity.py +0 -0
- siat/beta_adjustment.py +0 -0
- siat/beta_adjustment_china.py +0 -0
- siat/blockchain.py +0 -0
- siat/bond.py +0 -0
- siat/bond_base.py +0 -0
- siat/bond_china.py +0 -0
- siat/bond_zh_sina.py +0 -0
- siat/capm_beta.py +0 -0
- siat/capm_beta2.py +4 -4
- siat/common.py +9 -6
- siat/compare_cross.py +0 -0
- siat/copyrights.py +0 -0
- siat/cryptocurrency.py +0 -0
- siat/economy.py +0 -0
- siat/economy2.py +0 -0
- siat/esg.py +0 -0
- siat/event_study.py +0 -0
- siat/exchange_bond_china.pickle +0 -0
- siat/fama_french.py +0 -0
- siat/fin_stmt2_yahoo.py +0 -0
- siat/financial_base.py +0 -0
- siat/financial_statements.py +0 -0
- siat/financials.py +0 -0
- siat/financials2.py +0 -0
- siat/financials_china.py +0 -0
- siat/financials_china2.py +0 -0
- siat/fund.py +0 -0
- siat/fund_china.pickle +0 -0
- siat/fund_china.py +0 -0
- siat/future_china.py +0 -0
- siat/google_authenticator.py +0 -0
- siat/grafix.py +55 -4
- siat/holding_risk.py +0 -0
- siat/luchy_draw.py +0 -0
- siat/market_china.py +0 -0
- siat/markowitz.py +0 -0
- siat/markowitz2.py +1 -0
- siat/markowitz2_20250704.py +0 -0
- siat/markowitz2_20250705.py +0 -0
- siat/markowitz_simple.py +0 -0
- siat/ml_cases.py +0 -0
- siat/ml_cases_example.py +0 -0
- siat/option_china.py +0 -0
- siat/option_pricing.py +0 -0
- siat/other_indexes.py +0 -0
- siat/risk_adjusted_return.py +0 -0
- siat/risk_adjusted_return2.py +8 -4
- siat/risk_evaluation.py +0 -0
- siat/risk_free_rate.py +0 -0
- siat/save2docx.py +345 -0
- siat/save2pdf.py +145 -0
- siat/sector_china.py +0 -0
- siat/security_price2.py +0 -0
- siat/security_prices.py +168 -6
- siat/security_trend.py +0 -0
- siat/security_trend2.py +2 -2
- siat/stock.py +11 -1
- siat/stock_advice_linear.py +0 -0
- siat/stock_base.py +0 -0
- siat/stock_china.py +0 -0
- siat/stock_info.pickle +0 -0
- siat/stock_prices_kneighbors.py +0 -0
- siat/stock_prices_linear.py +0 -0
- siat/stock_profile.py +0 -0
- siat/stock_technical.py +0 -0
- siat/stooq.py +0 -0
- siat/transaction.py +0 -0
- siat/translate.py +0 -0
- siat/valuation.py +0 -0
- siat/valuation_china.py +0 -0
- siat/var_model_validation.py +0 -0
- siat/yf_name.py +0 -0
- {siat-3.10.132.dist-info/licenses → siat-3.11.1.dist-info}/LICENSE +0 -0
- {siat-3.10.132.dist-info → siat-3.11.1.dist-info}/METADATA +234 -235
- siat-3.11.1.dist-info/RECORD +80 -0
- {siat-3.10.132.dist-info → siat-3.11.1.dist-info}/WHEEL +1 -1
- {siat-3.10.132.dist-info → siat-3.11.1.dist-info}/top_level.txt +0 -1
- build/lib/build/lib/siat/__init__.py +0 -75
- build/lib/build/lib/siat/allin.py +0 -137
- build/lib/build/lib/siat/assets_liquidity.py +0 -915
- build/lib/build/lib/siat/beta_adjustment.py +0 -1058
- build/lib/build/lib/siat/beta_adjustment_china.py +0 -548
- build/lib/build/lib/siat/blockchain.py +0 -143
- build/lib/build/lib/siat/bond.py +0 -2900
- build/lib/build/lib/siat/bond_base.py +0 -992
- build/lib/build/lib/siat/bond_china.py +0 -100
- build/lib/build/lib/siat/bond_zh_sina.py +0 -143
- build/lib/build/lib/siat/capm_beta.py +0 -783
- build/lib/build/lib/siat/capm_beta2.py +0 -887
- build/lib/build/lib/siat/common.py +0 -5360
- build/lib/build/lib/siat/compare_cross.py +0 -642
- build/lib/build/lib/siat/copyrights.py +0 -18
- build/lib/build/lib/siat/cryptocurrency.py +0 -667
- build/lib/build/lib/siat/economy.py +0 -1471
- build/lib/build/lib/siat/economy2.py +0 -1853
- build/lib/build/lib/siat/esg.py +0 -536
- build/lib/build/lib/siat/event_study.py +0 -815
- build/lib/build/lib/siat/fama_french.py +0 -1521
- build/lib/build/lib/siat/fin_stmt2_yahoo.py +0 -982
- build/lib/build/lib/siat/financial_base.py +0 -1160
- build/lib/build/lib/siat/financial_statements.py +0 -598
- build/lib/build/lib/siat/financials.py +0 -2339
- build/lib/build/lib/siat/financials2.py +0 -1278
- build/lib/build/lib/siat/financials_china.py +0 -4433
- build/lib/build/lib/siat/financials_china2.py +0 -2212
- build/lib/build/lib/siat/fund.py +0 -629
- build/lib/build/lib/siat/fund_china.py +0 -3307
- build/lib/build/lib/siat/future_china.py +0 -551
- build/lib/build/lib/siat/google_authenticator.py +0 -47
- build/lib/build/lib/siat/grafix.py +0 -3636
- build/lib/build/lib/siat/holding_risk.py +0 -867
- build/lib/build/lib/siat/luchy_draw.py +0 -638
- build/lib/build/lib/siat/market_china.py +0 -1168
- build/lib/build/lib/siat/markowitz.py +0 -2363
- build/lib/build/lib/siat/markowitz2.py +0 -3150
- build/lib/build/lib/siat/markowitz2_20250704.py +0 -2969
- build/lib/build/lib/siat/markowitz2_20250705.py +0 -3158
- build/lib/build/lib/siat/markowitz_simple.py +0 -373
- build/lib/build/lib/siat/ml_cases.py +0 -2291
- build/lib/build/lib/siat/ml_cases_example.py +0 -60
- build/lib/build/lib/siat/option_china.py +0 -3069
- build/lib/build/lib/siat/option_pricing.py +0 -1925
- build/lib/build/lib/siat/other_indexes.py +0 -409
- build/lib/build/lib/siat/risk_adjusted_return.py +0 -1576
- build/lib/build/lib/siat/risk_adjusted_return2.py +0 -1900
- build/lib/build/lib/siat/risk_evaluation.py +0 -2218
- build/lib/build/lib/siat/risk_free_rate.py +0 -351
- build/lib/build/lib/siat/sector_china.py +0 -4140
- build/lib/build/lib/siat/security_price2.py +0 -727
- build/lib/build/lib/siat/security_prices.py +0 -3408
- build/lib/build/lib/siat/security_trend.py +0 -402
- build/lib/build/lib/siat/security_trend2.py +0 -646
- build/lib/build/lib/siat/stock.py +0 -4284
- build/lib/build/lib/siat/stock_advice_linear.py +0 -934
- build/lib/build/lib/siat/stock_base.py +0 -26
- build/lib/build/lib/siat/stock_china.py +0 -2095
- build/lib/build/lib/siat/stock_prices_kneighbors.py +0 -910
- build/lib/build/lib/siat/stock_prices_linear.py +0 -386
- build/lib/build/lib/siat/stock_profile.py +0 -707
- build/lib/build/lib/siat/stock_technical.py +0 -3305
- build/lib/build/lib/siat/stooq.py +0 -74
- build/lib/build/lib/siat/transaction.py +0 -347
- build/lib/build/lib/siat/translate.py +0 -5183
- build/lib/build/lib/siat/valuation.py +0 -1378
- build/lib/build/lib/siat/valuation_china.py +0 -2076
- build/lib/build/lib/siat/var_model_validation.py +0 -444
- build/lib/build/lib/siat/yf_name.py +0 -811
- build/lib/siat/__init__.py +0 -75
- build/lib/siat/allin.py +0 -137
- build/lib/siat/assets_liquidity.py +0 -915
- build/lib/siat/beta_adjustment.py +0 -1058
- build/lib/siat/beta_adjustment_china.py +0 -548
- build/lib/siat/blockchain.py +0 -143
- build/lib/siat/bond.py +0 -2900
- build/lib/siat/bond_base.py +0 -992
- build/lib/siat/bond_china.py +0 -100
- build/lib/siat/bond_zh_sina.py +0 -143
- build/lib/siat/capm_beta.py +0 -783
- build/lib/siat/capm_beta2.py +0 -887
- build/lib/siat/common.py +0 -5360
- build/lib/siat/compare_cross.py +0 -642
- build/lib/siat/copyrights.py +0 -18
- build/lib/siat/cryptocurrency.py +0 -667
- build/lib/siat/economy.py +0 -1471
- build/lib/siat/economy2.py +0 -1853
- build/lib/siat/esg.py +0 -536
- build/lib/siat/event_study.py +0 -815
- build/lib/siat/fama_french.py +0 -1521
- build/lib/siat/fin_stmt2_yahoo.py +0 -982
- build/lib/siat/financial_base.py +0 -1160
- build/lib/siat/financial_statements.py +0 -598
- build/lib/siat/financials.py +0 -2339
- build/lib/siat/financials2.py +0 -1278
- build/lib/siat/financials_china.py +0 -4433
- build/lib/siat/financials_china2.py +0 -2212
- build/lib/siat/fund.py +0 -629
- build/lib/siat/fund_china.py +0 -3307
- build/lib/siat/future_china.py +0 -551
- build/lib/siat/google_authenticator.py +0 -47
- build/lib/siat/grafix.py +0 -3636
- build/lib/siat/holding_risk.py +0 -867
- build/lib/siat/luchy_draw.py +0 -638
- build/lib/siat/market_china.py +0 -1168
- build/lib/siat/markowitz.py +0 -2363
- build/lib/siat/markowitz2.py +0 -3150
- build/lib/siat/markowitz2_20250704.py +0 -2969
- build/lib/siat/markowitz2_20250705.py +0 -3158
- build/lib/siat/markowitz_simple.py +0 -373
- build/lib/siat/ml_cases.py +0 -2291
- build/lib/siat/ml_cases_example.py +0 -60
- build/lib/siat/option_china.py +0 -3069
- build/lib/siat/option_pricing.py +0 -1925
- build/lib/siat/other_indexes.py +0 -409
- build/lib/siat/risk_adjusted_return.py +0 -1576
- build/lib/siat/risk_adjusted_return2.py +0 -1900
- build/lib/siat/risk_evaluation.py +0 -2218
- build/lib/siat/risk_free_rate.py +0 -351
- build/lib/siat/sector_china.py +0 -4140
- build/lib/siat/security_price2.py +0 -727
- build/lib/siat/security_prices.py +0 -3408
- build/lib/siat/security_trend.py +0 -402
- build/lib/siat/security_trend2.py +0 -646
- build/lib/siat/stock.py +0 -4284
- build/lib/siat/stock_advice_linear.py +0 -934
- build/lib/siat/stock_base.py +0 -26
- build/lib/siat/stock_china.py +0 -2095
- build/lib/siat/stock_prices_kneighbors.py +0 -910
- build/lib/siat/stock_prices_linear.py +0 -386
- build/lib/siat/stock_profile.py +0 -707
- build/lib/siat/stock_technical.py +0 -3305
- build/lib/siat/stooq.py +0 -74
- build/lib/siat/transaction.py +0 -347
- build/lib/siat/translate.py +0 -5183
- build/lib/siat/valuation.py +0 -1378
- build/lib/siat/valuation_china.py +0 -2076
- build/lib/siat/var_model_validation.py +0 -444
- build/lib/siat/yf_name.py +0 -811
- siat-3.10.132.dist-info/RECORD +0 -218
siat/__init__.py
CHANGED
File without changes
|
siat/allin.py
CHANGED
siat/assets_liquidity.py
CHANGED
File without changes
|
siat/beta_adjustment.py
CHANGED
File without changes
|
siat/beta_adjustment_china.py
CHANGED
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(
|
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("
|
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
|
siat/exchange_bond_china.pickle
CHANGED
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
|
siat/financial_statements.py
CHANGED
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
|
siat/google_authenticator.py
CHANGED
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
|
-
|
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
siat/markowitz2_20250704.py
CHANGED
File without changes
|
siat/markowitz2_20250705.py
CHANGED
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
|
siat/risk_adjusted_return.py
CHANGED
File without changes
|
siat/risk_adjusted_return2.py
CHANGED
@@ -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
|