siat 3.7.9__py3-none-any.whl → 3.7.10__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/event_study.py CHANGED
@@ -118,17 +118,20 @@ def event_study(ticker,event_date, \
118
118
  功能:展示事件研究法的累计异常收益率CAR。
119
119
  参数:
120
120
  ticker:证券代码,可为股票、债券、基金、指数、国债收益率等。可为单个或多个。
121
- event_date:事件发生日(注意时区的影响),以此日期为基期0,该日期可能在周末或假日。
121
+ event_date:事件发生日(注意时区的影响),以此日期为基期0,注意该日期可能在周末或假日。
122
122
  注意:允许标注多个事件日,但仅以第一个事件日计算相关日期。
123
123
  start/end:展示事件影响的起止日期,至少需要将事件日、事件窗口和事件后窗口包括在内,主要用于绘图。
124
124
  注意:如果不绘制AR仅绘制CAR,事件窗口前CAR均为空,start日期在绘图中将不起作用。
125
- event_window:事件窗口的起止日期,为相对事件日的相对日期,默认[0,0],即事件当日一天。
126
- 注意:事件窗口不一定包括事件日(适用于事件日在非交易日的情形,例如周末或假日)
125
+ event_window:事件窗口的起止日期,为相对事件日的相对日期
126
+ 默认[0,0],即事件当日一天。注意窗口期不宜过长,因为过长的期间中可能混杂其他事件的影响。
127
+ 注意:事件窗口不一定包括事件日(适用于事件日在非交易日的情形,例如周末或假日,或者在当日闭市后发生)
127
128
  如果事件日为非交易日,事件窗口需要后移至事件日后的第一个交易日。
128
129
  如果怀疑市场提前对事件发生反应,可以考虑前移事件窗口的开始日期。
129
- post_event_days:用于分析事件窗口后的漂移效应,取事件窗口后多少天。默认不分析,取0天。
130
- method:估计事件窗口以及事件后窗口收益率预期值的方法,默认为CAPM(主要用于ticker为股票等)
131
- 如果ticker为股票等,也可以直接使用指数的收益率为其预期收益率,此时method为Market或Index。
130
+ post_event_days:用于分析事件窗口后的漂移效应,取事件窗口后多少天。
131
+ 默认不分析,取0天。可以指定天数,注意是否跨过非交易日情形,过长的窗口期也可能混杂其他事件的影响。
132
+ method:估计事件窗口以及事件后窗口收益率预期值的方法
133
+ 默认为CAPM(主要用于ticker为股票等),即通常所说的市场模型。
134
+ 如果ticker为股票等,也可直接使用指数收益率为其预期收益率,此时method为Market或Index,即常说的市场调整模型。
132
135
  如果ticker为指数,无法再借助指数,method只能使用Random Walk,即使用前一个收益率为预期收益率。
133
136
  注意:不管多个ticker时里面的不同证券类型,仅按第一个ticker的类型判断,并使用同一种证券类型。
134
137
  early_response_days:默认为-2,即提前2天市场就开始有反应。
@@ -138,12 +141,15 @@ def event_study(ticker,event_date, \
138
141
  默认在事件窗口开始日期+提前反应天数前的365个自然日(约250个交易日)。
139
142
  market_index:当method为CAPM时,用于计算市场收益率。默认中国市场采用000300.SS。
140
143
  注意:需要根据不同市场采取不同的市场指数,例如香港市场为恒生指数,美国市场为标普500指数等。
141
- RF:年化无风险收益率,默认使用市场模型"market index",无需指定;可直接指定具体数值;
142
- 也可指定特定指标,例如一年期中国国债收益率"1YCNY.B"或一年期美债收益率"1YUSY.B"等。
144
+ RF:年化无风险收益率
145
+ 默认使用市场模型"market index"自动计算,无需指定。
146
+ 可直接指定具体数值。
147
+ 也可指定特定指标替代,例如一年期中国国债收益率"1YCNY.B"或一年期美债收益率"1YUSY.B"等。
143
148
  show_RF:在使用市场模型或指定指标时是否显示计算出的RF均值,默认为False。
144
149
  ticker_type:显式指明ticker的证券类型,当siat误判其类型(中国内地股票/债券/基金)时使用,默认'auto'。
145
150
  facecolor:显式指定绘图背景颜色,默认"whitesmoke"。
146
- show_AR:是否绘图时绘制异常收益率AR,默认'auto'(单个ticker时绘制,多个时不绘制)。
151
+ show_AR:是否绘图时绘制异常收益率AR
152
+ 默认'auto'(单个ticker时绘制,多个时不绘制)。
147
153
  也可指定True/False强行绘制/不绘制。
148
154
  """
149
155
 
@@ -499,7 +505,8 @@ def event_study(ticker,event_date, \
499
505
 
500
506
  #显著性检验:异于零的t检验,事件窗口
501
507
  df_event_window=df0[(df0.index >=event_window_start) & (df0.index <=event_window_end)]
502
- footnote5="事件窗口CAR(终值,p值):"
508
+ #footnote5="事件窗口CAR(终值,p值):"
509
+ footnote5="事件窗口CAR(均值,中位数,p值):"
503
510
  for c in list(df_event_window):
504
511
  if 'CAR' in c.upper():
505
512
  c_name=c[:-4]
@@ -507,11 +514,24 @@ def event_study(ticker,event_date, \
507
514
  event_window_endpd=pd.to_datetime(event_window_end)
508
515
  #car_value=df_event_window[df_event_window.index == event_window_endpd][c].values[0]
509
516
  car_value=df_event_window[c][-1]
517
+ car_mean=df_event_window[c].mean()
518
+ car_median=df_event_window[c].median()
519
+
510
520
  if car_value > 0:
511
521
  car_value_str=str(round(car_value,4))[:6]
512
522
  else:
513
523
  car_value_str=str(round(car_value,4))[:7]
514
524
 
525
+ if car_mean > 0:
526
+ car_mean_str=str(round(car_mean,4))[:6]
527
+ else:
528
+ car_mean_str=str(round(car_mean,4))[:7]
529
+
530
+ if car_median > 0:
531
+ car_median_str=str(round(car_median,4))[:6]
532
+ else:
533
+ car_median_str=str(round(car_median,4))[:7]
534
+
515
535
  if len(df_event_window[c])==1:
516
536
  if abs(df_event_window[c].values[0]) > 0.01:
517
537
  p_value=0.0
@@ -524,18 +544,19 @@ def event_study(ticker,event_date, \
524
544
  else:
525
545
  p_value_str=str(round(p_value,4))[:7]
526
546
  #footnote5=footnote5+c_name+p_value_str+","
527
- footnote5=footnote5+"{0}({1}, {2}), ".format(c_name,car_value_str,p_value_str)
547
+ #footnote5=footnote5+"{0}({1}, {2}), ".format(c_name,car_value_str,p_value_str)
548
+ footnote5=footnote5+"{0}({1}, {2}, {3}), ".format(c_name,car_mean_str,car_median_str,p_value_str)
528
549
  footnote5=footnote5.strip(", ")
529
550
 
530
551
  #显著性检验:异于零的t检验,事件后窗口
531
552
  df_post_event_window=df0[(df0.index >event_window_end) & (df0.index <=post_event_end)]
532
553
  if len(df_post_event_window) == 0:
533
554
  footnote6=''
534
-
535
555
  elif len(df_post_event_window) == 0:
536
556
  footnote6=''
537
557
  else:
538
- footnote6="事件后窗口CAR(终值,p值):"
558
+ #footnote6="事件后窗口CAR(终值,p值):"
559
+ footnote6="事件后窗口CAR(均值,中位数,p值):"
539
560
  for c in list(df_post_event_window):
540
561
  if 'CAR' in c.upper():
541
562
  c_name=c[:-4]
@@ -544,11 +565,24 @@ def event_study(ticker,event_date, \
544
565
  print(" DEBUG: c={0},post_event_end={1},df_post_event_window={2}".format(c,post_event_end,df_post_event_window))
545
566
  #car_value=df_post_event_window[df_post_event_window.index == post_event_endpd][c].values[0]
546
567
  car_value=df_post_event_window[c][-1]
568
+ car_mean=df_post_event_window[c].mean()
569
+ car_median=df_post_event_window[c].median()
570
+
547
571
  if car_value > 0:
548
572
  car_value_str=str(round(car_value,4))[:6]
549
573
  else:
550
574
  car_value_str=str(round(car_value,4))[:7]
551
575
 
576
+ if car_mean > 0:
577
+ car_mean_str=str(round(car_mean,4))[:6]
578
+ else:
579
+ car_mean_str=str(round(car_mean,4))[:7]
580
+
581
+ if car_median > 0:
582
+ car_median_str=str(round(car_median,4))[:6]
583
+ else:
584
+ car_median_str=str(round(car_median,4))[:7]
585
+
552
586
  if len(df_post_event_window[c])==1:
553
587
  if abs(df_post_event_window[c].values[0]) > 0.01:
554
588
  p_value=0.0
@@ -562,7 +596,7 @@ def event_study(ticker,event_date, \
562
596
  p_value_str=str(round(p_value,4))[:7]
563
597
 
564
598
  #footnote6=footnote6+c[:-4]+str(p_value)[:6]+","
565
- footnote6=footnote6+"{0}({1}, {2}), ".format(c_name,car_value_str,p_value_str)
599
+ footnote6=footnote6+"{0}({1}, {2}, {3}), ".format(c_name,car_mean_str,car_median_str,p_value_str)
566
600
  footnote6=footnote6.strip(", ")
567
601
 
568
602
  footnote7="数据来源:Sina/EM/Yahoo/Stooq/SWHY,"+stoday
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siat
3
- Version: 3.7.9
3
+ Version: 3.7.10
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
@@ -32,7 +32,7 @@ siat/economy.py,sha256=ijMAVA5ydghbQDgNDDdz8fz9NPd2eq90RzpJSRGWz5c,78638
32
32
  siat/economy_test.py,sha256=6vjNlPz7W125pJb7simCddobSEp3jmLIMvVkLRZ7zW8,13339
33
33
  siat/esg.py,sha256=GMhaonIKtvOK83rhpQUH5aJt2OL3HQBSVfD__Yw-0oo,19040
34
34
  siat/esg_test.py,sha256=Z9m6GUt8O7oHZSEG9aDYpGdvvrv2AiRJdHTiU6jqmZ0,2944
35
- siat/event_study.py,sha256=Q_AdnJzxxL6udCjn5LP6rdhOngsDRWPu5udFkK1CJZw,32223
35
+ siat/event_study.py,sha256=aDq-mrwHw3qw0fDJbAWovz1kppwE6BSeuwoMfWdSYQY,33892
36
36
  siat/exchange_bond_china.pickle,sha256=zDqdPrFacQ0nqjP_SuF6Yy87EgijIRsFvFroW7FAYYY,1265092
37
37
  siat/fama_french.py,sha256=aUTC-67t_CEPbLk4u79woW_zfZ7OCP6Fo4z5EdWCSkQ,48051
38
38
  siat/fama_french_test.py,sha256=M4O23lBKsJxhWHRluwCb3l7HSEn3OFTjzGMpehcevRg,4678
@@ -142,8 +142,8 @@ siat/valuation_china.py,sha256=CVp1IwIsF3Om0J29RGkyxZLt4n9Ug-ua_RKhLwL9fUQ,69624
142
142
  siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
143
143
  siat/var_model_validation.py,sha256=R0caWnuZarrRg9939hxh3vJIIpIyPfvelYmzFNZtPbo,14910
144
144
  siat/yf_name.py,sha256=r0Q67cSMMlfebEkI9h9pdGlJCooEq7hw_3M5IUs4cSI,20081
145
- siat-3.7.9.dist-info/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
146
- siat-3.7.9.dist-info/METADATA,sha256=pyvIy9bezvnV0iI6yULlndis1yvpId_7ufTIqlsYF_A,8063
147
- siat-3.7.9.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
148
- siat-3.7.9.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
149
- siat-3.7.9.dist-info/RECORD,,
145
+ siat-3.7.10.dist-info/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
146
+ siat-3.7.10.dist-info/METADATA,sha256=nY3QaZF7WEgmuQ6z6eucsLYyrHlhX-BiCYsY97jrMEQ,8064
147
+ siat-3.7.10.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
148
+ siat-3.7.10.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
149
+ siat-3.7.10.dist-info/RECORD,,
File without changes
File without changes