Comments (3)
这两个量这么算是我觉得会合理些,基本是我编的公式==
投资收益率本身不像 xirr,是个有点 ill defined 的量。如果有持有成本做分母的话,如果收益比较高,会出现很极端的数字。考虑下面具体极端的例子
-
买入 100,涨到 200,卖出 190,持有 10。这一系列交易对应的在该标的上的投资收益率是多少呢。收益是 100,除以持有成本 -90,收益率会是 -110%。 除以最大占用 100 更合理。也许会有人说,除以总买入也很合理,那就在考虑下面这个极端例子。
-
买入 100,涨到 200,全部卖出。买入 100,涨到 200,全部卖出。买入 100,涨到 200,全部卖出。总收益 300,应该除以总买入 300 更合适呢,还是除以最大占用 100 更合适呢,其实就见仁见智了。本质上讲,最大占用指的是整体时间上,你需要最多拿出多少钱参与这笔投资,那么作为收益率的分母,可能还是比较合理的。
至于换手率,就是个更随意的量,基本上只有定性(大还是小)的意义,具体数值的意义可能不大。我这里的处理大概就是算日均买入卖出的金额。为了抵消基底金额大小对换手率的影响,又除了最大占用归一化一下。
from xalpha.
谢谢! 我大概明白了。
我研究了一下支付宝的收益率计算方法,它是按照这种方式计算的:
T日投资总成本=T日加仓金额+(T-1)日投资总成本-T日减仓份额*T日成本单价
T日持有收益 = T日持仓市值 - T日投资总成本
T日持有收益率 = T日持有收益/T日投资总成本
持有单价 = 持有成本/持有份额
持有成本 = 持有份额 * 持有单价
支付宝的这种方式好像也能克服你上面所述的两个极端例子。支付宝的累计收益对应于xalpha的收益,支付宝的T日收益中相当于没有计算减持的收益。
from xalpha.
#53 之前可能相关的一个讨论,那时就有想法说,能不能软件同时支持几种不同模式的成本和收益计算
from xalpha.
Related Issues (20)
- 期待解锁宏观数据 from ycharts HOT 1
- ycharts 数据拉取错误 HOT 3
- 可以回测基于策略的基金买入卖出收益吗 HOT 1
- 增量更新分拆信息解析出错 HOT 1
- 测试”技术指标交叉类“时报错 HOT 1
- 使用多进程时报错 HOT 1
- xa.indexinfo接口无法使用 HOT 3
- indicator_cross中start日期问题 HOT 1
- 计算基金收益报错
- pandas更新之后dataframe没有append了 HOT 2
- the pinning pyecharts version doesn't support python3.10+
- sqlalchemy >= 2 报错 HOT 2
- [Warning] RCE in xalpha v0.11.4 ~ v0.11.8 HOT 4
- 请问作者怎么通过基金交易单申赎基金呀 HOT 1
- VInfo失效。
- 添加米筐数据源支持。
- 数据错误。 HOT 1
- indexinfo报错 HOT 1
- 这个问题是2023年年末提出的,请问当前数据源是否是正常运行的,包含最近三年的及时数据 HOT 2
- 总是报错TradeBehaviorError: You cannot sell first when you never buy,是什么问题? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xalpha.