Perp: Remove misleading LeafNode::price()
This commit is contained in:
parent
5d780a86dc
commit
3ccfa3241f
|
@ -142,20 +142,20 @@ mod tests {
|
|||
}
|
||||
}
|
||||
assert!(book.bids.fixed.is_full());
|
||||
assert_eq!(book.bids.fixed.min_leaf().unwrap().price(), 1001);
|
||||
assert_eq!(book.bids.fixed.min_leaf().unwrap().price_data(), 1001);
|
||||
assert_eq!(
|
||||
book.bids.fixed.max_leaf().unwrap().price(),
|
||||
fixed_price_lots(book.bids.fixed.max_leaf().unwrap().price_data()),
|
||||
(1000 + book.bids.fixed.leaf_count) as i64
|
||||
);
|
||||
|
||||
// add another bid at a higher price before expiry, replacing the lowest-price one (1001)
|
||||
new_order(&mut book, &mut event_queue, Side::Bid, 1005, 1000000 - 1);
|
||||
assert_eq!(book.bids.fixed.min_leaf().unwrap().price(), 1002);
|
||||
assert_eq!(book.bids.fixed.min_leaf().unwrap().price_data(), 1002);
|
||||
assert_eq!(event_queue.len(), 1);
|
||||
|
||||
// adding another bid after expiry removes the soonest-expiring order (1005)
|
||||
new_order(&mut book, &mut event_queue, Side::Bid, 999, 2000000);
|
||||
assert_eq!(book.bids.fixed.min_leaf().unwrap().price(), 999);
|
||||
assert_eq!(book.bids.fixed.min_leaf().unwrap().price_data(), 999);
|
||||
assert!(!order_tree_contains_key(&book.bids.fixed, 1005));
|
||||
assert_eq!(event_queue.len(), 2);
|
||||
|
||||
|
@ -288,7 +288,7 @@ mod tests {
|
|||
// (the maker account is unchanged: it was not even passed in)
|
||||
let order =
|
||||
order_tree_leaf_by_key(&book.bids.fixed, maker.perp_order_by_raw_index(0).id).unwrap();
|
||||
assert_eq!(order.price(), price_lots);
|
||||
assert_eq!(fixed_price_lots(order.price_data()), price_lots);
|
||||
assert_eq!(order.quantity, bid_quantity - match_quantity);
|
||||
|
||||
// fees were immediately accrued
|
||||
|
|
|
@ -177,12 +177,6 @@ impl LeafNode {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: remove, it's not always the price
|
||||
#[inline(always)]
|
||||
pub fn price(&self) -> i64 {
|
||||
self.price_data() as i64
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn price_data(&self) -> u64 {
|
||||
(self.key >> 64) as u64
|
||||
|
|
|
@ -108,6 +108,7 @@ impl OrderTree {
|
|||
}
|
||||
}
|
||||
|
||||
// only for fixed-price ordertrees
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code)]
|
||||
fn to_price_quantity_vec(&self, reverse: bool) -> Vec<(i64, i64)> {
|
||||
|
@ -130,7 +131,7 @@ impl OrderTree {
|
|||
NodeRef::Leaf(leaf) => {
|
||||
// if you hit leaf then pop stack and go right
|
||||
// all inner nodes on stack have already been visited to the left
|
||||
pqs.push((leaf.price(), leaf.quantity));
|
||||
pqs.push((fixed_price_lots(leaf.price_data()), leaf.quantity));
|
||||
match stack.pop() {
|
||||
None => return pqs,
|
||||
Some(inner) => {
|
||||
|
|
Loading…
Reference in New Issue