欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → hurst指数【VBA算法转换】

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有5358人关注过本帖树形打印复制链接

主题:hurst指数【VBA算法转换】

帅哥哟,离线,有人找我吗?
winsentess
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:10 积分:11 威望:0 精华:0 注册:2013/4/26 22:14:10
hurst指数【VBA算法转换】  发帖心情 Post By:2013/5/23 10:19:22    Post IP:116.233.161.54[只看该作者]

据资料表明,hurst指数构建的交易策略收益率奇高,欲证明其真实性,想自己构建此策略来尝试验证;无奈在金字塔里无法实现其算法,麻烦版主及金字塔高手帮忙转换,万分感谢。excel VBA源码如下:
Option Base 1
'This program calculates an estimate of the Hurst coefficient.
'Written by Martin Sewell <martin@martinsewell.com>
Sub Hurst()
Dim Data()
Dim Array1()
Dim Array2()
Dim Mean
Dim Result()

Dim NoOfDataPoints As Integer

Dim NoOfPlottedPoints As Integer
Dim PlottedPointNo As Integer

Dim NoOfPeriods As Integer
Dim PeriodNo As Integer

Dim N As Integer
Dim i As Integer
Dim m As Integer
Dim logten
Dim R
Dim S
Dim RS
Dim SumSquared

logten = Log(10)

'Delete any previous results
Worksheets("Data").Range("C3").Value = Null
Worksheets("Data").Range("D").Value = Null
Worksheets("Data").Range("E:E").Value = Null

'Get total number of data points
NoOfDataPoints = Worksheets("Data").Range("C1").Value

ReDim Data(NoOfDataPoints)

'Get data, ignoring any spaces
i = 1
counter = 1
Do While counter <= NoOfDataPoints
Set curCell = Worksheets("Data").Cells(i, 1)
If Application.WorksheetFunction.IsNumber(curCell.Value) Then
Data(counter) = curCell.Value
counter = counter + 1
End If
i = i + 1
Loop

NoOfPlottedPoints = NoOfDataPoints - 2
ReDim Result(NoOfPlottedPoints, 2)

'Begin main loop
For N = 3 To NoOfDataPoints

totalR = 0
totalS = 0

NoOfPeriods = NoOfDataPoints - N + 1

For PeriodNo = 1 To NoOfPeriods
ReDim Array1(N)
ReDim Array2(N)

For i = 1 To N
Array1(i) = Data((PeriodNo - 1) + i)
Array2(i) = 0
Next i
Summ = 0
SumSquared = 0
For i = 1 To N
Summ = Summ + Array1(i)
SumSquared = SumSquared + ((Array1(i)) * (Array1(i)))

Next i
Mean = Summ / N
'STDEV
'S = Sqr((SumSquared - (Summ * Summ) / N) / (N - 1))

'STDEVP
S = Sqr((SumSquared - (Summ * Summ) / N) / N)

For i = 1 To N
Array1(i) = Array1(i) - Mean
Next i

For i = 1 To N
For j = 1 To i
Array2(i) = Array2(i) + Array1(j)
Next j
Next i

Maxi = Array2(1)
Mini = Array2(1)
For i = 1 To N
If Array2(i) > Maxi Then Maxi = Array2(i)
If Array2(i) < Mini Then Mini = Array2(i)
Next i

R = Maxi - Mini
totalR = totalR + R
totalS = totalS + S

Next PeriodNo

R = totalR / NoOfPeriods
S = totalS / NoOfPeriods
RS = R / S

PlottedPointNo = N - 2
Result(PlottedPointNo, 1) = (Log(N)) / logten
Result(PlottedPointNo, 2) = (Log(RS)) / logten

Next N

Sumx = 0
Sumy = 0
Sumxy = 0
Sumxx = 0

For i = 1 To NoOfPlottedPoints
Worksheets("Data").Cells(i + 6, 4).Value = Result(i, 1)
Worksheets("Data").Cells(i + 6, 5).Value = Result(i, 2)
Sumx = Sumx + Result(i, 1)
Sumy = Sumy + Result(i, 2)
Sumxy = Sumxy + (Result(i, 1)) * (Result(i, 2))
Sumxx = Sumxx + (Result(i, 1)) * (Result(i, 1))
Next i

'Calculate Hurst coefficient
H = (Sumxy - ((Sumx * Sumy) / NoOfPlottedPoints)) / (Sumxx - ((Sumx * Sumx) / NoOfPlottedPoints))
Worksheets("Data").Range("C3").Value = H

End Sub

 回到顶部
帅哥哟,离线,有人找我吗?
lichenghu
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:5895 积分:3774 威望:0 精华:0 注册:2012/1/1 0:00:01
  发帖心情 Post By:2013/5/23 10:35:26    Post IP:58.246.57.26[只看该作者]

您好,已在vip论坛回复您


金字塔—专业程序化交易量化投资平台

客户服务部

-----------------------------------------------------------

欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com
 回到顶部
帅哥哟,离线,有人找我吗?
rushtaotao
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 czt
等级:蜘蛛侠 帖子:1445 积分:6114 威望:0 精华:3 注册:2012/1/16 10:31:19
  发帖心情 Post By:2013/5/23 10:37:23    Post IP:116.226.217.32[只看该作者]

有2种方式可以处理

1,比较简单的一种,你已经有了excel vba的算法,可以通过金字塔,取出数据,录入到你的excel里 通过excel宏来进行计算。

2,要把以上代码转成金字塔,但是具体的算法思路得先大致注释一下,而且工程量较大,还是推荐第一种方法。


 回到顶部