siat 2.14.1__py3-none-any.whl → 2.14.2__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
@@ -720,19 +720,20 @@ def save_to_excel(df,filedir,excelfile,sheetname="Sheet1"):
720
720
  注意:如果df中含有以文本表示的数字,写入到Excel会被自动转换为数字类型保存。
721
721
  从Excel中读出后为数字类型,因此将会与df的类型不一致
722
722
  """
723
+ DEBUG=True
723
724
 
724
725
  #检查目录是否存在
725
726
  import os
726
727
  try:
727
728
  os.chdir(filedir)
728
729
  except:
729
- print("Error #1(save_to_excel): folder does not exist")
730
- print("Information:",filedir)
730
+ print(" #Error(save_to_excel): folder does not exist",filedir)
731
731
  return
732
732
 
733
733
  #取得df字段列表
734
734
  dflist=df.columns
735
735
  #合成完整的带目录的文件名
736
+ #filename=filedir+'\\'+excelfile
736
737
  filename=filedir+'/'+excelfile
737
738
 
738
739
  import pandas as pd
@@ -740,9 +741,9 @@ def save_to_excel(df,filedir,excelfile,sheetname="Sheet1"):
740
741
  file1=pd.ExcelFile(excelfile)
741
742
  except:
742
743
  #不存在excelfile文件,直接写入
743
- df.to_excel(filename,sheet_name=sheetname, \
744
- header=True,encoding='utf-8')
745
- print("***Results saved in",filename,"@ sheet",sheetname)
744
+ #df.to_excel(filename,sheet_name=sheetname,header=True,encoding='utf-8')
745
+ df.to_excel(filename,sheet_name=sheetname,header=True)
746
+ print(" Successfully saved in",filename,"@ sheet",sheetname)
746
747
  return
747
748
  else:
748
749
  #已存在excelfile文件,先将所有sheet的内容读出到dict中
@@ -770,18 +771,25 @@ def save_to_excel(df,filedir,excelfile,sheetname="Sheet1"):
770
771
  result=pd.ExcelWriter(filename)
771
772
  for s in sheetlist:
772
773
  df1=dict[s][dflist]
773
- df1.to_excel(result,s,header=True,index=True,encoding='utf-8')
774
+ #df1.to_excel(result,s,header=True,index=True,encoding='utf-8')
775
+ df1.to_excel(result,s,header=True,index=True)
774
776
  #写入新内容
775
777
  if not dup: #sheetname未重复
776
- df.to_excel(result,sheetname,header=True,index=True,encoding='utf-8')
777
- try:
778
- result.save()
779
- result.close()
780
- except:
781
- print("Error #2(save_to_excel): writing file permission denied")
782
- print("Information:",filename)
783
- return
784
- print("***Results saved in",filename,"@ sheet",sheetname)
778
+ #df.to_excel(result,sheetname,header=True,index=True,encoding='utf-8')
779
+ df.to_excel(result,sheetname,header=True,index=True)
780
+ if DEBUG:
781
+ #result.save()
782
+ result.close()
783
+ else:
784
+ try:
785
+ #result.save()
786
+ result.close()
787
+ except:
788
+ print(" #Error(save_to_excel): writing file failed for",filename)
789
+ print(" Solution: change file name and try again")
790
+ return
791
+
792
+ print(" Successfully saved in",filename,"@ sheet",sheetname)
785
793
  return
786
794
  #==============================================================================
787
795
  def set_df_period(df,df_min,df_max):
@@ -2993,7 +3001,7 @@ def df_preprocess(dfs,measure,axhline_label,x_label,y_label,lang='Chinese', \
2993
3001
  elif scaling_option == 'change%':
2994
3002
  std_notes="注释:为突出变化趋势,图中数值为相对期间起点的增减百分比"
2995
3003
  #measure_suffix='(增/减%)'
2996
- measure_suffix='(涨/跌%)'
3004
+ measure_suffix='(涨跌幅度%)'
2997
3005
  axhline_label='零线' #可以在security_trend中使用critical_value选项指定水平线位置,默认0
2998
3006
  #axhline_value=0
2999
3007
 
siat/grafix.py CHANGED
@@ -93,7 +93,7 @@ def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
93
93
  power=0,zeroline=False,average_value=False, \
94
94
  resample_freq='H',loc='best', \
95
95
  date_range=False,date_freq=False,date_fmt='%Y-%m-%d', \
96
- mark_top=0,mark_bottom=0,mark_end=True):
96
+ mark_top=1,mark_bottom=1,mark_end=True):
97
97
  """
