由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Quant版 - 在看High Frequency Trading这本书,Irene Aldridge 写的
相关主题
诚心请问两个offer选择one algorithm problem
求建议:是不是放弃工作去读MFE求面经~~(Lehman)
刚刚电话interview完,提供题目请大家出一个主意
[Tokyo]Quant Strategist: FX Hi-Frequency TradingA hedge fund interview questions (CS)
[合集] 一道面试c程序题Who has txt file contents major ticker symbols?
[合集] 几道经典的面试老题high frequency应该看些什么书呢?
[合集] high frequency time series analysis的书high frequency options trading
[合集] one interview question about C谁讲讲fixed income 和equity market
相关话题的讨论汇总
话题: stddiff话题: avgdiff话题: close1话题: dates1话题: close2
进入Quant版参与讨论
1 (共1页)
s****d
发帖数: 14
1
http://www.hftradingbook.com/content/index.php?option=com_jumi&
Statistical Arbitrage(cpp文件)
内容如下:
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
void AnalyzePair(char* symbol1, char* symbol2)
{
double close1[100] = {0};
int n1 = 0, dates1[100] = {0};
double close2[100] = {0};
int n2 = 0, dates2[100] = {0};
double avgdiff = 0;
double stddiff = 0;
double nStdDevs = 2;
double minInfoRatio = 1;
double infoRatio = 0;
double closediff = 0;
double ub = 0;
double lb = 0;
// LoadPriceHistory is a function that populates arrays
// close1 and dates1 with closing prices and dates/times,
// respectively. n1 is the returned number of elements in
// arrays close1 and dates1.
// LoadPriceHistory has the following specification:
// void LoadPriceHistory(char * symbol, double* c, int* dates,
int* n)
//
LoadPriceHistory(symbol1, close1, dates1, &n1);
LoadPriceHistory(symbol2, close2, dates2, &n2);
int i = 0, j, k;
double n = (double)n2;
if(n1 < n2)
n = (double)n1;
if((n1 == 0) | (n2 == 0))
return;
if(n1 != n2)
{
//align dates
for(i = 0; i {
if(dates1[i] < dates2[i])
{
for(j = i; j {
if(dates2[j] == dates1[i])
break;
}
k = i;
while(j < n2)
{
dates2[k] = dates2[j];
high2[k] = high2[j];
low2[k] = low2[j];
close2[k] = close2[j];
j++;
k++;
}
}
if(dates1[i] > dates2[i])
{
for(j = i; j {
if(dates2[j] == dates1[i])
break;
}
k = i;
while(j < n1)
{
dates1[k] = dates1[j];
high1[k] = high1[j];
low1[k] = low1[j];
close1[k] = close1[j];
j++;
k++;
}
}
}
n = i;
}
if(n == 0)
return;
//compute avg and std out of sample for N=30
//calculate %accuracy the following day
double pctAccuracy = 0, sampleSize = 0;
int buy= 0, sell = 0;
avgdiff = 0;
stddiff = 0;
buy= 0;
sell = 0;
for(i = 1; i<31; i++)
{
avgdiff += close1[i] - close2[i];
}
avgdiff = avgdiff/n;
for(i = 1; i<31; i++)
{
stddiff += pow((close1[i] - close2[i] - avgdiff), 2);
}
stddiff = stddiff/(n-1);
stddiff = pow(stddiff, 0.5);
//
if(stddiff > 0)
{
infoRatio = stddiff/fabs(avgdiff);
if(infoRatio < minInfoRatio)
{
if(close1[0] - close2[0] < avgdiff - nStdDevs*stddiff)
buy = 1; //buy symbol 1 and sell symbol 2
if(close1[0] - close2[0] > avgdiff + nStdDevs*stddiff)
sell = 1; //buy symbol 2 and sell symbol 1
if((buy == 1) | (sell == 1))
{
closediff = close1[0] - close2[0];
ub = avgdiff + nStdDevs*stddiff;
lb = avgdiff - nStdDevs*stddiff;
if(buy)
printf("%s is underpriced relative to %sn", symbol1,
symbol2);
else
printf("%s is underpriced relative to %sn", symbol2,
symbol1);
}
}
}
return;
}
有2个问题问下版上的童鞋:
1,找不到LoadPriceHistory这个函数如何定义的,
2,请问谁知道这个程序该如何用吗,就是在哪个软件平台使用这个cpp文件
c*******y
发帖数: 1630
2
这本是科普书,这个女的也就写写科普了。不记得这本书里面有code啊?
要了解点HFT,all about 那本书要好得多,不过这产业已经退烧了吧。

//
//
//

【在 s****d 的大作中提到】
: http://www.hftradingbook.com/content/index.php?option=com_jumi&
: Statistical Arbitrage(cpp文件)
: 内容如下:
: ////////////////////////////////////////////////////////////////////////////
: ////////////////////////////////////////////////////////////////////////////
: ////////////////////////////////////////////////////////////////////////////
: void AnalyzePair(char* symbol1, char* symbol2)
: {
: double close1[100] = {0};
: int n1 = 0, dates1[100] = {0};

B******5
发帖数: 4676
3
就是个范例,这还能run?
s****d
发帖数: 14
4
不过这产业已经退烧了吧
咋讲,高频交易不流行了?那现在什么流行?
1 (共1页)
进入Quant版参与讨论
相关主题
谁讲讲fixed income 和equity market[合集] 一道面试c程序题
Quant Role for High Frequency Algo Trading![合集] 几道经典的面试老题
High Frequency Trading Analyst / Quant Research[合集] high frequency time series analysis的书
high frequency trading shop面经[合集] one interview question about C
诚心请问两个offer选择one algorithm problem
求建议:是不是放弃工作去读MFE求面经~~(Lehman)
刚刚电话interview完,提供题目请大家出一个主意
[Tokyo]Quant Strategist: FX Hi-Frequency TradingA hedge fund interview questions (CS)
相关话题的讨论汇总
话题: stddiff话题: avgdiff话题: close1话题: dates1话题: close2