Ejemplo n.º 1
0
        public static TradeField GetTrade(CtpTrade data)
        {
            if (data == null)
            {
                return(null);
            }
            var trade = new TradeField();

            trade.ID            = data.OrderRef;
            trade.ClientID      = data.OrderSysID;
            trade.InstrumentID  = data.InstrumentID;
            trade.ExchangeID    = data.ExchangeID;
            trade.AccountID     = data.InvestorID;
            trade.TradeID       = data.TradeID;
            trade.Side          = GetOrderSide(data.Direction);
            trade.Qty           = data.Volume;
            trade.Price         = data.Price;
            trade.OpenClose     = GetOpenClose(data.OffsetFlag);
            trade.HedgeFlag     = GetHedgeFlag(data.HedgeFlag);
            trade.Commission    = 0;//TODO收续费以后要计算出来
            trade.Time          = GetTime(data.TradeTime);
            trade.Date          = GetDate(data.TradeDate);
            trade.ReserveChar64 = CtpClientId;
            return(trade);
        }
Ejemplo n.º 2
0
 public static string DebugInfo(this TradeField field)
 {
     if (field == null)
     {
         return(string.Empty);
     }
     return($"[InstrumentID={field.InstrumentID};ExchangeID={field.ExchangeID};Side={field.Side};Qty={field.Qty};Price={field.Price};OpenClose={field.OpenClose};HedgeFlag={field.HedgeFlag};ID={field.ID};TradeID={field.TradeID};Date={field.Date};Time={field.Time};Commission={field.Commission}]");
 }
Ejemplo n.º 3
0
 public static DateTime UpdateTime(this TradeField field)
 {
     if (field == null || field.Time == 0)
     {
         return(DateTime.MaxValue);
     }
     return(GetDateTime(field.Date, field.Time));
 }
Ejemplo n.º 4
0
        public static DateTime UpdateTime(this TradeField field)
        {
            if (field == null || field.Time == 0)
            {
                return(DateTime.MaxValue);
            }
            var hh = field.Time / 10000;
            var mm = field.Time % 10000 / 100;
            var ss = field.Time % 100;

            if (field.Date > 0)
            {
                var year  = field.Date / 10000;
                var month = field.Date % 10000 / 100;
                var day   = field.Date % 100;
                return(new DateTime(year, month, day, hh, mm, ss));
            }
            return(DateTime.Today.Add(new TimeSpan(hh, mm, ss)));
        }
Ejemplo n.º 5
0
 void IXSpi.ProcessRtnTrade(TradeField trade)
 {
     TradeReturn?.Invoke(this, trade);
 }
Ejemplo n.º 6
0
 void IXSpi.ProcessQryTrade(TradeField trade, bool last)
 {
     TradeReceived?.Invoke(this, trade, last);
 }
Ejemplo n.º 7
0
 public static string DebugInfo(this TradeField field)
 {
     return(field == null ? string.Empty : $"[InstrumentID={field.InstrumentID},ExchangeID={field.ExchangeID},Side={field.Side},Qty={field.Qty},Price={field.Price},OpenClose={field.OpenClose},HedgeFlag={field.HedgeFlag},ID={field.ID},TradeID={field.TradeID},Date={field.Date},Time={field.Time},Commission={field.Commission}]");
 }