Example #1
0
        /// <summary>
        /// Extension method for the Spark.Event struct that converts a Spark event into LimitOrder that can be submitted
        /// into the LimitOrderBook
        /// </summary>
        /// <param name="eventItem">Spark event</param>
        internal static LimitOrder ToLimitOrder(this Spark.Event eventItem)
        {
            MarketSide side      = ApiFunctions.GetMarketSide(eventItem.Flags);
            int        price     = eventItem.Price;
            int        volume    = (int)eventItem.Volume;
            DateTime   timeStamp = DateTimeFromUnixTimestampSeconds(eventItem.Time);

            return(new LimitOrder(side, price, volume, timeStamp));
        }
Example #2
0
 /// <summary>
 /// Convert Spark.Event struct into tab-separted human readable string
 /// </summary>
 /// <param name="eventItem">Spark event item</param>
 internal static string ToOutputString(this Spark.Event eventItem)
 {
     System.Text.StringBuilder result = new StringBuilder();
     result.Append(DateTimeFromUnixTimestampSeconds(eventItem.Time).ToMarketDateTime() + "\t");
     result.Append(Spark.EventTypeToStr(eventItem.Type) + "\t");
     result.Append(eventItem.Code + "\t");
     result.Append(eventItem.Exchange + "\t");
     result.Append(ApiFunctions.GetMarketSide(eventItem.Flags).ToString() + "\t");
     result.Append(eventItem.Price.ToPriceString() + "\t");
     result.Append(eventItem.Volume + "\t");
     result.Append(Spark.ConditionCodesToStr(eventItem.ConditionCodes, eventItem.Exchange) + "\t");
     result.Append(eventItem.Flags + "\t");
     result.Append(Spark.StateToStr(eventItem.State) + "\t");
     result.Append(eventItem.Position + "\t");
     result.Append(Spark.QuoteBasesToStr(eventItem.QuoteBases, eventItem.Exchange) + "\t");
     result.Append(eventItem.Reference + "\t");
     result.Append(eventItem.Count + "\t");
     return(result.ToString());
 }