Changing managed PriceSize structure's size into floats
This commit is contained in:
1 parent
95e99f4855
commit
b5da4b3129
5 files changed
+29
-17
No files matched your search
+1
-1
Submodule externals updated: 5436e5a107...38b54a636f.
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -4,28 +4,29 @@ namespace mbts.co2 {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Size = System.Single;
|
||||
|
||||
public readonly struct NativePriceSize : IEquatable<NativePriceSize> {
|
||||
readonly IntPrice _price;
|
||||
readonly uint _size;
|
||||
readonly uint _direct_size;
|
||||
readonly Size _size;
|
||||
readonly Size _direct_size;
|
||||
|
||||
static NativePriceSize() =>
|
||||
Log.assert(Marshal.SizeOf<NativePriceSize>() == 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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user