siat 3.10.125__py3-none-any.whl → 3.10.126__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 (87) hide show
  1. siat/common.py +106 -2
  2. siat/exchange_bond_china.pickle +0 -0
  3. siat/fund_china.pickle +0 -0
  4. siat/stock.py +10 -2
  5. siat/stock_info.pickle +0 -0
  6. {siat-3.10.125.dist-info → siat-3.10.126.dist-info}/METADATA +234 -226
  7. siat-3.10.126.dist-info/RECORD +76 -0
  8. {siat-3.10.125.dist-info → siat-3.10.126.dist-info}/WHEEL +1 -1
  9. {siat-3.10.125.dist-info → siat-3.10.126.dist-info/licenses}/LICENSE +0 -0
  10. {siat-3.10.125.dist-info → siat-3.10.126.dist-info}/top_level.txt +0 -0
  11. siat/__init__ -20240701.py +0 -65
  12. siat/__init__.py.backup_20250214.py +0 -73
  13. siat/alpha_vantage_test.py +0 -24
  14. siat/assets_liquidity_test.py +0 -44
  15. siat/barrons_scraping_test.py +0 -276
  16. siat/beta_adjustment_test.py +0 -77
  17. siat/bond_test.py +0 -142
  18. siat/capm_beta_test.py +0 -49
  19. siat/cmat_commons.py +0 -961
  20. siat/compare_cross_test.py +0 -117
  21. siat/concepts_iwencai.py +0 -86
  22. siat/concepts_kpl.py +0 -93
  23. siat/cryptocurrency_test.py +0 -71
  24. siat/derivative.py +0 -1111
  25. siat/economy-20230125.py +0 -1206
  26. siat/economy_test.py +0 -360
  27. siat/esg_test.py +0 -63
  28. siat/fama_french_test.py +0 -115
  29. siat/financial_statements_test.py +0 -31
  30. siat/financials2 - /321/205/320/231/320/277/321/206/320/254/320/274.py" +0 -341
  31. siat/financials_china2_test.py +0 -67
  32. siat/financials_china2_test2.py +0 -88
  33. siat/financials_china2_test3.py +0 -87
  34. siat/financials_china_test.py +0 -475
  35. siat/financials_china_test2.py +0 -197
  36. siat/financials_china_test2_fin_indicator.py +0 -197
  37. siat/financials_test.py +0 -713
  38. siat/fred_test.py +0 -40
  39. siat/fund_china_test.py +0 -175
  40. siat/fund_test.py +0 -40
  41. siat/future_china_test.py +0 -37
  42. siat/global_index_test.py +0 -66
  43. siat/grafix_test.py +0 -112
  44. siat/holding_risk_test.py +0 -13
  45. siat/local_debug_test.py +0 -100
  46. siat/markowitz2-20240620.py +0 -2614
  47. siat/markowitz_ccb_test.py +0 -37
  48. siat/markowitz_ef_test.py +0 -136
  49. siat/markowitz_old.py +0 -871
  50. siat/markowitz_simple-20230709.py +0 -370
  51. siat/markowitz_test.py +0 -164
  52. siat/markowitz_test2.py +0 -69
  53. siat/ml_cases_example1.py +0 -60
  54. siat/option_china_test.py +0 -447
  55. siat/option_pricing_test.py +0 -81
  56. siat/option_sina_api_test.py +0 -112
  57. siat/proxy_test.py +0 -84
  58. siat/quandl_test.py +0 -39
  59. siat/risk_adjusted_return_test.py +0 -81
  60. siat/risk_evaluation_test.py +0 -96
  61. siat/risk_free_rate_test.py +0 -127
  62. siat/sector_china_test.py +0 -203
  63. siat/security_price.py +0 -831
  64. siat/security_prices_test.py +0 -310
  65. siat/security_trend2-20240620.py +0 -493
  66. siat/setup.py +0 -41
  67. siat/shenwan index history test.py +0 -41
  68. siat/stock_china_test.py +0 -38
  69. siat/stock_info_test.py +0 -189
  70. siat/stock_list_china_test.py +0 -33
  71. siat/stock_technical-20240620.py +0 -2736
  72. siat/stock_test.py +0 -487
  73. siat/temp.py +0 -36
  74. siat/test2_graphviz.py +0 -484
  75. siat/test_graphviz.py +0 -411
  76. siat/test_markowitz_simple.py +0 -198
  77. siat/test_markowitz_simple_revised.py +0 -215
  78. siat/test_markowitz_simple_revised2.py +0 -218
  79. siat/transaction_test.py +0 -436
  80. siat/translate-20230125.py +0 -2107
  81. siat/translate-20230206.py +0 -2109
  82. siat/translate-20230215.py +0 -2158
  83. siat/translate_20240606.py +0 -4206
  84. siat/translate_241003_keep.py +0 -4300
  85. siat/universal_test.py +0 -100
  86. siat/valuation_market_china_test.py +0 -36
  87. siat-3.10.125.dist-info/RECORD +0 -152
