Account for fractional outcome sets from split through redemption
This commit is contained in:
@@ -106,11 +106,20 @@ impl Filter {
|
||||
.map(|(m, o)| assets::id(m, o));
|
||||
let fee: i64 = r.get(14)?;
|
||||
let cash: i64 = r.get(9)?;
|
||||
let precise_deposit: Option<i64> = r.get(15)?;
|
||||
let gross = precise_deposit.map_or(i128::from(cash) * 10000, i128::from);
|
||||
let precise_cash: Option<i64> = r.get(15)?;
|
||||
let gross = precise_cash.map_or(i128::from(cash) * 10000, i128::from);
|
||||
let shares = match r.get::<_, Option<i64>>(16)? {
|
||||
Some(u) => Some(crate::inventory::decimal(u.into(), crate::inventory::UNIT)),
|
||||
None => r.get::<_, Option<i64>>(8)?.map(Into::into),
|
||||
};
|
||||
let cash_cents = if r.get::<_, String>(5)? == "DEPOSIT" {
|
||||
cash.into()
|
||||
} else {
|
||||
crate::inventory::decimal(gross, 10000)
|
||||
};
|
||||
items.push(json!({"type":r.get::<_,String>(5)?,"account":self.account,"at_ms":r.get::<_,Option<i64>>(4)?,
|
||||
"market":market,"group":r.get::<_,Option<String>>(7)?,"asset_id":asset,"outcome":outcome,
|
||||
"shares":r.get::<_,Option<i64>>(8)?,"cash_delta_cents":cash,"fee_micros":fee,"net_cash_delta_micros":gross-i128::from(fee),
|
||||
"shares":shares,"cash_delta_cents":cash_cents,"fee_micros":fee,"net_cash_delta_micros":gross-i128::from(fee),
|
||||
"side":r.get::<_,Option<String>>(12)?,"price_micros":r.get::<_,Option<i64>>(13)?.map(|p|p*10000),
|
||||
"request_id":r.get::<_,Option<String>>(10)?,"execution":(source==1).then_some(seq),"order":(source==1).then_some(leg)}));
|
||||
last = Some(Cursor {
|
||||
|
||||
Reference in New Issue
Block a user