98
98
  功能:绘制折线图。如果power=0不绘制趋势图,否则绘制多项式趋势图
99
99
  假定:数据表有索引,且已经按照索引排序
@@ -210,7 +210,9 @@ def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
210
210
  av=df[colname].mean()
211
211
  plt.axhline(y=av,ls="dashed",c="blueviolet",linewidth=2,label="均值")
212
212
  haveLegend=True
213
- footnote=footnote + ",均值"+str(round(av,2))
213
+ av=str(round(av,2)) if av < 100 else str(int(av))
214
+ #footnote=footnote + ",均值"+av
215
+ footnote="注:期间均值"+av+";"+footnote
214
216
 
215
217
  #绘制趋势线
216
218
  #print("--Debug(plot_line): power=",power)
siat/security_trend2.py CHANGED
@@ -349,7 +349,7 @@ def security_trend(ticker,indicator='Close', \
349
349
  average_value=average_value, \
350
350
  datatag=datatag,power=power,graph=graph, \
351
351
  source=source,
352
- mark_top=mark_top,mark_bottom=mark_bottom)
352
+ mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end)
353
353
  return df
354
354
 
355
355
  # 情形2:单个证券,两个普通指标,twinx==True =================================
@@ -367,7 +367,7 @@ def security_trend(ticker,indicator='Close', \
367
367
  date_range=date_range,date_freq=date_freq, \
368
368
  annotate=annotate,annotate_value=annotate_value, \
369
369
  source=source,
370
- mark_top=mark_top,mark_bottom=mark_bottom)
370
+ mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end)
371
371
  return df
372
372
 
373
373
  # 情形4:两个证券,取第一个普通指标,twinx==True =============================
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siat
3
- Version: 2.14.1
3
+ Version: 2.14.2
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
@@ -17,7 +17,7 @@ siat/capm_beta.py,sha256=cqbmfM4mrq73Ub0bq5QjWJjmJHj9x7-dSqbmNxnEj7k,28946
17
17
  siat/capm_beta2.py,sha256=tC2fhColziTeWzhzQNPff6LoGCsK6A5fw_NOEIKnNqo,22197
18
18
  siat/capm_beta_test.py,sha256=ImR0c5mc4hIl714XmHztdl7qg8v1E2lycKyiqnFj6qs,1745
19
19
  siat/cmat_commons.py,sha256=Nj9Kf0alywaztVoMVeVVL_EZk5jRERJy8R8kBw88_Tg,38116
20
- siat/common.py,sha256=uCzH0d5Z7ZOkYrGek8xtp06bZa1_EPy8dwUUYEH31JE,121770
20
+ siat/common.py,sha256=V0iYl9UrxSyuEtbvggGuJ_9HUeb8RjhvWpThk-AJQ9c,122131
21
21
  siat/compare_cross.py,sha256=-MZzxmX8_9oFZ7X0IcR51w87EWwssbitiw-BcmHMFzQ,26228
22
22
  siat/compare_cross_test.py,sha256=xra5XYmQGEtfIZL2h-GssdH2hLdFIhG3eoCrkDrL3gY,3473
23
23
  siat/concepts_iwencai.py,sha256=m1YEDtECRT6FqtzlKm91pt2I9d3Z_XoP59BtWdRdu8I,3061
