简体   繁体   English

如何计算开盘position股票Excel表的平均价格

[英]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 Position
After Trade交易后
Qty Delta数量三角洲
Position Position
Delta三角洲
Position Position
Value of的价值
Open Position打开 Position
What I got我得到了什么
so far至今
Average Price平均价格
Open Position打开 Position
C1 C1 C2 C2 C3 C3 C4 C4 C5 = C2 x C4 C5 = C2 x C4 C6 C6 C7 C7 C8 C8 C9 C9 C10 = C9 * C2 C10 = C9 * C2 C11 C11 C12 C12 C13 = C11 / C7 C13 = C11 / C7
2021-12-06 2021-12-06 328 328 Buy 99 99 32472 32472 0 0 99 99 long 99 99 32472 32472 HELP: 32472帮助:32472 32472 32472 328 328
2021-12-13 2021-12-13 291 291 Sell 99 99 28809 28809 99 99 0 0 zero 0 0 0 0 HELP: 0帮助:0 0 0 0 0
2022-01-31 2022-01-31 190 190 Sell 120 120 22800 22800 0 0 -120 -120 short短的 -120 -120 -22800 -22800 HELP: -22800帮助:-22800 -22800 -22800 190 190
2022-02-14 2022-02-14 165 165 Buy 120 120 19800 19800 -120 -120 0 0 zero 0 0 0 0 HELP: 0帮助:0 0 0 0 0
2022-04-20 2022-04-20 113,7 113,7 Sell 200 200 22740 22740 0 0 -200 -200 short短的 -200 -200 -22740 -22740 HELP: -22740帮助:-22740 -45540 -45540 113,7 113,7
2022-06-21 2022-06-21 74,333 74,333 Buy 300 300 22299,9 22299,9 -200 -200 100 100 long 100 100 7433,3 7433,3 HELP: 7433.3帮助:7433.3 39905,3 39905,3 74,333 74,333
2022-08-16 2022-08-16 86 86 Buy 50 50 4300 4300 100 100 150 150 long 50 50 4300 4300 HELP: 11733.3帮助:11733.3 44205,3 44205,3 78,222 78,222

The average price of an open position is calculated by this fórmula一个开放的position的平均价格是由这个公式计算的

Average price fórmula平均价格公式

Iteratively you can obtain this fórmula:迭代你可以获得这个公式:

Iterative fórmula迭代公式

  • First row (first operation) => Average price = M3 = If(C3='Buy';B3;-B3)第一行(第一次操作)=> 均价 = M3 = If(C3='买入';B3;-B3)
  • Second row => Average price => Average price = M4 = ((M3 F4)+(If(C4='Buy';B4 C4;-B4*C4) )) / G4第二行 => 均价 => 均价 = M4 = ((M3 F4)+(If(C4='买入';B4 C4;-B4*C4) )) / G4
  • Next rows you only have to iterate fórmula.接下来的行你只需要迭代公式。

I hope this can help you.我希望这可以帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM