Example #1
0
        public static MarketDetail CreateMarketDetail(string exchange, string instrument, string name)
        {
            MarketDetail result = new MarketDetail();

            switch (exchange)
            {
            case "大连":
                result.ExchangeID = ExchangeID.DCE;
                break;

            case "上海":
                result.ExchangeID = ExchangeID.SHFE;
                break;

            case "中金":
                result.ExchangeID = ExchangeID.CFFEX;
                break;

            case "郑州":
                result.ExchangeID = ExchangeID.CZCE;
                break;
            }
            result.InstrumentID   = instrument;
            result.InstrumentName = name;
            return(result);
        }
Example #2
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;
     }
 }
Example #3
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);
        }
Example #4
0
        public static MarketDetail CreateMarketDetail(CLRDFITCDepthMarketDataField market)
        {
            MarketDetail result = new MarketDetail();

            switch (market.exchangeID)
            {
            case "DCE":
                result.ExchangeID = ExchangeID.DCE;
                break;

            case "CZCE":
                result.ExchangeID = ExchangeID.CZCE;
                break;

            case "SHFE":
                result.ExchangeID = ExchangeID.SHFE;
                break;

            case "CFFEX":
                result.ExchangeID = ExchangeID.CFFEX;
                break;

            case "INE":
                result.ExchangeID = ExchangeID.INE;
                break;
            }
            result.InstrumentID     = market.instrumentID;
            result.LatestPrice      = market.lastPrice;
            result.OpenPrice        = market.openPrice;
            result.HighestPrice     = market.highestPrice;
            result.LowestPrice      = market.lowestPrice;
            result.ClosePrice       = market.closePrice;
            result.Volume           = market.Volume;
            result.TopLimitPrice    = market.upperLimitPrice;
            result.BottomLimitPrice = market.lowerLimitPrice;
            return(result);
        }