【发布时间】:2017-08-10 22:57:41
【问题描述】:
我需要从已经包含数据的数组中创建一个 DataFrame。我是 Python 新手,不知道我是否需要迭代(无论如何都需要 CALL 估值)。
基本上我需要从数字数组 SPREAD 中创建一个数据框
import numpy as np
import pandas as pd
def call_price ( precio, strike, time, volat):
r = 0.02 # riskless short rate
I = 100000 # number of simulations
z = np.random.standard_normal(I) # pseudorandom numbers
ST = precio * np.exp((r - 0.5 * volat ** 2) * time + volat * np.sqrt(time) * z)
hT = np.maximum(ST - strike, 0) # inner values at maturity
C0 = np.exp(-r * time) * np.sum(hT) / I # Monte Carlo estimator
return (C0)
precios = [2300,2400,2500,2600,2700,2800]
for i in range(6):
precio_call = call_price(precios[i],2400,0.333,0.09)
spread = precios[i] - precio_call
print(spread)
#df = pd.DataFrame(spread) #it doesn't work
【问题讨论】:
标签: python arrays pandas options finance