siat 3.1.15__tar.gz → 3.9.1__tar.gz

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 (147) hide show
  1. siat-3.9.1/LICENSE +7 -0
  2. siat-3.9.1/PKG-INFO +232 -0
  3. {siat-3.1.15 → siat-3.9.1}/setup.py +23 -17
  4. siat-3.9.1/siat/__init__.py +75 -0
  5. {siat-3.1.15 → siat-3.9.1}/siat/allin.py +15 -0
  6. {siat-3.1.15 → siat-3.9.1}/siat/assets_liquidity.py +8 -8
  7. {siat-3.1.15 → siat-3.9.1}/siat/barrons_scraping_test.py +8 -2
  8. {siat-3.1.15 → siat-3.9.1}/siat/beta_adjustment.py +2 -2
  9. {siat-3.1.15 → siat-3.9.1}/siat/beta_adjustment_china.py +1 -1
  10. {siat-3.1.15 → siat-3.9.1}/siat/bond.py +132 -2
  11. {siat-3.1.15 → siat-3.9.1}/siat/bond_base.py +2 -1
  12. {siat-3.1.15 → siat-3.9.1}/siat/bond_china.py +2 -1
  13. {siat-3.1.15 → siat-3.9.1}/siat/capm_beta2.py +217 -51
  14. {siat-3.1.15 → siat-3.9.1}/siat/common.py +1242 -66
  15. {siat-3.1.15 → siat-3.9.1}/siat/cryptocurrency.py +19 -7
  16. {siat-3.1.15 → siat-3.9.1}/siat/economy.py +299 -38
  17. siat-3.9.1/siat/economy2.py +1779 -0
  18. {siat-3.1.15 → siat-3.9.1}/siat/esg.py +2 -2
  19. siat-3.9.1/siat/event_study.py +757 -0
  20. siat-3.9.1/siat/fin_stmt2_yahoo.py +982 -0
  21. {siat-3.1.15 → siat-3.9.1}/siat/financial_base.py +4 -1
  22. {siat-3.1.15 → siat-3.9.1}/siat/financial_statements.py +2 -1
  23. {siat-3.1.15 → siat-3.9.1}/siat/financials.py +216 -66
  24. {siat-3.1.15 → siat-3.9.1}/siat/financials2.py +156 -62
  25. {siat-3.1.15 → siat-3.9.1}/siat/financials_china.py +70 -24
  26. {siat-3.1.15 → siat-3.9.1}/siat/financials_china2.py +59 -14
  27. {siat-3.1.15 → siat-3.9.1}/siat/fund.py +12 -12
  28. siat-3.9.1/siat/fund_china.pickle +0 -0
  29. {siat-3.1.15 → siat-3.9.1}/siat/fund_china.py +571 -9
  30. {siat-3.1.15 → siat-3.9.1}/siat/grafix.py +1564 -215
  31. {siat-3.1.15 → siat-3.9.1}/siat/holding_risk.py +9 -7
  32. siat-3.9.1/siat/luchy_draw.py +638 -0
  33. {siat-3.1.15 → siat-3.9.1}/siat/market_china.py +246 -5
  34. {siat-3.1.15 → siat-3.9.1}/siat/markowitz.py +48 -39
  35. {siat-3.1.15 → siat-3.9.1}/siat/markowitz2.py +477 -194
  36. {siat-3.1.15 → siat-3.9.1}/siat/markowitz_simple.py +1 -1
  37. {siat-3.1.15 → siat-3.9.1}/siat/option_china.py +261 -59
  38. {siat-3.1.15 → siat-3.9.1}/siat/option_pricing.py +169 -75
  39. siat-3.9.1/siat/other_indexes.py +189 -0
  40. {siat-3.1.15 → siat-3.9.1}/siat/risk_adjusted_return.py +16 -16
  41. {siat-3.1.15 → siat-3.9.1}/siat/risk_adjusted_return2.py +623 -210
  42. {siat-3.1.15 → siat-3.9.1}/siat/risk_evaluation.py +10 -6
  43. {siat-3.1.15 → siat-3.9.1}/siat/risk_free_rate.py +1 -1
  44. {siat-3.1.15 → siat-3.9.1}/siat/sector_china.py +1115 -178
  45. {siat-3.1.15 → siat-3.9.1}/siat/security_price2.py +57 -13
  46. {siat-3.1.15 → siat-3.9.1}/siat/security_prices.py +244 -102
  47. {siat-3.1.15 → siat-3.9.1}/siat/security_trend2.py +184 -60
  48. {siat-3.1.15 → siat-3.9.1}/siat/stock.py +728 -217
  49. {siat-3.1.15 → siat-3.9.1}/siat/stock_china.py +81 -48
  50. siat-3.9.1/siat/stock_info.pickle +0 -0
  51. {siat-3.1.15 → siat-3.9.1}/siat/stock_profile.py +2 -1
  52. {siat-3.1.15 → siat-3.9.1}/siat/stock_technical.py +1078 -447
  53. {siat-3.1.15 → siat-3.9.1}/siat/stooq.py +2 -1
  54. {siat-3.1.15 → siat-3.9.1}/siat/translate.py +1273 -315
  55. {siat-3.1.15 → siat-3.9.1}/siat/valuation.py +87 -28
  56. {siat-3.1.15 → siat-3.9.1}/siat/valuation_china.py +382 -34
  57. {siat-3.1.15 → siat-3.9.1}/siat/var_model_validation.py +1 -1
  58. siat-3.9.1/siat/yf_name.py +811 -0
  59. siat-3.9.1/siat.egg-info/PKG-INFO +232 -0
  60. {siat-3.1.15 → siat-3.9.1}/siat.egg-info/SOURCES.txt +8 -45
  61. {siat-3.1.15 → siat-3.9.1}/siat.egg-info/requires.txt +10 -1
  62. siat-3.1.15/PKG-INFO +0 -17
  63. siat-3.1.15/siat/__init__.py +0 -47
  64. siat-3.1.15/siat/alpha_vantage_test.py +0 -24
  65. siat-3.1.15/siat/assets_liquidity_test.py +0 -44
  66. siat-3.1.15/siat/beta_adjustment_test.py +0 -77
  67. siat-3.1.15/siat/bond_test.py +0 -142
  68. siat-3.1.15/siat/capm_beta_test.py +0 -49
  69. siat-3.1.15/siat/compare_cross_test.py +0 -117
  70. siat-3.1.15/siat/economy-20230125.py +0 -1206
  71. siat-3.1.15/siat/economy_test.py +0 -360
  72. siat-3.1.15/siat/financial_statements_test.py +0 -31
  73. siat-3.1.15/siat/financials_china2_test.py +0 -67
  74. siat-3.1.15/siat/financials_china2_test2.py +0 -88
  75. siat-3.1.15/siat/financials_china_test.py +0 -475
  76. siat-3.1.15/siat/financials_china_test2.py +0 -197
  77. siat-3.1.15/siat/financials_china_test2_fin_indicator.py +0 -197
  78. siat-3.1.15/siat/financials_test.py +0 -713
  79. siat-3.1.15/siat/fund_china.pickle +0 -0
  80. siat-3.1.15/siat/fund_china_test.py +0 -175
  81. siat-3.1.15/siat/fund_test.py +0 -40
  82. siat-3.1.15/siat/future_china_test.py +0 -37
  83. siat-3.1.15/siat/global_index_test.py +0 -66
  84. siat-3.1.15/siat/grafix_test.py +0 -112
  85. siat-3.1.15/siat/holding_risk_test.py +0 -13
  86. siat-3.1.15/siat/local_debug_test.py +0 -100
  87. siat-3.1.15/siat/markowitz_ccb_test.py +0 -37
  88. siat-3.1.15/siat/markowitz_ef_test.py +0 -136
  89. siat-3.1.15/siat/markowitz_old.py +0 -871
  90. siat-3.1.15/siat/markowitz_test.py +0 -164
  91. siat-3.1.15/siat/markowitz_test2.py +0 -69
  92. siat-3.1.15/siat/option_china_test.py +0 -447
  93. siat-3.1.15/siat/option_pricing_test.py +0 -81
  94. siat-3.1.15/siat/risk_adjusted_return_test.py +0 -81
  95. siat-3.1.15/siat/risk_evaluation_test.py +0 -96
  96. siat-3.1.15/siat/sector_china_test.py +0 -203
  97. siat-3.1.15/siat/security_prices_test.py +0 -310
  98. siat-3.1.15/siat/setup.py +0 -41
  99. siat-3.1.15/siat/stock_info.pickle +0 -0
  100. siat-3.1.15/siat/stock_info_test.py +0 -189
  101. siat-3.1.15/siat/stock_test.py +0 -487
  102. siat-3.1.15/siat/test2_graphviz.py +0 -484
  103. siat-3.1.15/siat/test_graphviz.py +0 -411
  104. siat-3.1.15/siat/test_markowitz_simple.py +0 -198
  105. siat-3.1.15/siat/test_markowitz_simple_revised.py +0 -215
  106. siat-3.1.15/siat/test_markowitz_simple_revised2.py +0 -218
  107. siat-3.1.15/siat/transaction_test.py +0 -436
  108. siat-3.1.15/siat/translate_20240606.py +0 -4206
  109. siat-3.1.15/siat/universal_test.py +0 -100
  110. siat-3.1.15/siat/valuation_market_china_test.py +0 -36
  111. siat-3.1.15/siat.egg-info/PKG-INFO +0 -17
  112. {siat-3.1.15 → siat-3.9.1}/MANIFEST.in +0 -0
  113. {siat-3.1.15 → siat-3.9.1}/setup.cfg +0 -0
  114. {siat-3.1.15 → siat-3.9.1}/siat/blockchain.py +0 -0
  115. {siat-3.1.15 → siat-3.9.1}/siat/bond_zh_sina.py +0 -0
  116. {siat-3.1.15 → siat-3.9.1}/siat/capm_beta.py +0 -0
  117. {siat-3.1.15 → siat-3.9.1}/siat/cmat_commons.py +0 -0
  118. {siat-3.1.15 → siat-3.9.1}/siat/compare_cross.py +0 -0
  119. {siat-3.1.15 → siat-3.9.1}/siat/concepts_iwencai.py +0 -0
  120. {siat-3.1.15 → siat-3.9.1}/siat/concepts_kpl.py +0 -0
  121. {siat-3.1.15 → siat-3.9.1}/siat/copyrights.py +0 -0
  122. {siat-3.1.15 → siat-3.9.1}/siat/cryptocurrency_test.py +0 -0
  123. {siat-3.1.15 → siat-3.9.1}/siat/esg_test.py +0 -0
  124. {siat-3.1.15 → siat-3.9.1}/siat/exchange_bond_china.pickle +0 -0
  125. {siat-3.1.15 → siat-3.9.1}/siat/fama_french.py +0 -0
  126. {siat-3.1.15 → siat-3.9.1}/siat/fama_french_test.py +0 -0
  127. {siat-3.1.15 → siat-3.9.1}/siat/fred_test.py +0 -0
  128. {siat-3.1.15 → siat-3.9.1}/siat/future_china.py +0 -0
  129. {siat-3.1.15 → siat-3.9.1}/siat/google_authenticator.py +0 -0
  130. {siat-3.1.15 → siat-3.9.1}/siat/ml_cases.py +0 -0
  131. {siat-3.1.15 → siat-3.9.1}/siat/ml_cases_example.py +0 -0
  132. {siat-3.1.15 → siat-3.9.1}/siat/ml_cases_example1.py +0 -0
  133. {siat-3.1.15 → siat-3.9.1}/siat/option_sina_api_test.py +0 -0
  134. {siat-3.1.15 → siat-3.9.1}/siat/proxy_test.py +0 -0
  135. {siat-3.1.15 → siat-3.9.1}/siat/quandl_test.py +0 -0
  136. {siat-3.1.15 → siat-3.9.1}/siat/risk_free_rate_test.py +0 -0
  137. {siat-3.1.15 → siat-3.9.1}/siat/security_trend.py +0 -0
  138. {siat-3.1.15 → siat-3.9.1}/siat/shenwan index history test.py +0 -0
  139. {siat-3.1.15 → siat-3.9.1}/siat/stock_advice_linear.py +0 -0
  140. {siat-3.1.15 → siat-3.9.1}/siat/stock_base.py +0 -0
  141. {siat-3.1.15 → siat-3.9.1}/siat/stock_china_test.py +0 -0
  142. {siat-3.1.15 → siat-3.9.1}/siat/stock_list_china_test.py +0 -0
  143. {siat-3.1.15 → siat-3.9.1}/siat/stock_prices_kneighbors.py +0 -0
  144. {siat-3.1.15 → siat-3.9.1}/siat/stock_prices_linear.py +0 -0
  145. {siat-3.1.15 → siat-3.9.1}/siat/transaction.py +0 -0
  146. {siat-3.1.15 → siat-3.9.1}/siat.egg-info/dependency_links.txt +0 -0
  147. {siat-3.1.15 → siat-3.9.1}/siat.egg-info/top_level.txt +0 -0
