siat 3.10.25__py3-none-any.whl → 3.10.125__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/option_pricing.py CHANGED
@@ -77,7 +77,9 @@ def bs_call(S0,X,Days,r0,sigma,printout=True):
77
77
  r0:年化无风险利率(需要转化为连续计算的无风险利率)
78
78
  Days:距离到期日的天数,需要转换为距离到期日的年数=距离到期日的天数/365
79
79
  """
80
- from scipy import log,exp,sqrt,stats
80
+ from scipy import stats
81
+ from numpy import log,exp,sqrt
82
+
81
83
  #Days为距离到期日的日历日天数
82
84
  T=Days/365.
83
85
  r=log(r0+1)
@@ -119,7 +121,7 @@ def bsm_call(S0,X,Days,r0,sigma,Days1=0,div1=0,printout=True):
119
121
  Days1:红利发放时距离到期日的天数,需要转换为年数
120
122
  div1:红利金额
121
123
  """
122
- from scipy import log,exp
124
+ from numpy import log,exp
123
125
  #Days1为距离到期日的日历日天数
124
126
  T=Days/365.
125
127
  T1=Days1/365.
@@ -164,7 +166,9 @@ def bs_put(S0,X,Days,r0,sigma,printout=True):
164
166
  r0:年化无风险利率(需要转化为连续计算的无风险利率)
165
167
  Days:距离到期日的天数,需要转换为距离到期日的年数=距离到期日的天数/365
166
168
  """
167
- from scipy import log,exp,sqrt,stats
169
+ from scipy import stats
170
+ from numpy import log,exp,sqrt
171
+
168
172
  #Days为距离到期日的日历日天数
169
173
  T=Days/365.
170
174
  r=log(r0+1)
@@ -206,7 +210,8 @@ def bsm_put(S0,X,Days,r0,sigma,Days1=0,div1=0,printout=True):
206
210
  Days1:红利发放时距离到期日的天数,需要转换为年数
207
211
  div1:红利金额
208
212
  """
209
- from scipy import log,exp,sqrt
213
+ from numpy import log,exp,sqrt
214
+
210
215
  #Days为距离到期日的日历日天数
211
216
  T=Days/365.
212
217
  T1=Days1/365.
@@ -1058,7 +1063,8 @@ def binomial_american_call(S0,X,Days,r0,sigma,q0=0,steps=200,printout=True):
1058
1063
  q0:年化红利收益率,由于美式期权可能提前行权,故不考虑发放日期
1059
1064
  steps:二叉树的步骤
1060
1065
  """
1061
- from scipy import log,exp
1066
+ from numpy import log,exp
1067
+
1062
1068
  #Days1为距离到期日的日历日天数
1063
1069
  t=Days/365.
1064
1070
  r=log(r0+1)
@@ -1113,7 +1119,8 @@ def binomial_american_put(S0,X,Days,r0,sigma,q0=0,steps=200,printout=True):
1113
1119
  q0:年化红利收益率,由于美式期权可能提前行权,故不考虑发放日期
1114
1120
  steps:二叉树的步骤
1115
1121
  """
1116
- from scipy import log,exp
1122
+ from numpy import log,exp
1123
+
1117
1124
  #Days1为距离到期日的日历日天数
1118
1125
  t=Days/365.
1119
1126
  r=log(r0+1)
@@ -1166,6 +1173,7 @@ if __name__=='__main__':
1166
1173
  def option_maturity(ticker,printout=True):
1167
1174
  """
1168
1175
  功能:获得期权的各个到期日期
1176
+ 注意:目前yfinance无法使用,股票期权链功能暂时不可用,可尝试yahooquery?
1169
1177
  """
1170
1178
  """
1171
1179
  if not test_yahoo_access():
@@ -1173,6 +1181,8 @@ def option_maturity(ticker,printout=True):
1173
1181
  return None
1174
1182
  """
1175
1183
  import yfinance as yf
1184
+ # yf.__version__
1185
+
1176
1186
  opt = yf.Ticker(ticker)
1177
1187
 
1178
1188
  #获得期权的各个到期日
siat/other_indexes.py CHANGED
@@ -36,7 +36,7 @@ def other_index_translate(index_code):
36
36
  trans_dict=pd.DataFrame([
37
37
 
38
38
  ['INDEXCF','俄罗斯MICEX指数','俄罗斯MICEX指数','MICEX Index','sina'],
39
- ['RTS','俄罗斯RTS指数','俄罗斯RTS指数','RTS Index','sina'],
39
+ ['RTS','俄罗斯RTS指数','俄罗斯RTS指数','RTS Index','em'],
40
40
  ['CASE','埃及CASE 30指数','埃及CASE30指数','CASE30 Index','sina'],
41
41
  ['VNINDEX','越南胡志明','越南胡志明指数','Ho Chi-Ming Index','em'],
42
42
  ['HSCEI','国企指数','港股国企指数','HK H-share Index','em'],
@@ -99,7 +99,11 @@ def get_other_index_em(index_code,start,end):
99
99
  return None
100
100
 
101
101
  import akshare as ak
102
- dft = ak.index_global_hist_em(symbol=symbol)
102
+ try:
103
+ dft = ak.index_global_hist_em(symbol=symbol)
104
+ except:
105
+ return None
106
+
103
107
  dft.rename(columns={'日期':'Date','代码':'ticker','名称':'Name','今开':'Open', \
104
108
  '最新价':'Close','最高':'High','最低':'Low','振幅':'Change'}, \
105
109
  inplace=True)
@@ -123,6 +127,11 @@ if __name__=='__main__':
123
127
  start='2025-2-1'; end='2025-3-31'
124
128
  get_other_index_em(index_code,start,end)
125
129
  #==============================================================================
130
+ if __name__=='__main__':
131
+ index_code='RTS'
132
+ start='2025-2-1'; end='2025-3-31'
133
+ get_other_index_em(index_code,start,end)
134
+
126
135
  def get_other_index_sina(index_code,start,end):
127
136
  """
128
137
  功能:获取另类指数历史行情,新浪财经
@@ -135,7 +144,11 @@ def get_other_index_sina(index_code,start,end):
135
144
  return None
136
145
 
137
146
  import akshare as ak
138
- dft = ak.index_global_hist_sina(symbol=symbol)
147
+ try:
148
+ dft = ak.index_global_hist_sina(symbol=symbol)
149
+ except:
150
+ return None
151
+
139
152
  dft.rename(columns={'open':'Open','high':'High','low':'Low','close':'Close', \
140
153
  'volume':'Volume'},inplace=True)
141
154
  dft['ticker']=index_code; dft['Name']=name; dft['Date']=dft['date']