position 每日持倉

Example

input
rp.position
output
date id direction qty entry_date entry_price CLOSE entry_cost market_value pnl
0 2021/5/31 META long 1000 2021/5/31 122.2806 123.4512 -122311 123297 986
1 2021/6/1 META long 1000 2021/5/31 122.2806 123.9914 -122311 123836 1525
2 2021/6/2 META long 1000 2021/5/31 122.2806 123.9914 -122311 123836 1525
3 2021/6/3 META long 1000 2021/5/31 122.2806 123.9014 -122311 123747 1436
4 2021/6/4 META long 1000 2021/5/31 122.2806 123.3161 -122311 123162 851
... ... ... ... ... ... ... ... ... ... ...
729 2024/12/13 GOOG long 1000 2024/8/7 893.5568 1065 -893780 1061539 167759
730 2024/12/16 GOOG long 1000 2024/8/7 893.5568 1085 -893780 1081474 187694
731 2024/12/17 GOOG long 1000 2024/8/7 893.5568 1075 -893780 1071506 177726
732 2024/12/18 GOOG long 1000 2024/8/7 893.5568 1085 -893780 1081474 187694
733 2024/12/19 GOOG long 1000 2024/8/7 893.5568 1070 -893780 1066522 172742

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 在對應日期時的預估收益