siat/proxy_test.py DELETED
@@ -1,84 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- import pandas_datareader.data as web
4
- import requests
5
- import urllib
6
-
7
- proxy_addr=['3.211.65.185:80',
8
- '47.52.3.320:443',
9
- '103.218.3.93:3128',
10
- '119.28.60.130:80',
11
- '203.174.112.13:3128',
12
- '123.176.103.44:80',
13
- '65.51.126.74:8080',
14
- '142.44.221.126:8080',
15
- '38.143.68.18:3128',
16
- '216.125.236.84:80',
17
- ]
18
- #设置和测试代理1
19
- headers = { "Accept":"application/json",
20
- 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
21
- "Accept-Encoding":"none",
22
- "Accept-Language":"en-US,en;q = 0.8",
23
- "Connection":"keep-alive",
24
- "Referer":"https://cssspritegenerator.com",
25
- "User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11"
26
- }
27
-
28
- for pa in proxy_addr:
29
- proxies = {'http': pa}
30
- with requests.Session() as s:
31
- s.headers = headers
32
- s.proxies.update(proxies)
33
- try:
34
- gspc = web.DataReader('^GSPC', 'yahoo', '2021-11-1', '2021-11-5', session=s)
35
- except:
36
- print(" Warning! Failed proxy",pa)
37
- continue
38
- else:
39
- print(" Success! Found workable proxy",pa)
40
- break
41
- #设置和测试代理2
42
- for pa in proxy_addr:
43
- proxies = {'http': pa}
44
- proxy_support = urllib.request.ProxyHandler(proxies)
45
- opener = urllib.request.build_opener(proxy_support)
46
- urllib.request.install_opener(opener)
47
-
48
- try:
49
- tsla = web.DataReader("TSLA", 'yahoo', '2021-11-1', '2021-11-5')
50
- except:
51
- print(" Warning! Failed proxy",pa)
52
- continue
53
- else:
54
- print(" Success! Found workable proxy",pa)
55
- break
56
-
57
- #设置和测试代理3
58
- for pa in proxy_addr:
59
- proxies = {'http': pa}
60
- try:
61
- r = requests.get(f"http://httpbin.org/ip", proxies=proxies)
62
- rj=r.json()
63
- except:
64
- print(" Warning! Failed proxy",pa)
65
- continue
66
- else:
67
- print(" Success! Found workable proxy",pa)
68
- continue
69
-
70
- #===========================================================================
71
- import requests
72
- import pandas as pd
73
-
74
- headers = {
75
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36'
76
- }
77
-
78
- #抓取代理服务器地址
79
- i = 1000
80
- url = f'https://www.kuaidaili.com/free/inha/{i}/'
81
- r = requests.get(url, headers=headers)
82
- r.encoding = 'u8'
83
- ip_df, = pd.read_html(r.text)
84
- ip_df
siat/quandl_test.py DELETED
@@ -1,39 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- start='2018-1-1'; end='2018-12-31'
4
-
5
- import quandl
6
- import quandl as qd
7
- quandl.ApiConfig.api_key = "jPxsQBSvfxF_qhzTdydi"
8
-
9
- # WTI Crude Oil price from the US Department of Energy
10
- df1 = qd.get("EIA/PET_RWTC_D",start_date='2018-1-1',end_date='2021-10-31')
11
-
12
- # 仅提取月底数值
13
- df2 = qd.get("EIA/PET_RWTC_D",start_date='2018-1-1',end_date='2021-10-31', collapse="monthly")
14
-
15
- # company profile and basic financial info
16
- df3 = qd.get_table('ZACKS/FC', ticker='AAPL')
17
-
18
- df4 = qd.get_table('ZACKS/FC', paginate=True)
19
-
20
- df5 = quandl.get_table('ZACKS/FC', paginate=True, ticker='AAPL', qopts={'columns': ['ticker', 'per_end_date']})
21
-
22
- df6 = quandl.get_table('ZACKS/FC', paginate=True, ticker=['AAPL', 'MSFT'], per_end_date={'gte': '2015-01-01'}, qopts={'columns':['ticker', 'per_end_date']})
23
-
24
-
25
- df7=quandl.get('WIKI/AAPL',start_date='2018-1-1',end_date='2021-10-31')
26
- #==============================================================================
27
- import os
28
- os.environ['QUANDL_API_KEY']="jPxsQBSvfxF_qhzTdydi"
29
-
30
- import pandas_datareader as web
31
- df11=web.DataReader('HKEX/00700','quandl','2018-1-1','2021-10-31')
32
- df12=web.DataReader('BSE/BOM532540','quandl','2018-1-1','2021-10-31')
33
-
34
- # S&P Composite
35
- df13=web.DataReader('YALE/SPCOMP','quandl','2018-1-1','2021-10-31')
36
- df13b = quandl.get('YALE/SPCOMP',start_date='2018-1-1',end_date='2021-10-31')
37
-
38
- quandl.ApiConfig.api_key = "jPxsQBSvfxF_qhzTdydi"
39
- df13 = quandl.get('WIKI/AAPL',start_date='2018-1-1',end_date='2021-10-31', api_key="jPxsQBSvfxF_qhzTdydi")
@@ -1,81 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- import os; os.chdir("S:/siat")
4
- from siat import *
5
- #==============================================================================
6
- portfolio={'Market': ('US','^GSPC'),'AMZN':0.5,'EBAY':0.3,'WMT':0.2}
7
- sr,rp=rar_ratio_portfolio(portfolio,'2021-1-1','2021-12-31',ratio_name='sharpe')
8
-
9
-
10
-
11
-
12
- #==============================================================================
13
-
14
- portfolio={'Market':('Israel','^TA125.TA'),'FIBI.TA':1.0}
15
- r=rar_ratio_rolling(portfolio,'2021-1-1','2021-10-30',ratio_name='sharpe',window=120)
16
-
17
- portfolio={'Market':('Israel','^TA125.TA'),'FIBI.TA':0.3,'TEVA.TA':0.7}
18
- r=rar_ratio_rolling(portfolio,'2021-1-1','2021-10-30',ratio_name='sharpe',window=120)
19
- r=rar_ratio_rolling(portfolio,'2021-1-1','2021-10-30',ratio_name='alpha',window=120)
20
-
21
- portfolio={'Market':('US','^DJI'),'TEVA':1.0}
22
- df=get_portfolio_prices(portfolio,'2020-4-1','2021-10-30')
23
-
24
- start='2020-4-1'
25
- end='2021-10-30'
26
- portfolio={'Market':('China','^HSI'),'0823.HK':1.0}
27
- r=rar_ratio_rolling(portfolio,'2021-7-1','2021-10-30',ratio_name='alpha',window=60)
28
- r=rar_ratio_rolling(portfolio,'2021-7-1','2021-10-30',ratio_name='sharpe',window=60)
29
- #==============================================================================
30
- portfolio={'Market':('US','^GSPC'),'BABA':10,'PDD':7,'JD':5,'VIPS':1}
31
- r=rar_ratio_rolling(portfolio,'2020-4-1','2021-3-31',ratio_name='treynor',window=60)
32
- r=rar_ratio_rolling(portfolio,'2020-4-1','2021-3-31',ratio_name='sharpe',window=60)
33
- r=rar_ratio_rolling(portfolio,'2020-4-1','2021-3-31',ratio_name='sortino',window=60)
34
- r=rar_ratio_rolling(portfolio,'2020-4-1','2021-3-31',ratio_name='alpha',window=60)
35
-
36
-
37
-
38
- #==============================================================================
39
-
40
- portfolio={'Market':('US','^GSPC'),'TSLA':1.0}
41
- #r=rar_ratio_rolling(portfolio,'2019-1-1','2020-12-31',ratio_name='treynor',window=30)
42
- r=rar_ratio_rolling(portfolio,'2019-1-1','2020-12-31',ratio_name='sharpe',window=30)
43
- r=rar_ratio_rolling(portfolio,'2019-1-1','2020-12-31',ratio_name='alpha',window=30)
44
-
45
-
46
- df4=get_prices_yf(['AAPL','MSFT','IBM'],'2020-1-1','2020-12-31')
47
- df4=get_prices_yf(tickerlist,'2020-1-1','2020-12-31')
48
-
49
-
50
-
51
- pf1={'Market':('US','^GSPC'),'AAPL':1}
52
- rars1=rar_ratio_rolling(pf1,'2019-12-1','2021-1-31',ratio_name='sharpe',window=30,graph=True)
53
-
54
- tr1,rp1=rar_ratio_portfolio(pf1,'2019-01-01','2019-01-31',ratio_name='sharpe')
55
-
56
-
57
- pf1={'Market':('US','^GSPC'),'AAPL':1}
58
- pf2={'Market':('US','^GSPC'),'MSFT':1}
59
- rars12=compare_rar_portfolio(pf1,pf2,'2019-11-1','2020-11-30')
60
-
61
- pfA={'Market':('China','000001.SS'),'600519.SS':1}
62
- pfB={'Market':('China','000001.SS'),'000858.SZ':1}
63
- rarsAB=compare_rar_portfolio(pfA,pfB,'2019-11-1','2020-11-30')
64
-
65
- pfbb={'Market':('US','^GSPC'),'BABA':1}
66
- pfjd={'Market':('US','^GSPC'),'JD':1}
67
- rarsbj=compare_rar_portfolio(pfbb,pfjd,'2019-11-1','2020-11-30')
68
-
69
- pfbb={'Market':('US','^GSPC'),'BABA':1}
70
- pfpd={'Market':('US','^GSPC'),'PDD':1}
71
- rarsbj=compare_rar_portfolio(pfbb,pfpd,'2019-11-1','2020-11-30')
72
-
73
-
74
- pf01={'Market':('US','^GSPC'),'BABA':0.5,'PDD':0.5}
75
- pf02={'Market':('US','^GSPC'),'JD':0.5,'VIPS':0.5}
76
- rars12=compare_rar_portfolio(pf01,pf02,'2019-11-1','2020-11-30')
77
-
78
-
79
- pf01={'Market':('US','^GSPC'),'BABA':0.2,'VIPS':0.8}
80
- pf02={'Market':('US','^GSPC'),'JD':0.6,'PDD':0.4}
81
- rars12=compare_rar_portfolio(pf01,pf02,'2019-11-1','2020-11-30')
@@ -1,96 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
- import os; os.chdir("S:/siat")
5
- from siat import *
6
-
7
- portfolio={'Market':('China','000001.SS'),'000661.SZ':2,'603392.SS':3,'300601.SZ':4}
8
- backtest_VaR_portfolio(portfolio,'2020-7-20',1, model="montecarlo")
9
-
10
-
11
- vl,rl=get_VaR_portfolio(portfolio,'2020-7-20',1,0.99,model='all')
12
-
13
-
14
- stock_quotes=get_stock_quotes('BABA','2021-11-1','2021-11-10')
15
-
16
- df=get_prices('BABA','2021-11-1','2021-11-10')
17
- get_prices('BABA','2021-11-1','2021-11-10')
18
-
19
- var,ratio=stock_VaR_normal_standard('BABA',1000,'2019-8-8',1,0.99)
20
-
21
- tlcps=series_VaR_tlcp(['GOOG','MSFT','AAPL'],'2020-7-20',0.99,model='montecarlo')
22
-
23
- backtest_VaR(['AAPL'],[1000],'2020-7-20',1,model="normal_standard")
24
-
25
-
26
-
27
-
28
-
29
- ticker=['000661.SZ', '603392.SS', '300601.SZ']
30
- get_prices(ticker,'2019-7-19','2020-7-20')
31
-
32
- prices=get_portfolio_prices(portfolio,'2019-7-19','2020-7-20')
33
-
34
-
35
- var,ratio=stock_VaR_normal_standard('BABA',1000,'2019-8-8',1,0.99)
36
-
37
-
38
- #==============================================================================
39
- import os; os.chdir("S:/siat")
40
- from siat import *
41
-
42
- var,ratio=stock_VaR_normal_standard('BABA',1000,'2019-8-8',1,0.99)
43
-
44
- tickerlist=['BABA','PDD','JD']
45
- datelist=['2019-1-1','2019-2-1','2019-3-1','2019-4-1','2019-5-1','2019-6-1','2019-7-1']
46
- compare_VaR_normal_standard(tickerlist,10000, datelist,1,0.99)
47
-
48
- var, ratio=stock_VaR_normal_standard('BIDU',1000,'2020-7-1',1,0.99)
49
- var,ratio=stock_VaR_normal_modified('BIDU',1000,'2020-7-1',1,0.99)
50
-
51
- test=stock_ret_Normality_SW('BIDU','2020-1-1','2020-6-30')
52
-
53
- plot_rets_curve('BIDU','2020-1-1','2020-6-30')
54
-
55
- plot_rets_curve('1166.HK','2015-1-1','2015-3-31')
56
-
57
- plot_rets_curve('0273.HK', '2011-4-1', '2011-6-30')
58
-
59
- var, ratio=stock_VaR_normal_standard('ZM',1000,'2020-5-1',1,0.99)
60
-
61
- var, ratio=stock_VaR_normal_modified('ZM',1000,'2020-5-1',1,0.99)
62
- var, ratio=stock_VaR_historical_1d('ZM',1000,'2020-5-1',0.99)
63
- test=stock_ret_Normality_SW('ZM','2020-1-1','2020-4-30', siglevel=0.05)
64
- plot_rets_curve('ZM','2020-1-1','2020-4-30')
65
-
66
- var, ratio=stock_VaR_historical_grouping('0992.HK',1000,'2020-5-1',1,0.99, pastyears=3)
67
- var, ratio=stock_VaR_historical_grouping('0992.HK',1000,'2020-5-1',5,0.99, pastyears=3)
68
- var, ratio=stock_VaR_historical_grouping('0992.HK',1000,'2020-5-1',10,0.99,pastyears=3)
69
- var, ratio=stock_VaR_historical_grouping('0992.HK',1000,'2020-5-1',15,0.99,pastyears=3)
70
-
71
- var, ratio=stock_VaR_montecarlo('1810.HK',1000,'2018-8-1',1,0.99)
72
- var, ratio=stock_VaR_montecarlo('1810.HK',1000,'2018-8-1',5,0.99)
73
-
74
- var, ratio=stock_VaR_montecarlo('1810.HK',1000,'2018-8-1',1,0.99,mctype='oversampling')
75
- var, ratio=stock_VaR_montecarlo('1810.HK',1000,'2018-8-1',5,0.99,mctype='oversampling')
76
- var, ratio=get_VaR_allmodels('1810.HK',1000,'2020-7-20',5,0.99)
77
-
78
- test=stock_ret_Normality_SW('1810.HK','2020-4-20','2020-7-20')
79
- backtest_VaR(['AAPL'], [1000],'2020-7-20',1, model="normal_standard")
80
- backtest_VaR(['AAPL'], [1000],'2020-7-20',1, model="normal_modified")
81
- backtest_VaR(['AAPL'], [1000],'2020-7-20',1, model="historical")
82
- backtest_VaR(['AAPL'], [1000],'2020-7-20',1, model="montecarlo")
83
-
84
- var, var_ratio=stock_VaR_normal_standard('JD',1000,'2019-8-9',1)
85
- es, es_ratio=stock_ES_normal_standard('JD',1000,'2019-8-9',1)
86
-
87
- portfolio={'Market':('China','000001.SS'),'000661.SZ':2,'603392.SS':3,'300601.SZ':4}
88
- vl, rl=get_VaR_portfolio(portfolio,'2020-7-20',1,0.99, model='all')
89
-
90
- portfolio_rets_curve(portfolio,'2019-7-20','2020-7-20')
91
-
92
- portfolio={'Market':('China','000001.SS'),'300782.SZ':2,'300661.SZ':3,'688019.SS':4}
93
- portfolio_rets_curve(portfolio,'2019-7-20','2020-7-20')
94
-
95
- v, r=get_VaR_portfolio(portfolio,'2020-7-20',5,0.99, model='historical')
96
- e, r=get_ES_portfolio(portfolio,'2020-7-20',5,0.99, model='historical')
@@ -1,127 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- import os; os.chdir("S:/siat")
4
- from siat.risk_free_rate import *
5
- #==============================================================================
6
- ff3=get_ff_factors("2018-1-1","2020-12-31",scope='US',factor='FF3',freq='daily')
7
-
8
-
9
-
10
- df1=get_rf_capm('AAPL','^GSPC','2018-1-1','2020-12-31',window=60)
11
- df1['Rf_5']=df1['Rf'].rolling(window=5).mean()
12
- compare_rf(df1,'Rf',df1,'Rf_5','2019-1-1','2019-12-31',twinx=True)
13
-
14
- df1['Rf_60']=df1['Rf'].rolling(window=60).mean()
15
- compare_rf(df1,'Rf',df1,'Rf_60','2019-1-1','2019-12-31',twinx=True)
16
-
17
- df1['Rf_cum5']=calc_rolling_cumret(df1,'Rf',period='Weekly')
18
- df1['Rf_cum60']=calc_rolling_cumret(df1,'Rf',period='Quarterly')
19
-
20
- df1['Rf_winsor']=winsor(df1,'Rf')
21
- compare_rf(df1,'Rf',df1,'Rf_winsor','2018-1-1','2020-12-31')
22
-
23
- df1=get_rf_capm('AAPL','^GSPC','2018-1-1','2020-12-31',window=60)
24
- df2=get_rf_capm('MSFT','^GSPC','2018-1-1','2020-12-31',window=60)
25
- df1['Rf_winsor10']=winsor(df1,'Rf',limits=[0.1,0.1])
26
- df2['Rf_winsor10']=winsor(df2,'Rf',limits=[0.1,0.1])
27
- df1['Rf_wa60']=df1['Rf_winsor10'].rolling(window=60).mean()
28
- df2['Rf_wa60']=df2['Rf_winsor10'].rolling(window=60).mean()
29
- compare_rf(df1,'Rf_wa60',df2,'Rf_wa60','2019-1-1','2020-12-31',twinx=True)
30
-
31
-
32
- df1=get_rf_capm('AAPL','^GSPC','2018-1-1','2020-12-31',window=240)
33
- df2=get_rf_capm('MSFT','^GSPC','2018-1-1','2020-12-31',window=240)
34
- compare_rf(df1,'Rf',df2,'Rf','2019-1-1','2020-12-31',twinx=True)
35
- compare_rf(df1,'Rf',df2,'Rf','2019-1-1','2020-12-31')
36
-
37
- df1['Rf_winsor10']=winsor(df1,'Rf',limits=[0.1,0.1])
38
- df2['Rf_winsor10']=winsor(df2,'Rf',limits=[0.1,0.1])
39
- df1['Rf_wa21']=df1['Rf_winsor10'].rolling(window=21).mean()
40
- df2['Rf_wa21']=df2['Rf_winsor10'].rolling(window=21).mean()
41
- compare_rf(df1,'Rf_wa21',df2,'Rf_wa21','2019-1-1','2020-12-31',twinx=True)
42
- compare_rf(df1,'Rf_wa21',df2,'Rf_wa21','2019-1-1','2020-12-31')
43
-
44
-
45
- df1=get_rf_capm('^DJI','^GSPC','2018-1-1','2020-12-31',window=240)
46
- df2=get_rf_capm('^GSPC','^DJI','2018-1-1','2020-12-31',window=240)
47
- df1['Rf_winsor']=winsor(df1,'Rf',limits=[0.01,0.01])
48
- df2['Rf_winsor']=winsor(df2,'Rf',limits=[0.01,0.01])
49
- df1['Rf_wa60']=df1['Rf_winsor'].rolling(window=60).mean()
50
- df2['Rf_wa60']=df2['Rf_winsor'].rolling(window=60).mean()
51
- compare_rf(df1,'Rf_wa60',df2,'Rf_wa60','2019-1-1','2020-12-31',twinx=True)
52
- compare_rf(df1,'Rf_wa60',df2,'Rf_wa60','2019-1-1','2020-12-31')
53
-
54
-
55
-
56
-
57
-
58
-
59
- df1['Rf'].plot()
60
-
61
-
62
- df1['Rf_5'].plot()
63
-
64
- df1['Rf_10']=df1['Rf'].rolling(window=10).mean()
65
- df1['Rf_10'].plot()
66
-
67
- df1['Rf_20']=df1['Rf'].rolling(window=20).mean()
68
- df1['Rf_20'].plot()
69
-
70
- df1['Rf_60']=df1['Rf'].rolling(window=60).mean()
71
- df1['Rf_60'].plot()
72
-
73
- df1['Rf_120']=df1['Rf'].rolling(window=120).mean()
74
- df1['Rf_120'].plot()
75
-
76
- df1['Rf_240']=df1['Rf'].rolling(window=240).mean()
77
- df1['Rf_240'].plot()
78
-
79
-
80
-
81
-
82
- df2=get_rf_capm('MSFT','^GSPC','2018-1-1','2020-12-31',window=30)
83
- df2['Rf'].plot()
84
-
85
- df2['Rf_240']=df2['Rf'].rolling(window=240).mean()
86
- df2['Rf_240'].plot()
87
-
88
- compare_rf(df1,'Rf_240',df2,'Rf_240','2019-1-1','2019-12-31',twinx=True)
89
-
90
-
91
-
92
-
93
-
94
- #==============================================================================
95
- df1=get_rf_capm('000001.SS','000300.SS','2020-1-1','2020-12-31',window=240)
96
- df1['Rf'].plot()
97
-
98
- df2=get_rf_capm('399001.SZ','000300.SS','2020-1-1','2020-12-31',window=240)
99
- df2['Rf'].plot()
100
-
101
- #==============================================================================
102
- df3=get_rf_capm('600519.SS','000300.SS','2020-1-1','2020-12-31',window=240)
103
- df3['Rf'].plot()
104
-
105
- df4=get_rf_capm('000858.SZ','000300.SS','2020-1-1','2020-12-31',window=240)
106
- df4['Rf'].plot()
107
-
108
- #==============================================================================
109
- df5=get_rf_capm('AAPL','^GSPC','2020-1-1','2020-12-31',window=240)
110
- df5['Rf'].plot()
111
-
112
- df6=get_rf_capm('MSFT','^GSPC','2020-1-1','2020-12-31',window=240)
113
- df6['Rf'].plot()
114
-
115
- #==============================================================================
116
- df7=get_rf_capm('AAPL','^GSPC','2018-1-1','2020-12-31',window=240)
117
- df7['Rf'].plot()
118
-
119
- df8=get_rf_capm('MSFT','^GSPC','2018-1-1','2020-12-31',window=240)
120
- df8['Rf'].plot()
121
-
122
- #==============================================================================
123
-
124
-
125
- if __name__=='__main__':
126
- compare_rf(df7,df8,'2018-1-1','2018-12-31')
127
-
siat/sector_china_test.py DELETED
@@ -1,203 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- import os; os.chdir("S:\siat")
4
- from siat.sector_china import *
5
-
6
- #==============================================================================
7
-
8
- # 设定观察期:近三年
9
- start='2020-1-1'; end='2022-12-31'
10
-
11
- # 收集行业市场业绩数据:一级行业,本案例重点
12
- idf1,idfall1=get_industry_info_sw(start,end,itype='I')
13
-
14
- # 投资收益率(持有收益率)
15
- df1=rank_industry_sw(idf1,
16
- measure='Exp Ret%',
17
- graph=True,
18
- axisamp=0.9,
19
- printout=True,
20
- )
21
-
22
- industry_list=['801730',
23
- '801950',
24
- '801210',
25
- '801050',
26
- '801030',
27
- '801120',
28
- '801230',
29
- '801880',
30
- '801740',
31
- '801890',
32
- '801150',
33
- '801160',
34
- '801040',
35
- '801140',
36
- '801080',
37
- ]
38
-
39
- mdf=compare_mindustry_sw(industry_list,
40
- measure='Exp Ret%',
41
- start=start,end=end,
42
- itype='I',#检查范围是一级行业
43
- graph=False,
44
- printout=True,
45
- )
46
-
47
- mdf2=compare_mindustry_sw2(industry_list,
48
- measure='Exp Ret%',
49
- start=start,end=end,
50
- #itype='I',#检查范围是一级行业
51
- graph=False,
52
- printout=True,
53
- )
54
-
55
-
56
-
57
-
58
-
59
- #==============================================================================
60
- df=sector_position_china('000661',"gn_swym")
61
-
62
- df=sector_position_china('000661',"new_swzz")
63
- df=sector_position_china('000661',"hangye_ZC27")
64
-
65
-
66
-
67
-
68
- df=sector_list_china("新浪行业")
69
-
70
-
71
-
72
- #数据网址:http://finance.sina.com.cn/stock/sl/#qmxindustry_1
73
-
74
- import akshare as ak
75
-
76
- # 板块行情
77
- stock_industry_sina_df = ak.stock_sector_spot(indicator="新浪行业")
78
- sectorlist=list(stock_industry_sina_df['板块'])
79
- num=len(sectorlist)
80
- for d in sectorlist:
81
- print(d,end=' ')
82
- pos=sectorlist.index(d)+1
83
- if (pos % 6 ==0) or (pos==num): print(' ')
84
-
85
-
86
-
87
-
88
- stock_industry_star_df = ak.stock_sector_spot(indicator="启明星行业")
89
-
90
- stock_industry_concept_df = ak.stock_sector_spot(indicator="概念")
91
-
92
- stock_industry_region_df = ak.stock_sector_spot(indicator="地域")
93
-
94
- stock_industry_industry_df = ak.stock_sector_spot(indicator="行业")
95
- hangye_list=list(set(list(stock_industry_industry_df['label'])))
96
- hangye_list.sort()
97
-
98
- #板块详情:nmc-流通市值?mktcap-总市值?
99
- #"行业"
100
- stock_sector_zl01_df = ak.stock_sector_detail(sector="hangye_ZL01")
101
- len(stock_sector_zl01_df)
102
-
103
- stock_sector_zc27_df = ak.stock_sector_detail(sector="hangye_ZC27")
104
-
105
- #"概念"
106
- stock_sector_kc50_df = ak.stock_sector_detail(sector="gn_kc50")
107
-
108
- #"地域"
109
- stock_sector_440000_df = ak.stock_sector_detail(sector="diyu_440000")
110
-
111
- #"新浪行业"
112
- stock_sector_dlhy_df = ak.stock_sector_detail(sector="new_dlhy")
113
-
114
- #"启明星行业":无详情
115
-
116
-
117
-
118
- import os; os.chdir("E:/siat")
119
- from siat.sector_china import *
120
-
121
- df=sector_list_china(indicator="概念")
122
- sector_code_china("重组概念")
123
- sector_code_china("建筑工程")
124
- sector_code_china("资产注入")
125
- sector_code_china("建筑节能")
126
- sector_code_china("建筑装饰和其他建筑业")
127
- sector_code_china("建筑安装业")
128
-
129
-
130
-
131
-
132
-
133
-
134
- df=sector_rank_china("涨跌幅","概念",80)
135
- df[df['板块']=='重组概念']
136
- df1=sector_detail_china(sector="gn_zzgn",comp="涨跌幅",num=10)
137
- df1=sector_detail_china(sector="gn_zzgn",comp="涨跌幅",num=-10)
138
-
139
-
140
- df=sector_list_china(indicator="新浪行业")
141
- df=sector_list_china(indicator="启明星行业")
142
- df=sector_list_china(indicator="行业")
143
- df=sector_list_china(indicator="概念")
144
- df=sector_list_china(indicator="地域")
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
- sector_code_china("资本市场服务")
155
- sector_code_china("房地产")
156
-
157
- df=sector_rank_china("涨跌幅","新浪行业")
158
- df=sector_rank_china("涨跌幅","新浪行业",-10)
159
-
160
- #df=sector_rank_china("成交量","新浪行业")
161
- df=sector_rank_china("平均价格","新浪行业")
162
- df=sector_rank_china("公司家数","新浪行业")
163
- df=sector_rank_china("公司家数","新浪行业",-10)
164
-
165
- df=sector_rank_china("涨跌幅","地域")
166
- df=sector_rank_china("涨跌幅","地域",-10)
167
-
168
- #df=sector_rank_china("成交量","地域")
169
- df=sector_rank_china("平均价格","地域")
170
-
171
- df=sector_rank_china("涨跌幅","启明星行业")
172
- df=sector_rank_china("涨跌幅","启明星行业",-10)
173
-
174
- df=sector_rank_china("涨跌幅","行业")
175
- df=sector_rank_china("涨跌幅","行业",10)
176
-
177
- df=sector_rank_china("涨跌幅","概念",-10)
178
- df=sector_rank_china("公司家数","概念",-10)
179
-
180
- df=sector_detail_china(sector="new_dlhy",comp="涨跌幅",num=-10)
181
- df=sector_detail_china(sector="new_dlhy",comp="换手率",num=10)
182
- df=sector_detail_china(sector="new_dlhy",comp="收盘价",num=10)
183
- df=sector_detail_china(sector="new_dlhy",comp="市盈率",num=10)
184
- df=sector_detail_china(sector="new_dlhy",comp="市净率",num=10)
185
- df=sector_detail_china(sector="new_dlhy",comp="流通市值",num=10)
186
- df=sector_detail_china(sector="new_dlhy",comp="总市值",num=10)
187
- df=sector_detail_china(sector="new_dlhy",comp="流通市值",num=-10)
188
-
189
-
190
- df=sector_position_china('600021',"new_dlhy")
191
- df=sector_position_china('000661',"yysw")
192
-
193
- df=sector_position_china('000661',"gn_swym")
194
-
195
-
196
- df=sector_position_china('002504',"jzgc")
197
- df=sector_position_china('002504',"gn_zczr")
198
- df=sector_position_china('002504',"gn_jzjn")
199
- df=sector_position_china('002504',"hangye_ZE50")
200
-
201
- import seaborn as sn
202
-
203
-