Redian新闻
>
这里的博士,博士后最好还是先研究一下
avatar
这里的博士,博士后最好还是先研究一下# Stock
r*t
1
Black-Scholes formula

binomial lattice method
再来玩option
我自己正在结合自己的操作经验 + 历史数据蒙特卡洛分析 + binomial lattice
method
生成一个超级option交易机器,貌似比较有帮助的说。
avatar
x*i
2
我觉得这玩艺有点用烂了。
我正在搞一个新算法。貌似可以赚大钱。
最近没空,过一阵实现一下。
avatar
s*n
3
pro每天都在算,世界上计算次数最多的公式。
散户有用没用不清楚。

【在 r*****t 的大作中提到】
: Black-Scholes formula
: 和
: binomial lattice method
: 再来玩option
: 我自己正在结合自己的操作经验 + 历史数据蒙特卡洛分析 + binomial lattice
: method
: 生成一个超级option交易机器,貌似比较有帮助的说。

avatar
r*t
4
using System;
namespace QFramework
{
///
/// Represents a Cox-Ross-Rubenstein binomial tree option pricing
calculator. May be used for pricing European or American options
///

public class BinomialTree
{
#region "Private Members"
private double assetPrice = 0.0;
private double strike = 0.0;
private double timeStep = 0.0;
private double volatility = 0.0;
private EPutCall putCall = EPutCall.Call;

private double riskFreeRate = 0.0;
private int steps = 0;

#endregion
#region "Properties'
public double AssetPrice
{
get { return assetPrice;}
set { assetPrice = value; }
}
public double Strike
{
get { return strike; }
set { strike = value; }
}
public double TimeStep
{
get { return timeStep; }
set { timeStep = value; }
}
public double Volatility
{
get { return volatility; }
set { volatility = value; }
}
public EPutCall PutCall
{
get { return putCall; }
set{ putCall = value; }
}
public double RiskFreeRate
{
get { return riskFreeRate; }
set { riskFreeRate = value; }
}
public int Steps
{
get { return steps; }
set { steps = value; }
}
#endregion
#region "Constructors"
///
/// Empty constructor. All properties may be set.
///

public BinomialTree()
{
}
///
/// Constructor that takes all parameters used for calculatin option
value using binomial tree
///

///
///
///
///
///
///
///
///
public BinomialTree(
double assetPriceParam,
double strikeParam,
double timeStepParam,
double volatilityParam,
double riskFreeRateParam,
EPutCall putCallParam,
int stepsParam)
{
assetPrice = assetPriceParam;
strike = strikeParam;
volatility = volatilityParam;
timeStep = timeStepParam;
riskFreeRate = riskFreeRateParam;
putCall = putCallParam;
steps = stepsParam;
}
#endregion
#region "Binomial Tree"
///
/// Part of the binomial node value equation, represents the
binomial coefficient
///

///
///
///
private double BinomialCoefficient(int m, int n)
{
return Factorial(n) / (Factorial(m) * Factorial(n - m));
}
///
/// Calculates the value of an individual node in the binomial tree
///

///
///
///
///
private double BinomialNodeValue(int m, int n, double p)
{
return BinomialCoefficient(m, n) * Math.Pow(p, (double)m) * Math
.Pow(1.0 - p, (double)(n - m));
}
///
/// Returns the present value of the option
///

///
public double OptionValue()
{
double totalValue = 0.0;
double u = OptionUp(timeStep, volatility, steps);
double d = OptionDown(timeStep, volatility, steps);
double p = Probability(timeStep, volatility, steps, riskFreeRate
);
double nodeValue = 0.0;
double payoffValue= 0.0;
for (int j = 0; j <= steps; j++)
{
payoffValue = Payoff(AssetPrice * Math.Pow(u, (double)j) *
Math.Pow(d, (double)(steps - j)), strike, putCall);
nodeValue = BinomialNodeValue(j, steps, p);
totalValue += nodeValue * payoffValue;
}
return PresentValue(totalValue, riskFreeRate, timeStep);
}
#endregion
#region "Probabilities"
private double OptionUp(double t, double s, int n)
{
return Math.Exp(s * Math.Sqrt(t / n));
}
private double OptionDown(double t, double s, int n)
{
return Math.Exp(-s * Math.Sqrt(t / n));
}
private double Probability(double t, double s, int n, double r)
{
double d1 = FutureValue(1.0, r, t / n);
double d2 = OptionUp(t, s, n);
double d3 = OptionDown(t, s, n);
return (d1 - d3) / (d2 - d3);
}
#endregion

#region "Payoffs"
private double Payoff(double S, double X, EPutCall PutCall)
{
switch (PutCall)
{
case EPutCall.Call:
return Call(S, X);
case EPutCall.Put:
return Put(S, X);
default:
return 0.0;
}
}
private double Call(double S, double X)
{
return Math.Max(0.0, S - X);
}
private double Put(double S, double X)
{
return Math.Max(0.0, X - S);
}
#endregion
#region "Financial Math Utility Functions"
private double Factorial(int n)
{
double d = 1.0;
for (int j = 1; j <= n; j++)
{
d *= j;
}
return d;
}
private double FutureValue(double P, double r, double n)
{
return P * Math.Pow(1.0 + r, n);
}
private double PresentValue(double F, double r, double n)
{
return F / Math.Exp(r * n);
}
#endregion

}
}
avatar
c*r
5
迂腐
avatar
x*i
6
写的蛮不赖。你这个算法是连IB的么?
avatar
x*i
7
迂腐p阿,用专业武器打游击战才是正道。支持楼主。
avatar
z*n
8
hehe, open source code is free

【在 r*****t 的大作中提到】
: Black-Scholes formula
: 和
: binomial lattice method
: 再来玩option
: 我自己正在结合自己的操作经验 + 历史数据蒙特卡洛分析 + binomial lattice
: method
: 生成一个超级option交易机器,貌似比较有帮助的说。

avatar
z*n
9
I'm using QT too, hehe
daniu

【在 r*****t 的大作中提到】
: using System;
: namespace QFramework
: {
: ///
: /// Represents a Cox-Ross-Rubenstein binomial tree option pricing
: calculator. May be used for pricing European or American options
: ///

: public class BinomialTree
: {
: #region "Private Members"

avatar
r*9
10
傻得可爱

【在 r*****t 的大作中提到】
: Black-Scholes formula
: 和
: binomial lattice method
: 再来玩option
: 我自己正在结合自己的操作经验 + 历史数据蒙特卡洛分析 + binomial lattice
: method
: 生成一个超级option交易机器,貌似比较有帮助的说。

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。