siat-3.9.1/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2024 WANG Dehong
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software (siat) and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
siat-3.9.1/PKG-INFO ADDED
@@ -0,0 +1,232 @@
1
+ Metadata-Version: 2.2
2
+ Name: siat
3
+ Version: 3.9.1
4
+ Summary: Securities Investment Analysis Tools (siat)
5
+ Home-page: https://pypi.org/project/siat/
6
+ Author: Prof. WANG Dehong, International Business School, Beijing Foreign Studies University
7
+ Author-email: wdehong2000@163.com
8
+ License: Copyright (C) WANG Dehong, 2024. For educational purpose only!
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: pandas_datareader
12
+ Requires-Dist: yfinance
13
+ Requires-Dist: tqdm
14
+ Requires-Dist: plotly_express
15
+ Requires-Dist: akshare
16
+ Requires-Dist: urllib3
17
+ Requires-Dist: mplfinance
18
+ Requires-Dist: statsmodels
19
+ Requires-Dist: yahoo_earnings_calendar
20
+ Requires-Dist: pypinyin
21
+ Requires-Dist: seaborn
22
+ Requires-Dist: numpy
23
+ Requires-Dist: scipy
24
+ Requires-Dist: pandas
25
+ Requires-Dist: scikit-learn
26
+ Requires-Dist: baostock
27
+ Requires-Dist: pyproject.toml
28
+ Requires-Dist: pathlib
29
+ Requires-Dist: ruamel-yaml
30
+ Requires-Dist: prettytable
31
+ Requires-Dist: graphviz
32
+ Requires-Dist: luddite
33
+ Requires-Dist: pendulum
34
+ Requires-Dist: itables
35
+ Requires-Dist: py_trans
36
+ Requires-Dist: bottleneck
37
+ Requires-Dist: translate
38
+ Requires-Dist: translators
39
+ Requires-Dist: nbconvert
40
+ Requires-Dist: ipywidgets==8.1.6
41
+ Requires-Dist: playwright
42
+ Requires-Dist: yahooquery==2.3.7
43
+ Dynamic: author
44
+ Dynamic: author-email
45
+ Dynamic: description
46
+ Dynamic: description-content-type
47
+ Dynamic: home-page
48
+ Dynamic: license
49
+ Dynamic: requires-dist
50
+ Dynamic: summary
51
+
52
+
53
+ # What is siat?
54
+ siat is a Python 3 plug-in for security investment analysis, primarily designed for teaching and learning purposes in universities for undergraduate and postgraduate programs.
55
+
56
+ siat is recommended to run in Jupyter Notebook or Jupyter Lab, and most of its results are in the forms of figures and/or tables.
57
+ # Version naming
58
+ Version structure: X.Y.Z
59
+
60
+ X is the major version for architecture upgrade only.
61
+ Y is the functional version for functional enhancements.
62
+ Z is the minor version just for bug fixing.
63
+
64
+ # Quick examples of using siat
65
+
66
+
67
+ ```python
68
+ # Enable siat
69
+ from siat import *
70
+ ```
71
+
72
+
73
+ ```python
74
+ # Set language to English, default is Chinese
75
+ set_language("English")
76
+ ```
77
+
78
+ ## Example 1: Apple stock price for the recent month
79
+
80
+
81
+ ```python
82
+ # Simple way: show Apple's stock price in recent month
83
+ apple=security_trend("AAPL")
84
+ ```
85
+ You may expect more information, such as price trend in a recent year (MRY), with the high/low point, current price and average price, like below:
86
+
87
+ ```python
88
+ apple=security_trend("AAPL", start="MRY",
89
+ mark_top=True, mark_bottom=True, mark_end=True,
90
+ average_value=True)
91
+ ```
92
+
93
+ ## Example 2: Comparing Price changes among Apple, Microsoft and NVidia
94
+ You may expect compare the price changes for the recent quarter (MRQ) for the three stocks.
95
+
96
+ Since there is a major stock split for NVidia in 2024 by 1:10, it is necessary to use adjusted prices (Adj Close) to compare these stock prices.
97
+
98
+ ```python
99
+ comp=security_trend(['AAPL','MSFT','NVDA'],
100
+ start='MRQ',
101
+ indicator='Adj Close',
102
+ preprocess='scaling', #use scaling drawing method to avoid loss of details
103
+ mark_top=True, mark_bottom=True,
104
+ annotate=True, annotate_value=True)
105
+ ```
106
+
107
+ ## Example 4: Bollinger band for Apple in the recent quarter
108
+
109
+
110
+ ```python
111
+ # security_technical only supports 4 popular technical indicators: MACD, Bollinger, KDJ and RSI.
112
+ apple=security_technical("AAPL",
113
+ technical="Bollinger",
114
+ start="MRQ",
115
+ facecolor="white",
116
+ loc1="upper left", loc2="lower right")
117
+ ```
118
+
119
+ ## Example 5: CCI for Apple in recent quarter
120
+
121
+
122
+ ```python
123
+ # security_technical2 supports up to 14 popular technical indicators.
124
+ # security_technical2 uses a simplied drawing method (Dehong graph) to avoid trypophobia [藢tr瑟p蓹u'f蓹蕣bj蓹]
125
+ apple=security_technical2("AAPL",
126
+ technical="CCI",
127
+ start="MRM",
128
+ loc1="upper left", loc2="lower right")
129
+ ```
130
+
131
+ # What security products does siat support?
132
+ 1. Public company profile: world-wide
133
+ 2. Stock & stock market index: world-wide
134
+ 3. Stock valuation: primarily in China (mainland and HK) and the U.S.
135
+ 4. Stock option chain: primarily in the U.S.
136
+ 5. Bond: primarily in China and the U.S.
137
+ 6. Markowitz portfolio: with all the supported stocks and bonds
138
+ 7. Fund: primarily in China and the U.S.
139
+ 8. Futures: primarily in China and the U.S.
140
+ 9. Options: primarily in China and the U.S.
141
+ 10. Digital currency: world-wide (some may be restricted by data sources)
142
+ 11. Balance sheet: in China (full function) and world-wide (basic function)
143
+ 12. Income statement: in China mainland (full function) and world-wide (basic function)
144
+ 13. Cash flow statement: in China mainland (full function) and world-wide (basic function)
145
+ 14. DuPont Identity: world-wide
146
+ 15. Sector trend and valuation: primarily in China
147
+ # What analytical methods does siat support?
148
+ 1. Trend analysis
149
+ 2. Panel comparation
150
+ 3. Return analysis: rolling returns, holding period returns
151
+ 4. Risk analysis: rolling volatility, holding period volatility, LPSD
152
+ 5. Technical analysis: more than 15 indicators
153
+ 6. Risk-adjusted return: Sharpe ratio, Sortino ratio, Treynor ratio, Jensen alpha
154
+ 7. Portfolio optimization: four risk-adjusted returns
155
+ 8. CAPM beta trend
156
+ 9. Beta adjustments: simple adjustment, Scholes-Williams, Dimson
157
+ 10. Beta leverage: Hamada Model
158
+ 11. Fama-French three-factor model
159
+ 12. Fama-French-Carhart four-factor model
160
+ 13. Fama-French five-factor model
161
+ 14. Future pricing
162
+ 15. Option pricing: European style, American style, with/without dividends
163
+ 16. VaR & ES: variance-covariance, historic simulation, Monte Carlo, multiple periods
164
+ 17. Liquidity risk: Roll spread, Amihud, Pastor-Stambaugh
165
+ 18. ESG: basic functions
166
+ # Do I have to download data first before using siat?
167
+ NO!
168
+ siat will search the internet data sources for all the required data during analysis.
169
+ The main data sources siat uses:
170
+ 1. Yahoo Finance
171
+ 2. Sina Finance
172
+ 3. East Money
173
+ 4. Stooq (Polish)
174
+ 5. FRED
175
+ 6. OECD
176
+ 7. IMF
177
+ 8. Shanghai Stock Exchange
178
+ 9. Shenzhen Stock Exchange
179
+ 10. Hong Kong Stock Exchange
180
+ 11. Beijing Stock Exchange
181
+ 12. Tokyo Stock Exchange
182
+ 13. London Stock Exchange
183
+ 14. New York Stock Exchange
184
+ 15. NASDAQ
185
+ 16. Sustainalytics
186
+
187
+ Thanks the above websites for their valuable data!
188
+ # How to install siat?
189
+ The author strongly recommends using siat together with Jupyter Notebook or Jupyter Lab in Anaconda.
190
+ In order to install siat for the very first time, open a Jupyter Notebook, and type in the following command:
191
+
192
+ !pip install siat
193
+
194
+ If the above method does not work, something might be wrong in your Python path settings. Try to open an Anaconda Prompt in Windows or a Terminal App in Mac or Linux, and type in the following command:
195
+
196
+ pip install siat
197
+ # How to upgrade siat?
198
+ In Jupyter Notebook or Jupyter Lab:
199
+
200
+ upgrade_siat()
201
+
202
+ If you suffer from slow internet connection (often in campus classrooms with many students), try to use alternative sources, such as:
203
+
204
+ upgrade_siat(alternative="tsinghua")
205
+
206
+ upgrade_siat(alternative="alibaba")
207
+
208
+ If the above methods do not work for your environment, you have to goto the traditional ways to use command-line script, such as:
209
+
210
+ pip install --upgrade siat
211
+
212
+ *** For users in China
213
+ The pypi mirror websites may provide siat installing and upgrading in a much faster speed in the following commands: taking aliyun as an example
214
+
215
+ pip install siat -i https://mirrors.aliyun.com/pypi/simple/
216
+
217
+ pip install --upgrade siat https://mirrors.aliyun.com/pypi/simple/
218
+
219
+ *** Warning
220
+ 1. The pip command itself may need upgrade as well.
221
+ 2. The pip command sometimes may have conflicts with some vpn programs.
222
+ If in this case, try quit vpn program first, and try again.
223
+ # Are there more detailed case studies on using siat?
224
+ YES!
225
+
226
+ There are hundreds of video case studies in the author's channel (most in Chinese, some in English).
227
+
228
+ https://space.bilibili.com/284812153
229
+
230
+ Welcome to follow the channel!
231
+ # How to report a bug or look for help?
232
+ Write to the author, Prof. WANG Dehong, wdehong2000@163.com
@@ -3,32 +3,29 @@
3
3
  @author: WANG Dehong (Peter), IBS BFSU
4
4
  """
5
5
 
6
- #from __future__ import print_function
7
6
  from setuptools import setup, find_packages
8
- #import sys
7
+ from pathlib import Path
8
+ this_directory = Path(__file__).parent
9
+ long_description = (this_directory / "README.md").read_text()
10
+ #description does not support image, text only
9
11
 
10
12
  setup(
11
13
  name="siat",
12
- version="3.1.15",
14
+ version="3.9.1",
13
15
  #author="Prof. WANG Dehong, Business School, BFSU (北京外国语大学 国际商学院 王德宏)",
14
16
  author="Prof. WANG Dehong, International Business School, Beijing Foreign Studies University",
15
17
  author_email="wdehong2000@163.com",
16
18
  description="Securities Investment Analysis Tools (siat)",
17
19
  url = "https://pypi.org/project/siat/",
18
- long_description="""
19
- Security Investment Analysis Toolkit (siat) is designed to use for making case studies in learning security investment,
20
- where cases can be replayed, updated and re-created in different securities,
21
- different time lines and different measurements.
22
- The plug-in is only licensed for teaching and learning purposes, not for commercial use.
23
- The author is not responsible for any results of applying this plug-in in real
24
- investment activities.
25
- """,
20
+ long_description=long_description,
21
+ long_description_content_type='text/markdown',
26
22
  license="Copyright (C) WANG Dehong, 2024. For educational purpose only!",
27
23
  packages = find_packages(),
28
24
  install_requires=[
29
25
  'pandas_datareader',
30
26
  'yfinance',
31
- #'pandas_alive','tqdm',
27
+ #'pandas_alive',
28
+ 'tqdm',
32
29
  'plotly_express',
33
30
  #'akshare==1.3.95',#为与urllib3兼容
34
31
  #'akshare==1.4.57',#为其他兼容考虑
@@ -40,8 +37,6 @@ setup(
40
37
  'mplfinance',
41
38
  'statsmodels',
42
39
  'yahoo_earnings_calendar',
43
- #'yahooquery==2.2.14',#为其他兼容考虑
44
- 'yahooquery',
45
40
  'pypinyin',
46
41
  'seaborn',
47
42
  'numpy',
@@ -51,9 +46,20 @@ setup(
51
46
  'scikit-learn',
52
47
  'baostock',
53
48
  'pyproject.toml',
54
- #'ta-lib',
55
- 'pathlib','ruamel-yaml','prettytable','graphviz','luddite',
56
- 'pendulum',
49
+ #'ta-lib',#ta-lib需要单独安装,并与Python版本配套
50
+ 'pathlib','ruamel-yaml','prettytable',
51
+ 'graphviz',#graphviz可能还需要额外安装程序
52
+ 'luddite',
53
+ 'pendulum','itables','py_trans','bottleneck',
54
+ 'translate','translators',
55
+ #注意:translators 5.9.5要求lxml >=5.3.0,与yahooquery的要求矛盾
56
+ 'nbconvert',
57
+ 'ipywidgets==8.1.6',#解决Error loading widgets
58
+ 'playwright',#安装后还需要执行指令:playwright install
59
+ #'yahooquery==2.2.14',#为其他兼容考虑
60
+ 'yahooquery==2.3.7',#解决数据获取失败crump限制
61
+ #注意:临时措施,yahooquery 2.3.7要求lxml 4.9.4
62
+
57
63
  ],
58
64
  #zip_sage=False,
59
65
  include_package_data=True, # 打包包含静态文件标识
@@ -0,0 +1,75 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ 功能:一次性引入SIAT的所有模块
4
+ 作者:王德宏,北京外国语大学国际商学院
5
+ 版权:2021-2025(C) 仅限教学使用,商业使用需要授权
6
+ 联络:wdehong2000@163.com
7
+ """
8
+
9
+ #==============================================================================
10
+ #屏蔽所有警告性信息
11
+ import warnings; warnings.filterwarnings('ignore')
12
+ #==============================================================================
13
+ from siat.allin import *
14
+
15
+ import pkg_resources
16
+ current_version=pkg_resources.get_distribution("siat").version
17
+ #current_list=current_version.split('.')
18
+
19
+ #==============================================================================
20
+ # 处理stooq.py修复问题
21
+ restart=False
22
+ tagfile='fix_package.pkl'
23
+
24
+ #判断操作系统
25
+ import sys; czxt=sys.platform
26
+ if czxt in ['win32','win64']:
27
+ os='windows'
28
+ elif czxt in ['darwin']: #MacOSX
29
+ os='mac'
30
+ elif czxt in ['linux']: #linux
31
+ os='linux'
32
+ else:
33
+ os='windows'
34
+
35
+ # 确定标记文件存放地址
36
+ import pandas
37
+ srcpath=pandas.__path__[0]
38
+ if os == 'windows':
39
+ srcpath1=srcpath.replace("\\",'/')
40
+ srcfile=srcpath1+'/'+tagfile
41
+ else:
42
+ srcpath1=srcpath
43
+ srcfile=srcpath1+'/'+file
44
+
45
+ try:
46
+ with open(srcfile,'rb') as file:
47
+ siat_ver=pickle.load(file)
48
+ if siat_ver != current_version:
49
+ restart=True
50
+ with open(srcfile,'wb') as file:
51
+ pickle.dump(current_version,file)
52
+ except:
53
+ restart=True
54
+ with open(srcfile,'wb') as file:
55
+ pickle.dump(current_version,file)
56
+
57
+ #屏蔽函数内print信息输出的类
58
+ import os, sys
59
+ class HiddenPrints:
60
+ def __enter__(self):
61
+ self._original_stdout = sys.stdout
62
+ sys.stdout = open(os.devnull, 'w')
63
+
64
+ def __exit__(self, exc_type, exc_val, exc_tb):
65
+ sys.stdout.close()
66
+ sys.stdout = self._original_stdout
67
+
68
+ if not restart:
69
+ print(" Successfully enabled siat v{}".format(current_version))
70
+ else:
71
+ with HiddenPrints():
72
+ fix_package()
73
+ print(" Please RESTART Python kernel and run this command again")
74
+
75
+ #==============================================================================
@@ -25,6 +25,8 @@ from siat.cryptocurrency import *
25
25
 
