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
        protected override void InstantiationFinished()
        {
            base.InstantiationFinished();
            var gnrl = AlphaClient.Instance.GetRoot <GeneralVM>();

            Instruments = gnrl.DerivativeVMs;
            Slots       = CreateObservableCollection(m_slots);

            CollectionViewSource.GetDefaultView(Instruments).Filter = InstrumentsFilter;
            CollectionViewSource.GetDefaultView(Slots).Filter       = SlotsFilter;

            CollectionViewSource.GetDefaultView(Slots).CollectionChanged += SlotsCollectionChanged;

            AddCommand    = new RelayCommand(ExecuteAdd, _o => Instruments.Any(_vm => _vm.Selected && InstrumentsFilter(_vm)));
            RemoveCommand = new RelayCommand(ExecuteRemove, _o => Slots.Any(_vm => _vm.Selected && SlotsFilter(_vm)));
        }