[英]How to calculate average price of open position of stocks Excel Table
I have a simple table with some dummy data to simulate stock trades.我有一个简单的表格,其中包含一些虚拟数据来模拟股票交易。 I know the its model is not exactly right, but it does comply with the basics and that's what I'm looking for.
我知道它的 model 并不完全正确,但它确实符合基础知识,这就是我正在寻找的。 The answer I'm looking for is how would I calculate the data on column 12. It's supposed to show the Average Price of the position at that date.
我正在寻找的答案是如何计算第 12 列的数据。它应该显示 position 在该日期的平均价格。 If the position opened with the current row then the average price is the actual price of the trade, however the position can be increased or decreased with new prices and I want to know the average price up to that date (last two rows have this example).
如果 position 以当前行打开,则平均价格是交易的实际价格,但是 position 可以随着新价格增加或减少,我想知道截至该日期的平均价格(最后两行有这个例子)。
Column 13 (What I got so far) has this definition*: =SUMPRODUCT([Delta Position];--([Date Trade]<=[@[Date Trade]]);--([Position After Trade]=[@[Position After Trade]]))
*actually the there's two more columns, Trader and Maturity Date, these two are used to filter data and are not shown to make it more readable: --([Person]=[@Person]);--([Month]=[@month])
第 13 列(到目前为止我得到的)有这个定义*:
=SUMPRODUCT([Delta Position];--([Date Trade]<=[@[Date Trade]]);--([Position After Trade]=[@[Position After Trade]]))
*实际上还有两列,Trader 和 Maturity Date,这两列用于过滤数据,没有显示以使其更具可读性: --([Person]=[@Person]);--([Month]=[@month])
(second row just shows the definition of the simpler columns) (第二行只显示更简单列的定义)
Date![]() Trade ![]() |
Price![]() |
op![]() |
Qty![]() |
Total![]() |
Accumulated![]() Before ![]() |
Accumulated![]() After ![]() |
Position ![]() After Trade ![]() |
Qty Delta![]() Position ![]() |
Delta![]() Position ![]() |
Value of![]() Open Position ![]() |
What I got![]() so far ![]() |
Average Price![]() Open Position ![]() |
---|---|---|---|---|---|---|---|---|---|---|---|---|
C1 ![]() |
C2 ![]() |
C3 ![]() |
C4 ![]() |
C5 = C2 x C4 ![]() |
C6 ![]() |
C7 ![]() |
C8 ![]() |
C9 ![]() |
C10 = C9 * C2 ![]() |
C11 ![]() |
C12 ![]() |
C13 = C11 / C7 ![]() |
2021-12-06 ![]() |
328 ![]() |
Buy![]() |
99 ![]() |
32472 ![]() |
0 ![]() |
99 ![]() |
long![]() |
99 ![]() |
32472 ![]() |
HELP: 32472![]() |
32472 ![]() |
328 ![]() |
2021-12-13 ![]() |
291 ![]() |
Sell![]() |
99 ![]() |
28809 ![]() |
99 ![]() |
0 ![]() |
zero![]() |
0 ![]() |
0 ![]() |
HELP: 0![]() |
0 ![]() |
0 ![]() |
2022-01-31 ![]() |
190 ![]() |
Sell![]() |
120 ![]() |
22800 ![]() |
0 ![]() |
-120 ![]() |
short![]() |
-120 ![]() |
-22800 ![]() |
HELP: -22800![]() |
-22800 ![]() |
190 ![]() |
2022-02-14 ![]() |
165 ![]() |
Buy![]() |
120 ![]() |
19800 ![]() |
-120 ![]() |
0 ![]() |
zero![]() |
0 ![]() |
0 ![]() |
HELP: 0![]() |
0 ![]() |
0 ![]() |
2022-04-20 ![]() |
113,7 ![]() |
Sell![]() |
200 ![]() |
22740 ![]() |
0 ![]() |
-200 ![]() |
short![]() |
-200 ![]() |
-22740 ![]() |
HELP: -22740![]() |
-45540 ![]() |
113,7 ![]() |
2022-06-21 ![]() |
74,333 ![]() |
Buy![]() |
300 ![]() |
22299,9 ![]() |
-200 ![]() |
100 ![]() |
long![]() |
100 ![]() |
7433,3 ![]() |
HELP: 7433.3![]() |
39905,3 ![]() |
74,333 ![]() |
2022-08-16 ![]() |
86 ![]() |
Buy![]() |
50 ![]() |
4300 ![]() |
100 ![]() |
150 ![]() |
long![]() |
50 ![]() |
4300 ![]() |
HELP: 11733.3![]() |
44205,3 ![]() |
78,222 ![]() |
The average price of an open position is calculated by this fórmula一个开放的position的平均价格是由这个公式计算的
Iteratively you can obtain this fórmula:迭代你可以获得这个公式:
I hope this can help you.我希望这可以帮助你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.