26
26
  # 宏观经济
27
27
  from siat.economy import *
28
+ from siat.economy2 import *
29
+
28
30
 
29
31
  # ESG
30
32
  from siat.esg import *
@@ -41,6 +43,9 @@ from siat.financials import *
41
43
  # 财务分析:雅虎源
42
44
  from siat.financials2 import *
43
45
 
46
+ # 财务报表:雅虎源
47
+ from siat.fin_stmt2_yahoo import *
48
+
44
49
  # 财务分析:中国
45
50
  from siat.financials_china import *
46
51
 
@@ -88,6 +93,7 @@ from siat.valuation_china import *
88
93
  # 获取证券价格与计算
89
94
  from siat.security_prices import *
90
95
  from siat.security_price2 import *
96
+ from siat.other_indexes import *
91
97
 
92
98
  # 股票分析
93
99
  from siat.stock import *
@@ -117,6 +123,15 @@ from siat.compare_cross import *
117
123
  # 股票技术分析
118
124
  from siat.stock_technical import *
119
125
 
126
+ # 事件研究法
127
+ from siat.event_study import *
128
+
120
129
  # 2FA: Google Authenticator
121
130
  from siat.google_authenticator import *
122
131
 
132
+ # 提问记录
133
+ from siat.luchy_draw import *
134
+
135
+ # 搜索全球上市公司的英文名称,需要访问雅虎
136
+ from siat.yf_name import *
137
+
@@ -111,7 +111,7 @@ def roll_spread_portfolio(portfolio,start,end,printout=True):
111
111
  '-'+str(sp.index[-1].day)
