Files
spark/src/client/spark_api/MarketData/NativePriceLevel.cs
T

33 lines
969 B
C#

namespace mbts.co2 {
using System.Runtime.InteropServices;
using Size = System.Single;
[StructLayout(LayoutKind.Sequential)]
public readonly struct NativePriceLevel {
readonly IntPrice _bid;
readonly IntPrice _ask;
readonly Size _bid_size;
readonly Size _ask_size;
public NativePriceLevel(IntPrice bid, Size bid_size, IntPrice ask, Size ask_size) {
_bid = bid;
_bid_size = bid_size;
_ask = ask;
_ask_size = ask_size;
}
public NativePriceSize bid => new(_bid, _bid_size);
public NativePriceSize ask => new(_ask, _ask_size);
public void Deconstruct(out NativePriceSize bid, out NativePriceSize ask) {
bid = this.bid;
ask = this.ask;
}
public override string ToString() =>
$"b [{bid.price} {bid.size}] a [{ask.price} {ask.size}]";
internal static NativePriceLevel empty => new(IntPrice.NaN, 0, IntPrice.NaN, 0);
}
}