Exemple #1
0
 public static void AddInstrument(QuikConnectionManager.StaticInstrument obj)
 {
     if (Instruments.Any(k => k.Id == obj.Id))
     {
         //var i=Instruments.First(k => k.Id == obj.Id);
         log.Warn("Trying to add existing instrument Id={0} Code={1} Class={2} ", obj.Id, obj.Code, obj.Class);
     }
     else
     {
         if (obj.InstrumentType == "Futures")
         {
             Entities.Instrument instr = new Entities.Instrument(obj.Id, obj.Code, obj.Class, Entities.InstrumentType.Futures, obj.BaseContract, obj.BaseContractClass, obj.FullName);
             instr.DaysToMate   = obj.DaysToMate;
             instr.MaturityDate = Convert.ToDateTime(obj.MaturityDate).Date;
             Instruments.Add(instr);
         }
         else
         {
             Entities.Instrument instr = new Entities.Instrument(obj.Id, obj.Code, obj.Class, Entities.InstrumentType.Option, obj.FullName, obj.OptionType == "Call" ? Entities.OptionType.Call : Entities.OptionType.Put, obj.Strike, obj.BaseContract, obj.BaseContractClass);
             instr.DaysToMate   = obj.DaysToMate;
             instr.MaturityDate = Convert.ToDateTime(obj.MaturityDate).Date;
             Instruments.Add(instr);
         }
         log.Trace("New instrument added Id={0} Code={1} Class={2}", obj.Id, obj.Code, obj.Class);
     }
 }
Exemple #2
0
 public static void UpdatePosition(QuikConnectionManager.Position obj)
 {
     if (Positions.Any(k => k.AccountName == obj.AccountName && k.Instrument.Code == obj.SecurityCode))
     {
         Entities.Position p = Positions.First(k => k.AccountName == obj.AccountName && k.Instrument.Code == obj.SecurityCode);
         p.Update(obj.TotalNet, obj.BuyQty, obj.SellQty, obj.VarMargin);
         //p.TotalNet = obj.TotalNet;
         //p.BuyQty = obj.BuyQty;
         //p.SellQty = obj.SellQty;
         //p.VM = obj.VarMargin;
     }
     else
     {
         log.Warn("Update on unknown position {0} {1}", obj.AccountName, obj.SecurityCode);
     }
     // update portfolio
     try
     {
         Entities.Instrument i    = Instruments.First(k => k.Code == obj.SecurityCode);
         string             basec = i.Type == Entities.InstrumentType.Futures? i.Code:i.BaseContract;
         Entities.Portfolio p     = Portfolios.First(k => k.Account == obj.AccountName && k.BaseCode == basec);
         Entities.Position  pos   = p.Positions.First(k => k.AccountName == obj.AccountName && k.Instrument.Code == obj.SecurityCode);
         pos.Update(obj.TotalNet, obj.BuyQty, obj.SellQty, obj.VarMargin);
         //pos.TotalNet=obj.TotalNet;
         //pos.VM = obj.VarMargin;
         //pos.BuyQty = obj.BuyQty;
         //pos.SellQty = obj.SellQty;
     }
     catch { log.Warn("Can`t find portfolio for position update!"); }
 }
Exemple #3
0
        public static void AddInstrument(QuikConnectionManager.StaticInstrument obj)
        {
            if (Instruments.Any(k=> k.Id==obj.Id))
            {
                //var i=Instruments.First(k => k.Id == obj.Id);
                log.Warn("Trying to add existing instrument Id={0} Code={1} Class={2} ",obj.Id,obj.Code,obj.Class);

            }
            else
            {
                if (obj.InstrumentType == "Futures")
                {
                    Entities.Instrument instr = new Entities.Instrument(obj.Id, obj.Code, obj.Class, Entities.InstrumentType.Futures, obj.BaseContract,obj.BaseContractClass, obj.FullName);
                    instr.DaysToMate = obj.DaysToMate;
                    instr.MaturityDate = Convert.ToDateTime(obj.MaturityDate).Date;
                    Instruments.Add(instr);
                }
                else
                {
                    Entities.Instrument instr = new Entities.Instrument(obj.Id, obj.Code, obj.Class, Entities.InstrumentType.Option, obj.FullName, obj.OptionType == "Call" ? Entities.OptionType.Call : Entities.OptionType.Put, obj.Strike, obj.BaseContract, obj.BaseContractClass);
                    instr.DaysToMate = obj.DaysToMate;
                    instr.MaturityDate = Convert.ToDateTime(obj.MaturityDate).Date;
                    Instruments.Add(instr);
                }
                log.Trace("New instrument added Id={0} Code={1} Class={2}",obj.Id,obj.Code,obj.Class);
            }
        }
Exemple #4
0
 public DeskViewModel(Entities.Instrument Call, Entities.Instrument Put, double strike, DateTime MatDate)
 {
     this._Put = Put;
     this._Call = Call;
     this._Strike = strike;
     this._MaturityDate = MatDate;
     this._IsViewed = false;
 }