Setting last_price to avg_price for SOD records
This commit is contained in:
1 parent
33658f13f6
commit
bd4f840d27
1 file changed
+4
-3
@@ -118,12 +118,12 @@ std::string SODPosition::_sod_fill_id(const Fill& fill,api::Side side){
|
||||
void SODPosition::_merge_pos(Fill& pos, const Fill& fill){
|
||||
bts_assert(pos.security_key()==fill.security_key());
|
||||
bts_assert(pos.account()==fill.account());
|
||||
bts_assert(pos.side()==fill.side());
|
||||
pos.set_last_price(fill.last_price());
|
||||
bts_assert(pos.side()==fill.side());
|
||||
double total_qty=pos.last_shares()+fill.last_shares();
|
||||
double avg_price=(pos.avg_price()*pos.last_shares()+
|
||||
fill.avg_price()*fill.last_shares())/total_qty;
|
||||
fill.last_price()*fill.last_shares())/total_qty;
|
||||
pos.set_avg_price(avg_price);
|
||||
pos.set_last_price(avg_price);
|
||||
pos.set_last_shares(total_qty);
|
||||
}
|
||||
|
||||
@@ -136,6 +136,7 @@ void SODPosition::_zero_pos(Fill& pos, const Fill& fill, api::Side side){
|
||||
pos.set_fill_kind(Fill::FILL_KIND_SOD);
|
||||
pos.set_order_key(0);
|
||||
pos.set_fill_key(_sod_fill_id(fill,side));
|
||||
pos.set_last_shares(0);
|
||||
}
|
||||
|
||||
bool SODPosition::add_fill_to_sod_pos(const Fill& fill){
|
||||
|
||||
Reference in new issue
Block a user