Exemplo n.º 1
0
 private void OnMarketDataReturn(object sender, RspEventArgs e)
 {
     switch (sender.ToString())
     {
     case "ProgramTradeApi.XMduserSpi":
         MarketDetail market = MarketDetail.CreateMarketDetail((e as TypedRspEventArgs <CLRDFITCDepthMarketDataField, object>).Data);
         Markets.AddOrUpdate(market.InstrumentID, market, (k, v) => { market.InstrumentName = v.InstrumentName; return(market); });
         //eventMarketChanged?.Invoke(this, null);
         break;
     }
 }
Exemplo n.º 2
0
        public MarketList CreateMarketsFromConf(string path = "")
        {
            MarketList list = new MarketList();

            //list.TryAdd("a1607", MarketDetail.CreateMarketDetail("大连", "a1607", "黄大豆1号"));
            //list.TryAdd("a1609", MarketDetail.CreateMarketDetail("大连", "a1609", "黄大豆1号"));
            //list.TryAdd("a1611", MarketDetail.CreateMarketDetail("大连", "a1611", "黄大豆1号"));
            System.IO.FileStream   fs = null;
            System.IO.StreamReader rd = null;
            try
            {
                fs = new System.IO.FileStream(@"Instruments.csv", System.IO.FileMode.Open, System.IO.FileAccess.Read);
                rd = new System.IO.StreamReader(fs, Encoding.Default);
                rd.ReadLine();
                string line = "";
                while ((line = rd.ReadLine()) != null)
                {
                    string[] items = line.Split(',');
                    list.TryAdd(items[1], MarketDetail.CreateMarketDetail(items[0], items[1], items[2]));
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                // do something here
                fs = null;
                rd = null;
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
                if (rd != null)
                {
                    rd.Close();
                }
            }
            return(list);
        }