112
112
  print("\n===== 投资组合的流动性风险 =====")
113
113
 
114
- _,_,tickerlist,sharelist=decompose_portfolio(portfolio)
114
+ _,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
115
115
  if len(tickerlist)==1:
116
116
  product=str(ticker_name(tickerlist,'bond'))
117
117
  else:
@@ -192,7 +192,7 @@ def amihud_illiquidity_portfolio(portfolio,start,end,printout=True):
192
192
  '-'+str(sp.index[-1].day)
193
193
  print("\n===== 投资组合的流动性风险 =====")
194
194
 
195
- _,_,tickerlist,sharelist=decompose_portfolio(portfolio)
195
+ _,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
196
196
  if len(tickerlist)==1:
197
197
  product=str(ticker_name(tickerlist,'bond'))
198
198
  else:
@@ -338,7 +338,7 @@ def ps_liquidity_portfolio(portfolio,start,end,printout=True):
338
338
  '-'+str(sp.index[-1].day)
339
339
  print("\n===== 投资组合的流动性风险 =====")
340
340
 
341
- _,_,tickerlist,sharelist=decompose_portfolio(portfolio)
341
+ _,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
342
342
  if len(tickerlist)==1:
343
343
  product=str(ticker_name(tickerlist,'bond'))
344
344
  else:
