public void Insert()
        {
            //Setup
            Instrument instrument = new Instrument
            {
                Description = "SLTEST"
            };
            InstrumentList instruments = new InstrumentList();

            instruments.Load();
            int originalCount = instruments.Count();



            //Act
            HttpClient client = InitializeClient();
            //Serialize a instrument object that we're trying to insert
            string serializedInstrument = JsonConvert.SerializeObject(instrument);
            var    content = new StringContent(serializedInstrument);

            content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = client.PostAsync("Instrument", content).Result;

            //Assert
            instruments.Clear();
            instruments.Load();
            Assert.AreEqual(originalCount + 1, instruments.Count);
        }
        void LoadFromDB()
        {
            var connectionStr = ConfigurationManager.ConnectionStrings["MarketDataConnectionString"];

            using (var conn = new SqlConnection(connectionStr.ConnectionString))
            {
                conn.Open();
                var rl = conn.Query <Instrument>("Select * from Table_Instruments", new { }, null, true, 60000).ToList();
                InstrumentList.Clear();
                foreach (var r in rl)
                {
                    r.Ticker    = r.Ticker.Trim();
                    r.Currency  = r.Currency.Trim();
                    r.Industory = r.Industory.Trim();
                    r.Name      = r.Name.Trim();
                    r.Region    = r.Region.Trim();
                    if (r.Memo != null)
                    {
                        r.Memo = r.Memo.Trim();
                    }

                    InstrumentList.Add(r);
                }
            }
            ClearChangedFlag();
        }
 void Load(DistributeAnalyse obj)
 {
     TargetObject = obj;
     InstrumentList.Clear();
     TargetObject.InstrumentList.ForEach(v => InstrumentList.Add(v));
     SectorList.Clear();
     TargetObject.SectorList.ForEach(v => SectorList.Add(v));
     CurrentDataSource = TargetObject.CurrentDataSource;
 }
예제 #4
0
 public void Init()
 {
     AllInstrumentList.Clear();
     InstrumentList.Clear();
     Instrument.AllInstrumentList.ForEach(r =>
     {
         AllInstrumentList.Add(r);
         InstrumentList.Add(r);
     });
 }
예제 #5
0
        public int SetInstrumentInfo(string s)
        {
            var l = CommonLib.CommonProc.ConvertStringToObject <List <Instrument> >(s);

            if (l == null || l.Count == 0)
            {
                return(0);
            }
            InstrumentList.Clear();
            l.ForEach(v => InstrumentList.Add(v));
            return(l.Count);
        }
예제 #6
0
 public List <IMarketData> GetMarketDataList()
 {
     if (CurrentDataSource == null)
     {
         return(null);
     }
     if (AnalyseType != DistributeAnalyseType.Instrument)
     {
         InstrumentList.Clear();
         SectorList.ForEach(s =>
         {
             InstrumentList.AddRange(Instrument.GetInstrumentBySector(s, AnalyseType));
         });
     }
     return(CurrentDataSource.GetDataList(InstrumentList, StartTime, EndTime, Grade));
 }
        void LoadFromFile()
        {
            var dlg = new OpenFileDialog()
            {
                Filter = "Text File|*.txt|Csv File|*.CSV| (*.*)|*.*"
            };

            if (dlg.ShowDialog() == true)
            {
                var ep  = new ReportCommonLib.ReportExportHelper();
                var dic = ep.LoadMappingFile(System.AppDomain.CurrentDomain.BaseDirectory + "MarketDataSupport\\InstrumentMapping.txt");
                var l   = ep.LoadFromCsvFile <InstrumentModel>(dlg.FileName, Encoding.GetEncoding("GB18030")  , GetSeperateChar(), dic , preProcess);
                InstrumentList.Clear();
                l.ForEach(v => InstrumentList.Add(v));
            }
            ClearChangedFlag();
        }
        public void Delete()
        {
            //Setup
            InstrumentList instruments = new InstrumentList();

            instruments.Load();
            int        originalCount = instruments.Count();
            Instrument instrument    = instruments.FirstOrDefault(ct => ct.Description == "SLTEST1");


            //Act
            if (instrument != null)
            {
                HttpClient          client   = InitializeClient();
                HttpResponseMessage response = client.DeleteAsync("Instrument/" + instrument.Id).Result;
            }

            //Assert
            instruments.Clear();
            instruments.Load();
            Assert.AreEqual(originalCount - 1, instruments.Count);
        }
예제 #9
0
        public override void LoadInfo()
        {
            if (TargetProject == null)
            {
                return;
            }

            ConditionList.Clear();
            TargetProject.ConditionList.ForEach(v => ConditionList.Add(new ConditionViewModel()
            {
                TargetObject = v
            }));
            InstrumentList.Clear();
            TargetProject.InstrumentList.ForEach(v => InstrumentList.Add(v));
            CurrentStrategy   = TargetProject.TestStrategy;
            CurrentTradeGate  = TargetProject.CurrentTradeGate;
            CurrentDataSource = TargetProject.CurrentDataSource;
            IsChanged         = false;
            if (TargetSummaryVM != null)
            {
                TargetSummaryVM.Refresh();
            }
        }
예제 #10
0
 public void Filter(string filter)
 {
     InstrumentList.Clear();
     if (!string.IsNullOrEmpty(filter))
     {
         GetTargetProject().InstrumentList.ForEach(v =>
         {
             if (v.Ticker.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0 ||
                 v.Name.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0 ||
                 v.PYName.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0)
             {
                 InstrumentList.Add(v);
             }
         });
     }
     else
     {
         GetTargetProject().InstrumentList.ForEach(v =>
         {
             InstrumentList.Add(v);
         });
     }
 }
예제 #11
0
        public override void LoadInfo()
        {
            if (TargetProject == null)
            {
                return;
            }
            ConditionList.Clear();
            TargetProject.ConditionList.ForEach(v => ConditionList.Add(new ConditionViewModel()
            {
                TargetObject = v
            }));
            PredicateList.Clear();
            TargetProject.PredicateList.ForEach(v => PredicateList.Add(new ConditionViewModel()
            {
                TargetObject = v
            }));

            InstrumentList.Clear();
            TargetProject.InstrumentList.ForEach(v => InstrumentList.Add(v));
            ResultList.Clear();
            TargetProject.ResultList.ForEach(v => ResultList.Add(new InstrumentViewModel()
            {
                TargetObject = v, GetCurrentDataSource = () => { return(CurrentDataSource); }
            }));
            TargetProject.BlockList.ForEach(v => BlockList.Add(new InstrumentViewModel()
            {
                TargetObject = v, GetCurrentDataSource = () => { return(CurrentDataSource); }
            }));
            CurrentDataSource = TargetProject.CurrentDataSource;

            IsChanged = false;
            if (TargetSummaryVM != null)
            {
                TargetSummaryVM.Refresh();
            }
        }
 void Clear()
 {
     InstrumentList.Clear();
 }