position 每日持倉

Example

input
rp.position
output
date id direction qty entry_date entry_price CLOSE entry_cost market_value pnl
0 2021-12-24 0050 long 1000 2021-12-24 31.6089 31.6199 -31617 31580 -37
1 2021-12-27 0050 long 1000 2021-12-24 31.6089 31.8631 -31617 31823 206
2 2021-12-28 0050 long 1000 2021-12-24 31.6089 32.1173 -31617 32077 460
3 2021-12-29 0050 long 1000 2021-12-24 31.6089 32.2609 -31617 32221 604
4 2021-12-30 0050 long 1000 2021-12-24 31.6089 32.1615 -31617 32121 504
... ... ... ... ... ... ... ... ... ... ...
1672 2025-10-20 2330 long 1000 2025-04-24 878.7259 1480 -878946 1475190 596244
1673 2025-10-21 2330 long 1000 2025-04-24 878.7259 1480 -878946 1475190 596244
1674 2025-10-22 2330 long 1000 2025-04-24 878.7259 1460 -878946 1455255 576309
1675 2025-10-23 2330 long 1000 2025-04-24 878.7259 1450 -878946 1445288 566342
1676 2025-10-27 2330 long 1000 2025-04-24 878.7259 1480 -878946 1475190 596244

Return Attribute

Return type: Object DataFrame

參數 資料型態 說明
date datetime 日期
id object 交易標的代碼
direction object 交易方向,'long' or 'short'
long:代表"多"
short:代表"空"
qty float 交易股數
entry_date datetime 進場時間
entry_price float 進場價格
CLOSE float 在對應日期的收盤價
entry_cost float 進場時付出費用
market_value float 在對應日期的倉位市值
pnl float 在對應日期時的預估收益