@@ -423,7 +423,7 @@ def plot_liquidity_monthly(portfolio,start,end,liquidity_type):
423
423
  ylabeltxt=ectranslate(liquidity_type)
424
424
  titletxt="证券流动性风险的月度指标"
425
425
 
426
- _,_,tickerlist,sharelist=decompose_portfolio(portfolio)
426
+ _,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
427
427
  if len(tickerlist)==1:
428
428
  product=str(ticker_name(tickerlist,'bond'))
429
429
  else:
@@ -521,7 +521,7 @@ def plot_liquidity_annual(portfolio,start,end,liquidity_type):
521
521
  ylabeltxt=ectranslate(liquidity_type)
522
522
  titletxt="证券流动性风险的年度指标"
523
523
 
524
- _,_,tickerlist,sharelist=decompose_portfolio(portfolio)
524
+ _,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
525
525
  if len(tickerlist)==1:
526
526
  product=str(ticker_name(tickerlist,'bond'))
527
527
  else:
@@ -565,7 +565,7 @@ def draw_liquidity(liqs):
565
565
  ylabeltxt=ectranslate(liqs['Type'][0])
566
566
  titletxt="证券流动性风险的滚动趋势"
567
567
 
568
- _,_,tickerlist,sharelist=decompose_portfolio(portfolio)
568
+ _,_,tickerlist,sharelist,ticker_type=decompose_portfolio(portfolio)
569
569
  if len(tickerlist)==1:
