From b5da4b31294b065d528fa23101abce07b1f554ea Mon Sep 17 00:00:00 2001 From: Taha Afzal Date: Mon, 24 Oct 2022 13:45:14 -0400 Subject: [PATCH] Changing managed PriceSize structure's size into floats --- externals | 2 +- src/client/spark/Daemons/MergedMDDaemon.cs | 8 +++++++- .../spark_api/MarketData/NativePriceLevel.cs | 7 ++++--- .../spark_api/MarketData/NativePriceSize.cs | 20 +++++++++++-------- src/client/spark_api/MarketData/PriceSize.cs | 9 +++++---- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/externals b/externals index 5436e5a10..38b54a636 160000 --- a/externals +++ b/externals @@ -1 +1 @@ -Subproject commit 5436e5a10783d7545244ccc53a557168422a2328 +Subproject commit 38b54a636f9a7ab05cf266d5be3f21e10a04782a diff --git a/src/client/spark/Daemons/MergedMDDaemon.cs b/src/client/spark/Daemons/MergedMDDaemon.cs index 61619fd26..4ae563c26 100644 --- a/src/client/spark/Daemons/MergedMDDaemon.cs +++ b/src/client/spark/Daemons/MergedMDDaemon.cs @@ -52,10 +52,16 @@ namespace bts { string rv = "MergedMDDaemon Options:\n"; foreach (var kv in sec_map) { var sec = kv.Value.security; + var md = kv.Value.md; + ulong time = 0; + NativePriceSize bid, ask; + var has_md = md.get_bbo(ref time, out bid, out ask); if (sec.HasOption) { rv += $"id: {kv.Key} desc: {sec.security_desc()} sym: {sec.Symbol} " + $"exp: {sec.security_expiration()} " + - $"k: {sec.Option.Strike} cp: {sec.Option.CallPut}" + "\n"; + $"k: {sec.Option.Strike} cp: {sec.Option.CallPut} " + + $"bid: p: {bid.price} q: {bid.size} qf: {bid.size_f} ask: p: {ask.price} q: {ask.size} qf: {ask.size_f}" + + "\n"; } } Log.Gen.info(rv); diff --git a/src/client/spark_api/MarketData/NativePriceLevel.cs b/src/client/spark_api/MarketData/NativePriceLevel.cs index b90ee4d0f..7b75ac17e 100644 --- a/src/client/spark_api/MarketData/NativePriceLevel.cs +++ b/src/client/spark_api/MarketData/NativePriceLevel.cs @@ -1,14 +1,15 @@ 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 uint _bid_size; - readonly uint _ask_size; + readonly Size _bid_size; + readonly Size _ask_size; - public NativePriceLevel(IntPrice bid, uint bid_size, IntPrice ask, uint ask_size) { + public NativePriceLevel(IntPrice bid, Size bid_size, IntPrice ask, Size ask_size) { _bid = bid; _bid_size = bid_size; _ask = ask; diff --git a/src/client/spark_api/MarketData/NativePriceSize.cs b/src/client/spark_api/MarketData/NativePriceSize.cs index fa766ece6..07eb89e15 100644 --- a/src/client/spark_api/MarketData/NativePriceSize.cs +++ b/src/client/spark_api/MarketData/NativePriceSize.cs @@ -4,28 +4,29 @@ namespace mbts.co2 { using System; using System.Runtime.InteropServices; + using Size = System.Single; public readonly struct NativePriceSize : IEquatable { readonly IntPrice _price; - readonly uint _size; - readonly uint _direct_size; + readonly Size _size; + readonly Size _direct_size; static NativePriceSize() => Log.assert(Marshal.SizeOf() == 16); - public NativePriceSize(IntPrice price, uint size) { + public NativePriceSize(IntPrice price, Size size) { _price = price; _size = size; _direct_size = size; } - public NativePriceSize(long mantissa, sbyte exponent, uint size) { + public NativePriceSize(long mantissa, sbyte exponent, Size size) { _price = new IntPrice(mantissa, exponent); _size = size; _direct_size = size; } - public NativePriceSize(IntPrice price, uint direct_size, uint implied_size) { + public NativePriceSize(IntPrice price, Size direct_size, Size implied_size) { _price = price; _size = direct_size + implied_size; _direct_size = direct_size; @@ -36,9 +37,12 @@ namespace mbts.co2 { public IntPrice int_price => _price; public long mantissa => _price.mantissa; public sbyte exponent => _price.exponent; - public uint size => _size; - public uint direct_size => _direct_size; - public uint implied_size => _size - _direct_size; + public Size size => _size; + public Size direct_size => _direct_size; + public Size implied_size => _size - _direct_size; + public Size size_f => _size; + public Size direct_size_f => _direct_size; + public Size implied_size_f => _size - _direct_size; public double price => _price.price(); public bool is_nan => _price.is_nan; diff --git a/src/client/spark_api/MarketData/PriceSize.cs b/src/client/spark_api/MarketData/PriceSize.cs index 621f225a2..95999d319 100644 --- a/src/client/spark_api/MarketData/PriceSize.cs +++ b/src/client/spark_api/MarketData/PriceSize.cs @@ -3,13 +3,14 @@ using mbts.co2; namespace bts.md { + using Size = System.Single; public class PriceSize { - public uint size { get; } - public uint direct_size { get; } - public uint implied_size { get; } + public Size size { get; } + public Size direct_size { get; } + public Size implied_size { get; } public double price { get; } - public PriceSize(uint sz, uint direct_sz, uint implied_sz, double prx) + public PriceSize(Size sz, Size direct_sz, Size implied_sz, double prx) { size = sz; direct_size = direct_sz;