基金份额参考价值 IOPV 计算

您所在的位置:网站首页 通达信iopv 基金份额参考价值 IOPV 计算

基金份额参考价值 IOPV 计算

2024-03-21 12:01| 来源: 网络整理| 查看: 265

在 DolphinDB 中利用 pivot by 生成一个数据面板(矩阵),再对矩阵进行向量化运算可以提高计算速度,同时代码更为简洁。

timeSeriesValue = select tradetime, SecurityID, price * portfolio[SecurityID]/1000 as constituentValue from loadTable("dfs://LEVEL2_SZ","Trade") where SecurityID in portfolio.keys(), tradedate = 2020.12.01, price > 0 iopvHist = select rowSum(ffill(constituentValue)) as IOPV from timeSeriesValue pivot by tradetime, SecurityID计算股票价值

timeSeriesValue 得到每个时间戳下的所有成分券价值,本次代码示例计算深交所 2021.12.01 这一日的逐笔成交的历史 IOPV,其中 loadTable("dfs://LEVEL2_SZ","Trade") 使用的是逐笔成交表。

上图中 constituentValue 是每一时间戳时当前股票仓位的价值。

面板数据计算 IOPV

利用 DolphinDB 中的 pivot by 数据透视功能生成一个面板数据,横轴是50只成分券,纵轴是时间戳,数据点代表每只成分券在一个时间戳上的价值。

对面板数据的纵轴(时间序列)的空置填充最近前一笔有效价值,再对横轴(成分券)汇总即可得到每个时间戳上的 IOPV 结果。

ffill会找到前一笔最近的非空值,相当于传统方法取前一股票价值。rowSum对横向行数据汇总,即把所有成分券的价值汇总得出 IOPV。

在 DolphinDB 中使用一行代码就能完成传统 IOPV 计算步骤3中的复杂逻辑;同时,DolphinDB 是向量计算,能够充分利用多线程完成高效运算。

面板数据有以下优点,参考阅读 Baltagi, Econometric Analysis of Panel Data Chapter 1 1.2 Why should we use Panel Data? The Benefits and Limitations:

Benefits

Controlling for individual heterogeneity.Panel data give more informative data, more variablility, less collinearity among the variables, more degrees of freedom and more effciency.Panel data are better able to study the dymanics of adjustment.Panel data are better able to identify and measure effects that are simply not detectable in pure cross-section or pure time-series data.Panel data models allow us to construct and test more complicated behavioral models than purely cross-section or time-series data.Micro panel data gathered on individuals, firms and households may be more accurately measured than similar variables measured at the macro level.Macro panel data on the other hand have a longer time series and unlike the problem of nonstandard distributions typical of units roots tests in time-series analysis.

Limitations

Design and data collection problems.Distortions of measurement errors.Selectivity problems.Short time-series dimensions.Cross-section dependence.


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3