siat 3.10.129__py3-none-any.whl → 3.10.131__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 +36 -105
- siat/exchange_bond_china.pickle +0 -0
- siat/fund_china.pickle +0 -0
- siat/market_china.py +6 -0
- siat/security_prices.py +3 -3
- siat/stock_info.pickle +0 -0
- {siat-3.10.129.dist-info/licenses → siat-3.10.131.dist-info}/LICENSE +0 -0
- {siat-3.10.129.dist-info → siat-3.10.131.dist-info}/METADATA +227 -235
- {siat-3.10.129.dist-info → siat-3.10.131.dist-info}/RECORD +8 -8
- {siat-3.10.129.dist-info → siat-3.10.131.dist-info}/WHEEL +1 -1
- {siat-3.10.129.dist-info → siat-3.10.131.dist-info}/top_level.txt +0 -0
siat/common.py
CHANGED
@@ -4923,6 +4923,11 @@ if __name__ == '__main__':
|
|
4923
4923
|
# 注意:上面的await命令会导致编译失败,测试后要注释掉
|
4924
4924
|
|
4925
4925
|
#==============================================================================
|
4926
|
+
if __name__ == '__main__':
|
4927
|
+
# 定义 Notebook 路径和输出 PDF 路径
|
4928
|
+
notebook_dir = r"E:\北外工作-25春\SICA-BFSU\Session 2" # 替换为你的 Notebook 文件路径
|
4929
|
+
notebook_file= r"Session 2-Market index v3en" # 替换为你想保存的 PDF 文件路径
|
4930
|
+
|
4926
4931
|
async def jupyter2pdf2(notebook_dir, notebook_file):
|
4927
4932
|
"""
|
4928
4933
|
===========================================================================
|
@@ -4947,6 +4952,8 @@ async def jupyter2pdf2(notebook_dir, notebook_file):
|
|
4947
4952
|
else:
|
4948
4953
|
sep='\\'
|
4949
4954
|
|
4955
|
+
#import os; sep=os.sep
|
4956
|
+
|
4950
4957
|
# ipynb文件的完整路径
|
4951
4958
|
if ('.ipynb' in notebook_file):
|
4952
4959
|
notebook_file1=notebook_file.replace('.ipynb','')
|
@@ -4958,11 +4965,17 @@ async def jupyter2pdf2(notebook_dir, notebook_file):
|
|
4958
4965
|
output_pdf_path1=notebook_dir+sep+notebook_file1+'A4.pdf'
|
4959
4966
|
output_pdf_path2=notebook_dir+sep+notebook_file1+'A3.pdf'
|
4960
4967
|
|
4961
|
-
import os
|
4968
|
+
import os,sys
|
4962
4969
|
from nbconvert import HTMLExporter
|
4963
4970
|
|
4971
|
+
"""
|
4972
|
+
import nest_asyncio
|
4973
|
+
nest_asyncio.apply() # 修复 Notebook 的事件循环问题
|
4974
|
+
"""
|
4975
|
+
|
4964
4976
|
try:
|
4965
4977
|
from playwright.async_api import async_playwright
|
4978
|
+
#from playwright.sync_api import sync_playwright
|
4966
4979
|
except:
|
4967
4980
|
print(" #Warning(jupyter2pdf2): playwright seems not fully installed yet")
|
4968
4981
|
print(" [Solution] execute the command before re-run: playwright install")
|
@@ -4993,17 +5006,35 @@ async def jupyter2pdf2(notebook_dir, notebook_file):
|
|
4993
5006
|
await page.goto(f"file://{os.path.abspath(html_file)}")
|
4994
5007
|
|
4995
5008
|
# 避免加载html文件超时,用于macOS
|
4996
|
-
|
5009
|
+
if not sys.platform.startswith('win'):
|
5010
|
+
page.wait_for_selector(".jp-Notebook", state="visible", timeout=60000) # 等待笔记本主体出现
|
4997
5011
|
|
4998
5012
|
await page.pdf(path=output_pdf_path1, format='A4')
|
4999
5013
|
await page.pdf(path=output_pdf_path2, format='A3')
|
5000
5014
|
|
5001
5015
|
await browser.close()
|
5002
|
-
|
5003
|
-
|
5016
|
+
"""
|
5017
|
+
with sync_playwright() as p:
|
5018
|
+
browser = p.chromium.launch()
|
5019
|
+
page = browser.new_page()
|
5020
|
+
page.goto(f"file://{os.path.abspath(html_file)}")
|
5021
|
+
|
5022
|
+
# 避免加载html文件超时,用于macOS
|
5023
|
+
if not sys.platform.startswith('win'):
|
5024
|
+
page.wait_for_selector(".jp-Notebook", state="visible", timeout=60000) # 等待笔记本主体出现
|
5025
|
+
|
5026
|
+
page.pdf(path=output_pdf_path1, format='A4')
|
5027
|
+
page.pdf(path=output_pdf_path2, format='A3')
|
5028
|
+
|
5029
|
+
browser.close()
|
5030
|
+
"""
|
5031
|
+
|
5032
|
+
print(f"2 PDFs created in the same directory, pick 1 you think best")
|
5004
5033
|
|
5005
5034
|
except Exception as e:
|
5006
|
-
|
5035
|
+
if str(e)=='':
|
5036
|
+
e="because of issues in your playwright or Python environment"
|
5037
|
+
print(f"PDF conversion failed {e}")
|
5007
5038
|
return
|
5008
5039
|
|
5009
5040
|
finally:
|
@@ -5023,106 +5054,6 @@ if __name__ == '__main__':
|
|
5023
5054
|
#await jupyter2pdf2(notebook_dir, notebook_file)
|
5024
5055
|
# 注意:上面的await命令会导致编译失败,测试后要注释掉
|
5025
5056
|
|
5026
|
-
#==============================================================================
|
5027
|
-
async def jupyter2pdf3(notebook_file):
|
5028
|
-
"""
|
5029
|
-
===========================================================================
|
5030
|
-
将 Jupyter Notebook 转换为 PDF 文件,异步方式。
|
5031
|
-
主要参数:
|
5032
|
-
notebook_file (str): Jupyter Notebook文件名,不含目录
|
5033
|
-
|
5034
|
-
输出:
|
5035
|
-
同时生成A4和A3两种幅面的pdf文件,由使用者自行挑选一个效果最好的。
|
5036
|
-
返回:
|
5037
|
-
None
|
5038
|
-
|
5039
|
-
注意1:如果指令异常,可能还要执行python -m playwright install
|
5040
|
-
注意2:调用本函数的格式是异步await开头,例如:
|
5041
|
-
await jupyter2pdf3(notebook_file)
|
5042
|
-
|
5043
|
-
注意:目前无法正确获得ipynb文件的所在目录,使用使用!!!
|
5044
|
-
"""
|
5045
|
-
# 获得路径
|
5046
|
-
import os
|
5047
|
-
notebook_dir=os.getcwd()
|
5048
|
-
# 注意:上述指令无法获取当前Jupyter文件的目录
|
5049
|
-
|
5050
|
-
# 路径分割符号
|
5051
|
-
if ('/' in notebook_dir) and not ('\\' in notebook_dir):
|
5052
|
-
sep='/'
|
5053
|
-
else:
|
5054
|
-
sep='\\'
|
5055
|
-
|
5056
|
-
# ipynb文件的完整路径
|
5057
|
-
if ('.ipynb' in notebook_file):
|
5058
|
-
notebook_file1=notebook_file.replace('.ipynb','')
|
5059
|
-
else:
|
5060
|
-
notebook_file1=notebook_file
|
5061
|
-
notebook_path=notebook_dir+sep+notebook_file1+'.ipynb'
|
5062
|
-
|
5063
|
-
# pdf文件的完整路径
|
5064
|
-
output_pdf_path1=notebook_dir+sep+notebook_file1+'A4.pdf'
|
5065
|
-
output_pdf_path2=notebook_dir+sep+notebook_file1+'A3.pdf'
|
5066
|
-
|
5067
|
-
from nbconvert import HTMLExporter
|
5068
|
-
|
5069
|
-
try:
|
5070
|
-
from playwright.async_api import async_playwright
|
5071
|
-
except:
|
5072
|
-
print(" #Warning(jupyter2pdf2): playwright seems not fully installed yet")
|
5073
|
-
print(" [Solution] execute the command before re-run: playwright install")
|
5074
|
-
return
|
5075
|
-
|
5076
|
-
html_file = ""
|
5077
|
-
|
5078
|
-
try:
|
5079
|
-
# 导出 Notebook 为 HTML
|
5080
|
-
html_exporter = HTMLExporter()
|
5081
|
-
try:
|
5082
|
-
html_content, _ = html_exporter.from_filename(notebook_path)
|
5083
|
-
print("Converting notebook file to pdf in both A4 and A3 sizes ...")
|
5084
|
-
|
5085
|
-
except:
|
5086
|
-
print("File not found for {}".format(notebook_path))
|
5087
|
-
return
|
5088
|
-
|
5089
|
-
# 创建临时 HTML 文件
|
5090
|
-
html_file = "temp_notebook.html"
|
5091
|
-
with open(html_file, "w", encoding="utf-8") as f:
|
5092
|
-
f.write(html_content)
|
5093
|
-
|
5094
|
-
# 使用 Playwright 打开 HTML 并保存为 PDF
|
5095
|
-
async with async_playwright() as p:
|
5096
|
-
browser = await p.chromium.launch()
|
5097
|
-
page = await browser.new_page()
|
5098
|
-
await page.goto(f"file://{os.path.abspath(html_file)}")
|
5099
|
-
|
5100
|
-
await page.pdf(path=output_pdf_path1, format='A4')
|
5101
|
-
await page.pdf(path=output_pdf_path2, format='A3')
|
5102
|
-
|
5103
|
-
await browser.close()
|
5104
|
-
|
5105
|
-
print(f"2 PDF created in the same directory, pick 1 you think best")
|
5106
|
-
|
5107
|
-
except Exception as e:
|
5108
|
-
print(f"Conversion failed because {e}")
|
5109
|
-
return
|
5110
|
-
|
5111
|
-
finally:
|
5112
|
-
if html_file == "":
|
5113
|
-
return
|
5114
|
-
# 删除临时 HTML 文件
|
5115
|
-
elif os.path.exists(html_file):
|
5116
|
-
os.remove(html_file)
|
5117
|
-
|
5118
|
-
return
|
5119
|
-
|
5120
|
-
if __name__ == '__main__':
|
5121
|
-
# 替换为你想转存PDF的Notebook文件名
|
5122
|
-
file = "Session 1 全球证券市场-简化版.ipynb"
|
5123
|
-
#await jupyter2pdf3(file)
|
5124
|
-
# 注意:上面的await命令会导致编译失败,测试后要注释掉
|
5125
|
-
|
5126
5057
|
#==============================================================================
|
5127
5058
|
if __name__ == '__main__':
|
5128
5059
|
df=security_trend("600519.SS",indicator=['Close','Open','High','Low'],graph=False)
|
siat/exchange_bond_china.pickle
CHANGED
File without changes
|
siat/fund_china.pickle
CHANGED
File without changes
|
siat/market_china.py
CHANGED
@@ -442,6 +442,12 @@ def market_detail_exchange_china(exchange='SSE',category='price'):
|
|
442
442
|
except:
|
443
443
|
print(" #Error(market_detail_exchange_china): info unavailable for",exchange,"\b, try again later")
|
444
444
|
return None
|
445
|
+
|
446
|
+
# 检查东方财富抓取限制
|
447
|
+
if len(df0) <= 100:
|
448
|
+
print(" #Warning(market_detail_exchange_china): web scraping restricted to 100 records by data source")
|
449
|
+
print(" Solution: upgrade akshare (pip install akshare --upgrade), restart Python kernel, run again")
|
450
|
+
return None
|
445
451
|
|
446
452
|
#DEBUG
|
447
453
|
#print(" Check1:",len(df0))
|
siat/security_prices.py
CHANGED
@@ -1782,7 +1782,7 @@ def get_dividend_yq(ticker,start,end,facecolor="papayawhip"):
|
|
1782
1782
|
import datetime
|
1783
1783
|
todaydt = datetime.date.today()
|
1784
1784
|
footnote_cn=f"【注】期间:{start}至{end}, 数据来源:雅虎, {todaydt}"
|
1785
|
-
footnote_en=f"
|
1785
|
+
footnote_en=f"Period:{start} to {end}. Data source:Yahoo, {todaydt}"
|
1786
1786
|
footnote=text_lang(footnote_cn,footnote_en)
|
1787
1787
|
df_display_CSS(div2,titletxt=titletxt,footnote=footnote,facecolor=facecolor,decimals=2, \
|
1788
1788
|
first_col_align='center',second_col_align='center', \
|
@@ -1819,7 +1819,7 @@ def get_split_yq(ticker,start,end,facecolor="papayawhip"):
|
|
1819
1819
|
return None
|
1820
1820
|
|
1821
1821
|
div2['Close']=div2['Close']*div2['splits']
|
1822
|
-
div2['splits']=div2['splits'].apply(lambda x: int(x) if x.is_integer() else round(x,1))
|
1822
|
+
div2['splits']=div2['splits'].apply(lambda x: str(int(x)) if x.is_integer() else str(round(x,1)))
|
1823
1823
|
div2['Close']=div2['Close'].apply(lambda x: round(x,2))
|
1824
1824
|
div2['Adj Close']=div2['Adj Close'].apply(lambda x: round(x,2))
|
1825
1825
|
div2.rename(columns={"date":text_lang("分拆日期","Split Date"), \
|
@@ -1832,7 +1832,7 @@ def get_split_yq(ticker,start,end,facecolor="papayawhip"):
|
|
1832
1832
|
import datetime
|
1833
1833
|
todaydt = datetime.date.today()
|
1834
1834
|
footnote_cn=f"【注】期间:{start}至{end}, 数据来源:雅虎, {todaydt}"
|
1835
|
-
footnote_en=f"
|
1835
|
+
footnote_en=f"Period:{start} to {end}. Data source:Yahoo, {todaydt}"
|
1836
1836
|
footnote=text_lang(footnote_cn,footnote_en)
|
1837
1837
|
df_display_CSS(div2,titletxt=titletxt,footnote=footnote,facecolor=facecolor,decimals=2, \
|
1838
1838
|
first_col_align='center',second_col_align='center', \
|
siat/stock_info.pickle
CHANGED
File without changes
|
File without changes
|
@@ -1,235 +1,227 @@
|
|
1
|
-
Metadata-Version: 2.
|
2
|
-
Name: siat
|
3
|
-
Version: 3.10.
|
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, 2025. For educational purpose only!
|
9
|
-
Description-Content-Type: text/markdown
|
10
|
-
License-File: LICENSE
|
11
|
-
Requires-Dist:
|
12
|
-
Requires-Dist: yfinance
|
13
|
-
Requires-Dist: tqdm
|
14
|
-
Requires-Dist:
|
15
|
-
Requires-Dist: akshare
|
16
|
-
Requires-Dist: urllib3
|
17
|
-
Requires-Dist: mplfinance
|
18
|
-
Requires-Dist: statsmodels
|
19
|
-
Requires-Dist:
|
20
|
-
Requires-Dist: pypinyin
|
21
|
-
Requires-Dist: seaborn
|
22
|
-
Requires-Dist: scipy
|
23
|
-
Requires-Dist: pandas
|
24
|
-
Requires-Dist: scikit-learn
|
25
|
-
Requires-Dist: baostock
|
26
|
-
Requires-Dist: pyproject.toml
|
27
|
-
Requires-Dist: pathlib
|
28
|
-
Requires-Dist: ruamel-yaml
|
29
|
-
Requires-Dist: prettytable
|
30
|
-
Requires-Dist: graphviz
|
31
|
-
Requires-Dist: luddite
|
32
|
-
Requires-Dist: pendulum
|
33
|
-
Requires-Dist: itables
|
34
|
-
Requires-Dist:
|
35
|
-
Requires-Dist: bottleneck
|
36
|
-
Requires-Dist: translate
|
37
|
-
Requires-Dist: translators
|
38
|
-
Requires-Dist: nbconvert
|
39
|
-
Requires-Dist: ipywidgets
|
40
|
-
Requires-Dist: yahooquery==2.3.7
|
41
|
-
Requires-Dist: lxml==4.9.4
|
42
|
-
Requires-Dist:
|
43
|
-
Requires-Dist: tiingo[pandas]
|
44
|
-
Requires-Dist: numpy<2
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
```python
|
77
|
-
#
|
78
|
-
|
79
|
-
```
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
#
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
In
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
If
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
The
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
#
|
227
|
-
|
228
|
-
|
229
|
-
There are hundreds of video case studies in the author's channel (most in Chinese, some in English).
|
230
|
-
|
231
|
-
https://space.bilibili.com/284812153
|
232
|
-
|
233
|
-
Welcome to follow the channel!
|
234
|
-
# How to report a bug or look for help?
|
235
|
-
Write to the author, Prof. WANG Dehong, wdehong2000@163.com
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: siat
|
3
|
+
Version: 3.10.131
|
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, 2025. 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: scipy
|
23
|
+
Requires-Dist: pandas
|
24
|
+
Requires-Dist: scikit-learn
|
25
|
+
Requires-Dist: baostock
|
26
|
+
Requires-Dist: pyproject.toml
|
27
|
+
Requires-Dist: pathlib
|
28
|
+
Requires-Dist: ruamel-yaml
|
29
|
+
Requires-Dist: prettytable
|
30
|
+
Requires-Dist: graphviz
|
31
|
+
Requires-Dist: luddite
|
32
|
+
Requires-Dist: pendulum
|
33
|
+
Requires-Dist: itables
|
34
|
+
Requires-Dist: py-trans
|
35
|
+
Requires-Dist: bottleneck
|
36
|
+
Requires-Dist: translate
|
37
|
+
Requires-Dist: translators
|
38
|
+
Requires-Dist: nbconvert
|
39
|
+
Requires-Dist: ipywidgets ==8.1.6
|
40
|
+
Requires-Dist: yahooquery ==2.3.7
|
41
|
+
Requires-Dist: lxml ==4.9.4
|
42
|
+
Requires-Dist: alpha-vantage
|
43
|
+
Requires-Dist: tiingo[pandas]
|
44
|
+
Requires-Dist: numpy <2
|
45
|
+
Requires-Dist: playwright
|
46
|
+
|
47
|
+
|
48
|
+
# What is siat?
|
49
|
+
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.
|
50
|
+
|
51
|
+
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.
|
52
|
+
# Version naming
|
53
|
+
Version structure: X.Y.Z
|
54
|
+
|
55
|
+
X is the major version for architecture upgrade only.
|
56
|
+
Y is the functional version for functional enhancements.
|
57
|
+
Z is the minor version just for bug fixing.
|
58
|
+
|
59
|
+
# Quick examples of using siat
|
60
|
+
|
61
|
+
|
62
|
+
```python
|
63
|
+
# Enable siat
|
64
|
+
from siat import *
|
65
|
+
```
|
66
|
+
|
67
|
+
|
68
|
+
```python
|
69
|
+
# Set language to English, default is Chinese
|
70
|
+
set_language("English")
|
71
|
+
```
|
72
|
+
|
73
|
+
## Example 1: Apple stock price for the recent month
|
74
|
+
|
75
|
+
|
76
|
+
```python
|
77
|
+
# Simple way: show Apple's stock price in recent month
|
78
|
+
apple=security_trend("AAPL")
|
79
|
+
```
|
80
|
+
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:
|
81
|
+
|
82
|
+
```python
|
83
|
+
apple=security_trend("AAPL", start="MRY",
|
84
|
+
mark_top=True, mark_bottom=True, mark_end=True,
|
85
|
+
average_value=True)
|
86
|
+
```
|
87
|
+
|
88
|
+
## Example 2: Comparing Price changes among Apple, Microsoft and NVidia
|
89
|
+
You may expect compare the price changes for the recent quarter (MRQ) for the three stocks.
|
90
|
+
|
91
|
+
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.
|
92
|
+
|
93
|
+
```python
|
94
|
+
comp=security_trend(['AAPL','MSFT','NVDA'],
|
95
|
+
start='MRQ',
|
96
|
+
indicator='Adj Close',
|
97
|
+
preprocess='scaling', #use scaling drawing method to avoid loss of details
|
98
|
+
mark_top=True, mark_bottom=True,
|
99
|
+
annotate=True, annotate_value=True)
|
100
|
+
```
|
101
|
+
|
102
|
+
## Example 4: Bollinger band for Apple in the recent quarter
|
103
|
+
|
104
|
+
|
105
|
+
```python
|
106
|
+
# security_technical only supports 4 popular technical indicators: MACD, Bollinger, KDJ and RSI.
|
107
|
+
apple=security_technical("AAPL",
|
108
|
+
technical="Bollinger",
|
109
|
+
start="MRQ",
|
110
|
+
facecolor="white",
|
111
|
+
loc1="upper left", loc2="lower right")
|
112
|
+
```
|
113
|
+
|
114
|
+
## Example 5: CCI for Apple in recent quarter
|
115
|
+
|
116
|
+
|
117
|
+
```python
|
118
|
+
# security_technical2 supports up to 14 popular technical indicators.
|
119
|
+
# security_technical2 uses a simplied drawing method (Dehong graph) to avoid trypophobia [藢tr瑟p蓹u'f蓹蕣bj蓹]
|
120
|
+
apple=security_technical2("AAPL",
|
121
|
+
technical="CCI",
|
122
|
+
start="MRM",
|
123
|
+
loc1="upper left", loc2="lower right")
|
124
|
+
```
|
125
|
+
|
126
|
+
# What security products does siat support?
|
127
|
+
1. Public company profile: world-wide
|
128
|
+
2. Stock & stock market index: world-wide
|
129
|
+
3. Stock valuation: primarily in China (mainland and HK) and the U.S.
|
130
|
+
4. Stock option chain: primarily in the U.S.
|
131
|
+
5. Bond: primarily in China and the U.S.
|
132
|
+
6. Markowitz portfolio: with all the supported stocks and bonds
|
133
|
+
7. Fund: primarily in China and the U.S.
|
134
|
+
8. Futures: primarily in China and the U.S.
|
135
|
+
9. Options: primarily in China and the U.S.
|
136
|
+
10. Digital currency: world-wide (some may be restricted by data sources)
|
137
|
+
11. Balance sheet: in China (full function) and world-wide (basic function)
|
138
|
+
12. Income statement: in China mainland (full function) and world-wide (basic function)
|
139
|
+
13. Cash flow statement: in China mainland (full function) and world-wide (basic function)
|
140
|
+
14. DuPont Identity: world-wide
|
141
|
+
15. Sector trend and valuation: primarily in China
|
142
|
+
# What analytical methods does siat support?
|
143
|
+
1. Trend analysis
|
144
|
+
2. Panel comparation
|
145
|
+
3. Return analysis: rolling returns, holding period returns
|
146
|
+
4. Risk analysis: rolling volatility, holding period volatility, LPSD
|
147
|
+
5. Technical analysis: more than 15 indicators
|
148
|
+
6. Risk-adjusted return: Sharpe ratio, Sortino ratio, Treynor ratio, Jensen alpha
|
149
|
+
7. Portfolio optimization: four risk-adjusted returns
|
150
|
+
8. CAPM beta trend
|
151
|
+
9. Beta adjustments: simple adjustment, Scholes-Williams, Dimson
|
152
|
+
10. Beta leverage: Hamada Model
|
153
|
+
11. Fama-French three-factor model
|
154
|
+
12. Fama-French-Carhart four-factor model
|
155
|
+
13. Fama-French five-factor model
|
156
|
+
14. Future pricing
|
157
|
+
15. Option pricing: European style, American style, with/without dividends
|
158
|
+
16. VaR & ES: variance-covariance, historic simulation, Monte Carlo, multiple periods
|
159
|
+
17. Liquidity risk: Roll spread, Amihud, Pastor-Stambaugh
|
160
|
+
18. ESG: basic functions
|
161
|
+
# Do I have to download data first before using siat?
|
162
|
+
NO!
|
163
|
+
siat will search the internet data sources for all the required data during analysis.
|
164
|
+
The main data sources siat uses:
|
165
|
+
1. Yahoo Finance
|
166
|
+
2. Sina Finance
|
167
|
+
3. East Money
|
168
|
+
4. Stooq (Polish)
|
169
|
+
5. FRED
|
170
|
+
6. OECD
|
171
|
+
7. IMF
|
172
|
+
8. Shanghai Stock Exchange
|
173
|
+
9. Shenzhen Stock Exchange
|
174
|
+
10. Hong Kong Stock Exchange
|
175
|
+
11. Beijing Stock Exchange
|
176
|
+
12. Tokyo Stock Exchange
|
177
|
+
13. London Stock Exchange
|
178
|
+
14. New York Stock Exchange
|
179
|
+
15. NASDAQ
|
180
|
+
16. Sustainalytics
|
181
|
+
|
182
|
+
Thanks the above websites for their valuable data!
|
183
|
+
# How to install siat?
|
184
|
+
The author strongly recommends using siat together with Jupyter Notebook or Jupyter Lab in Anaconda.
|
185
|
+
In order to install siat for the very first time, open a Jupyter Notebook, and type in the following command:
|
186
|
+
|
187
|
+
!pip install siat
|
188
|
+
|
189
|
+
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:
|
190
|
+
|
191
|
+
pip install siat
|
192
|
+
# How to upgrade siat?
|
193
|
+
In Jupyter Notebook or Jupyter Lab:
|
194
|
+
|
195
|
+
upgrade_siat()
|
196
|
+
|
197
|
+
If you suffer from slow internet connection (often in campus classrooms with many students), try to use alternative sources, such as:
|
198
|
+
|
199
|
+
upgrade_siat(alternative="tsinghua")
|
200
|
+
|
201
|
+
upgrade_siat(alternative="alibaba")
|
202
|
+
|
203
|
+
If the above methods do not work for your environment, you have to goto the traditional ways to use command-line script, such as:
|
204
|
+
|
205
|
+
pip install --upgrade siat
|
206
|
+
|
207
|
+
*** For users in China
|
208
|
+
The pypi mirror websites may provide siat installing and upgrading in a much faster speed in the following commands: taking aliyun as an example
|
209
|
+
|
210
|
+
pip install siat -i https://mirrors.aliyun.com/pypi/simple/
|
211
|
+
|
212
|
+
pip install --upgrade siat https://mirrors.aliyun.com/pypi/simple/
|
213
|
+
|
214
|
+
*** Warning
|
215
|
+
1. The pip command itself may need upgrade as well.
|
216
|
+
2. The pip command sometimes may have conflicts with some vpn programs.
|
217
|
+
If in this case, try quit vpn program first, and try again.
|
218
|
+
# Are there more detailed case studies on using siat?
|
219
|
+
YES!
|
220
|
+
|
221
|
+
There are hundreds of video case studies in the author's channel (most in Chinese, some in English).
|
222
|
+
|
223
|
+
https://space.bilibili.com/284812153
|
224
|
+
|
225
|
+
Welcome to follow the channel!
|
226
|
+
# How to report a bug or look for help?
|
227
|
+
Write to the author, Prof. WANG Dehong, wdehong2000@163.com
|
@@ -10,7 +10,7 @@ siat/bond_china.py,sha256=WzUhjYYk8tsr3BDWLQcpuj9DqNxTzBSIi_wuAOZ48kY,3082
|
|
10
10
|
siat/bond_zh_sina.py,sha256=26BohGcS120utwqg9dJvdGm5OkuNpNu5bco80uOuQpU,4423
|
11
11
|
siat/capm_beta.py,sha256=t8-xr90II0JzbjsTOZNpRze_mKTvBRXjwN2o0N0tgD8,30521
|
12
12
|
siat/capm_beta2.py,sha256=4g8pOFCwFrEpLx2NJbhL2nl_nrWaOwgbPCHx1G6P_tI,35949
|
13
|
-
siat/common.py,sha256=
|
13
|
+
siat/common.py,sha256=x2NeGGST15qG42oLo2R9r1LyZOPxMIMTnzjLe6z6rdc,188811
|
14
14
|
siat/compare_cross.py,sha256=3iP9TH2h3w27F2ARZc7FjKcErYCzWRc-TPiymOyoVtw,24171
|
15
15
|
siat/copyrights.py,sha256=YMLjZb328YpFMR-s_GUu0HBgeGce3pV7DgRut8S3I7w,690
|
16
16
|
siat/cryptocurrency.py,sha256=QSc4jK9VFlqBWVu-0th1BIMt8wC-5R5sWky3EaNupy0,27940
|
@@ -35,7 +35,7 @@ siat/google_authenticator.py,sha256=ZUbZR8OW0IAKDbcYtlqGqIpZdERpFor9NccFELxg9yI,
|
|
35
35
|
siat/grafix.py,sha256=HSCBSAvoYpP-WcuThvwiQ1--bba9_mtPu4y5X5WBk4A,145099
|
36
36
|
siat/holding_risk.py,sha256=SCHVxRBEhseUrgMpsnvR9Pt6ns-V-voRl3hCuK1p5y4,31114
|
37
37
|
siat/luchy_draw.py,sha256=8Ue-NKnvSVqINPY1eXat0NJat5MR-gex_K62aOYFdmA,20486
|
38
|
-
siat/market_china.py,sha256=
|
38
|
+
siat/market_china.py,sha256=d8bHryhMJti5dqz7-XfuVgbOIoqo5dBg-UWz6-f82UE,51757
|
39
39
|
siat/markowitz.py,sha256=PtQ_6rLyh5SEXyO7SCDyYChcgXl6ddcdgQ06HETjDVE,97990
|
40
40
|
siat/markowitz2.py,sha256=wjmfvsFYXPz3nhnhDi7S9D_V6iCyXniquW2uvxgpe5c,125857
|
41
41
|
siat/markowitz_simple.py,sha256=aJVvx669ngcCsqoQtA9kvFOQVjsuipYt2fyTc4yMItE,14286
|
@@ -50,7 +50,7 @@ siat/risk_evaluation.py,sha256=xfgLSKlIWYmRJrIL4kn2k2hp9fyOMAzYGIhi9ImvKOw,88917
|
|
50
50
|
siat/risk_free_rate.py,sha256=IBuRqA2kppdZsW4D4fapW7vnM5HMEXOn95A5r9Pkwlo,12384
|
51
51
|
siat/sector_china.py,sha256=uLsDXdRBDVfgG6tnXWnQOTyDmyZfglVO9DRUYU2e3pk,157914
|
52
52
|
siat/security_price2.py,sha256=DDiZ2dlv_TYPLhA8-gGb9i9xrl88r4rgSMEcxqQ6aU0,28065
|
53
|
-
siat/security_prices.py,sha256=
|
53
|
+
siat/security_prices.py,sha256=8hDAzq7hmanuUC-sIV9NaedA47OMIbFQoHji19W32Ac,122899
|
54
54
|
siat/security_trend.py,sha256=o0vpWdrJkmODCP94X-Bvn-w7efHhj9HpUYBHtLl55D0,17240
|
55
55
|
siat/security_trend2.py,sha256=HmUk1Va94qSbgo-WQw-n5DuwBVfO8yb1m9B-d9rEGd8,31762
|
56
56
|
siat/stock.py,sha256=s7ny7He7vAIuF8xcWQKjc8VK_9_XuI9P4niobHX-5vw,161339
|
@@ -69,8 +69,8 @@ siat/valuation.py,sha256=xGizcKJZ3ADLWWHm2TFQub18FxiDv2doQwBwbEqyqz0,51980
|
|
69
69
|
siat/valuation_china.py,sha256=eSKIDckyjG8QkENlW_OKkqbQHno8pzDcomBO9iGNJVM,83079
|
70
70
|
siat/var_model_validation.py,sha256=loqziBYO2p0xkeWm3Rb1rJsDhbcgAZ5aR9rBLRwLU5E,17624
|
71
71
|
siat/yf_name.py,sha256=laNKMTZ9hdenGX3IZ7G0a2RLBKEWtUQJFY9CWuk_fp8,24058
|
72
|
-
siat-3.10.
|
73
|
-
siat-3.10.
|
74
|
-
siat-3.10.
|
75
|
-
siat-3.10.
|
76
|
-
siat-3.10.
|
72
|
+
siat-3.10.131.dist-info/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
|
73
|
+
siat-3.10.131.dist-info/METADATA,sha256=dn1zkJ9eec1lfHFwSuzpXGmJEBUfXtFHFB68R7iRnlY,8255
|
74
|
+
siat-3.10.131.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
75
|
+
siat-3.10.131.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
76
|
+
siat-3.10.131.dist-info/RECORD,,
|
File without changes
|