|
|
@@ -100,24 +100,45 @@ fn easy_query<W>( |
|
|
|
let mut gdax_amount = 0.0; |
|
|
|
let mut n_gdax = 0; |
|
|
|
|
|
|
|
const MASK : i32 = i32::from_le_bytes([ 255, 255, 255, 0]); |
|
|
|
const BMEX_BTC_USD : i32 = i32::from_le_bytes([ e!(bmex) as u8, c!(btc) as u8, c!(usd) as u8, 0 ]); |
|
|
|
const GDAX_BTC_USD : i32 = i32::from_le_bytes([ e!(gdax) as u8, c!(btc) as u8, c!(usd) as u8, 0 ]); |
|
|
|
|
|
|
|
macro_rules! update { // in macro to avoid repeating code once outside loop, and again in loop body |
|
|
|
($trade:ident) => {{ |
|
|
|
match ($trade.exch(), $trade.base(), $trade.quote()) { |
|
|
|
(Ok(e!(bmex)), Ok(c!(btc)), Ok(c!(usd))) => { |
|
|
|
bmex_total += $trade.price() * $trade.amount(); |
|
|
|
bmex_amount += $trade.amount(); |
|
|
|
n_bmex += 1; |
|
|
|
} |
|
|
|
|
|
|
|
(Ok(e!(gdax)), Ok(c!(btc)), Ok(c!(usd))) => { |
|
|
|
gdax_total += $trade.price() * $trade.amount(); |
|
|
|
gdax_amount += $trade.amount(); |
|
|
|
n_gdax += 1; |
|
|
|
let meta_sans_side: i32 = $trade.meta_i32() & MASK; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_ => {} |
|
|
|
} |
|
|
|
let is_bmex_btc_usd: f64 = (meta_sans_side == BMEX_BTC_USD) as u8 as f64; |
|
|
|
|
|
|
|
let is_gdax_btc_usd: f64 = (meta_sans_side == GDAX_BTC_USD) as u8 as f64; |
|
|
|
|
|
|
|
let amount = $trade.amount(); |
|
|
|
let total = $trade.price() * amount; |
|
|
|
|
|
|
|
bmex_total += is_bmex_btc_usd * total; |
|
|
|
bmex_amount += is_bmex_btc_usd * amount; |
|
|
|
n_bmex += is_bmex_btc_usd as usize * 1; |
|
|
|
|
|
|
|
gdax_total += is_gdax_btc_usd * total; |
|
|
|
gdax_amount += is_gdax_btc_usd * amount; |
|
|
|
n_gdax += is_gdax_btc_usd as usize * 1; |
|
|
|
|
|
|
|
|
|
|
|
//match ($trade.exch(), $trade.base(), $trade.quote()) { |
|
|
|
// (Ok(e!(bmex)), Ok(c!(btc)), Ok(c!(usd))) => { |
|
|
|
// n_bmex += 1; |
|
|
|
// } |
|
|
|
|
|
|
|
// (Ok(e!(gdax)), Ok(c!(btc)), Ok(c!(usd))) => { |
|
|
|
// gdax_total += $trade.price() * $trade.amount(); |
|
|
|
// gdax_amount += $trade.amount(); |
|
|
|
// n_gdax += 1; |
|
|
|
|
|
|
|
// } |
|
|
|
// |
|
|
|
// _ => {} |
|
|
|
//} |
|
|
|
}} |
|
|
|
} |
|
|
|
|
|
|
|