DolphinDB 有没有内置的函数支持计算价格变动幅度?

在python中可以配合shift实现

data['last_price'] = data['price'].shift(1)
res = (data['price'] / data['last_price'] - 1)
请先 登录 后评论

1 个回答

Yingnan Wang

ratios函数,对应问题中的python实现逻辑可以这样实现:

price = 3 12 0 -5 32;
res = ratios(price) - 1;

具体用法见手册:https://www.dolphindb.cn/cn/help/FunctionsandCommands/FunctionReferences/r/ratios.html

请先 登录 后评论