siat 3.7.23__py3-none-any.whl → 3.7.24__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 CHANGED
@@ -4848,12 +4848,104 @@ async def jupyter2pdf(notebook_path, output_pdf_path, size="A3"):
4848
4848
  elif os.path.exists(html_file):
4849
4849
  os.remove(html_file)
4850
4850
 
4851
+ return
4852
+
4851
4853
  if __name__ == '__main__':
4852
4854
  # 定义 Notebook 路径和输出 PDF 路径
4853
4855
  notebook_path = r"S:\SIA\机工社版本\脚本测试\证券投资分析-第一章案例Python脚本-检测2.ipynb" # 替换为你的 Notebook 文件路径
4854
4856
  output_pdf_path = "E:/output_notebook.pdf" # 替换为你想保存的 PDF 文件路径
4855
- #await convert_notebook_to_pdf(notebook_path, output_pdf_path)
4857
+ #await jupyter2pdf(notebook_path, output_pdf_path)
4858
+ # 注意:上面的await命令会导致编译失败,测试后要注释掉
4859
+
4860
+ #==============================================================================
4861
+ async def jupyter2pdf2(notebook_dir, notebook_file):
4862
+ """
4863
+ 将 Jupyter Notebook 转换为 PDF 文件
4864
+ 参数:
4865
+ notebook_dir (str): Jupyter Notebook文件所在的目录,不含文件名
4866
+ notebook_file (str): Jupyter Notebook文件名
4867
+ 输出:
4868
+ 同时生成A4和A3两种幅面的pdf文件,由使用者自行挑选一个效果最好的。
4869
+ 返回:
4870
+ None
4871
+ 注意1:pip install playwright之后可能还要执行playwright install
4872
+ 注意2:调用本函数的格式是异步await开头
4873
+ await convert_notebook_to_pdf(notebook_path, output_pdf_path)
4874
+ 注意3:notebook_path和output_pdf_path中可以带路径
4875
+ """
4876
+
4877
+ # 路径分割符号
4878
+ if ('/' in notebook_dir) and not ('\\' in notebook_dir):
4879
+ sep='/'
4880
+ else:
4881
+ sep='\\'
4882
+
4883
+ # ipynb文件的完整路径
4884
+ if ('.ipynb' in notebook_file):
4885
+ notebook_file1=notebook_file.replace('.ipynb','')
4886
+ else:
4887
+ notebook_file1=notebook_file
4888
+ notebook_path=notebook_dir+sep+notebook_file1+'.ipynb'
4889
+
4890
+ # pdf文件的完整路径
4891
+ output_pdf_path1=notebook_dir+sep+notebook_file1+'A4.pdf'
4892
+ output_pdf_path2=notebook_dir+sep+notebook_file1+'A3.pdf'
4893
+
4894
+ import os
4895
+ from nbconvert import HTMLExporter
4896
+ from playwright.async_api import async_playwright
4897
+
4898
+ html_file = ""
4899
+
4900
+ try:
4901
+ # 导出 Notebook 为 HTML
4902
+ html_exporter = HTMLExporter()
4903
+ try:
4904
+ html_content, _ = html_exporter.from_filename(notebook_path)
4905
+ print("Converting notebook file to pdf in both A4 and A3 sizes ...")
4856
4906
 
4907
+ except:
4908
+ print("File not found for {}".format(notebook_path))
4909
+ return
4910
+
4911
+ # 创建临时 HTML 文件
4912
+ html_file = "temp_notebook.html"
4913
+ with open(html_file, "w", encoding="utf-8") as f:
4914
+ f.write(html_content)
4915
+
4916
+ # 使用 Playwright 打开 HTML 并保存为 PDF
4917
+ async with async_playwright() as p:
4918
+ browser = await p.chromium.launch()
4919
+ page = await browser.new_page()
4920
+ await page.goto(f"file://{os.path.abspath(html_file)}")
4921
+
4922
+ await page.pdf(path=output_pdf_path1, format='A4')
4923
+ await page.pdf(path=output_pdf_path2, format='A3')
4924
+
4925
+ await browser.close()
4926
+
4927
+ print(f"2 PDF created in the same directory, pick 1 you think best")
4928
+
4929
+ except Exception as e:
4930
+ print(f"Conversion failed because {e}")
4931
+ return
4932
+
4933
+ finally:
4934
+ if html_file == "":
4935
+ return
4936
+ # 删除临时 HTML 文件
4937
+ elif os.path.exists(html_file):
4938
+ os.remove(html_file)
4939
+
4940
+ return
4941
+
4942
+ if __name__ == '__main__':
4943
+ # 替换为你的Notebook文件路径
4944
+ notebook_dir = r"S:\北外工作-25春\周4.财经与生活附校\Session 1"
4945
+ # 替换为你想转存PDF的Notebook文件名
4946
+ notebook_file = "Session 1 全球证券市场-简化版.ipynb"
4947
+ #await jupyter2pdf2(notebook_dir, notebook_file)
4948
+ # 注意:上面的await命令会导致编译失败,测试后要注释掉
4857
4949
  #==============================================================================
4858
4950
  #==============================================================================
4859
4951
  #==============================================================================
