DolphinDB中有没有适合计算金融中最大回撤的函数?

DolphinDB有许多的内置函数,请问有没有适合计算金融中最大回撤的函数?
如下图所示:

attachments-2021-05-wWq2ikJc60ac68ded4175.png

请先 登录 后评论

2 个回答

Jason Tang - 时序数据库技术支持

交易回测在DolphinDB中的实现,可以参考:交易回测系列-技术信号回测
上述案例可以通过下面的函数实现:

defg maxDrawDown(price){
         return max(1.0 - price\price.cummax())
}

tb = table(rand(1 2 3 , 10) as id, rand(1.5, 10) as price)

select maxDrawDown(price) as group_max_drawdown from tb group by id
请先 登录 后评论
谭华

代码简化:

tb = table(rand(1 2 3 , 10) as id, rand(1.5, 10) as price)
defg maxDrawDown(price): max(1.0 - price\price.cummax())
select maxDrawDown(price) as group_max_drawdown from tb group by id
请先 登录 后评论