示例#1
0
        /// <summary>
        /// Process the config file for the simulator
        /// </summary>
        /// <param name="myPath"></param>
        private void processConfigFile(string myPath)
        {
            try
            {
                using (StreamReader sr = new StreamReader(myPath))
                {
                    _config = JsonConvert.DeserializeObject<SimulatorConfig>(sr.ReadToEnd());
                }

                if (_config.ProductFilePath.Length > 0)
                {
                    AddProductDirect(_config.ProductFilePath);
                }

                // process the config file products these are the things we will simulate
                foreach (SimulatorProduct myProd in _config.SimulatorProduct)
                {
                    try
                    {

                        _products.Add(myProd.Mnemonic, myProd);
                        if (myProd.RunAsMarket)
                        {
                            CreateMarket(myProd.Mnemonic);
                        }

                        if (myProd.CannedData != null && myProd.IsCannedData)
                        {
                            this.AddPriceFile(myProd.Mnemonic, myProd.CannedData.CannedDataFile, myProd.CannedData.RunInterval, myProd.CannedData.RunRealTime, myProd.CannedData.RepeatOnEnd, myProd.CannedData.PlayOnSubscribe);
                        }
                        else
                        {
                            _products.Add(myProd.Mnemonic, myProd);
                        }

                    }
                    catch (Exception myE)
                    {
                        log.Error("processConfigFile:loop", myE);
                    }
                }

            }
            catch (Exception myE)
            {
                log.Error("processConfigFile", myE);
            }
        }
示例#2
0
        private void genSampleConfig()
        {
            SimulatorConfig config = new SimulatorConfig();
            SimulatorProduct mySimProduct = new SimulatorProduct();
            CannedData cannedData = new CannedData();
            K2DataObjects.Product myProduct = new K2DataObjects.Product();

            myProduct.Symbol = "EPZ8";
            myProduct.CFICode = "FXXXXX";
            myProduct.MMY = "20081219";
            myProduct.Exchange = "CME";
            myProduct.TradeVenue = "CQG";
            myProduct.Mnemonic = "EMINI";
            myProduct.LongName = "CME eMini SP500";
            myProduct.SecurityID = "ZPZ8";

            //mySimProduct.InstrDef = myProduct;
            mySimProduct.HighPrice = 99.99M;
            mySimProduct.LowPrice = 98.99M;
            mySimProduct.IsAutoFill = true;
            mySimProduct.IsCannedData = true;
            mySimProduct.RunAsMarket = true;
            mySimProduct.Mnemonic = "EPZ8";

            cannedData.CannedDataFile = "filepath";
            cannedData.RepeatOnEnd = true;
            cannedData.RunInterval = 100;
            cannedData.RunRealTime = true;
            cannedData.PlayOnSubscribe = true;

            mySimProduct.CannedData = cannedData;

            config.SimulatorProduct.Add(mySimProduct);

            string configData = JsonConvert.SerializeObject(config);

            //m_Config.
               // _config.ToXmlFile("KTSimConfigTEMP.xml");
        }