siat/security_trend2.py CHANGED
@@ -185,6 +185,10 @@ def security_trend(ticker,indicator='Close',adjust='', \
185
185
  attention_value参数:绘图时绘制一条水平线,用以强调一个阈值。默认不绘制。
186
186
  average_value参数:开关打开时,绘图时绘制一条均值线,仅适用于绘制单条曲线。默认关闭。
187
187
 
188
+ attention_point:绘制横轴竖线,可为单个横轴点或列表,默认不绘制
189
+ attention_point_area:为两个横轴点的列表,其间区域着色,默认不绘制。
190
+ 可与attention_point配合使用。
191
+
188
192
  kline参数:开关打开时,绘制一条K线图,仅适用于单只股票。默认关闭。
189
193
  kline_demo参数:与kline开关同时打开时,绘制一条K线图原理演示图,仅适用于单只股票。
190
194
  mav参数:仅当kline开关打开时有效,用于指定K线图中单条或多条移动平均线的天数。
siat/yf_name.py CHANGED
@@ -657,6 +657,8 @@ def stooq_name1(stock_code,add_suffix=True):
657
657
  if sid not in ['CN','US']:
658
658
  t_name=t_name+'('+sid+')'
659
659
 
660
+ t_name=t_name.strip()
661
+
660
662
  return t_name
661
663
 
662
664
  #==============================================================================
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siat
3
- Version: 3.7.23
3
+ Version: 3.7.24
4
4
  Summary: Securities Investment Analysis Tools (siat)
5
5
  Home-page: https://pypi.org/project/siat/
6
6
  Author: Prof. WANG Dehong, International Business School, Beijing Foreign Studies University
@@ -19,7 +19,7 @@ siat/capm_beta.py,sha256=cxXdRVBQBllhbfz1LeTJAIWvyRYhW54nhtNUXv4HwS0,29063
19
19
  siat/capm_beta2.py,sha256=-ZYYp1HK7SkfTR3vBKZ0QVC4Q_tbST2O4MGbX_V77J0,32031
20
20
  siat/capm_beta_test.py,sha256=ImR0c5mc4hIl714XmHztdl7qg8v1E2lycKyiqnFj6qs,1745
21
21
  siat/cmat_commons.py,sha256=Nj9Kf0alywaztVoMVeVVL_EZk5jRERJy8R8kBw88_Tg,38116
22
- siat/common.py,sha256=u5Q24UXX6jstkemvo-owK5v3akNNHyrRuwXjjQwJsjk,175935
22
+ siat/common.py,sha256=JZyGEXHevW6NovmfvrMCR5fwVovO8d_wRb7MLHFiBvM,179306
23
23
  siat/compare_cross.py,sha256=3iP9TH2h3w27F2ARZc7FjKcErYCzWRc-TPiymOyoVtw,24171
24
24
  siat/compare_cross_test.py,sha256=xra5XYmQGEtfIZL2h-GssdH2hLdFIhG3eoCrkDrL3gY,3473
25
25
  siat/concepts_iwencai.py,sha256=m1YEDtECRT6FqtzlKm91pt2I9d3Z_XoP59BtWdRdu8I,3061
@@ -105,7 +105,7 @@ siat/security_prices.py,sha256=HoCZ7YPrQYZHgKC-LyXFeeBCTfRc3EMMEiEg52SVv2w,10907
105
105
  siat/security_prices_test.py,sha256=OEphoJ87NPKoNow1QA8EU_5MUYrJF-qKoWKNapVfZNI,10779
106
106
  siat/security_trend.py,sha256=o0vpWdrJkmODCP94X-Bvn-w7efHhj9HpUYBHtLl55D0,17240
107
107
  siat/security_trend2-20240620.py,sha256=QVnEcb7AyVbO77jVqfFsJffGXrX8pgJ9xCfoAKmWBPk,24854
108
- siat/security_trend2.py,sha256=mamJtFAbXC1orGgMEmp0taPk-yUqWm-jdGf64bjhn2Q,29756
108
+ siat/security_trend2.py,sha256=TmfPG5RqT2nzJpYwBYCFrD-NC82uaz8MxbAMmGVdJzY,29995
109
109
  siat/setup.py,sha256=up65rQGLmTBkhtaMLowjoQXYmIsnycnm4g1SYmeQS6o,1335
110
110
  siat/shenwan index history test.py,sha256=JCVAzOSEldHalhSFa3pqD8JI_8_djPMQOxpkuYU-Esg,1418
111
111
  siat/stock.py,sha256=JT_sq-9B8A25fzTh7rSj5-NnO2IlGbI_7O47ZZu9Dk0,159068
@@ -142,9 +142,9 @@ siat/valuation.py,sha256=tSW5jyda3lChqBkdsbBGfdUeh9bCfjo6P93CjLif9eM,50825
142
142
  siat/valuation_china.py,sha256=CVp1IwIsF3Om0J29RGkyxZLt4n9Ug-ua_RKhLwL9fUQ,69624
143
143
  siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
144
144
  siat/var_model_validation.py,sha256=R0caWnuZarrRg9939hxh3vJIIpIyPfvelYmzFNZtPbo,14910
145
- siat/yf_name.py,sha256=_WhJmon5KbTw3yR54bfTkiAhkP6GenuCcQ2Vmx5El2I,24025
146
- siat-3.7.23.dist-info/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
147
- siat-3.7.23.dist-info/METADATA,sha256=wdVz2LprfX0smE-JCetYAgGRH0pV0XnavkRyUK02uz4,8117
148
- siat-3.7.23.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
149
- siat-3.7.23.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
150
- siat-3.7.23.dist-info/RECORD,,
145
+ siat/yf_name.py,sha256=laNKMTZ9hdenGX3IZ7G0a2RLBKEWtUQJFY9CWuk_fp8,24058
146
+ siat-3.7.24.dist-info/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
147
+ siat-3.7.24.dist-info/METADATA,sha256=hBqKjbbQcLQQWREZYGZNHB5Ge5n1A-wdUI178kn2z6E,8117
148
+ siat-3.7.24.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
149
+ siat-3.7.24.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
150
+ siat-3.7.24.dist-info/RECORD,,
File without changes
File without changes