예제 #1
0
        public static void WriteCompressedDecimal(this IWriteBytes stream, decimal value)
        {
            value = value / 1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000m;
            var bits = decimal.GetBits(value);

            stream.WriteCompressedInt(bits[0]);
            stream.WriteCompressedInt(bits[1]);
            stream.WriteCompressedInt(bits[2]);
            stream.WriteCompressedInt(bits[3]);
        }
예제 #2
0
 public static void WriteDoubleOffset(this IWriteBytes stream, double seed, double tickSize, double value)
 {
     if (value == seed)
     {
         /// Since this is true 80% of the time in a trading platform, we use this optimization for significant performance gains.
         stream.WriteCompressedInt(0);
     }
     else
     {
         stream.WriteCompressedInt(ToTicks(value - seed, tickSize));
     }
 }
예제 #3
0
 public static void WriteCompressedNullableInt(this IWriteBytes stream, int?value)
 {
     if (value.HasValue)
     {
         stream.WriteCompressedBool(true);
         stream.WriteCompressedInt(value.Value);
     }
     else
     {
         stream.WriteCompressedBool(false);
     }
 }
예제 #4
0
 public static void WriteCompressedEnum <T>(this IWriteBytes stream, T value) where T : Enum
 {
     stream.WriteCompressedInt((int)(object)value);
 }