570
570
  product=str(ticker_name(tickerlist))
571
571
  else:
@@ -721,12 +721,12 @@ def compare_liquidity_rolling(portfolio1,portfolio2,start,end,liquidity_type,win
721
721
  ylabeltxt=ectranslate(liquidity_type)
722
722
  titletxt="证券流动性风险走势比较"
723
723
 
724
- _,_,tickerlist1,sharelist1=decompose_portfolio(portfolio1)
724
+ _,_,tickerlist1,sharelist1,ticker_type1=decompose_portfolio(portfolio1)
725
725
  if len(tickerlist1)==1:
726
726
  product1=str(ticker_name(tickerlist1,'bond'))
727
727
  else:
728
728
  product1=str(ticker_name(tickerlist1,'bond'))+',持仓'+str(sharelist1)
729
- _,_,tickerlist2,sharelist2=decompose_portfolio(portfolio2)
729
+ _,_,tickerlist2,sharelist2,ticker_type2=decompose_portfolio(portfolio2)
730
730
  if len(tickerlist2)==1:
731
731
  product2=str(ticker_name(tickerlist2,'bond'))
732
732
  else:
@@ -102,7 +102,10 @@ def query_stock_symbol(self):
102
102
 
103
103
  # Check for two different Barron's URLs
104
104
  url = 'http://www.barrons.com/quote/stock/us/xnas/%s' % (self.symbol)
105
- page = requests.get(url)
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)
106
109
  if page.status_code == 404:
