Browse Source

adds plnx ws count to ExperiencedLatency and LatencyUpdate

master
Jonathan Strong 7 years ago
parent
commit
80bf0d60b2
1 changed files with 15 additions and 4 deletions
  1. +15
    -4
      src/latency.rs

+ 15
- 4
src/latency.rs View File

@@ -12,15 +12,12 @@ use influent::measurement::{Measurement, Value};
use sloggers::types::Severity; use sloggers::types::Severity;
use shuteye; use shuteye;


use windows::{DurationWindow, Incremental};
use windows::{DurationWindow, Incremental, Window};
use money::{Ticker, Side, ByExchange, Exchange}; use money::{Ticker, Side, ByExchange, Exchange};


use super::file_logger; use super::file_logger;
use influx::{self, OwnedMeasurement, OwnedValue}; use influx::{self, OwnedMeasurement, OwnedValue};





pub type Nanos = u64; pub type Nanos = u64;


pub const SECOND: u64 = 1e9 as u64; pub const SECOND: u64 = 1e9 as u64;
@@ -127,6 +124,8 @@ pub enum ExperiencedLatency {


EventLoop(Duration), EventLoop(Duration),


PlnxWs(Ticker),

Terminate Terminate
} }


@@ -219,6 +218,8 @@ pub struct LatencyUpdate<W>
pub plnx_last: DateTime<Utc>, pub plnx_last: DateTime<Utc>,
pub krkn_last: DateTime<Utc>, pub krkn_last: DateTime<Utc>,


pub plnx_ws_count: u64,

//pub event_loop: Nanos, //pub event_loop: Nanos,


pub size: W, pub size: W,
@@ -241,6 +242,8 @@ impl<W> Default for LatencyUpdate<W>
krkn_trade_300_mean: Nanos::default(), krkn_trade_300_mean: Nanos::default(),
krkn_trade_300_max: Nanos::default(), krkn_trade_300_max: Nanos::default(),


plnx_ws_count: 0,

plnx_last: Utc::now(), plnx_last: Utc::now(),
krkn_last: Utc::now(), krkn_last: Utc::now(),


@@ -454,6 +457,7 @@ impl LatencyManager<WTen> {
let mut plnx_pub = DurationWindow::new(w.duration()); let mut plnx_pub = DurationWindow::new(w.duration());
let mut plnx_priv = DurationWindow::new(w.duration()); let mut plnx_priv = DurationWindow::new(w.duration());
let mut plnx_order = DurationWindow::new(w.duration()); let mut plnx_order = DurationWindow::new(w.duration());
let mut plnx_ws_count: Window<u32> = Window::new(w.duration());




// yes I am intentionally breaking from the hard-typed duration // yes I am intentionally breaking from the hard-typed duration
@@ -510,6 +514,11 @@ impl LatencyManager<WTen> {
plnx_order.update(loop_time, d) plnx_order.update(loop_time, d)
} }


ExperiencedLatency::PlnxWs(_) => {
last.plnx = loop_time;
plnx_ws_count.update(loop_time, 1_u32);
}

ExperiencedLatency::KrknTrade(d, cmd, ticker, side) => { ExperiencedLatency::KrknTrade(d, cmd, ticker, side) => {
debug!(logger, "new KrknTrade"; debug!(logger, "new KrknTrade";
"cmd" => cmd); "cmd" => cmd);
@@ -566,6 +575,8 @@ impl LatencyManager<WTen> {
plnx_last: dt_from_dur(loop_time - last.plnx), plnx_last: dt_from_dur(loop_time - last.plnx),
krkn_last: dt_from_dur(loop_time - last.krkn), krkn_last: dt_from_dur(loop_time - last.krkn),


plnx_ws_count: plnx_ws_count.refresh(&loop_time).count() as u64,

//event_loop: event_loop.refresh(&now).mean_nanos(), //event_loop: event_loop.refresh(&now).mean_nanos(),
size: w.clone(), size: w.clone(),
}; };


Loading…
Cancel
Save