diff --git a/src/client/spark_api/MarketData/Book.cs b/src/client/spark_api/MarketData/Book.cs new file mode 100644 index 000000000..13b61d034 --- /dev/null +++ b/src/client/spark_api/MarketData/Book.cs @@ -0,0 +1,44 @@ +namespace bts.md { + using bts.api.core; + + using mbts; + using mbts.co2; + using mbts.spark; + + using System; + using System.Collections.Generic; + using System.Linq; + using System.Reactive.Linq; + + public readonly struct Book : IEquatable { + public Book(uint security_id, List bids, List asks) { + this.security_id = security_id; + this.bids = bids; + this.asks = asks; + } + + public uint security_id { get; } + public List bids { get; } + public List asks { get; } + + public static Book empty(uint security_id) => + new(security_id, new(0), new(0)); + + public bool Equals(Book other) => + security_id == other.security_id && + bids.SequenceEqual(other.bids) && + asks.SequenceEqual(other.asks); + + public override bool Equals(object obj) => + obj is Book other && Equals(other); + + public override int GetHashCode() => + security_id.GetHashCode(); + + public static bool operator ==(Book left, Book right) => + left.Equals(right); + + public static bool operator !=(Book left, Book right) => + !(left == right); + } +} diff --git a/src/client/spark_api/MarketData/IncrementalMarketDataClient.cs b/src/client/spark_api/MarketData/IncrementalMarketDataClient.cs index 63a60f8d0..1f17a4147 100644 --- a/src/client/spark_api/MarketData/IncrementalMarketDataClient.cs +++ b/src/client/spark_api/MarketData/IncrementalMarketDataClient.cs @@ -10,38 +10,6 @@ namespace bts.md { using System.Linq; using System.Reactive.Linq; - public readonly struct Book : IEquatable { - public Book(uint security_id, List bids, List asks) { - this.security_id = security_id; - this.bids = bids; - this.asks = asks; - } - - public uint security_id { get; } - public List bids { get; } - public List asks { get; } - - public static Book empty(uint security_id) => - new(security_id, new(0), new(0)); - - public bool Equals(Book other) => - security_id == other.security_id && - bids.SequenceEqual(other.bids) && - asks.SequenceEqual(other.asks); - - public override bool Equals(object obj) => - obj is Book other && Equals(other); - - public override int GetHashCode() => - security_id.GetHashCode(); - - public static bool operator ==(Book left, Book right) => - left.Equals(right); - - public static bool operator !=(Book left, Book right) => - !(left == right); - } - public class IncrementalMarketDataClient { readonly MDSource _source; readonly TimeSpan _poll_interval;