107
110
  url = 'http://www.barrons.com/quote/stock/us/xnys/%s?mod=DNH_S' % (self.symbol)
108
111
 
@@ -159,7 +162,10 @@ def query_stock_symbol(self):
159
162
  """
160
163
  # Check for two different Barron's URLs
161
164
  url = 'http://www.barrons.com/quote/stock/us/xnas/%s' % (self.symbol)
162
- page = requests.get(url)
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)
163
169
  if page.status_code == 404:
164
170
  url = 'http://www.barrons.com/quote/stock/us/xnys/%s?mod=DNH_S' % (self.symbol)
165
171
  """
@@ -727,7 +727,7 @@ def draw_hamada_factors(stkcd,mktidx,betas):
727
727
  #计算资产负债率:由 D/E到 D/(A=D+E)
728
728
  betas['Debt/Assets%']=1/(1+1/(betas['Debt Ratio%']/100))*100
729
729
 
730
- #fig=plt.figure(figsize=(8,6))
730
+ #fig=plt.figure(figsize=(12.8,6.4))
731
731
  fig=plt.figure()
732
732
  ax1=fig.add_subplot(111)
733
733
  ax1.plot(betas['CFLB%'],marker='o',color='green',lw=3,label='CFLB%')
@@ -991,7 +991,7 @@ def compare_mhamada(tickers,market_index="000001.SS"):
991
991
 
992
992
  import pandas as pd
993
993
  df=pd.DataFrame()
994
- print("Starting to retrive and calculate Hamada ratios, please wait ......")
994
+ print("Starting to retrieve and calculate Hamada ratios, please wait ......")
995
995
  for t in tickers:
996
996
 
997
997
  with HiddenPrints():
@@ -345,7 +345,7 @@ def draw_hamada_factors_china(stkcd,mktidx,betas):
345
345
  #计算资产负债率:由 D/E到 D/(A=D+E)
346
346
  betas['Debt/Assets%']=1/(1+1/(betas['lev ratio']/100))*100
347
347
 
348
- #fig=plt.figure(figsize=(8,6))
348
+ #fig=plt.figure(figsize=(12.8,6.4))
349
349
  fig=plt.figure()
350
350
  ax1=fig.add_subplot(111)
351
351
  ax1.plot(betas['CFLB%'],marker='o',color='green',lw=3,label='CFLB%')