@@ -59,7 +59,7 @@ siat/future_china.py,sha256=F-HsIf2Op8Z22RzTjet1g8COzldgnMjFNSXsAkeGyWo,17595
59
59
  siat/future_china_test.py,sha256=BrSzmDVaOHki6rntOtosmRn-6dkfOBuLulJNqh7MOpc,1163
60
60
  siat/global_index_test.py,sha256=hnFp3wqqzzL-kAP8mgxDZ54Bd5Ijf6ENi5YJlGBgcXw,2402
61
61
  siat/google_authenticator.py,sha256=ZUbZR8OW0IAKDbcYtlqGqIpZdERpFor9NccFELxg9yI,1637
62
- siat/grafix.py,sha256=bTVBUEHR8LokYVIRUIK8Q_QzxE8Nmeqi0og9F4UOnKY,76609
62
+ siat/grafix.py,sha256=jndxeDXgJjrBVSDDdTMjpNfCZcS1KFJUwVG0Z9ibev0,76712
63
63
  siat/grafix_test.py,sha256=kXvcpLgQNO7wd30g_bWljLj5UH7bIVI0_dUtXbfiKR0,3150
64
64
  siat/holding_risk.py,sha256=Dh4zXEw-0hnbMNorbsRS142C8mUzq4NhFjYnauWu5tc,30548
65
65
  siat/holding_risk_test.py,sha256=FRlw_9wFG98BYcg_cSj95HX5WZ1TvkGaOUdXD7-V86s,474
@@ -96,7 +96,7 @@ siat/security_price.py,sha256=2oHskgiw41KMGfqtnA0i2YjNNV6cYgtlUK0j3YeuXWs,29185
96
96
  siat/security_prices.py,sha256=ES7EVWEdPdSMTEeJSk5WFTux1O_HN0ybcluSW9qmYK0,80420
97
97
  siat/security_prices_test.py,sha256=OEphoJ87NPKoNow1QA8EU_5MUYrJF-qKoWKNapVfZNI,10779
98
98
  siat/security_trend.py,sha256=BNZm0Yujs3V6tlOirtcKqsKAegy36shWXGen_c4KwBo,17204
99
- siat/security_trend2.py,sha256=B9m1C845WDotQUclxIU_QdzYWYTC0tJAvD0HUMVRCCY,24761
99
+ siat/security_trend2.py,sha256=gbdrvzrp5UglSNdqw8y9IVhkFk0QU4tKzUTFSueMpPo,24797
100
100
  siat/setup.py,sha256=up65rQGLmTBkhtaMLowjoQXYmIsnycnm4g1SYmeQS6o,1335
101
101
  siat/shenwan index history test.py,sha256=JCVAzOSEldHalhSFa3pqD8JI_8_djPMQOxpkuYU-Esg,1418
102
102
  siat/stock.py,sha256=Sg3Qsv8uCm3uIK2UurR5Chf1Sq8i3PZ3UsEQsaeANaE,142556
@@ -130,7 +130,7 @@ siat/valuation.py,sha256=x-3qpu_14SLAPuO2gwmT9ojPYIEZCX8KcnIbezDiFKI,47362
130
130
  siat/valuation_china.py,sha256=oEQRrktJNHiOG1mJSQN1aSSQAQrwrg-ppIHyNVjMjNg,67603
131
131
  siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
132
132
  siat/var_model_validation.py,sha256=zB_Skk_tmzIR15l6oAW3am4HBGVIG-eZ8gJhCdXZ8Qw,14859
133
- siat-2.14.1.dist-info/METADATA,sha256=o1TYSfa1kGqGd6eDO7V6A-030-2BYrCmcoez7sDK2zI,1448
134
- siat-2.14.1.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
135
- siat-2.14.1.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
136
- siat-2.14.1.dist-info/RECORD,,
133
+ siat-2.14.2.dist-info/METADATA,sha256=NWrDiu1w4EuA_bqczpwbwBODqR8vhYa0wnz3FcG8Npc,1448
134
+ siat-2.14.2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
135
+ siat-2.14.2.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
136
+ siat-2.14.2.dist-info/RECORD,,
File without changes