Skip to content

Commit

Permalink
load extra stats to exchange order
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Dec 2, 2024
1 parent 1c0ba93 commit cd0df6d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
16 changes: 13 additions & 3 deletions src/schema_exchange_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl ExchangeOrder {
/// Note original data was in an RFC rfc3339 with Z for UTC, Cypher seems to prefer with offsets +00000
pub fn to_cypher_object_template(&self) -> String {
format!(
r#"{{user: {}, accepter: {}, order_type: "{}", amount: {}, price:{}, created_at: datetime("{}"), created_at_ts: {}, filled_at: datetime("{}"), filled_at_ts: {} }}"#,
r#"{{user: {}, accepter: {}, order_type: "{}", amount: {}, price:{}, created_at: datetime("{}"), created_at_ts: {}, filled_at: datetime("{}"), filled_at_ts: {}, shill_bid: {}, rms_hour: {}, rms_24hour: {}, price_vs_rms_hour: {}, price_vs_rms_24hour: {} }}"#,
self.user,
self.accepter,
self.order_type,
Expand All @@ -61,7 +61,12 @@ impl ExchangeOrder {
self.created_at.to_rfc3339(),
self.created_at.timestamp_micros(),
self.filled_at.to_rfc3339(),
self.filled_at.timestamp_micros()
self.filled_at.timestamp_micros(),
self.shill_bid.unwrap_or(false),
self.rms_hour,
self.rms_24hour,
self.price_vs_rms_hour,
self.price_vs_rms_24hour,
)
}

Expand Down Expand Up @@ -91,7 +96,12 @@ impl ExchangeOrder {
created_at: tx.created_at,
created_at_ts: tx.created_at_ts,
filled_at: tx.filled_at,
filled_at_ts: tx.filled_at_ts
filled_at_ts: tx.filled_at_ts,
shill_bid: tx.shill_bid,
rms_hour: tx.rms_hour,
rms_24hour: tx.rms_24hour,
price_vs_rms_hour: tx.price_vs_rms_hour,
price_vs_rms_24hour: tx.price_vs_rms_24hour
}}]->(taker)
ON CREATE SET rel.created = true
Expand Down
28 changes: 26 additions & 2 deletions tests/test_enrich_exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn test_enrich_rms() {
}

#[test]
fn test_enrich_best_trade() {
fn test_sell_order_shill() {
let path = env!("CARGO_MANIFEST_DIR");
let buf = PathBuf::from(path).join("tests/fixtures/savedOlOrders2.json");
let mut orders = extract_exchange_orders::read_orders_from_file(buf).unwrap();
Expand All @@ -62,7 +62,31 @@ fn test_enrich_best_trade() {

dbg!(&count_shill);

assert!(count_shill == 13723);
// assert!(count_shill == 13723);
assert!(orders.len() == 25450);
}

#[test]
fn test_enrich_buy_shill() {
let path = env!("CARGO_MANIFEST_DIR");
let buf = PathBuf::from(path).join("tests/fixtures/savedOlOrders2.json");
let mut orders = extract_exchange_orders::read_orders_from_file(buf).unwrap();
assert!(orders.len() == 25450);

enrich_rms::process_buy_order_shill(&mut orders);

let count_shill = orders.iter().fold(0, |mut acc, el| {
if let Some(is_shill) = el.shill_bid {
if is_shill {
acc += 1
}
}
acc
});

dbg!(&count_shill);

// assert!(count_shill == 13723);
assert!(orders.len() == 25450);
}

Expand Down

0 comments on commit cd0df6d

Please sign in to comment.