siat 3.4.7__py3-none-any.whl → 3.4.9__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 +2 -0
- siat/grafix.py +2 -1
- siat/market_china.py +1 -5
- siat/option_china.py +258 -57
- siat/option_pricing.py +125 -56
- siat/sector_china.py +109 -2
- siat/security_prices.py +10 -7
- siat/translate.py +2 -0
- {siat-3.4.7.dist-info → siat-3.4.9.dist-info}/METADATA +1 -1
- {siat-3.4.7.dist-info → siat-3.4.9.dist-info}/RECORD +12 -12
- {siat-3.4.7.dist-info → siat-3.4.9.dist-info}/WHEEL +0 -0
- {siat-3.4.7.dist-info → siat-3.4.9.dist-info}/top_level.txt +0 -0
siat/common.py
CHANGED
siat/grafix.py
CHANGED
@@ -370,8 +370,9 @@ def plot2_line2(df1,ticker1,colname1,label1, \
|
|
370
370
|
date_range=False,date_freq=False,date_fmt='%Y-%m-%d', \
|
371
371
|
color1='red',color2='blue',facecolor='whitesmoke'):
|
372
372
|
"""
|
373
|
-
|
373
|
+
注意:可能有bug,twinx=True时左纵坐标轴和横坐标轴标记可能发生重叠!!!暂不建议使用
|
374
374
|
facecolor不起作用
|
375
|
+
目前的解决方案:改用函数plot_line2
|
375
376
|
|
376
377
|
功能:绘制两个证券的折线图。如果power=0不绘制趋势图,否则绘制多项式趋势图
|
377
378
|
假定:数据表有索引,且已经按照索引排序
|
siat/market_china.py
CHANGED
@@ -268,10 +268,6 @@ def market_profile_china(market='SSE'):
|
|
268
268
|
|
269
269
|
|
270
270
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
271
|
def market_profile_china_tmp(market='SSE'):
|
276
272
|
"""
|
277
273
|
功能:沪深市场概况,废弃!
|
@@ -921,7 +917,7 @@ if __name__=='__main__':
|
|
921
917
|
def market_detail_china2(category='price',
|
922
918
|
facecolor='papayawhip',
|
923
919
|
decimals=2,
|
924
|
-
font_size='
|
920
|
+
font_size='20px'):
|
925
921
|
"""
|
926
922
|
功能:给出中国当前最新的三大股票交易所的更多细节,合成
|
927
923
|
输出:构造表格型数据框df,利用CSS格式输出
|
siat/option_china.py
CHANGED
@@ -2032,7 +2032,7 @@ def fin_option_risk_sse(option,maturity,exercise,trade_date,printout=True):
|
|
2032
2032
|
"""
|
2033
2033
|
|
2034
2034
|
#初始检查:期权名称
|
2035
|
-
optionlist=["50ETF","300ETF","500ETF"]
|
2035
|
+
optionlist=["50ETF","300ETF","500ETF","科创50","科创板50"]
|
2036
2036
|
if not (option in optionlist):
|
2037
2037
|
print(" #Error(fin_option_risk_sse): option not found in SSE for",option)
|
2038
2038
|
return None
|
@@ -2061,13 +2061,15 @@ def fin_option_risk_sse(option,maturity,exercise,trade_date,printout=True):
|
|
2061
2061
|
|
2062
2062
|
df['direction']=df['CONTRACT_ID'].apply(lambda x: x[6:7])
|
2063
2063
|
df['underlying']=df['CONTRACT_ID'].apply(lambda x: x[:6])
|
2064
|
-
|
2065
|
-
df['
|
2064
|
+
|
2065
|
+
df['ETF end']=df['CONTRACT_SYMBOL'].apply(lambda x: x.find('购'))
|
2066
|
+
df['ETF end']=df.apply(lambda x: x['CONTRACT_SYMBOL'].find('沽') if x['ETF end'] < 0 else x['ETF end'],axis=1)
|
2067
|
+
df['option']=df.apply(lambda x: x['CONTRACT_SYMBOL'][:x['ETF end']],axis=1)
|
2068
|
+
|
2066
2069
|
df['exercise']=df['CONTRACT_ID'].apply(lambda x: float(x[12:]))
|
2067
2070
|
|
2068
2071
|
#进一步检查:到期日
|
2069
2072
|
df['maturity']=df['CONTRACT_ID'].apply(lambda x: x[7:11])
|
2070
|
-
#进一步检查:到期日
|
2071
2073
|
if not (maturity in list(df['maturity'])):
|
2072
2074
|
print(" #Error(fin_option_risk_sse): maturity not found in SSE for",maturity)
|
2073
2075
|
|
@@ -2105,14 +2107,15 @@ def fin_option_risk_sse(option,maturity,exercise,trade_date,printout=True):
|
|
2105
2107
|
& (df2['maturity']==maturity) & (df2['exercise']==exercise)]
|
2106
2108
|
#综合检查:全部条件
|
2107
2109
|
if len(df9) == 0:
|
2108
|
-
print(" #
|
2110
|
+
print(" #Warning(fin_option_risk_sse): options not available combining",option,maturity,exercise)
|
2109
2111
|
df9tmp=df2[(df2['option']==option) & (df2['maturity']==maturity)]
|
2110
2112
|
execlist=list(df9tmp['exercise'])
|
2111
2113
|
exerciselist=[]
|
2112
2114
|
for e in execlist:
|
2113
2115
|
eint=int(e)
|
2114
2116
|
exerciselist=exerciselist+[eint]
|
2115
|
-
|
2117
|
+
# 消除重复并排序
|
2118
|
+
print(" Exercises available under",option,maturity,"\b:",sorted(list(set(exerciselist))))
|
2116
2119
|
return None
|
2117
2120
|
|
2118
2121
|
df9C=df9[(df9['direction']=='C')]
|
@@ -2132,7 +2135,7 @@ def fin_option_risk_sse(option,maturity,exercise,trade_date,printout=True):
|
|
2132
2135
|
rhoP=df9P['rho'][0]
|
2133
2136
|
impvolP=df9P['implied volatility'][0]
|
2134
2137
|
|
2135
|
-
print("\n=====
|
2138
|
+
print("\n===== 期权风险指标 =====\n")
|
2136
2139
|
print("***期权:",option,"\b,交易日期:",trade_date)
|
2137
2140
|
print("标的物代码:",underlying,"\b,到期时间:",maturity,"\b,行权股指点位:",exercise)
|
2138
2141
|
|
@@ -2155,15 +2158,17 @@ if __name__=='__main__':
|
|
2155
2158
|
#==============================================================================
|
2156
2159
|
if __name__=='__main__':
|
2157
2160
|
option='50ETF'
|
2158
|
-
|
2159
|
-
maturity='2306'
|
2161
|
+
maturity='2412'
|
2160
2162
|
exercise=3000
|
2163
|
+
|
2164
|
+
option='300ETF'
|
2161
2165
|
exercise=3500
|
2162
|
-
|
2166
|
+
|
2167
|
+
trade_date='2024-9-10'
|
2163
2168
|
printout=True
|
2164
2169
|
|
2165
2170
|
def fin_option_risk_sse2(option,maturity,exercise,trade_date, \
|
2166
|
-
printout=True,loc='best'):
|
2171
|
+
printout=True,loc='best',facecolor='whitesmoke'):
|
2167
2172
|
"""
|
2168
2173
|
功能:显示指定上交所金融期权的风险指标
|
2169
2174
|
option: 期权名称
|
@@ -2173,7 +2178,7 @@ def fin_option_risk_sse2(option,maturity,exercise,trade_date, \
|
|
2173
2178
|
"""
|
2174
2179
|
|
2175
2180
|
#初始检查:期权名称
|
2176
|
-
optionlist=["50ETF","300ETF","500ETF"]
|
2181
|
+
optionlist=["50ETF","300ETF","500ETF","科创50","科创板50"]
|
2177
2182
|
if not (option in optionlist):
|
2178
2183
|
print(" #Error(fin_option_risk_sse): option not found in SSE for",option)
|
2179
2184
|
return None
|
@@ -2203,15 +2208,20 @@ def fin_option_risk_sse2(option,maturity,exercise,trade_date, \
|
|
2203
2208
|
|
2204
2209
|
df['direction']=df['CONTRACT_ID'].apply(lambda x: x[6:7])
|
2205
2210
|
df['underlying']=df['CONTRACT_ID'].apply(lambda x: x[:6])
|
2206
|
-
|
2211
|
+
|
2212
|
+
df['ETF end']=df['CONTRACT_SYMBOL'].apply(lambda x: x.find('购'))
|
2213
|
+
df['ETF end']=df.apply(lambda x: x['CONTRACT_SYMBOL'].find('沽') if x['ETF end'] < 0 else x['ETF end'],axis=1)
|
2207
2214
|
df['option']=df.apply(lambda x: x['CONTRACT_SYMBOL'][:x['ETF end']],axis=1)
|
2215
|
+
|
2208
2216
|
df['exercise']=df['CONTRACT_ID'].apply(lambda x: float(x[12:]))
|
2209
2217
|
|
2218
|
+
#筛选指定的期权
|
2219
|
+
df=df[df['option']==option]
|
2220
|
+
|
2210
2221
|
#进一步检查:到期日
|
2211
2222
|
df['maturity']=df['CONTRACT_ID'].apply(lambda x: x[7:11])
|
2212
|
-
#进一步检查:到期日
|
2213
2223
|
if not (maturity in list(df['maturity'])):
|
2214
|
-
print(" #
|
2224
|
+
print(" #Warning(fin_option_risk_sse): maturity not found in SSE for",maturity)
|
2215
2225
|
|
2216
2226
|
df_maturity=df[(df['option']==option) & (df['exercise']==exercise)]
|
2217
2227
|
maturitylist=list(set(list(df_maturity['maturity'])))
|
@@ -2221,7 +2231,7 @@ def fin_option_risk_sse2(option,maturity,exercise,trade_date, \
|
|
2221
2231
|
|
2222
2232
|
#进一步检查:行权点位
|
2223
2233
|
if not (exercise in list(df['exercise'])):
|
2224
|
-
print(" #
|
2234
|
+
print(" #Warning(fin_option_risk_sse): exericse point not found in SSE for",exercise)
|
2225
2235
|
|
2226
2236
|
df_exercise=df[(df['option']==option) & (df['maturity']==maturity)]
|
2227
2237
|
exerciselist=list(set(list(df_exercise['exercise'])))
|
@@ -2230,7 +2240,7 @@ def fin_option_risk_sse2(option,maturity,exercise,trade_date, \
|
|
2230
2240
|
print(" Available exercises:",exerciselist2)
|
2231
2241
|
return None
|
2232
2242
|
|
2233
|
-
|
2243
|
+
#整理数据项
|
2234
2244
|
df['Delta']=df['DELTA_VALUE']
|
2235
2245
|
df['Gamma']=df['GAMMA_VALUE']
|
2236
2246
|
df['Theta']=df['THETA_VALUE']
|
@@ -2272,7 +2282,7 @@ def fin_option_risk_sse2(option,maturity,exercise,trade_date, \
|
|
2272
2282
|
#柱状图填充图案
|
2273
2283
|
hatch_par = ['/', '', '|', '-', '+', 'x', 'o', 'O', '.', '*']
|
2274
2284
|
c=dfg.plot(kind='bar', y=['看涨期权','看跌期权'],width=0.8,
|
2275
|
-
color=['green','red'],fontsize=16)
|
2285
|
+
color=['green','red'],fontsize=16,alpha=0.5)
|
2276
2286
|
|
2277
2287
|
#display the percentages above the bars as shown above 数据标签列表
|
2278
2288
|
x=np.arange(len(dfg.index))
|
@@ -2299,6 +2309,9 @@ def fin_option_risk_sse2(option,maturity,exercise,trade_date, \
|
|
2299
2309
|
c.spines['bottom'].set_visible(True) #保留横坐标边框
|
2300
2310
|
c.spines['left'].set_visible(True)
|
2301
2311
|
|
2312
|
+
#绘制零线
|
2313
|
+
plt.axhline(y=0, color='k', linestyle='--')
|
2314
|
+
|
2302
2315
|
plt.xticks(rotation=0)
|
2303
2316
|
|
2304
2317
|
#option,maturity,exercise,trade_date
|
@@ -2311,12 +2324,12 @@ def fin_option_risk_sse2(option,maturity,exercise,trade_date, \
|
|
2311
2324
|
plt.ylabel('希腊值') # y轴空轴
|
2312
2325
|
|
2313
2326
|
#use font size 16 for the title, and, 标题字号
|
2314
|
-
plt.title("
|
2327
|
+
plt.title("希腊值风险全景图:"+option+"期权",fontsize=18)
|
2315
2328
|
|
2316
2329
|
#use font size 14 for the bar labels, percentages, and legend, 图例颜色
|
2317
2330
|
plt.legend(fontsize=16,loc=loc)
|
2318
2331
|
|
2319
|
-
plt.gca().set_facecolor(
|
2332
|
+
plt.gca().set_facecolor(facecolor)
|
2320
2333
|
plt.show
|
2321
2334
|
|
2322
2335
|
return df9
|
@@ -2331,19 +2344,27 @@ if __name__=='__main__':
|
|
2331
2344
|
#==============================================================================
|
2332
2345
|
if __name__=='__main__':
|
2333
2346
|
option='50ETF'
|
2334
|
-
maturity='
|
2335
|
-
exercise=
|
2336
|
-
|
2347
|
+
maturity='2412'
|
2348
|
+
exercise=2500
|
2349
|
+
trade_date='2024-9-10'
|
2350
|
+
measure='delta'
|
2351
|
+
|
2337
2352
|
graph=True
|
2338
2353
|
loc1='best'
|
2339
2354
|
loc2='best'
|
2355
|
+
|
2356
|
+
twinx=False
|
2357
|
+
zeroline=False
|
2358
|
+
loc1='best';loc2='best'
|
2359
|
+
date_range=False;date_freq=False;date_fmt='%Y-%m'
|
2340
2360
|
|
2341
2361
|
def fin_option_maturity_risk_sse(option,exercise,trade_date, \
|
2342
2362
|
measure='delta', \
|
2343
2363
|
graph=True, \
|
2344
2364
|
twinx=False,zeroline=False, \
|
2345
2365
|
loc1='best',loc2='best', \
|
2346
|
-
date_range=False,date_freq=False,date_fmt='%Y-%m'
|
2366
|
+
date_range=False,date_freq=False,date_fmt='%Y-%m',
|
2367
|
+
facecolor='whitesmoke'):
|
2347
2368
|
"""
|
2348
2369
|
功能:绘制指定上交所金融期权的风险指标曲线,风险因素:到期日maturity(横轴),各个风险指标(纵轴,看涨/看跌)
|
2349
2370
|
option: 期权名称
|
@@ -2353,7 +2374,7 @@ def fin_option_maturity_risk_sse(option,exercise,trade_date, \
|
|
2353
2374
|
"""
|
2354
2375
|
|
2355
2376
|
#初步检查:期权名称
|
2356
|
-
optionlist=["50ETF","300ETF","500ETF"]
|
2377
|
+
optionlist=["50ETF","300ETF","500ETF","科创50","科创板50"]
|
2357
2378
|
if not (option in optionlist):
|
2358
2379
|
print(" #Error(fin_option_maturity_risk_sse): option not found in SSE for",option)
|
2359
2380
|
return None
|
@@ -2384,9 +2405,15 @@ def fin_option_maturity_risk_sse(option,exercise,trade_date, \
|
|
2384
2405
|
df['underlying']=df['CONTRACT_ID'].apply(lambda x: x[:6])
|
2385
2406
|
df['maturity']=df['CONTRACT_ID'].apply(lambda x: x[7:11])
|
2386
2407
|
|
2408
|
+
#获得期权名称
|
2409
|
+
#df['ETF end']=df['CONTRACT_SYMBOL'].apply(lambda x: x.find('ETF')+3)
|
2410
|
+
df['ETF end']=df['CONTRACT_SYMBOL'].apply(lambda x: x.find('购'))
|
2411
|
+
df['ETF end']=df.apply(lambda x: x['CONTRACT_SYMBOL'].find('沽') if x['ETF end'] < 0 else x['ETF end'],axis=1)
|
2412
|
+
df['option']=df.apply(lambda x: x['CONTRACT_SYMBOL'][:x['ETF end']],axis=1)
|
2413
|
+
|
2387
2414
|
df['exercise']=df['CONTRACT_ID'].apply(lambda x: float(x[12:]))
|
2388
2415
|
if not (exercise in list(df['exercise'])):
|
2389
|
-
print(" #
|
2416
|
+
print(" #Warning(fin_option_maturity_risk_sse): exericse point not found in SSE for",exercise)
|
2390
2417
|
|
2391
2418
|
df_exercise=df[(df['option']==option)]
|
2392
2419
|
exerciselist=list(set(list(df_exercise['exercise'])))
|
@@ -2395,10 +2422,6 @@ def fin_option_maturity_risk_sse(option,exercise,trade_date, \
|
|
2395
2422
|
print(" Available exercises:",exerciselist2)
|
2396
2423
|
return None
|
2397
2424
|
|
2398
|
-
#获得期权名称
|
2399
|
-
df['ETF end']=df['CONTRACT_SYMBOL'].apply(lambda x: x.find('ETF')+3)
|
2400
|
-
df['option']=df.apply(lambda x: x['CONTRACT_SYMBOL'][:x['ETF end']],axis=1)
|
2401
|
-
|
2402
2425
|
#获得风险指标
|
2403
2426
|
df['delta']=df['DELTA_VALUE']
|
2404
2427
|
df['theta']=df['THETA_VALUE']
|
@@ -2413,7 +2436,7 @@ def fin_option_maturity_risk_sse(option,exercise,trade_date, \
|
|
2413
2436
|
|
2414
2437
|
df9=df2[(df2['option']==option) & (df2['exercise']==exercise)]
|
2415
2438
|
if len(df9) == 0:
|
2416
|
-
print(" #
|
2439
|
+
print(" #Warning(fin_option_maturity_risk_sse): options not available fulfilling",option,exercise)
|
2417
2440
|
return None
|
2418
2441
|
|
2419
2442
|
df9['Date']=df9['maturity'].apply(lambda x: '20'+x[:2]+'-'+x[2:4]+'-26')
|
@@ -2434,7 +2457,7 @@ def fin_option_maturity_risk_sse(option,exercise,trade_date, \
|
|
2434
2457
|
#label2=measure
|
2435
2458
|
#ylabeltxt="风险指标"
|
2436
2459
|
ylabeltxt=ectranslate(measure)
|
2437
|
-
titletxt='
|
2460
|
+
titletxt='希腊值风险趋势:'+option+'期权,到期时间对'+ylabeltxt+"的影响"
|
2438
2461
|
|
2439
2462
|
footnote0="到期时间(不同期权)\n"
|
2440
2463
|
footnote1=option+"期权"+",行权股指点位"+str(exercise)+",交易日"+trade_date
|
@@ -2442,8 +2465,22 @@ def fin_option_maturity_risk_sse(option,exercise,trade_date, \
|
|
2442
2465
|
footnote2="数据来源: 新浪财经/东方财富, 制图"+str(today)
|
2443
2466
|
footnote=footnote0+footnote1+"\n"+footnote2
|
2444
2467
|
|
2468
|
+
#设置zeroline
|
2469
|
+
maxC=df9C[colname1].max(); minC=df9C[colname1].min()
|
2470
|
+
maxP=df9P[colname2].max(); minP=df9P[colname2].min()
|
2471
|
+
|
2472
|
+
aboveZero=False; belowZero=False
|
2473
|
+
if maxC>0 or minC>0 or maxP>0 or minP>0: aboveZero=True
|
2474
|
+
if maxC<0 or minC<0 or maxP<0 or minP<0: belowZero=True
|
2475
|
+
if aboveZero and belowZero:
|
2476
|
+
zeroline=True
|
2477
|
+
else:
|
2478
|
+
zeroline=False
|
2479
|
+
|
2445
2480
|
if twinx:
|
2446
2481
|
zeroline=False
|
2482
|
+
|
2483
|
+
"""
|
2447
2484
|
plot2_line2(df9C,ticker1,colname1,'', \
|
2448
2485
|
df9P,ticker2,colname2,'', \
|
2449
2486
|
ylabeltxt,titletxt,footnote, \
|
@@ -2451,6 +2488,14 @@ def fin_option_maturity_risk_sse(option,exercise,trade_date, \
|
|
2451
2488
|
zeroline=zeroline,yline=0, \
|
2452
2489
|
loc1=loc1,loc2=loc2, \
|
2453
2490
|
date_range=date_range,date_freq=date_freq,date_fmt=date_fmt)
|
2491
|
+
"""
|
2492
|
+
plot_line2(df9C,ticker1,colname1,'', \
|
2493
|
+
df9P,ticker2,colname2,'', \
|
2494
|
+
ylabeltxt=ylabeltxt,titletxt=titletxt,footnote=footnote, \
|
2495
|
+
zeroline=zeroline,twinx=twinx, \
|
2496
|
+
loc1=loc1,loc2=loc2, \
|
2497
|
+
facecolor=facecolor
|
2498
|
+
)
|
2454
2499
|
|
2455
2500
|
return df9
|
2456
2501
|
|
@@ -2472,7 +2517,8 @@ def fin_option_exercise_risk_sse(option,maturity,trade_date, \
|
|
2472
2517
|
measure='delta', \
|
2473
2518
|
graph=True, \
|
2474
2519
|
zeroline=False, \
|
2475
|
-
loc1='best',loc2='best'
|
2520
|
+
loc1='best',loc2='best',
|
2521
|
+
facecolor='whitesmoke'):
|
2476
2522
|
"""
|
2477
2523
|
功能:绘制指定上交所金融期权的风险指标曲线,风险因素:行权点位exercise(横轴),各个风险指标(纵轴,看涨/看跌)
|
2478
2524
|
option: 期权名称
|
@@ -2482,7 +2528,7 @@ def fin_option_exercise_risk_sse(option,maturity,trade_date, \
|
|
2482
2528
|
"""
|
2483
2529
|
|
2484
2530
|
#初步检查:期权名称
|
2485
|
-
optionlist=["50ETF","300ETF","500ETF"]
|
2531
|
+
optionlist=["50ETF","300ETF","500ETF","科创50","科创板50"]
|
2486
2532
|
if not (option in optionlist):
|
2487
2533
|
print(" #Error(fin_option_exercise_risk_sse): option not found in SSE for",option)
|
2488
2534
|
return None
|
@@ -2528,8 +2574,9 @@ def fin_option_exercise_risk_sse(option,maturity,trade_date, \
|
|
2528
2574
|
df['exercise']=df['CONTRACT_ID'].apply(lambda x: float(x[12:]))
|
2529
2575
|
|
2530
2576
|
#获得期权名称
|
2531
|
-
df['ETF end']=df['CONTRACT_SYMBOL'].apply(lambda x: x.find('
|
2532
|
-
df['
|
2577
|
+
df['ETF end']=df['CONTRACT_SYMBOL'].apply(lambda x: x.find('购'))
|
2578
|
+
df['ETF end']=df.apply(lambda x: x['CONTRACT_SYMBOL'].find('沽') if x['ETF end'] < 0 else x['ETF end'],axis=1)
|
2579
|
+
df['option']=df.apply(lambda x: x['CONTRACT_SYMBOL'][:x['ETF end']],axis=1)
|
2533
2580
|
|
2534
2581
|
#获得风险指标
|
2535
2582
|
df['delta']=df['DELTA_VALUE']
|
@@ -2565,7 +2612,19 @@ def fin_option_exercise_risk_sse(option,maturity,trade_date, \
|
|
2565
2612
|
labeltxt="看跌期权"
|
2566
2613
|
plt.plot(dftmp.exercise,dftmp[measure],'-',label=labeltxt, \
|
2567
2614
|
linestyle='--',color='orange',linewidth=2)
|
2615
|
+
|
2616
|
+
#设置zeroline
|
2617
|
+
maxC=df9C[measure].max(); minC=df9C[measure].min()
|
2618
|
+
maxP=df9P[measure].max(); minP=df9P[measure].min()
|
2568
2619
|
|
2620
|
+
aboveZero=False; belowZero=False
|
2621
|
+
if maxC>0 or minC>0 or maxP>0 or minP>0: aboveZero=True
|
2622
|
+
if maxC<0 or minC<0 or maxP<0 or minP<0: belowZero=True
|
2623
|
+
if aboveZero and belowZero:
|
2624
|
+
zeroline=True
|
2625
|
+
else:
|
2626
|
+
zeroline=False
|
2627
|
+
|
2569
2628
|
if zeroline:
|
2570
2629
|
plt.axhline(y=0,label='',ls=":",c="black",linewidth=2.5)
|
2571
2630
|
|
@@ -2581,10 +2640,10 @@ def fin_option_exercise_risk_sse(option,maturity,trade_date, \
|
|
2581
2640
|
footnote=footnote1+"\n"+footnote2+"\n"+footnote3
|
2582
2641
|
plt.xlabel(footnote,fontsize=xlabel_txt_size)
|
2583
2642
|
|
2584
|
-
titletxt='
|
2643
|
+
titletxt='希腊值风险趋势:'+option+'期权,股指点位对'+ylabeltxt+'的影响'
|
2585
2644
|
plt.title(titletxt,fontweight='bold',fontsize=title_txt_size)
|
2586
2645
|
|
2587
|
-
plt.gca().set_facecolor(
|
2646
|
+
plt.gca().set_facecolor(facecolor)
|
2588
2647
|
plt.show()
|
2589
2648
|
plt.close()
|
2590
2649
|
|
@@ -2595,23 +2654,36 @@ if __name__=='__main__':
|
|
2595
2654
|
|
2596
2655
|
#==============================================================================
|
2597
2656
|
if __name__=='__main__':
|
2598
|
-
option='
|
2599
|
-
maturity='
|
2657
|
+
option='300ETF'
|
2658
|
+
maturity='2412'
|
2600
2659
|
exercise=3500
|
2601
|
-
start='
|
2602
|
-
end="
|
2660
|
+
start='2024-8-10'
|
2661
|
+
end ="2024-9-10"
|
2662
|
+
measure='delta'
|
2663
|
+
|
2603
2664
|
graph=True
|
2665
|
+
twinx=True;zeroline=True
|
2604
2666
|
loc1='best'
|
2605
2667
|
loc2='best'
|
2606
2668
|
date_range=False
|
2607
2669
|
date_freq=False
|
2670
|
+
facecolor='whitesmoke'
|
2671
|
+
|
2672
|
+
df=fin_option_time_risk_sse(option='300ETF',
|
2673
|
+
maturity='2412',
|
2674
|
+
exercise=3500,
|
2675
|
+
start='2024-8-10',end='2024-9-10',
|
2676
|
+
measure='delta',
|
2677
|
+
twinx=True,
|
2678
|
+
zeroline=True)
|
2608
2679
|
|
2609
2680
|
def fin_option_time_risk_sse(option,maturity,exercise,start,end, \
|
2610
2681
|
measure='delta', \
|
2611
2682
|
graph=True, \
|
2612
2683
|
twinx=False, zeroline=False, \
|
2613
2684
|
loc1='best',loc2='best', \
|
2614
|
-
date_range=False,date_freq=False
|
2685
|
+
date_range=False,date_freq=False,
|
2686
|
+
facecolor='whitesmoke'):
|
2615
2687
|
"""
|
2616
2688
|
功能:绘制指定上交所金融期权的风险指标曲线,风险因素:随时间推移start/end(横轴),各个风险指标(纵轴,看涨/看跌)
|
2617
2689
|
option: 期权名称
|
@@ -2624,7 +2696,7 @@ def fin_option_time_risk_sse(option,maturity,exercise,start,end, \
|
|
2624
2696
|
"""
|
2625
2697
|
|
2626
2698
|
#初步检查:期权名称
|
2627
|
-
optionlist=["50ETF","300ETF","500ETF"]
|
2699
|
+
optionlist=["50ETF","300ETF","500ETF","科创50","科创板50"]
|
2628
2700
|
if not (option in optionlist):
|
2629
2701
|
print(" #Error(fin_option_time_risk_sse): option not found in SSE for",option)
|
2630
2702
|
return None
|
@@ -2649,21 +2721,25 @@ def fin_option_time_risk_sse(option,maturity,exercise,start,end, \
|
|
2649
2721
|
#循环获取各个交易日的指标
|
2650
2722
|
df=pd.DataFrame()
|
2651
2723
|
curdate=start; curdatepd=startpd
|
2652
|
-
|
2724
|
+
|
2725
|
+
num_days=calculate_days(start, end)
|
2726
|
+
num=0
|
2727
|
+
#print("Searching information on ",end='')
|
2653
2728
|
while curdatepd <= endpd:
|
2654
|
-
print(curdate,end=' ')
|
2729
|
+
#print(curdate,end=' ')
|
2655
2730
|
akdate=convert_date_ts(curdate)
|
2656
2731
|
try:
|
2657
2732
|
dftmp = ak.option_risk_indicator_sse(date=akdate)
|
2658
|
-
except:
|
2659
|
-
curdate=date_adjust(curdate,adjust=1)
|
2660
|
-
continue
|
2661
|
-
try:
|
2662
|
-
df=df.append(dftmp)
|
2663
|
-
except:
|
2664
2733
|
df=df._append(dftmp)
|
2734
|
+
except:
|
2735
|
+
pass
|
2736
|
+
|
2665
2737
|
curdate=date_adjust(curdate,adjust=1)
|
2666
2738
|
curdatepd=pd.to_datetime(curdate)
|
2739
|
+
|
2740
|
+
print_progress_percent(num,num_days-1,steps=5,leading_blanks=2)
|
2741
|
+
num=num+1
|
2742
|
+
|
2667
2743
|
print(' ')
|
2668
2744
|
|
2669
2745
|
#整理数据
|
@@ -2677,7 +2753,8 @@ def fin_option_time_risk_sse(option,maturity,exercise,start,end, \
|
|
2677
2753
|
df['underlying']=df['CONTRACT_ID'].apply(lambda x: x[:6])
|
2678
2754
|
|
2679
2755
|
#获得期权名称
|
2680
|
-
df['ETF end']=df['CONTRACT_SYMBOL'].apply(lambda x: x.find('
|
2756
|
+
df['ETF end']=df['CONTRACT_SYMBOL'].apply(lambda x: x.find('购'))
|
2757
|
+
df['ETF end']=df.apply(lambda x: x['CONTRACT_SYMBOL'].find('沽') if x['ETF end'] < 0 else x['ETF end'],axis=1)
|
2681
2758
|
df['option']=df.apply(lambda x: x['CONTRACT_SYMBOL'][:x['ETF end']],axis=1)
|
2682
2759
|
|
2683
2760
|
df['maturity']=df['CONTRACT_ID'].apply(lambda x: x[7:11])
|
@@ -2731,7 +2808,7 @@ def fin_option_time_risk_sse(option,maturity,exercise,start,end, \
|
|
2731
2808
|
#label2=measure
|
2732
2809
|
#ylabeltxt="风险指标"
|
2733
2810
|
ylabeltxt=ectranslate(measure)
|
2734
|
-
titletxt='
|
2811
|
+
titletxt='希腊值风险趋势:'+option+'期权,时间流逝对'+ylabeltxt+'的影响'
|
2735
2812
|
|
2736
2813
|
footnote0="时间流逝(同一期权)\n"
|
2737
2814
|
footnote1=option+"期权"+",行权股指点位"+str(exercise)+",到期时间"+maturity
|
@@ -2750,8 +2827,21 @@ def fin_option_time_risk_sse(option,maturity,exercise,start,end, \
|
|
2750
2827
|
elif ndays <=80:
|
2751
2828
|
date_range=True; date_freq='4D'
|
2752
2829
|
|
2830
|
+
#设置zeroline
|
2831
|
+
maxC=df9C[colname1].max(); minC=df9C[colname1].min()
|
2832
|
+
maxP=df9P[colname2].max(); minP=df9P[colname2].min()
|
2833
|
+
|
2834
|
+
aboveZero=False; belowZero=False
|
2835
|
+
if maxC>0 or minC>0 or maxP>0 or minP>0: aboveZero=True
|
2836
|
+
if maxC<0 or minC<0 or maxP<0 or minP<0: belowZero=True
|
2837
|
+
if aboveZero and belowZero:
|
2838
|
+
zeroline=True
|
2839
|
+
else:
|
2840
|
+
zeroline=False
|
2841
|
+
|
2753
2842
|
if twinx:
|
2754
2843
|
zeroline=False
|
2844
|
+
"""
|
2755
2845
|
plot2_line2(df9C,ticker1,colname1,'', \
|
2756
2846
|
df9P,ticker2,colname2,'', \
|
2757
2847
|
ylabeltxt,titletxt,footnote, \
|
@@ -2759,13 +2849,21 @@ def fin_option_time_risk_sse(option,maturity,exercise,start,end, \
|
|
2759
2849
|
zeroline=zeroline,yline=0, \
|
2760
2850
|
loc1=loc1,loc2=loc2, \
|
2761
2851
|
date_range=date_range,date_freq=date_freq)
|
2852
|
+
"""
|
2853
|
+
plot_line2(df9C,ticker1,colname1,'', \
|
2854
|
+
df9P,ticker2,colname2,'', \
|
2855
|
+
ylabeltxt=ylabeltxt,titletxt=titletxt,footnote=footnote, \
|
2856
|
+
zeroline=zeroline,twinx=twinx, \
|
2857
|
+
loc1=loc1,loc2=loc2, \
|
2858
|
+
facecolor=facecolor
|
2859
|
+
)
|
2762
2860
|
|
2763
2861
|
return df9
|
2764
2862
|
|
2765
2863
|
if __name__=='__main__':
|
2766
2864
|
df=fin_option_time_risk_sse(option='300ETF',maturity='2209',exercise=4500,start='2022-8-26',end='2022-9-26',measure='implied volatility')
|
2767
2865
|
#==============================================================================
|
2768
|
-
|
2866
|
+
#==============================================================================
|
2769
2867
|
#==============================================================================
|
2770
2868
|
if __name__=='__main__':
|
2771
2869
|
end_month="2303"
|
@@ -2801,5 +2899,108 @@ def option_expire_date(end_month,numOfWeek,numOfWeekday):
|
|
2801
2899
|
print(" #Error(option_expire_date): invalid date --> weekday",numOfWeekday,'of week',numOfWeek,'in',end_month)
|
2802
2900
|
return None
|
2803
2901
|
|
2804
|
-
|
2805
|
-
|
2902
|
+
#==============================================================================
|
2903
|
+
#==============================================================================
|
2904
|
+
#==============================================================================
|
2905
|
+
if __name__=='__main__':
|
2906
|
+
options='50ETF'
|
2907
|
+
maturity='2412'
|
2908
|
+
exercise=3000
|
2909
|
+
trade_date='recent'
|
2910
|
+
period_days=30
|
2911
|
+
risk='none'
|
2912
|
+
twinx=False
|
2913
|
+
zeroline=False
|
2914
|
+
printout=True; graph=True
|
2915
|
+
facecolor='whitesmoke'
|
2916
|
+
|
2917
|
+
def options_greek_china(options, \
|
2918
|
+
exercise=0, \
|
2919
|
+
maturity='recent', \
|
2920
|
+
trade_date='recent', \
|
2921
|
+
period_days=30, \
|
2922
|
+
risk='none', \
|
2923
|
+
greek='delta', \
|
2924
|
+
twinx=False, \
|
2925
|
+
zeroline=False, \
|
2926
|
+
printout=False, graph=True, \
|
2927
|
+
facecolor='whitesmoke', \
|
2928
|
+
loc1='best',loc2='best'):
|
2929
|
+
"""
|
2930
|
+
功能:套壳函数
|
2931
|
+
套壳:fin_option_risk_sse, fin_option_risk_sse2, fin_option_maturity_risk_sse,
|
2932
|
+
fin_option_exercise_risk_sse, fin_option_time_risk_sse
|
2933
|
+
|
2934
|
+
套壳条件:
|
2935
|
+
当printout==True且risk=='none'时,执行fin_option_risk_sse
|
2936
|
+
当printout==False且graph==True且risk=='none'时,执行fin_option_risk_sse2
|
2937
|
+
当risk=='maturity'时,执行fin_option_maturity_risk_sse
|
2938
|
+
当risk=='exercise'时,执行fin_option_exercise_risk_sse
|
2939
|
+
当risk=='time'时,执行fin_option_time_risk_sse
|
2940
|
+
"""
|
2941
|
+
#处理默认日期为上一个非周末的交易日,也可手动指定交易日
|
2942
|
+
if trade_date=='recent':
|
2943
|
+
import datetime as dt; stoday=dt.date.today()
|
2944
|
+
wd=stoday.weekday() #周一为0
|
2945
|
+
if wd==6:#周日
|
2946
|
+
trade_date=date_adjust(str(stoday), adjust=-2)
|
2947
|
+
elif wd==0:#周一
|
2948
|
+
trade_date=date_adjust(str(stoday), adjust=-3)
|
2949
|
+
else:
|
2950
|
+
trade_date=date_adjust(str(stoday), adjust=-1)
|
2951
|
+
|
2952
|
+
if risk=='none':
|
2953
|
+
if printout:
|
2954
|
+
df=fin_option_risk_sse(option=options,
|
2955
|
+
maturity=maturity,
|
2956
|
+
exercise=exercise,
|
2957
|
+
trade_date=trade_date)
|
2958
|
+
return df
|
2959
|
+
|
2960
|
+
if not printout and graph:
|
2961
|
+
df=fin_option_risk_sse2(option=options,
|
2962
|
+
maturity=maturity,
|
2963
|
+
exercise=exercise,
|
2964
|
+
trade_date=trade_date)
|
2965
|
+
return df
|
2966
|
+
|
2967
|
+
if risk=='maturity':
|
2968
|
+
df=fin_option_maturity_risk_sse(option=options,
|
2969
|
+
exercise=exercise,
|
2970
|
+
trade_date=trade_date,
|
2971
|
+
measure=greek,
|
2972
|
+
twinx=twinx,
|
2973
|
+
zeroline=zeroline,
|
2974
|
+
loc1=loc1,loc2=loc2)
|
2975
|
+
return df
|
2976
|
+
|
2977
|
+
if risk=='exercise':
|
2978
|
+
df=fin_option_exercise_risk_sse(option=options,
|
2979
|
+
maturity=maturity,
|
2980
|
+
trade_date=trade_date,
|
2981
|
+
measure=greek,
|
2982
|
+
zeroline=zeroline,
|
2983
|
+
loc1=loc1,loc2=loc2)
|
2984
|
+
return df
|
2985
|
+
|
2986
|
+
if risk=='time':
|
2987
|
+
start=date_adjust(trade_date, adjust=-period_days)
|
2988
|
+
df=fin_option_time_risk_sse(option=options,
|
2989
|
+
maturity=maturity,
|
2990
|
+
exercise=exercise,
|
2991
|
+
start=start,end=trade_date,
|
2992
|
+
measure=greek,
|
2993
|
+
twinx=twinx,
|
2994
|
+
zeroline=zeroline,
|
2995
|
+
loc1=loc1,loc2=loc2)
|
2996
|
+
return df
|
2997
|
+
|
2998
|
+
print("Sorry, no idea on what I can do for you:-(")
|
2999
|
+
return None
|
3000
|
+
|
3001
|
+
|
3002
|
+
#==============================================================================
|
3003
|
+
#==============================================================================
|
3004
|
+
#==============================================================================
|
3005
|
+
#==============================================================================
|
3006
|
+
#==============================================================================
|
siat/option_pricing.py
CHANGED
@@ -19,6 +19,7 @@ from siat.common import *
|
|
19
19
|
from siat.translate import *
|
20
20
|
from siat.grafix import *
|
21
21
|
from siat.security_prices import *
|
22
|
+
from siat.security_trend2 import *
|
22
23
|
#==============================================================================
|
23
24
|
import matplotlib.pyplot as plt
|
24
25
|
|
@@ -1177,9 +1178,11 @@ def option_maturity(ticker,printout=True):
|
|
1177
1178
|
if not printout:
|
1178
1179
|
return datelist
|
1179
1180
|
|
1181
|
+
tname=get_stock_name1_en(ticker)
|
1182
|
+
|
1180
1183
|
#显示结果
|
1181
1184
|
print("\n===== 期权的时间序列 =====")
|
1182
|
-
print("标的资产:",
|
1185
|
+
print("标的资产:",tname)
|
1183
1186
|
print("到期日期:")
|
1184
1187
|
|
1185
1188
|
num=len(datelist)
|
@@ -1191,7 +1194,7 @@ def option_maturity(ticker,printout=True):
|
|
1191
1194
|
print("总计:",num,"个日期")
|
1192
1195
|
import datetime
|
1193
1196
|
today = datetime.date.today()
|
1194
|
-
print("*** 数据来源: 雅虎财经,",today)
|
1197
|
+
print("\n*** 数据来源: 雅虎财经,",today)
|
1195
1198
|
|
1196
1199
|
return datelist
|
1197
1200
|
|
@@ -1204,12 +1207,18 @@ if __name__=='__main__':
|
|
1204
1207
|
#================================================================
|
1205
1208
|
if __name__=='__main__':
|
1206
1209
|
ticker="AAPL"
|
1207
|
-
|
1210
|
+
maturity_date="2025-2-21"
|
1208
1211
|
|
1209
|
-
def option_chain(ticker,
|
1212
|
+
def option_chain(ticker,maturity_date='today',printout=True):
|
1210
1213
|
"""
|
1211
1214
|
功能:获得期权的各个到期日期,并列出某个到期日的期权合约
|
1212
1215
|
"""
|
1216
|
+
mdate=maturity_date
|
1217
|
+
|
1218
|
+
if mdate=='today':
|
1219
|
+
import datetime as dt; stoday=dt.date.today()
|
1220
|
+
mdate=str(stoday)
|
1221
|
+
|
1213
1222
|
import yfinance as yf
|
1214
1223
|
opt = yf.Ticker(ticker)
|
1215
1224
|
|
@@ -1257,12 +1266,11 @@ def option_chain(ticker,mdate,printout=True):
|
|
1257
1266
|
|
1258
1267
|
if not printout:
|
1259
1268
|
return opt_call2, opt_put2
|
1260
|
-
|
1261
|
-
|
1262
|
-
today = datetime.date.today()
|
1269
|
+
|
1270
|
+
tname=get_stock_name1_en(ticker)
|
1263
1271
|
|
1264
1272
|
print("\n===== 期权链的结构 =====")
|
1265
|
-
print("标的资产:",
|
1273
|
+
print("标的资产:",tname)
|
1266
1274
|
print("到期日期:",mdate)
|
1267
1275
|
print("看涨期权:",num_call)
|
1268
1276
|
print(" 实值/虚值:",num_call_ITM,'/',num_call_OTM)
|
@@ -1271,29 +1279,44 @@ def option_chain(ticker,mdate,printout=True):
|
|
1271
1279
|
print("最低/最高行权价:",strike_min,'/',strike_max,currency)
|
1272
1280
|
|
1273
1281
|
import datetime
|
1274
|
-
|
1275
|
-
print("*数据来源: 雅虎财经,",
|
1282
|
+
stoday = datetime.date.today()
|
1283
|
+
print("\n*数据来源: 雅虎财经,",stoday)
|
1276
1284
|
|
1277
|
-
|
1285
|
+
#设置绘图数据
|
1278
1286
|
df1=opt_call2.copy()
|
1279
1287
|
df1.sort_values(by=['strike'],axis=0,ascending=[True],inplace=True)
|
1280
1288
|
df1.set_index(['strike'],inplace=True)
|
1289
|
+
df1['exercise']=df1.index
|
1281
1290
|
colname1='lastPrice'; label1='看涨期权价格'
|
1282
1291
|
|
1283
1292
|
df2=opt_put2.copy()
|
1284
1293
|
df2.sort_values(by=['strike'],axis=0,ascending=[True],inplace=True)
|
1285
1294
|
df2.set_index(['strike'],inplace=True)
|
1295
|
+
df2['exercise']=df2.index
|
1286
1296
|
colname2='lastPrice'; label2='看跌期权价格'
|
1287
1297
|
|
1288
1298
|
ylabeltxt='期权价格('+currency+')'
|
1289
|
-
titletxt="
|
1290
|
-
footnote="
|
1291
|
-
"标的资产: "+
|
1299
|
+
titletxt="期权价格与标的行权价格的关系"
|
1300
|
+
footnote="标的行权价("+currency+") -->\n"+ \
|
1301
|
+
"标的资产: "+tname+ \
|
1292
1302
|
", "+"到期日: "+mdate+ \
|
1293
|
-
"\n数据来源: 雅虎财经, "+str(
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1303
|
+
"\n数据来源: 雅虎财经, "+str(stoday)
|
1304
|
+
|
1305
|
+
#绘图
|
1306
|
+
import matplotlib.pyplot as plt
|
1307
|
+
plt.plot(df1.index,df1[colname1],color='red',linestyle='-',linewidth=1.5, \
|
1308
|
+
label=label1)
|
1309
|
+
|
1310
|
+
plt.plot(df2.index,df2[colname2],color='blue',linestyle='-',linewidth=1.5, \
|
1311
|
+
label=label2)
|
1312
|
+
|
1313
|
+
plt.ylabel(ylabeltxt,fontsize=ylabel_txt_size)
|
1314
|
+
plt.xlabel(footnote,fontsize=xlabel_txt_size)
|
1315
|
+
plt.title(titletxt,fontsize=title_txt_size)
|
1316
|
+
plt.legend(fontsize=legend_txt_size)
|
1317
|
+
plt.show()
|
1318
|
+
|
1319
|
+
|
1297
1320
|
return opt_call2, opt_put2
|
1298
1321
|
|
1299
1322
|
if __name__=='__main__':
|
@@ -1307,26 +1330,31 @@ if __name__ =="__main__":
|
|
1307
1330
|
lastndays=7
|
1308
1331
|
|
1309
1332
|
#def predict_stock_trend_by_option(ticker,lastndays=7,power=4):
|
1310
|
-
def
|
1333
|
+
def market_prospect_via_option(ticker,lastdays=7):
|
1311
1334
|
"""
|
1312
|
-
|
1335
|
+
功能:根据股票期权行权价及交易量预测股价
|
1336
|
+
注意:本函数与price_prospect_via_option内容基本一致,图示方式略有不同
|
1313
1337
|
"""
|
1338
|
+
lastndays=lastdays
|
1314
1339
|
|
1340
|
+
DEBUG=False
|
1315
1341
|
try:
|
1316
1342
|
datelist=option_maturity(ticker,printout=False)
|
1317
1343
|
except:
|
1318
|
-
print("#Error(predict_stock_price_by_option): option info not found for
|
1344
|
+
print(" #Error(predict_stock_price_by_option): option info not found for",ticker)
|
1319
1345
|
if datelist is None:
|
1320
|
-
print("Warning(predict_stock_price_by_option): options not found for
|
1346
|
+
print(" #Warning(predict_stock_price_by_option): options not found for",ticker)
|
1321
1347
|
return None
|
1322
|
-
print("\nFound
|
1348
|
+
print("\nFound options with",len(datelist),"maturity dates for",ticker)
|
1323
1349
|
|
1324
1350
|
import pandas as pd
|
1325
1351
|
df=pd.DataFrame(columns=['Ticker','Date','WA Strike','Total Options', \
|
1326
1352
|
'Calls in Total%','OTM in Calls%','OTM Calls in Total%', \
|
1327
1353
|
'Puts in Total%','OTM in Puts%','OTM Puts in Total%'])
|
1328
1354
|
for d in datelist:
|
1329
|
-
|
1355
|
+
print_progress_percent2(d,datelist,steps=5,leading_blanks=4)
|
1356
|
+
|
1357
|
+
if DEBUG: print("Processing options matured on",d)
|
1330
1358
|
opt_call,opt_put=option_chain(ticker,d,printout=False)
|
1331
1359
|
|
1332
1360
|
numofcalls=len(opt_call)
|
@@ -1386,7 +1414,7 @@ def predict_stock_trend_by_option(ticker,lastndays=7):
|
|
1386
1414
|
colname2='Puts in Total%'
|
1387
1415
|
label2='Puts in Total%'
|
1388
1416
|
ylabeltxt='Percentage'
|
1389
|
-
titletxt="
|
1417
|
+
titletxt="Option Comparison: "+ticker+", Calls vs Puts"
|
1390
1418
|
|
1391
1419
|
footnote="Source: Yahoo Finance, "+str(today)
|
1392
1420
|
plot_line2(df2,ticker,colname1,label1, \
|
@@ -1399,7 +1427,7 @@ def predict_stock_trend_by_option(ticker,lastndays=7):
|
|
1399
1427
|
colname2='OTM in Puts%'
|
1400
1428
|
label2='OTM in Puts%'
|
1401
1429
|
ylabeltxt='Percentage'
|
1402
|
-
titletxt="
|
1430
|
+
titletxt="Option Relative Proportion Comparison\n("+ticker+", OTM Calls vs OTM Puts)"
|
1403
1431
|
|
1404
1432
|
footnote="Source: Yahoo Finance, "+str(today)
|
1405
1433
|
plot_line2(df2,ticker,colname1,label1, \
|
@@ -1412,7 +1440,7 @@ def predict_stock_trend_by_option(ticker,lastndays=7):
|
|
1412
1440
|
colname2='OTM Puts in Total%'
|
1413
1441
|
label2='OTM Puts in Total%'
|
1414
1442
|
ylabeltxt='Percentage'
|
1415
|
-
titletxt="
|
1443
|
+
titletxt="Option Absolute Proportion Comparison\n("+ticker+", OTM Calls vs OTM Puts)"
|
1416
1444
|
|
1417
1445
|
footnote="Source: Yahoo Finance, "+str(today)
|
1418
1446
|
plot_line2(df2,ticker,colname1,label1, \
|
@@ -1423,9 +1451,9 @@ def predict_stock_trend_by_option(ticker,lastndays=7):
|
|
1423
1451
|
df2x=df2.drop(df2[df2['Total Options']<=1].index)
|
1424
1452
|
"""
|
1425
1453
|
colname='WA Strike'
|
1426
|
-
collabel='Predicted
|
1454
|
+
collabel='Predicted Price'
|
1427
1455
|
ylabeltxt=''
|
1428
|
-
titletxt="Predicting
|
1456
|
+
titletxt="Predicting Prices via Options: "+ticker
|
1429
1457
|
footnote="Source: Yahoo Finance, "+str(today)
|
1430
1458
|
plot_line(df2x,colname,collabel,ylabeltxt,titletxt,footnote,power=power)
|
1431
1459
|
"""
|
@@ -1445,7 +1473,8 @@ def predict_stock_trend_by_option(ticker,lastndays=7):
|
|
1445
1473
|
df3.rename(columns={'OTM in Calls%':'OTMinCalls%','OTM in Puts%':'OTMinPuts%'}, inplace = True)
|
1446
1474
|
df3.rename(columns={'OTM Calls in Total%':'OTM Calls/Total%','OTM Puts in Total%':'OTM Puts/Total%'}, inplace = True)
|
1447
1475
|
|
1448
|
-
|
1476
|
+
"""
|
1477
|
+
print("\n ======= Predicting Price Trend via Option Configuration: "+ticker+" =======")
|
1449
1478
|
#设置打印对齐
|
1450
1479
|
pd.set_option('display.max_columns', 1000)
|
1451
1480
|
pd.set_option('display.width', 1000)
|
@@ -1453,14 +1482,32 @@ def predict_stock_trend_by_option(ticker,lastndays=7):
|
|
1453
1482
|
pd.set_option('display.unicode.ambiguous_as_wide', True)
|
1454
1483
|
pd.set_option('display.unicode.east_asian_width', True)
|
1455
1484
|
print(df3.to_string(index=False))
|
1456
|
-
|
1457
|
-
lastdate,lastprice=
|
1485
|
+
"""
|
1486
|
+
#lastdate,lastprice=get_last_close1(ticker)
|
1487
|
+
prices_tmp=security_trend(ticker,graph=False)
|
1488
|
+
lastdate=str(prices_tmp.tail(1).index.values[0].date())
|
1489
|
+
lastprice=str(prices_tmp.tail(1).Close.values[0])
|
1490
|
+
"""
|
1458
1491
|
print(" Note:")
|
1459
1492
|
print(" 1) Recent price:",lastprice,"\b,",lastdate,'\b.')
|
1460
1493
|
print(" 2) +(-) predicts higher(lower) price than recent, ++(--) for more likely, +/- for undetermined trend.")
|
1461
1494
|
print(" 3) Option trade period: recent "+str(lastndays)+" days. No stock splits in the period. Dates with only 1 option removed.")
|
1462
1495
|
#print(" 4) Removed those samples with only one option, if any.")
|
1463
1496
|
print(" "+footnote+'.')
|
1497
|
+
"""
|
1498
|
+
tname=get_stock_name1_en(ticker,short_name=True)
|
1499
|
+
titletxt="Predicting Price Trend via Option Configuration: "+tname
|
1500
|
+
footnote1="Note:\n"
|
1501
|
+
footnote2="1. Recent price: "+lastprice+", "+lastdate+'\n'
|
1502
|
+
footnote3="2. +(-) predicts higher(lower) price than recent, ++(--) more likely, +/- undetermined\n"
|
1503
|
+
footnote4="3. Period: recent "+str(lastndays)+" days. No stock splits in the period. Removed dates with 1 option only\n"
|
1504
|
+
footnote9=footnote1+footnote2+footnote3+footnote4+footnote
|
1505
|
+
|
1506
|
+
df_display_CSS(df3,titletxt=titletxt,footnote=footnote9,facecolor='papayawhip',decimals=2, \
|
1507
|
+
first_col_align='left',second_col_align='right', \
|
1508
|
+
last_col_align='right',other_col_align='right', \
|
1509
|
+
titile_font_size='15px',heading_font_size='13px', \
|
1510
|
+
data_font_size='13px')
|
1464
1511
|
|
1465
1512
|
return df2
|
1466
1513
|
|
@@ -1561,10 +1608,10 @@ def put_timevalue(row):
|
|
1561
1608
|
#==============================================================================
|
1562
1609
|
|
1563
1610
|
if __name__ =="__main__":
|
1564
|
-
ticker='
|
1611
|
+
ticker='AAPL'
|
1565
1612
|
lastndays=2
|
1566
1613
|
|
1567
|
-
def
|
1614
|
+
def price_prospect_via_option(ticker,lastdays=7,cutoff=[1.1,5.0,10.0]):
|
1568
1615
|
"""
|
1569
1616
|
功能:根据股票期权预测股价
|
1570
1617
|
算法:
|
@@ -1575,39 +1622,47 @@ def stock_trend_by_option(ticker,lastndays=7,cutoff=[1.1,5.0,10.0]):
|
|
1575
1622
|
5、否则,为不明确
|
1576
1623
|
返回:股票期权明细
|
1577
1624
|
"""
|
1578
|
-
|
1579
|
-
|
1625
|
+
lastndays=lastdays
|
1626
|
+
|
1627
|
+
DEBUG=False
|
1628
|
+
print("Searching option chain for",ticker,'...',end='')
|
1580
1629
|
|
1581
1630
|
try:
|
1582
1631
|
datelist=option_maturity(ticker,printout=False)
|
1583
1632
|
except:
|
1584
|
-
print("\n #
|
1633
|
+
print("\n #Warning(price_prospect_via_option): option info not found for",ticker)
|
1585
1634
|
return None
|
1586
1635
|
if datelist is None:
|
1587
|
-
print("\n Warning(
|
1636
|
+
print("\n #Warning(price_prospect_via_option): options not found for",ticker)
|
1588
1637
|
return None
|
1589
|
-
print("found",len(datelist),"maturity dates")
|
1638
|
+
print("found",len(datelist),"maturity dates of options")
|
1590
1639
|
|
1591
1640
|
#最新的股价
|
1592
|
-
print("Searching
|
1641
|
+
#print("Searching recent close price for",ticker,'...',end='')
|
1593
1642
|
try:
|
1594
|
-
lastsdate,lastsprice=
|
1643
|
+
#lastsdate,lastsprice=get_last_close1(ticker)
|
1644
|
+
prices_tmp=security_trend(ticker,graph=False)
|
1645
|
+
lastsdate=str(prices_tmp.tail(1).index.values[0].date())
|
1646
|
+
lastsprice=str(prices_tmp.tail(1).Close.values[0])
|
1647
|
+
|
1595
1648
|
except:
|
1596
|
-
print("\n#Error(
|
1649
|
+
print("\n #Error(price_prospect_via_option): failed in retrieving close price for",ticker)
|
1597
1650
|
return None
|
1598
1651
|
if (lastsdate is None) or (lastsprice is None):
|
1599
|
-
print("\n#Error(
|
1652
|
+
print("\n #Error(price_prospect_via_option): retrieving close price failed for",ticker)
|
1600
1653
|
return None
|
1601
|
-
print(lastsprice,'\b,',lastsdate)
|
1654
|
+
if DEBUG: print(lastsprice,'\b,',lastsdate)
|
1602
1655
|
|
1603
1656
|
import pandas as pd
|
1604
1657
|
df=pd.DataFrame(columns=['Ticker','Date','Trend','Estimated Price', \
|
1605
1658
|
'OTM Volume Call/Put','OTM Amount Call/Put','Spot Date','Spot Price'])
|
1606
1659
|
for d in datelist:
|
1607
|
-
|
1660
|
+
print_progress_percent2(d,datelist,steps=5,leading_blanks=4)
|
1661
|
+
|
1662
|
+
if DEBUG: print("Analyzing options matured on",d,'...')
|
1608
1663
|
opt_call,opt_put=option_chain(ticker,d,printout=False)
|
1609
1664
|
if (len(opt_call) == 0) or (len(opt_put) == 0):
|
1610
|
-
print(" #Error(
|
1665
|
+
print(" #Error(price_prospect_via_option): failed in retrieving options matured on",d)
|
1611
1666
|
break
|
1612
1667
|
return None
|
1613
1668
|
currency=list(opt_call['currency'])[0]
|
@@ -1697,7 +1752,7 @@ def stock_trend_by_option(ticker,lastndays=7,cutoff=[1.1,5.0,10.0]):
|
|
1697
1752
|
if DEBUG: print(", done!")
|
1698
1753
|
|
1699
1754
|
#比较虚值看涨/看跌期权的数量和交易金额
|
1700
|
-
if DEBUG: print(" Evaluating
|
1755
|
+
if DEBUG: print(" Evaluating price trend ...",end='')
|
1701
1756
|
rateqty=round(numofotmcalls/numofotmputs,2)
|
1702
1757
|
rateamt=round(amtofotmcalls/amtofotmputs,2)
|
1703
1758
|
trend='+/-'
|
@@ -1737,10 +1792,11 @@ def stock_trend_by_option(ticker,lastndays=7,cutoff=[1.1,5.0,10.0]):
|
|
1737
1792
|
df['date']=df['Date'].apply(todatetime)
|
1738
1793
|
df2=df.set_index(['date'])
|
1739
1794
|
|
1795
|
+
tname=get_stock_name1_en(ticker,short_name=True)
|
1740
1796
|
|
1741
1797
|
#绘图1:虚值Calls vs Puts数量比例
|
1742
1798
|
import datetime
|
1743
|
-
|
1799
|
+
stoday = datetime.date.today()
|
1744
1800
|
|
1745
1801
|
df2['Benchmark']=1.0
|
1746
1802
|
colname1='OTM Volume Call/Put'
|
@@ -1748,9 +1804,9 @@ def stock_trend_by_option(ticker,lastndays=7,cutoff=[1.1,5.0,10.0]):
|
|
1748
1804
|
colname2='Benchmark'
|
1749
1805
|
label2='等比例线'
|
1750
1806
|
ylabeltxt='比例'
|
1751
|
-
titletxt="
|
1807
|
+
titletxt="期权链中的合约数量: "+tname+", 虚值看涨/看跌期权比例"
|
1752
1808
|
|
1753
|
-
footnote="数据来源:雅虎财经, "+str(
|
1809
|
+
footnote="数据来源:雅虎财经, "+str(stoday)
|
1754
1810
|
plot_line2(df2,ticker,colname1,label1, \
|
1755
1811
|
df2,ticker,colname2,label2, \
|
1756
1812
|
ylabeltxt,titletxt,footnote)
|
@@ -1758,9 +1814,8 @@ def stock_trend_by_option(ticker,lastndays=7,cutoff=[1.1,5.0,10.0]):
|
|
1758
1814
|
#绘图2:OTM Calls vs OTM Puts交易金额比例
|
1759
1815
|
colname1='OTM Amount Call/Put'
|
1760
1816
|
label1='虚值看涨/看跌期权交易金额比例'
|
1761
|
-
titletxt="
|
1817
|
+
titletxt="期权链中的交易金额: "+tname+", 虚值看涨/看跌期权比例"
|
1762
1818
|
|
1763
|
-
footnote="数据来源:雅虎财经, "+str(today)
|
1764
1819
|
plot_line2(df2,ticker,colname1,label1, \
|
1765
1820
|
df2,ticker,colname2,label2, \
|
1766
1821
|
ylabeltxt,titletxt,footnote)
|
@@ -1772,9 +1827,8 @@ def stock_trend_by_option(ticker,lastndays=7,cutoff=[1.1,5.0,10.0]):
|
|
1772
1827
|
colname2='Benchmark'
|
1773
1828
|
label2='当前股价'
|
1774
1829
|
ylabeltxt='股价('+currency+')'
|
1775
|
-
titletxt="
|
1830
|
+
titletxt="期权链与标的价格预期: "+tname
|
1776
1831
|
|
1777
|
-
footnote="数据来源:雅虎财经, "+str(today)
|
1778
1832
|
plot_line2(df2,ticker,colname1,label1, \
|
1779
1833
|
df2,ticker,colname2,label2, \
|
1780
1834
|
ylabeltxt,titletxt,footnote)
|
@@ -1782,8 +1836,8 @@ def stock_trend_by_option(ticker,lastndays=7,cutoff=[1.1,5.0,10.0]):
|
|
1782
1836
|
#打印预测结果
|
1783
1837
|
collist=['Date','Trend','Estimated Price','OTM Volume Call/Put','OTM Amount Call/Put']
|
1784
1838
|
df3=df2[collist]
|
1785
|
-
|
1786
|
-
print("\n ======= 基于期权链结构的股票走势和价格预期: "+
|
1839
|
+
"""
|
1840
|
+
print("\n ======= 基于期权链结构的股票走势和价格预期: "+tname+" =======")
|
1787
1841
|
#设置打印对齐
|
1788
1842
|
pd.set_option('display.max_columns', 1000)
|
1789
1843
|
pd.set_option('display.width', 1000)
|
@@ -1799,6 +1853,21 @@ def stock_trend_by_option(ticker,lastndays=7,cutoff=[1.1,5.0,10.0]):
|
|
1799
1853
|
print(" 3) 期权交易样本期间: 最近"+str(lastndays)+"个日历日,且期间内未发生分拆.")
|
1800
1854
|
print(" 4) 股价估计可能随时变化,越远期的估计可能准确度越欠佳.")
|
1801
1855
|
print(" "+footnote+'.')
|
1856
|
+
"""
|
1857
|
+
titletxt="期权链与标的价格预期: "+tname
|
1858
|
+
footnote1="注:\n"
|
1859
|
+
footnote2="1、当前股价: "+currency+str(lastsprice)+", "+lastsdate+'\n'
|
1860
|
+
footnote3="2、+(-)表示股价将比当前变高(低), +/-表示趋势不明朗\n"
|
1861
|
+
footnote4="3、期权交易样本期间: 最近"+str(lastndays)+"个日历日,且期间内未发生分拆\n"
|
1862
|
+
footnote5="4) 股价估计可能随时变化,越远期的估计可能准确度越欠佳\n"
|
1863
|
+
|
1864
|
+
footnote9=footnote1+footnote2+footnote3+footnote4+footnote5+footnote
|
1865
|
+
|
1866
|
+
df_display_CSS(df3,titletxt=titletxt,footnote=footnote9,facecolor='papayawhip',decimals=2, \
|
1867
|
+
first_col_align='left',second_col_align='right', \
|
1868
|
+
last_col_align='right',other_col_align='right', \
|
1869
|
+
titile_font_size='15px',heading_font_size='13px', \
|
1870
|
+
data_font_size='13px')
|
1802
1871
|
|
1803
1872
|
return df2
|
1804
1873
|
|
siat/sector_china.py
CHANGED
@@ -3065,7 +3065,7 @@ if __name__=='__main__':
|
|
3065
3065
|
|
3066
3066
|
find_industry_sw(ticker)
|
3067
3067
|
|
3068
|
-
def find_industry_sw(ticker,level='1',ticker_order=True,max_sleep=
|
3068
|
+
def find_industry_sw(ticker,level='1',ticker_order=True,max_sleep=10):
|
3069
3069
|
"""
|
3070
3070
|
功能:寻找一只或一组股票所属的申万行业,支持股票代码和股票名称。
|
3071
3071
|
level='1':默认只查找申万1级行业,以便节省时间
|
@@ -3188,8 +3188,115 @@ def find_industry_sw(ticker,level='1',ticker_order=True,max_sleep=8):
|
|
3188
3188
|
return result
|
3189
3189
|
|
3190
3190
|
#==============================================================================
|
3191
|
+
#东方财富板块分类:查找股票所属行业与主要同行
|
3191
3192
|
#==============================================================================
|
3192
|
-
|
3193
|
+
if __name__=='__main__':
|
3194
|
+
ticker='600519.SS'
|
3195
|
+
indicator="市盈率"
|
3196
|
+
rank=40
|
3197
|
+
|
3198
|
+
font_size="16px"; facecolor="papayawhip"
|
3199
|
+
|
3200
|
+
peers=stock_peer_em(ticker,indicator="市盈率",rank=10)
|
3201
|
+
|
3202
|
+
def stock_peer_em(ticker,indicator="市盈率",rank=10, \
|
3203
|
+
font_size="16px",facecolor="papayawhip"):
|
3204
|
+
"""
|
3205
|
+
功能:基于东方财富行业分类,查找股票所属的行业板块以及主要同行
|
3206
|
+
特点:行业板块分类较粗糙,略胜于无
|
3207
|
+
"""
|
3208
|
+
if indicator in ["股价","股票价格","价格","收盘价","价位"]:
|
3209
|
+
indicator="最新价"
|
3210
|
+
if indicator in ["流动性","热门","活跃"]:
|
3211
|
+
indicator="换手率"
|
3212
|
+
|
3213
|
+
if rank==0:
|
3214
|
+
rank=5
|
3215
|
+
|
3216
|
+
import akshare as ak
|
3217
|
+
|
3218
|
+
#股票基本信息
|
3219
|
+
try:
|
3220
|
+
info=ak.stock_individual_info_em(symbol=ticker[:6])
|
3221
|
+
except:
|
3222
|
+
print(" #Warning(stock_peer_em): stock info not found for",ticker,"\n")
|
3223
|
+
df_em=ak.stock_board_industry_name_em()
|
3224
|
+
#df_em.sort_values(by="板块名称",ascending=True,inplace=True)
|
3225
|
+
#industry_names_em=sorted(list(df_em["板块名称"]),reverse=True)
|
3226
|
+
industry_names_em=list(df_em["板块名称"])
|
3227
|
+
print(" List of sectors/industries in East Money:",len(df_em))
|
3228
|
+
printlist(industry_names_em,numperline=7,beforehand=' ')
|
3229
|
+
|
3230
|
+
return None
|
3231
|
+
|
3232
|
+
#东方财富板块名称
|
3233
|
+
hangye=info[info['item']=='行业']['value'].values[0]
|
3234
|
+
|
3235
|
+
#东方财富板块成分股
|
3236
|
+
cfg=ak.stock_board_industry_cons_em(symbol=hangye)
|
3237
|
+
|
3238
|
+
cfg_col_list=list(cfg)
|
3239
|
+
indicator_col=''
|
3240
|
+
for i in cfg_col_list:
|
3241
|
+
if indicator in i:
|
3242
|
+
indicator_col=i
|
3243
|
+
if indicator_col=='':
|
3244
|
+
print(" #Warning(stock_peer_em): unsupported indicator",indicator)
|
3245
|
+
|
3246
|
+
remove_list=["序号","代码","名称"]
|
3247
|
+
cfg_col_list_tmp = [x for x in cfg_col_list if x not in remove_list]
|
3248
|
+
print(" Supported indicators:",)
|
3249
|
+
print_list(cfg_col_list_tmp,leading_blanks=2)
|
3250
|
+
return None
|
3251
|
+
|
3252
|
+
collist=['序号','名称','代码','市盈率-动态','市净率','最新价','涨跌幅','换手率']
|
3253
|
+
if not indicator_col in collist:
|
3254
|
+
collist=collist+[indicator_col]
|
3255
|
+
|
3256
|
+
#重新排序
|
3257
|
+
cfg.sort_values(by=indicator_col,ascending=False,inplace=True)
|
3258
|
+
cfg.reset_index(drop=True,inplace=True)
|
3259
|
+
cfg['序号']=cfg.index+1
|
3260
|
+
|
3261
|
+
#行业均值与中位数
|
3262
|
+
indicator_mean=cfg[indicator_col].mean()
|
3263
|
+
indicator_median=cfg[indicator_col].median()
|
3264
|
+
indicator_total=cfg["代码"].count()
|
3265
|
+
|
3266
|
+
indicator_value=cfg[cfg['代码']==ticker[:6]][indicator_col].values[0]
|
3267
|
+
indicator_seq=cfg[cfg['代码']==ticker[:6]]["序号"].values[0]
|
3268
|
+
from scipy.stats import percentileofscore
|
3269
|
+
indicator_pct=percentileofscore(cfg[indicator_col],indicator_value)
|
3270
|
+
|
3271
|
+
#筛选
|
3272
|
+
if rank > 0:
|
3273
|
+
rank_flag="前"
|
3274
|
+
df_disp=cfg[collist].head(rank)
|
3275
|
+
else:
|
3276
|
+
rank_flag="后"
|
3277
|
+
df_disp=cfg[collist].tail(abs(rank))
|
3278
|
+
|
3279
|
+
#制表
|
3280
|
+
tname=ticker_name(ticker)
|
3281
|
+
titletxt="行业板块及其上市公司排名:"+hangye+","+indicator_col+"("+rank_flag+str(abs(rank))+"名)"
|
3282
|
+
|
3283
|
+
footnote1="全行业的"+indicator_col+"状况:均值"+str(round(indicator_mean,2))+",中位数"+str(round(indicator_median,2))+"\n"
|
3284
|
+
footnote2=tname+"的"+indicator_col+":"+str(round(indicator_value,2))+",行业排名"+str(indicator_seq)+"/"+str(indicator_total)+",分位数"+str(round(indicator_pct,2))+"%\n"
|
3285
|
+
import datetime; stoday = datetime.date.today()
|
3286
|
+
footnote3="*** 信息来源:东方财富,"+str(stoday)
|
3287
|
+
footnote=footnote1+footnote2+footnote3
|
3288
|
+
|
3289
|
+
#确定表格字体大小
|
3290
|
+
titile_font_size=font_size
|
3291
|
+
heading_font_size=data_font_size=str(int(font_size.replace('px',''))-1)+'px'
|
3292
|
+
|
3293
|
+
df_display_CSS(df_disp,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
3294
|
+
first_col_align='center',second_col_align='left', \
|
3295
|
+
titile_font_size=titile_font_size,heading_font_size=heading_font_size, \
|
3296
|
+
data_font_size=data_font_size)
|
3297
|
+
|
3298
|
+
return cfg
|
3299
|
+
|
3193
3300
|
|
3194
3301
|
|
3195
3302
|
|
siat/security_prices.py
CHANGED
@@ -2386,6 +2386,7 @@ if __name__ =="__main__":
|
|
2386
2386
|
#==============================================================================
|
2387
2387
|
if __name__ =="__main__":
|
2388
2388
|
ticker='AAPL'
|
2389
|
+
get_last_close(ticker)
|
2389
2390
|
|
2390
2391
|
def get_last_close(ticker):
|
2391
2392
|
"""
|
@@ -2397,22 +2398,24 @@ def get_last_close(ticker):
|
|
2397
2398
|
"""
|
2398
2399
|
#获取今日日期
|
2399
2400
|
import datetime
|
2400
|
-
|
2401
|
-
fromdate = date_adjust(
|
2401
|
+
stoday = datetime.date.today()
|
2402
|
+
fromdate = date_adjust(stoday,-30)
|
2403
|
+
todate=str(stoday)
|
2402
2404
|
|
2403
2405
|
#抓取新浪/stooq股票价格
|
2404
|
-
from pandas_datareader import data
|
2405
2406
|
try:
|
2406
|
-
price=
|
2407
|
+
#price,found=get_price_1ticker_mixed(ticker,fromdate=fromdate,todate=todate,source='yahoo')
|
2408
|
+
price,found=get_price_1ticker_mixed(ticker,fromdate=fromdate,todate=todate)
|
2407
2409
|
except:
|
2408
|
-
print("\n #Error(get_last_close): failed in retrieving prices
|
2410
|
+
print("\n #Error(get_last_close): failed in retrieving prices for",ticker)
|
2409
2411
|
return None,None
|
2410
2412
|
if price is None:
|
2411
|
-
print("\n #Error(get_last_close): retrieved none info
|
2413
|
+
print("\n #Error(get_last_close): retrieved none info for",ticker)
|
2412
2414
|
return None,None
|
2413
2415
|
if len(price)==0:
|
2414
|
-
print("\n #Error(get_last_close): retrieved empty info
|
2416
|
+
print("\n #Error(get_last_close): retrieved empty info for",ticker)
|
2415
2417
|
return None,None
|
2418
|
+
|
2416
2419
|
price['date']=price.index
|
2417
2420
|
datecvt=lambda x:x.strftime("%Y-%m-%d")
|
2418
2421
|
price['date']=price['date'].apply(datecvt)
|
siat/translate.py
CHANGED
@@ -1263,6 +1263,7 @@ def codetranslate0(code):
|
|
1263
1263
|
|
1264
1264
|
#期货==================================================================
|
1265
1265
|
["HG=F",'COMEX铜矿石期货'],["CL=F",'NYM原油期货'],
|
1266
|
+
["6B=F",'CME英镑兑美元期货'],
|
1266
1267
|
["S=F",'CBT大豆期货'],["C=F",'CBT玉米期货'],
|
1267
1268
|
["ES=F",'CME标普500指数期货'],["YM=F",'CBT道指期货'],
|
1268
1269
|
["NQ=F",'CME纳指100期货'],["RTY=F",'罗素2000指数期货'],
|
@@ -2085,6 +2086,7 @@ def codetranslate1(code):
|
|
2085
2086
|
|
2086
2087
|
#期货==================================================================
|
2087
2088
|
["HG=F",'COMEX铜矿石期货'],["CL=F",'NYM原油期货'],
|
2089
|
+
["6B=F",'CME英镑兑美元期货'],
|
2088
2090
|
["S=F",'CBT大豆期货'],["C=F",'CBT玉米期货'],
|
2089
2091
|
["ES=F",'CME标普500指数期货'],["YM=F",'CBT道指期货'],
|
2090
2092
|
["NQ=F",'CME纳指100期货'],["RTY=F",'罗素2000指数期货'],
|
@@ -18,7 +18,7 @@ siat/capm_beta.py,sha256=cxXdRVBQBllhbfz1LeTJAIWvyRYhW54nhtNUXv4HwS0,29063
|
|
18
18
|
siat/capm_beta2.py,sha256=lUuCPVSxebkA2yye1PXu1V2Jd2UKEwD_kIA25DCIDTs,29750
|
19
19
|
siat/capm_beta_test.py,sha256=ImR0c5mc4hIl714XmHztdl7qg8v1E2lycKyiqnFj6qs,1745
|
20
20
|
siat/cmat_commons.py,sha256=Nj9Kf0alywaztVoMVeVVL_EZk5jRERJy8R8kBw88_Tg,38116
|
21
|
-
siat/common.py,sha256=
|
21
|
+
siat/common.py,sha256=UBmP_PES09tiht6K_DlM08BLlXGC-_CFB4FqoCORu9c,151695
|
22
22
|
siat/compare_cross.py,sha256=3iP9TH2h3w27F2ARZc7FjKcErYCzWRc-TPiymOyoVtw,24171
|
23
23
|
siat/compare_cross_test.py,sha256=xra5XYmQGEtfIZL2h-GssdH2hLdFIhG3eoCrkDrL3gY,3473
|
24
24
|
siat/concepts_iwencai.py,sha256=m1YEDtECRT6FqtzlKm91pt2I9d3Z_XoP59BtWdRdu8I,3061
|
@@ -60,13 +60,13 @@ siat/future_china.py,sha256=F-HsIf2Op8Z22RzTjet1g8COzldgnMjFNSXsAkeGyWo,17595
|
|
60
60
|
siat/future_china_test.py,sha256=BrSzmDVaOHki6rntOtosmRn-6dkfOBuLulJNqh7MOpc,1163
|
61
61
|
siat/global_index_test.py,sha256=hnFp3wqqzzL-kAP8mgxDZ54Bd5Ijf6ENi5YJlGBgcXw,2402
|
62
62
|
siat/google_authenticator.py,sha256=ZUbZR8OW0IAKDbcYtlqGqIpZdERpFor9NccFELxg9yI,1637
|
63
|
-
siat/grafix.py,sha256=
|
63
|
+
siat/grafix.py,sha256=dFec-2Ds76JEfvsMj2HS-gHcufv3vpsWe4LwpNX_XoM,87219
|
64
64
|
siat/grafix_test.py,sha256=kXvcpLgQNO7wd30g_bWljLj5UH7bIVI0_dUtXbfiKR0,3150
|
65
65
|
siat/holding_risk.py,sha256=G3wpaewAKF9CwEqRpr4khyuDu9SU2EGyQUHdk7cmHOA,30693
|
66
66
|
siat/holding_risk_test.py,sha256=FRlw_9wFG98BYcg_cSj95HX5WZ1TvkGaOUdXD7-V86s,474
|
67
67
|
siat/local_debug_test.py,sha256=CDAOffW1Rvs-TcNN5giWVvHMlch1w4dp-w5SIV9jXL0,3936
|
68
68
|
siat/luchy_draw.py,sha256=8Ue-NKnvSVqINPY1eXat0NJat5MR-gex_K62aOYFdmA,20486
|
69
|
-
siat/market_china.py,sha256=
|
69
|
+
siat/market_china.py,sha256=fQjAFyu4JAqtVA8I1QYfzv0fmYhLP3zoNe5Ftk63qgM,50724
|
70
70
|
siat/markowitz.py,sha256=DsfS6vG9TAfdJP4GgN-CCArujPi84XjD23CWbxaA2o4,97627
|
71
71
|
siat/markowitz2-20240620.py,sha256=irZAPnjaatFsKQmFRMENP-cO6bEUl2narYtkU5NKTWI,108019
|
72
72
|
siat/markowitz2.py,sha256=LK2pDEtE5PUmBtCHmCcRs8FlPqZKmhFXiuLIL4JeQa8,121991
|
@@ -80,9 +80,9 @@ siat/markowitz_test2.py,sha256=FcVZqYU5va4567WGUVUJ7cMQdVbBGxeBAz82Y3BhCTI,2193
|
|
80
80
|
siat/ml_cases.py,sha256=FYDk0O7l9hhHlbrlOVGgbH-h2DA503lhKFi9XugH1f0,86874
|
81
81
|
siat/ml_cases_example.py,sha256=xRGb3YTQEDTOnaWNzZN_myU5umQnA2RdMNiPrxTmn9c,1673
|
82
82
|
siat/ml_cases_example1.py,sha256=xRGb3YTQEDTOnaWNzZN_myU5umQnA2RdMNiPrxTmn9c,1673
|
83
|
-
siat/option_china.py,sha256=
|
83
|
+
siat/option_china.py,sha256=0eIWy5-0L8fECVwakVoA8EUO-_5u5jGW66dVLRi1_PY,120954
|
84
84
|
siat/option_china_test.py,sha256=UQ-YUHUjoGBQyanLcM-yzqeEIUQP_gCQIeT0W6rnUnA,16355
|
85
|
-
siat/option_pricing.py,sha256=
|
85
|
+
siat/option_pricing.py,sha256=VEqe7VbPkdWX8lS7fJaL1GF9cQx2HRe3UBI2XZJouBQ,73237
|
86
86
|
siat/option_pricing_test.py,sha256=eeorV5Ja5vjlRXnP6fWJHetGU5Vb8SnLopkC6RV3GfA,2203
|
87
87
|
siat/option_sina_api_test.py,sha256=dn-k_wrQnAaNKHoROvWJEc7lqlU0bwiV2Aa4usWAFGM,5908
|
88
88
|
siat/proxy_test.py,sha256=erQJrmGs2X46z8Gb1h-7GYQ0rTUcaR8dxHExWoBz2eM,2610
|
@@ -94,11 +94,11 @@ siat/risk_evaluation.py,sha256=I6B3gty-t--AkDCO0tKF-291YfpnF-IkXcFjqNKCt9I,76286
|
|
94
94
|
siat/risk_evaluation_test.py,sha256=YEXM96gKzTfwN4U61AS4Rr1tV7KgUvn4rRC6f3iMw9s,3731
|
95
95
|
siat/risk_free_rate.py,sha256=ZMr4cHikPvXvywr54gGqiI3Nvb69am6tq3zj2hwzANE,12384
|
96
96
|
siat/risk_free_rate_test.py,sha256=CpmhUf8aEAEZeNu4gvWP2Mz2dLoIgBX5bI41vfUBEr8,4285
|
97
|
-
siat/sector_china.py,sha256=
|
97
|
+
siat/sector_china.py,sha256=y07Yh8t_LKc7MPOeOw6sTNgzmJR6vgYyLVUY9XB3rCU,122864
|
98
98
|
siat/sector_china_test.py,sha256=1wq7ef8Bb_L8F0h0W6FvyBrIcBTEbrTV7hljtpj49U4,5843
|
99
99
|
siat/security_price.py,sha256=2oHskgiw41KMGfqtnA0i2YjNNV6cYgtlUK0j3YeuXWs,29185
|
100
100
|
siat/security_price2.py,sha256=65s64L68aRZdVVK3V8UYxdPd_JHMqgJ2FBJJX5MSW-Q,26174
|
101
|
-
siat/security_prices.py,sha256=
|
101
|
+
siat/security_prices.py,sha256=ZEnuKgLnkw1O41BpR44Mpq53N69mW3UdSzEnI_4LuPc,106387
|
102
102
|
siat/security_prices_test.py,sha256=OEphoJ87NPKoNow1QA8EU_5MUYrJF-qKoWKNapVfZNI,10779
|
103
103
|
siat/security_trend.py,sha256=o0vpWdrJkmODCP94X-Bvn-w7efHhj9HpUYBHtLl55D0,17240
|
104
104
|
siat/security_trend2-20240620.py,sha256=QVnEcb7AyVbO77jVqfFsJffGXrX8pgJ9xCfoAKmWBPk,24854
|
@@ -131,7 +131,7 @@ siat/transaction_test.py,sha256=Z8g1LJCN4-mnUByXMUMoFmN0t105cbmsz2QmvSuIkbU,1858
|
|
131
131
|
siat/translate-20230125.py,sha256=NPPSXhT38s5t9fzMvl_fvi4ckSB73ThLmZetVI-xGdU,117953
|
132
132
|
siat/translate-20230206.py,sha256=-vtI125WyaJhmPotOpDAmclt_XnYVaWU9ByLWZ6FyYE,118133
|
133
133
|
siat/translate-20230215.py,sha256=TJgtPE3n8IjljmZ4Pefy8dmHoNdFF-1zpML6BhA9FKE,121657
|
134
|
-
siat/translate.py,sha256=
|
134
|
+
siat/translate.py,sha256=Nspy2Ts2QTqWcqH94BXHO7OjnNvYOCqfPCcwTFoWwxc,218285
|
135
135
|
siat/translate_20240606.py,sha256=63IyHWEU3Uz9mjwyuAX3fqY4nUMdwh0ICQAgmgPXP7Y,215121
|
136
136
|
siat/universal_test.py,sha256=CDAOffW1Rvs-TcNN5giWVvHMlch1w4dp-w5SIV9jXL0,3936
|
137
137
|
siat/valuation.py,sha256=NKfeZMdDJOW42oLVHob6eSVBXUqlN1OCnnzwyGAst8c,48855
|
@@ -139,7 +139,7 @@ siat/valuation_china.py,sha256=EkZQaVkoBjM0c4MCNbaX-bMnlG0e3FXeaWczZDnkptU,67784
|
|
139
139
|
siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
|
140
140
|
siat/var_model_validation.py,sha256=R0caWnuZarrRg9939hxh3vJIIpIyPfvelYmzFNZtPbo,14910
|
141
141
|
siat/yf_name.py,sha256=H1EM8YYXA8nQHIqsJlso0I3HKPiJLT3QujO4gRVQXWs,13945
|
142
|
-
siat-3.4.
|
143
|
-
siat-3.4.
|
144
|
-
siat-3.4.
|
145
|
-
siat-3.4.
|
142
|
+
siat-3.4.9.dist-info/METADATA,sha256=JWFmtzgZF0_L_HvISH6Cy_rbSOykNGFnSx0vUHqpEMA,7682
|
143
|
+
siat-3.4.9.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
144
|
+
siat-3.4.9.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
145
|
+
siat-3.4.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|