账户收益和归因输入
原能力
计算账户收益及归因输入,区分投入、收益、费用和估值变化。(合同附件 R7 13.8)
首选项目
Empyrical(Apache-2.0)。 Empyrical
匹配范围
从经核数据计算收益风险指标并读取分录。
源码
Empyrical · def cum_returns(
empyrical/stats.py · 219–232 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
def cum_returns(returns, starting_value=0, out=None):
"""
Compute cumulative returns from simple returns.
Parameters
----------
returns : pd.Series, np.ndarray, or pd.DataFrame
Returns of the strategy as a percentage, noncumulative.
- Time series with decimal returns.
- Example::
2015-07-16 -0.012143
2015-07-17 0.045350
2015-07-20 0.030957
- # Copyright 2016 Quantopian, Inc.
Formance Ledger · func (s *Server) handleCreateTransaction(
internal/adapter/http/handlers_create_transaction.go · 13–26 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
func (s *Server) handleCreateTransaction(w http.ResponseWriter, r *http.Request) {
ledgerName, ok := requireLedgerName(w, r)
if !ok {
return
}
// Decode request body into protobuf CreateTransactionPayload.
// The custom UnmarshalJSON in service.pb.json.go drives field naming
// from the public camelCase contract (scriptReference, accountMetadata,
// …) — the default protoc-gen-go tags are snake_case and would silently
// drop multi-word keys (#452).
req := &servicepb.CreateTransactionPayload{}
err := json.UnmarshalRead(r.Body, req)
实现与验收要点
区分实际入金、账目变动与投资收益,复核归因来源。