siat 3.10.125__py3-none-any.whl → 3.10.127__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/common.py +106 -2
- siat/exchange_bond_china.pickle +0 -0
- siat/fund_china.pickle +0 -0
- siat/stock.py +10 -2
- siat/stock_info.pickle +0 -0
- {siat-3.10.125.dist-info → siat-3.10.127.dist-info}/METADATA +235 -226
- siat-3.10.127.dist-info/RECORD +76 -0
- {siat-3.10.125.dist-info → siat-3.10.127.dist-info}/WHEEL +1 -1
- {siat-3.10.125.dist-info → siat-3.10.127.dist-info/licenses}/LICENSE +0 -0
- {siat-3.10.125.dist-info → siat-3.10.127.dist-info}/top_level.txt +0 -0
- siat/__init__ -20240701.py +0 -65
- siat/__init__.py.backup_20250214.py +0 -73
- siat/alpha_vantage_test.py +0 -24
- siat/assets_liquidity_test.py +0 -44
- siat/barrons_scraping_test.py +0 -276
- siat/beta_adjustment_test.py +0 -77
- siat/bond_test.py +0 -142
- siat/capm_beta_test.py +0 -49
- siat/cmat_commons.py +0 -961
- siat/compare_cross_test.py +0 -117
- siat/concepts_iwencai.py +0 -86
- siat/concepts_kpl.py +0 -93
- siat/cryptocurrency_test.py +0 -71
- siat/derivative.py +0 -1111
- siat/economy-20230125.py +0 -1206
- siat/economy_test.py +0 -360
- siat/esg_test.py +0 -63
- siat/fama_french_test.py +0 -115
- siat/financial_statements_test.py +0 -31
- siat/financials2 - /321/205/320/231/320/277/321/206/320/254/320/274.py" +0 -341
- siat/financials_china2_test.py +0 -67
- siat/financials_china2_test2.py +0 -88
- siat/financials_china2_test3.py +0 -87
- siat/financials_china_test.py +0 -475
- siat/financials_china_test2.py +0 -197
- siat/financials_china_test2_fin_indicator.py +0 -197
- siat/financials_test.py +0 -713
- siat/fred_test.py +0 -40
- siat/fund_china_test.py +0 -175
- siat/fund_test.py +0 -40
- siat/future_china_test.py +0 -37
- siat/global_index_test.py +0 -66
- siat/grafix_test.py +0 -112
- siat/holding_risk_test.py +0 -13
- siat/local_debug_test.py +0 -100
- siat/markowitz2-20240620.py +0 -2614
- siat/markowitz_ccb_test.py +0 -37
- siat/markowitz_ef_test.py +0 -136
- siat/markowitz_old.py +0 -871
- siat/markowitz_simple-20230709.py +0 -370
- siat/markowitz_test.py +0 -164
- siat/markowitz_test2.py +0 -69
- siat/ml_cases_example1.py +0 -60
- siat/option_china_test.py +0 -447
- siat/option_pricing_test.py +0 -81
- siat/option_sina_api_test.py +0 -112
- siat/proxy_test.py +0 -84
- siat/quandl_test.py +0 -39
- siat/risk_adjusted_return_test.py +0 -81
- siat/risk_evaluation_test.py +0 -96
- siat/risk_free_rate_test.py +0 -127
- siat/sector_china_test.py +0 -203
- siat/security_price.py +0 -831
- siat/security_prices_test.py +0 -310
- siat/security_trend2-20240620.py +0 -493
- siat/setup.py +0 -41
- siat/shenwan index history test.py +0 -41
- siat/stock_china_test.py +0 -38
- siat/stock_info_test.py +0 -189
- siat/stock_list_china_test.py +0 -33
- siat/stock_technical-20240620.py +0 -2736
- siat/stock_test.py +0 -487
- siat/temp.py +0 -36
- siat/test2_graphviz.py +0 -484
- siat/test_graphviz.py +0 -411
- siat/test_markowitz_simple.py +0 -198
- siat/test_markowitz_simple_revised.py +0 -215
- siat/test_markowitz_simple_revised2.py +0 -218
- siat/transaction_test.py +0 -436
- siat/translate-20230125.py +0 -2107
- siat/translate-20230206.py +0 -2109
- siat/translate-20230215.py +0 -2158
- siat/translate_20240606.py +0 -4206
- siat/translate_241003_keep.py +0 -4300
- siat/universal_test.py +0 -100
- siat/valuation_market_china_test.py +0 -36
- siat-3.10.125.dist-info/RECORD +0 -152
@@ -0,0 +1,76 @@
|
|
1
|
+
siat/__init__.py,sha256=Y21NfAoDxQ3srK1tK-j8EQHzovAA4V_0ntqH8Sa_1E0,2236
|
2
|
+
siat/allin.py,sha256=--32Bt2Mfg7l38w7X9cLJCdWtYRB3tTtVHnS9WnqKDI,3035
|
3
|
+
siat/assets_liquidity.py,sha256=OnE_DyTznIs_m76MtszIvPXFVIjvB4_X2D3Y2-hlVO8,33892
|
4
|
+
siat/beta_adjustment.py,sha256=u_EZt3rEbvXDpqcJp_hUh9637P5vsrRHEfX6uG9Uin8,37292
|
5
|
+
siat/beta_adjustment_china.py,sha256=z17bstK2WtlKKqUl6aCcP3Pv661PWgyWqAqGHGUH7Yk,20807
|
6
|
+
siat/blockchain.py,sha256=awF3GDtlwaJhku0a2kLuXOS8d3IzkjR_RyzlZWvD3L4,6032
|
7
|
+
siat/bond.py,sha256=tSUY9o31_Q8d7TVEsy4b6AeGr1tj9UGV6fl52LXy2hQ,112805
|
8
|
+
siat/bond_base.py,sha256=ClHJ5dzjoO9knGhX65Sbyk0i0uKQpmdKGUblR-wrXTs,37681
|
9
|
+
siat/bond_china.py,sha256=WzUhjYYk8tsr3BDWLQcpuj9DqNxTzBSIi_wuAOZ48kY,3082
|
10
|
+
siat/bond_zh_sina.py,sha256=26BohGcS120utwqg9dJvdGm5OkuNpNu5bco80uOuQpU,4423
|
11
|
+
siat/capm_beta.py,sha256=t8-xr90II0JzbjsTOZNpRze_mKTvBRXjwN2o0N0tgD8,30521
|
12
|
+
siat/capm_beta2.py,sha256=4g8pOFCwFrEpLx2NJbhL2nl_nrWaOwgbPCHx1G6P_tI,35949
|
13
|
+
siat/common.py,sha256=sml-hCMfC4mSkdpURrI5UbkUudvq2FpFlsilwTO3ojw,191049
|
14
|
+
siat/compare_cross.py,sha256=3iP9TH2h3w27F2ARZc7FjKcErYCzWRc-TPiymOyoVtw,24171
|
15
|
+
siat/copyrights.py,sha256=YMLjZb328YpFMR-s_GUu0HBgeGce3pV7DgRut8S3I7w,690
|
16
|
+
siat/cryptocurrency.py,sha256=QSc4jK9VFlqBWVu-0th1BIMt8wC-5R5sWky3EaNupy0,27940
|
17
|
+
siat/economy.py,sha256=4HxAb44uQKyrYAMcS9RoSVc3xiHn7GSeliQ6ICQKoOc,84197
|
18
|
+
siat/economy2.py,sha256=SVy4PV7a0_4FI2FGNDEyvWxeFNUxci9AMxx8hKmucY8,84356
|
19
|
+
siat/esg.py,sha256=GMhaonIKtvOK83rhpQUH5aJt2OL3HQBSVfD__Yw-0oo,19040
|
20
|
+
siat/event_study.py,sha256=uQojKR5Mg3AC1PCSpx_CBHfUjJr0B4E-iCWxNF0Vif8,37178
|
21
|
+
siat/exchange_bond_china.pickle,sha256=Bbbnbf_jr6D_JCZ5gFf4dqz4XJ5UYIrSB3oRzgGfPIk,92214
|
22
|
+
siat/fama_french.py,sha256=L5_pI8FQa1ZNB15XyKK50Zb-ZWy0h0LSFQMAfCxDrvw,57863
|
23
|
+
siat/fin_stmt2_yahoo.py,sha256=LGmspk0nKyz4X87MtcovZXUfMQkAvrWINuxR4HQ8PI8,41178
|
24
|
+
siat/financial_base.py,sha256=A1rV7XQOVFpCXCV-T6Ge0QeF897hINiu0olN1XWeaFk,41287
|
25
|
+
siat/financial_statements.py,sha256=c5IdzGbOv7wTsve6CFqd7Fo7QTamhl-9v6BPgfNknxA,23331
|
26
|
+
siat/financials.py,sha256=VFdaA3ijDuToM_ASntmbGohFmSUORTe-51AlMFMhmwM,91747
|
27
|
+
siat/financials2.py,sha256=xCxqubwCNdfS7WyIb5IXTFonMZfw8FM9F8TCIkAruhk,58795
|
28
|
+
siat/financials_china.py,sha256=GbjxOHqfHqhXHu_SWSYczTSkoly1m--CzkcfPGzAP0s,192484
|
29
|
+
siat/financials_china2.py,sha256=VvkzkjZeH84zwypR7ReldgJeZ7jnNw0qkzebvWMPm10,94956
|
30
|
+
siat/fund.py,sha256=KS7NgzLLifwUJAQX4HpPi4CjLBamUcTpjsda4KSnfHE,24656
|
31
|
+
siat/fund_china.pickle,sha256=x_nPPdwy7wzIhtZQOplgDyTSyyUdXy9lbNxWysq7N6k,2437771
|
32
|
+
siat/fund_china.py,sha256=U7bN8mOJ_4RBkxRzrR26LSj4YJyMNpRjBtrZNUH8JI4,138286
|
33
|
+
siat/future_china.py,sha256=LORFv7AaaQHq9QBk9ZSVVOjmxY_YWyPVRdpDxfCJvdo,17828
|
34
|
+
siat/google_authenticator.py,sha256=ZUbZR8OW0IAKDbcYtlqGqIpZdERpFor9NccFELxg9yI,1637
|
35
|
+
siat/grafix.py,sha256=HSCBSAvoYpP-WcuThvwiQ1--bba9_mtPu4y5X5WBk4A,145099
|
36
|
+
siat/holding_risk.py,sha256=SCHVxRBEhseUrgMpsnvR9Pt6ns-V-voRl3hCuK1p5y4,31114
|
37
|
+
siat/luchy_draw.py,sha256=8Ue-NKnvSVqINPY1eXat0NJat5MR-gex_K62aOYFdmA,20486
|
38
|
+
siat/market_china.py,sha256=6UcOdLl842Mkwwg8wPW9rPyq6On0UJxpdAC431KkK10,51441
|
39
|
+
siat/markowitz.py,sha256=PtQ_6rLyh5SEXyO7SCDyYChcgXl6ddcdgQ06HETjDVE,97990
|
40
|
+
siat/markowitz2.py,sha256=wjmfvsFYXPz3nhnhDi7S9D_V6iCyXniquW2uvxgpe5c,125857
|
41
|
+
siat/markowitz_simple.py,sha256=aJVvx669ngcCsqoQtA9kvFOQVjsuipYt2fyTc4yMItE,14286
|
42
|
+
siat/ml_cases.py,sha256=FYDk0O7l9hhHlbrlOVGgbH-h2DA503lhKFi9XugH1f0,86874
|
43
|
+
siat/ml_cases_example.py,sha256=xRGb3YTQEDTOnaWNzZN_myU5umQnA2RdMNiPrxTmn9c,1673
|
44
|
+
siat/option_china.py,sha256=16I9_e7OG0ziHtBgwjp9ss2GEwPZGoCWYd_3KFJ9V5E,123631
|
45
|
+
siat/option_pricing.py,sha256=gB5k-LQ3VOIdyllsW1xUtAT9Me2nTfl_kueysb1JmYE,74278
|
46
|
+
siat/other_indexes.py,sha256=68MDpQOBuiCOC4w0HMqNDihudMOkK7qnvgLbtpeHyt0,14084
|
47
|
+
siat/risk_adjusted_return.py,sha256=Q4ZRdTF57eNt4QCjeQ7uA8nG56Jls8f_QfJasZQEo0M,58748
|
48
|
+
siat/risk_adjusted_return2.py,sha256=U1iKADTnWjywCkABPtr6tICYY8zmiLZyuENMLV0yMZk,87216
|
49
|
+
siat/risk_evaluation.py,sha256=xfgLSKlIWYmRJrIL4kn2k2hp9fyOMAzYGIhi9ImvKOw,88917
|
50
|
+
siat/risk_free_rate.py,sha256=IBuRqA2kppdZsW4D4fapW7vnM5HMEXOn95A5r9Pkwlo,12384
|
51
|
+
siat/sector_china.py,sha256=uLsDXdRBDVfgG6tnXWnQOTyDmyZfglVO9DRUYU2e3pk,157914
|
52
|
+
siat/security_price2.py,sha256=DDiZ2dlv_TYPLhA8-gGb9i9xrl88r4rgSMEcxqQ6aU0,28065
|
53
|
+
siat/security_prices.py,sha256=GrgwJ4uksXQCTGJZAqI9iEP5MvaxeZyeYSpzC2QLUbM,122867
|
54
|
+
siat/security_trend.py,sha256=o0vpWdrJkmODCP94X-Bvn-w7efHhj9HpUYBHtLl55D0,17240
|
55
|
+
siat/security_trend2.py,sha256=HmUk1Va94qSbgo-WQw-n5DuwBVfO8yb1m9B-d9rEGd8,31762
|
56
|
+
siat/stock.py,sha256=s7ny7He7vAIuF8xcWQKjc8VK_9_XuI9P4niobHX-5vw,161339
|
57
|
+
siat/stock_advice_linear.py,sha256=-twT7IGP-NEplkL1WPSACcNJjggRB2j4mlAQCkzOAuo,31655
|
58
|
+
siat/stock_base.py,sha256=uISvbRyOGy8p9QREA96CVydgflBkn5L3OXOGKl8oanc,1312
|
59
|
+
siat/stock_china.py,sha256=vHIc2UuXIGRkRvyL4fjTaNAoyFaq022p9FxPah6dscI,96399
|
60
|
+
siat/stock_info.pickle,sha256=XqcFwQrXoBXAzZnE6rnfpI7zETXZS2usqzsx2ff7MEg,1319005
|
61
|
+
siat/stock_prices_kneighbors.py,sha256=WfZvo5EyeBsm-T37zDj7Sl9dPSRq5Bx4JxIJ9IUum6s,36738
|
62
|
+
siat/stock_prices_linear.py,sha256=-OUKRr27L2aStQgJSlJOrJ4gay_G7P-m-7t7cU2Yoqk,13991
|
63
|
+
siat/stock_profile.py,sha256=BuvdrQ3bqIAUCaM2GxPR6_rUhigQQa_YMeUov2zY6Y0,26084
|
64
|
+
siat/stock_technical.py,sha256=1P4FkOTPknG2m18NTgwMxN-NgwIAdW3qR09VoFz00Hc,140928
|
65
|
+
siat/stooq.py,sha256=TTLjAAp-TcoEezgCPu6eM_5naI4yCshp1S7V3pyc-og,2519
|
66
|
+
siat/transaction.py,sha256=nZTYYkx1BVBLDovSlZCtcviRuFxrYe9YFXOMZgo6QXo,14563
|
67
|
+
siat/translate.py,sha256=kQhCLVivJeKT05aHedYAZD-C0PKQ0Ux2Lwd0l9s94O4,263513
|
68
|
+
siat/valuation.py,sha256=xGizcKJZ3ADLWWHm2TFQub18FxiDv2doQwBwbEqyqz0,51980
|
69
|
+
siat/valuation_china.py,sha256=eSKIDckyjG8QkENlW_OKkqbQHno8pzDcomBO9iGNJVM,83079
|
70
|
+
siat/var_model_validation.py,sha256=loqziBYO2p0xkeWm3Rb1rJsDhbcgAZ5aR9rBLRwLU5E,17624
|
71
|
+
siat/yf_name.py,sha256=laNKMTZ9hdenGX3IZ7G0a2RLBKEWtUQJFY9CWuk_fp8,24058
|
72
|
+
siat-3.10.127.dist-info/licenses/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
|
73
|
+
siat-3.10.127.dist-info/METADATA,sha256=F8l2O5ngelIiliB9VxRi2Su-chEyQ2efvvSjDFJVQ64,8176
|
74
|
+
siat-3.10.127.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
75
|
+
siat-3.10.127.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
76
|
+
siat-3.10.127.dist-info/RECORD,,
|
File without changes
|
File without changes
|
siat/__init__ -20240701.py
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
"""
|
3
|
-
功能:一次性引入SIAT的所有模块
|
4
|
-
作者:王德宏,北京外国语大学国际商学院
|
5
|
-
版权:2021-2024(C) 仅限教学使用,商业使用需要授权
|
6
|
-
联络:wdehong2000@163.com
|
7
|
-
"""
|
8
|
-
|
9
|
-
#==============================================================================
|
10
|
-
#屏蔽所有警告性信息
|
11
|
-
import warnings; warnings.filterwarnings('ignore')
|
12
|
-
#==============================================================================
|
13
|
-
from siat.allin import *
|
14
|
-
#==============================================================================
|
15
|
-
#同一命令行多个输出,主要用于Jupyter Notebook
|
16
|
-
from IPython.core.interactiveshell import InteractiveShell
|
17
|
-
InteractiveShell.ast_node_interactivity='all'
|
18
|
-
#==============================================================================
|
19
|
-
# 检查是否存在新版本
|
20
|
-
try:
|
21
|
-
import pkg_resources
|
22
|
-
current_version=pkg_resources.get_distribution("siat").version
|
23
|
-
current_list=current_version.split('.')
|
24
|
-
print("Successfully imported siat version",current_version)
|
25
|
-
|
26
|
-
import luddite
|
27
|
-
latest_version=luddite.get_version_pypi("siat")
|
28
|
-
latest_list=latest_version.split('.')
|
29
|
-
|
30
|
-
newest=True
|
31
|
-
for i in range(3):
|
32
|
-
#print(i)
|
33
|
-
if int(current_list[i]) < int(latest_list[i]):
|
34
|
-
newest=False
|
35
|
-
|
36
|
-
"""
|
37
|
-
if not newest:
|
38
|
-
print("The latest version of siat is",latest_version,'\n')
|
39
|
-
print("*** If you expect to upgrade siat in Anaconda Prompt, use the instruction below:")
|
40
|
-
print(" pip install siat --upgrade")
|
41
|
-
print("*** If you expect to upgrade in Jupyter, add a \'!\' right before the instruction above",'\n')
|
42
|
-
|
43
|
-
print("*** If you encounter incompatible plug-in, try to uninstall siat first and reinstall it:")
|
44
|
-
print(" pip uninstall siat")
|
45
|
-
print(" pip install siat",'\n')
|
46
|
-
|
47
|
-
print("*** If you have a slow internet connection, use an option trailing the instruction above:")
|
48
|
-
print(" -i https://mirrors.aliyun.com/pypi/simple/",'\n')
|
49
|
-
|
50
|
-
print("If you have done any of the above, restart the Python (eg. restarting the kernel)")
|
51
|
-
print("Provided you still need additional help, please contact wdehong2000@163.com")
|
52
|
-
"""
|
53
|
-
if not newest:
|
54
|
-
#print("The latest version of siat is",latest_version,'\n')
|
55
|
-
print("Now there is a newer version of siat",latest_version,'\n')
|
56
|
-
print("*** How to upgrade siat?")
|
57
|
-
print("Upgrade directly from official source? use command: upgrade_siat()")
|
58
|
-
print("Upgrade from Tsinghua? use command: upgrade_siat(alternative='tsinghua')")
|
59
|
-
print("Upgrade from Alibaba? use command: upgrade_siat(alternative='alibaba')")
|
60
|
-
|
61
|
-
except:
|
62
|
-
pass
|
63
|
-
|
64
|
-
|
65
|
-
#==============================================================================
|
@@ -1,73 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
"""
|
3
|
-
功能:一次性引入SIAT的所有模块
|
4
|
-
作者:王德宏,北京外国语大学国际商学院
|
5
|
-
版权:2021-2024(C) 仅限教学使用,商业使用需要授权
|
6
|
-
联络:wdehong2000@163.com
|
7
|
-
"""
|
8
|
-
|
9
|
-
#==============================================================================
|
10
|
-
#屏蔽所有警告性信息
|
11
|
-
import warnings; warnings.filterwarnings('ignore')
|
12
|
-
#==============================================================================
|
13
|
-
try:
|
14
|
-
from siat.allin import *
|
15
|
-
success=True
|
16
|
-
except:
|
17
|
-
print(" #Warning: failed to enable siat!")
|
18
|
-
import sys; version=sys.version
|
19
|
-
version_list=version.split('|')
|
20
|
-
python_version=version_list[0].strip()
|
21
|
-
python_version_list=python_version.split('.')
|
22
|
-
python_version2="{0}.{1}".format(python_version_list[0],python_version_list[1])
|
23
|
-
|
24
|
-
if python_version2 < '3.11':
|
25
|
-
print(" Solution: your Python version is {0}, suggest upgrade to {1} or above".format(python_version2,'3.11'))
|
26
|
-
elif python_version2 < '3.12':
|
27
|
-
print(" Solution: your Python version is {0}, suggest upgrade to {1} or above".format(python_version2,'3.12'))
|
28
|
-
else:
|
29
|
-
print(" Solution: your Python version is {}, suggest upgrade to the newest one".format(python_version2))
|
30
|
-
|
31
|
-
success=False
|
32
|
-
|
33
|
-
if success:
|
34
|
-
#==============================================================================
|
35
|
-
#同一命令行多个输出,主要用于Jupyter Notebook
|
36
|
-
from IPython.core.interactiveshell import InteractiveShell
|
37
|
-
InteractiveShell.ast_node_interactivity='all'
|
38
|
-
#==============================================================================
|
39
|
-
# 检查是否存在新版本
|
40
|
-
check_newer_version=False
|
41
|
-
|
42
|
-
try:
|
43
|
-
import pkg_resources
|
44
|
-
current_version=pkg_resources.get_distribution("siat").version
|
45
|
-
current_list=current_version.split('.')
|
46
|
-
print("Successfully enabled siat version",current_version)
|
47
|
-
|
48
|
-
if check_newer_version:
|
49
|
-
import luddite
|
50
|
-
latest_version=luddite.get_version_pypi("siat")
|
51
|
-
latest_list=latest_version.split('.')
|
52
|
-
|
53
|
-
newest=True
|
54
|
-
for i in range(3):
|
55
|
-
#print(i)
|
56
|
-
if int(current_list[i]) < int(latest_list[i]):
|
57
|
-
newest=False
|
58
|
-
|
59
|
-
if not newest:
|
60
|
-
#print("The latest version of siat is",latest_version,'\n')
|
61
|
-
print("There is a newer version of siat",latest_version,'\n')
|
62
|
-
print("*** How to upgrade siat?")
|
63
|
-
print("Upgrade from official website? Command: upgrade_siat()")
|
64
|
-
print("Upgrade from Tsinghua? Command: upgrade_siat(alternative='tsinghua')")
|
65
|
-
print("Upgrade from Alibaba? Command: upgrade_siat(alternative='alibaba')")
|
66
|
-
|
67
|
-
except:
|
68
|
-
print(" #Warning: plugin went unexpected with either {0} or {1}".format("pkg_resources","luddite"))
|
69
|
-
print(" Solution: please re-run. If problem remains, contact the author of siat for help")
|
70
|
-
#pass
|
71
|
-
|
72
|
-
|
73
|
-
#==============================================================================
|
siat/alpha_vantage_test.py
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
"""
|
4
|
-
功能:测试新的插件,仅限测试使用
|
5
|
-
作者:王德宏,北京外国语大学国际商学院
|
6
|
-
版权:2022(C) 仅限教学使用,商业使用需要授权
|
7
|
-
联络:wdehong2000@163.com
|
8
|
-
"""
|
9
|
-
|
10
|
-
# 绝对引用指定目录中的模块
|
11
|
-
import sys
|
12
|
-
sys.path.insert(0,r'S:\siat\siat')
|
13
|
-
|
14
|
-
|
15
|
-
#========================================================================
|
16
|
-
from alpha_vantage.timeseries import TimeSeries
|
17
|
-
ts = TimeSeries(key='J4L80CM3ATCKNONG', output_format='pandas', indexing_type='date')
|
18
|
-
data, meta_data = ts.get_daily('GOOGL', outputsize='full')
|
19
|
-
data, meta_data = ts.get_daily('FCHI', outputsize='full')
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
#========================================================================
|
24
|
-
|
siat/assets_liquidity_test.py
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
import os; os.chdir("S:\siat")
|
4
|
-
from siat import *
|
5
|
-
#==============================================================================
|
6
|
-
hn_cn={'Market':('China','000001.SS'),'601633.SS':1,'600104.SS':1,'002594.SZ':1}
|
7
|
-
rsp=roll_spread_portfolio(hn_cn,'2020-1-1','2021-11-30')
|
8
|
-
hb_cn={'Market':('China','000001.SS'),'600135.SS':2,'600559.SS':3,'600340.SS':1}
|
9
|
-
compare_liquidity_rolling(hn_cn,hb_cn,'2021-7-1','2021-11-30','roll_spread',30)
|
10
|
-
|
11
|
-
#==============================================================================
|
12
|
-
from siat.assets_liquidity import *
|
13
|
-
|
14
|
-
portfolio={'Market':('China','000001.SS'),'600011.SS':1}
|
15
|
-
start='2020-1-1'
|
16
|
-
end='2020-6-30'
|
17
|
-
liquidity_type='roll_spread'
|
18
|
-
l=liquidity_rolling(portfolio,start,end,liquidity_type,30)
|
19
|
-
|
20
|
-
ticker=['600011.SS']
|
21
|
-
start='2020-1-1'
|
22
|
-
end='2020-6-30'
|
23
|
-
pak=get_prices_ak(ticker,start,end)
|
24
|
-
|
25
|
-
pyf=get_price_yf(ticker,start,end)
|
26
|
-
|
27
|
-
pyh=p=get_prices_yahoo(ticker,start,end)
|
28
|
-
|
29
|
-
p=get_prices(ticker,start,end)
|
30
|
-
|
31
|
-
tickerlist=['600011.SS']
|
32
|
-
sharelist=[1]
|
33
|
-
p1=get_price_portfolio(tickerlist,sharelist,start,end)
|
34
|
-
|
35
|
-
|
36
|
-
if __name__=='__main__':
|
37
|
-
tickerlist=['INTC','MSFT']
|
38
|
-
sharelist=[0.6,0.4]
|
39
|
-
fromdate='2020-11-1'
|
40
|
-
todate='2021-1-31'
|
41
|
-
|
42
|
-
p2=get_prices_portfolio(tickerlist,sharelist,fromdate,todate)
|
43
|
-
|
44
|
-
|
siat/barrons_scraping_test.py
DELETED
@@ -1,276 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
"""Program to collect and present stock market data for Nasdaq, S&P 500, and Dow 30 indexes."""
|
4
|
-
import os
|
5
|
-
import sys
|
6
|
-
import math
|
7
|
-
import csv
|
8
|
-
import time
|
9
|
-
import bisect
|
10
|
-
import urllib as urllib2
|
11
|
-
import string
|
12
|
-
import requests
|
13
|
-
import random
|
14
|
-
import bs4
|
15
|
-
from bs4 import BeautifulSoup
|
16
|
-
|
17
|
-
class Index:
|
18
|
-
def __init__(self, name, index_link):
|
19
|
-
self.name = name
|
20
|
-
self.index_link = index_link
|
21
|
-
self.index_dict = {}
|
22
|
-
self.stock_list = []
|
23
|
-
self.stock_data = []
|
24
|
-
self.out_file = '../docs/' + name.lower() + '-dividend-stocks-sorted.csv'
|
25
|
-
|
26
|
-
def create_dict(self):
|
27
|
-
if self.name == 'Nasdaq':
|
28
|
-
self.create_dict_from_csv()
|
29
|
-
elif self.name == 'S&P 500' or self.name == 'Dow 30':
|
30
|
-
self.create_dict_from_web()
|
31
|
-
|
32
|
-
def create_dict_from_csv(self):
|
33
|
-
with open(self.index_file) as csv_file:
|
34
|
-
read_csv = csv.reader(csv_file, delimiter=',')
|
35
|
-
for row in read_csv:
|
36
|
-
if row[1].find('iShares') == -1 and row[1].find('iPath') == -1:
|
37
|
-
self.index_dict[row[0]] = row[1]
|
38
|
-
|
39
|
-
def create_dict_from_web(self):
|
40
|
-
# Create a new URL request
|
41
|
-
user_agent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'
|
42
|
-
headers = { 'User-Agent' : user_agent }
|
43
|
-
url = self.index_link
|
44
|
-
req = urllib2.Request(url, headers=headers)
|
45
|
-
|
46
|
-
# Catch potential URL error
|
47
|
-
try:
|
48
|
-
response = urllib2.urlopen(req)
|
49
|
-
except urllib2.URLError as e:
|
50
|
-
print(e.reason)
|
51
|
-
|
52
|
-
# Create BeautifulSoup object
|
53
|
-
self.soup = BeautifulSoup(response, 'html.parser')
|
54
|
-
|
55
|
-
#store the list of components in a dictionary by ticker symbol
|
56
|
-
if self.name == 'S&P 500':
|
57
|
-
for a in self.soup.findAll('table', {'class': 'wikitable sortable'}, limit=1):
|
58
|
-
for b in a.findAll('tr'):
|
59
|
-
count = 1
|
60
|
-
for c in b.findAll('td', limit=2):
|
61
|
-
if count == 1:
|
62
|
-
stock_symbol = c.text
|
63
|
-
count += 1
|
64
|
-
elif count == 2:
|
65
|
-
company_name = c.text
|
66
|
-
self.index_dict[stock_symbol] = company_name
|
67
|
-
count = 1
|
68
|
-
elif self.name == 'Dow 30':
|
69
|
-
for a in self.soup.findAll('table', {'class': 'wikitable sortable'}):
|
70
|
-
for b in a.findAll('tr'):
|
71
|
-
count = 1
|
72
|
-
for c in b.findAll('td', limit=3):
|
73
|
-
if count == 1:
|
74
|
-
company_name = c.text
|
75
|
-
count += 1
|
76
|
-
elif count == 2:
|
77
|
-
count += 1
|
78
|
-
elif count == 3:
|
79
|
-
stock_symbol = c.text
|
80
|
-
self.index_dict[stock_symbol] = company_name
|
81
|
-
count = 1
|
82
|
-
|
83
|
-
class Stock:
|
84
|
-
def __init__(self, symbol, company):
|
85
|
-
self.symbol = symbol
|
86
|
-
self.company = company
|
87
|
-
self.data = []
|
88
|
-
|
89
|
-
def add_stocks(self):
|
90
|
-
for key, value in self.index_dict.items():
|
91
|
-
new_stock = Stock(key, value)
|
92
|
-
new_stock.query_stock_symbol()
|
93
|
-
if new_stock.div_yield != None:
|
94
|
-
self.stock_list.append(new_stock)
|
95
|
-
#Sort the stock list by yield amount, in desecending order
|
96
|
-
self.stock_list.sort(key=lambda stock: stock.div_yield, reverse=True)
|
97
|
-
|
98
|
-
def query_stock_symbol(self):
|
99
|
-
# Add wait times in between getting each stock's data to prevent overload
|
100
|
-
wait_time = round(max(5, 10 + random.gauss(0,3)), 2)
|
101
|
-
time.sleep(wait_time)
|
102
|
-
|
103
|
-
# Check for two different Barron's URLs
|
104
|
-
url = 'http://www.barrons.com/quote/stock/us/xnas/%s' % (self.symbol)
|
105
|
-
headers = {
|
106
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
107
|
-
}
|
108
|
-
page = requests.get(url,headers=headers)
|
109
|
-
if page.status_code == 404:
|
110
|
-
url = 'http://www.barrons.com/quote/stock/us/xnys/%s?mod=DNH_S' % (self.symbol)
|
111
|
-
|
112
|
-
# Create a new URL request
|
113
|
-
user_agent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'
|
114
|
-
headers = { 'User-Agent' : user_agent }
|
115
|
-
req = urllib2.Request(url, headers=headers)
|
116
|
-
|
117
|
-
# Catch potential URL error
|
118
|
-
try:
|
119
|
-
response = urllib2.urlopen(req)
|
120
|
-
except urllib2.URLError as e:
|
121
|
-
print(e.reason)
|
122
|
-
|
123
|
-
# Create BeautifulSoup object
|
124
|
-
self.soup = BeautifulSoup(response, 'html.parser')
|
125
|
-
|
126
|
-
# Find stock price
|
127
|
-
for a in self.soup.findAll('span', {'class':'market__price'}):
|
128
|
-
stock_price_str = a.text.replace(',', '')
|
129
|
-
if stock_price_str != 'N/A':
|
130
|
-
self.stock_price = float(stock_price_str)
|
131
|
-
else:
|
132
|
-
self.stock_price = None
|
133
|
-
|
134
|
-
# Append remaining data
|
135
|
-
for a in self.soup.findAll('div', {'class': 'nutrition'}):
|
136
|
-
for b in a.findAll('td'):
|
137
|
-
self.data.append(b.text)
|
138
|
-
|
139
|
-
# Extract remaining data
|
140
|
-
self.market_cap = None
|
141
|
-
for i in xrange(0, len(self.data)):
|
142
|
-
if self.data[i] == 'Market Value':
|
143
|
-
self.market_cap = self.data[i+1]
|
144
|
-
elif self.data[i] == 'Ytd net Change':
|
145
|
-
self.ytd_net_change_str = self.data[i+1].strip('%')
|
146
|
-
if self.ytd_net_change_str != 'N/A':
|
147
|
-
self.ytd_net_change = float(self.ytd_net_change_str)
|
148
|
-
else:
|
149
|
-
self.ytd_net_change = -1
|
150
|
-
elif self.data[i] == 'Div & Yield':
|
151
|
-
div_amount_str = self.data[i+1].split(' (')[0].strip(' ')
|
152
|
-
div_amount_str = div_amount_str.strip('$')
|
153
|
-
div_yield_str = self.data[i+1].split(' (')[1].strip(')')
|
154
|
-
div_yield_str = div_yield_str.strip('%')
|
155
|
-
if div_amount_str != 'N/A':
|
156
|
-
self.div_amount = float(div_amount_str)
|
157
|
-
self.div_yield = float(div_yield_str)
|
158
|
-
else:
|
159
|
-
self.div_amount = None
|
160
|
-
self.div_yield = None
|
161
|
-
|
162
|
-
"""
|
163
|
-
# Check for two different Barron's URLs
|
164
|
-
url = 'http://www.barrons.com/quote/stock/us/xnas/%s' % (self.symbol)
|
165
|
-
headers = {
|
166
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
167
|
-
}
|
168
|
-
page = requests.get(url,headers=headers)
|
169
|
-
if page.status_code == 404:
|
170
|
-
url = 'http://www.barrons.com/quote/stock/us/xnys/%s?mod=DNH_S' % (self.symbol)
|
171
|
-
"""
|
172
|
-
|
173
|
-
# Find stock price
|
174
|
-
for a in self.soup.findAll('span', {'class':'market__price'}):
|
175
|
-
stock_price_str = a.text.replace(',', '')
|
176
|
-
if stock_price_str != 'N/A':
|
177
|
-
self.stock_price = float(stock_price_str)
|
178
|
-
else:
|
179
|
-
self.stock_price = None
|
180
|
-
|
181
|
-
# Append remaining data
|
182
|
-
for a in self.soup.findAll('div', {'class': 'nutrition'}):
|
183
|
-
for b in a.findAll('td'):
|
184
|
-
self.data.append(b.text)
|
185
|
-
|
186
|
-
# Extract remaining data
|
187
|
-
self.market_cap = None
|
188
|
-
for i in xrange(0, len(self.data)):
|
189
|
-
if self.data[i] == 'Market Value':
|
190
|
-
self.market_cap = self.data[i+1]
|
191
|
-
elif self.data[i] == 'Ytd net Change':
|
192
|
-
self.ytd_net_change_str = self.data[i+1].strip('%')
|
193
|
-
if self.ytd_net_change_str != 'N/A':
|
194
|
-
self.ytd_net_change = float(self.ytd_net_change_str)
|
195
|
-
else:
|
196
|
-
self.ytd_net_change = -1
|
197
|
-
elif self.data[i] == 'Div & Yield':
|
198
|
-
div_amount_str = self.data[i+1].split(' (')[0].strip(' ')
|
199
|
-
div_amount_str = div_amount_str.strip('$')
|
200
|
-
div_yield_str = self.data[i+1].split(' (')[1].strip(')')
|
201
|
-
div_yield_str = div_yield_str.strip('%')
|
202
|
-
if div_amount_str != 'N/A':
|
203
|
-
self.div_amount = float(div_amount_str)
|
204
|
-
self.div_yield = float(div_yield_str)
|
205
|
-
else:
|
206
|
-
self.div_amount = None
|
207
|
-
self.div_yield = None
|
208
|
-
|
209
|
-
def add_stocks(self):
|
210
|
-
for key, value in self.index_dict.items():
|
211
|
-
new_stock = Stock(key, value)
|
212
|
-
new_stock.query_stock_symbol()
|
213
|
-
if new_stock.div_yield != None:
|
214
|
-
self.stock_list.append(new_stock)
|
215
|
-
#Sort the stock list by yield amount, in desecending order
|
216
|
-
self.stock_list.sort(key=lambda stock: stock.div_yield, reverse=True)
|
217
|
-
|
218
|
-
def from_dict_to_csv(self):
|
219
|
-
self.add_stocks()
|
220
|
-
self.headings = ['Company','Symbol','Current Price','Market Cap','Dividend', 'Yield', '52-Week Return']
|
221
|
-
for i in xrange(0, len(self.stock_list)):
|
222
|
-
new_dict = {}
|
223
|
-
new_dict['Company'] = self.stock_list[i].company
|
224
|
-
new_dict['Symbol'] = self.stock_list[i].symbol
|
225
|
-
new_dict['Current Price'] = self.stock_list[i].stock_price
|
226
|
-
new_dict['Market Cap'] = self.stock_list[i].market_cap
|
227
|
-
new_dict['Dividend'] = self.stock_list[i].div_amount
|
228
|
-
if self.stock_list[i].div_yield != None:
|
229
|
-
new_dict['Yield'] = str(self.stock_list[i].div_yield) + '%'
|
230
|
-
else:
|
231
|
-
new_dict['Yield'] = 'N/A'
|
232
|
-
if self.stock_list[i].ytd_net_change != None:
|
233
|
-
new_dict['52-Week Return'] = str(self.stock_list[i].ytd_net_change) + '%'
|
234
|
-
else:
|
235
|
-
new_dict['52-Week Return'] = 'None'
|
236
|
-
self.stock_data.append(new_dict)
|
237
|
-
|
238
|
-
try:
|
239
|
-
with open(self.out_file, "wb") as csv_file:
|
240
|
-
writer = csv.DictWriter(csv_file, fieldnames=self.headings, dialect='excel', delimiter=',', quoting=csv.QUOTE_NONNUMERIC)
|
241
|
-
writer.writeheader()
|
242
|
-
for data in self.stock_data:
|
243
|
-
writer.writerow(data)
|
244
|
-
|
245
|
-
except IOError as (errno, strerror):
|
246
|
-
print "I/O error({0}): {1}".format(errno, strerror)
|
247
|
-
|
248
|
-
def generate_dividend_stocks():
|
249
|
-
nasdaq_file = '../docs/dividend-stocks-nasdaq.csv'
|
250
|
-
nasdaq_index = Index('Nasdaq', nasdaq_file)
|
251
|
-
nasdaq_index.create_dict()
|
252
|
-
nasdaq_index.from_dict_to_csv()
|
253
|
-
|
254
|
-
sp_link = 'https://en.wikipedia.org/wiki/List_of_S%26P_500_companies'
|
255
|
-
sp_index = Index('S&P 500', sp_link)
|
256
|
-
sp_index.create_dict()
|
257
|
-
sp_index.from_dict_to_csv()
|
258
|
-
|
259
|
-
dow_link = 'https://en.wikipedia.org/wiki/Dow_Jones_Industrial_Average#Components'
|
260
|
-
dow_index = Index('Dow 30', dow_link)
|
261
|
-
dow_index.create_dict()
|
262
|
-
dow_index.from_dict_to_csv()
|
263
|
-
|
264
|
-
def main():
|
265
|
-
generate_dividend_stocks()
|
266
|
-
|
267
|
-
if __name__ == '__main__':
|
268
|
-
sys.exit(main())
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
siat/beta_adjustment_test.py
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
import os; os.chdir("S:/siat")
|
4
|
-
from siat import *
|
5
|
-
|
6
|
-
betas=get_beta_hamada_china('600606.SS','000001.SS','2014-1-1','2021-9-30')
|
7
|
-
|
8
|
-
betas=get_beta_hamada_china('600606.SS','000001.SS','2018-1-1','2020-9-30')
|
9
|
-
|
10
|
-
betas2=get_beta_hamada_china('600606.SS','000001.SS','2017-1-1','2020-9-30','annual')
|
11
|
-
betas=get_beta_hamada_china('600606.SS','000001.SS','2017-1-1','2020-9-30')
|
12
|
-
|
13
|
-
#===============================================================================
|
14
|
-
prepare_hamada_patch_is('600519.SS')
|
15
|
-
|
16
|
-
yearlist=gen_yearlist('2011','2020')
|
17
|
-
betas=betas_dji=get_beta_ML('EDU','^DJI',yearlist)
|
18
|
-
|
19
|
-
betas_dji=get_beta_ML('IDCBY','^DJI',yearlist)
|
20
|
-
|
21
|
-
betas_sp500=get_beta_ML('IDCBY','^GSPC',yearlist)
|
22
|
-
|
23
|
-
betas_sw=get_beta_SW('PG','^DJI', yearlist)
|
24
|
-
|
25
|
-
betas_sw_4452t=get_beta_SW('4452.T','^N225', yearlist)
|
26
|
-
|
27
|
-
yearlist=gen_yearlist('2011','2019')
|
28
|
-
betas_sw_hmif=get_beta_SW('HMI.F','^FCHI',yearlist)
|
29
|
-
betas_sw_diof=get_beta_SW('DIO.F','^FCHI', yearlist)
|
30
|
-
|
31
|
-
r=prepare_capm('600340.SS','000001.SS','2011-1-1','2020-12-31')
|
32
|
-
stock=get_price('600340.SS','2011-1-1','2020-12-31')
|
33
|
-
stock=get_price_ak_cn('600340.SS','2011-1-1','2020-12-31')
|
34
|
-
|
35
|
-
betas_dimson=get_beta_dimson('600376.SS','000001.SS', yearlist)
|
36
|
-
betas_dimson=get_beta_dimson('600340.SS','000001.SS', yearlist)
|
37
|
-
|
38
|
-
betas_hamada=get_beta_hamada2('600519.SS','000001.SS')
|
39
|
-
|
40
|
-
betas_hamada=get_beta_hamada2('600606.SS','000001.SS')
|
41
|
-
|
42
|
-
betas_hamada=get_beta_hamada2('GS','^GSPC')
|
43
|
-
|
44
|
-
#==============================================================================
|
45
|
-
stkcd='0700.HK'
|
46
|
-
mktidx='^HSI'
|
47
|
-
h=get_beta_hamada2(stkcd,mktidx)
|
48
|
-
|
49
|
-
|
50
|
-
from siat.financial_statements import *
|
51
|
-
fs_is=get_income_statements(stkcd).T
|
52
|
-
fs_bs=get_balance_sheet(stkcd).T
|
53
|
-
|
54
|
-
betas_hamada=get_beta_hamada_ts('600519.SS','000001.SS', yearlist)
|
55
|
-
import tushare as ts
|
56
|
-
|
57
|
-
pro=init_ts()
|
58
|
-
is0=pro.income(ts_code='600519.SH')
|
59
|
-
|
60
|
-
token='49f134b05e668d288be43264639ac77821ab9938ff40d6013c0ed24f'
|
61
|
-
pro=ts.pro_api(token)
|
62
|
-
pro.income(ts_code='600519.sh')
|
63
|
-
|
64
|
-
R=prepare_capm(stkcd,mktidx,start,end)
|
65
|
-
|
66
|
-
|
67
|
-
betas1=get_beta_hamada2('0700.HK','^HSI')
|
68
|
-
betas1=get_beta_hamada2('MSFT','^GSPC')
|
69
|
-
|
70
|
-
betas1=get_beta_hamada2('BA','^GSPC')
|
71
|
-
betas1=get_beta_hamada2('GS','^GSPC')
|
72
|
-
betas1=get_beta_hamada2('AAPL','^GSPC')
|
73
|
-
|
74
|
-
betas1=get_beta_hamada2('000002.SZ','000001.SS')
|
75
|
-
betas1=get_beta_hamada2('600519.SS','000001.SS')
|
76
|
-
betas1=get_beta_hamada2('600606.SS','000001.SS')
|
77
|
-
#==============================================================================
|