public void Start() { m_setting = Setting.GetInstance(); if (m_setting.Exchange == null || string.IsNullOrEmpty(m_setting.Parameter.Symbol)) { Console.WriteLine("Does not find setting.xml file. Type any key to exist ..."); Console.Read(); return; } m_mockTrade = m_setting.IsMockTrade; m_exchange = m_setting.Exchange; m_account = new StockAccount(); m_fairValueMgr = FairValueMgr.GetInstance(); m_quoteMgr = QuoteMgr.GetInstance(); m_hedgeMgr = AutoHedgeMgr.GetInstance(); m_quoteParameter = m_setting.Parameter; //Test ExchangeOKDEX okdex = m_exchange as ExchangeOKDEX; string privateKey = m_setting.ExchangeSettingMap["PrivateKey"]; string key = okdex.GetPublicKey(privateKey); //quote logic m_quoteThread = new Thread(() => m_quoteMgr.Start()); m_quoteThread.Start(); //Update fair value logic m_marketDataThread = new Thread(() => m_fairValueMgr.Start(m_setting.Parameter.Symbol)); m_marketDataThread.Start(); //Hedge logic m_hedgeThread = new Thread(() => m_hedgeMgr.Start()); m_hedgeThread.Start(); }
public void LoadSetting() { string fileName = "Setting.xml"; if (File.Exists(fileName)) { XmlDocument doc = new XmlDocument(); doc.Load(fileName); //Exchange XmlNode exchangeNode = doc.DocumentElement.SelectSingleNode("Exchange"); if (null != exchangeNode) { //Only support okdex currently if (exchangeNode.Attributes["Type"].Value == "ExchangeOKDEX") { Exchange = new ExchangeOKDEX(); } if (exchangeNode.Attributes.GetNamedItem("MockTrade") != null && exchangeNode.Attributes["MockTrade"].Value == "1") { IsMockTrade = true; } foreach (XmlAttribute attribute in exchangeNode.Attributes) { ExchangeSettingMap[attribute.Name] = attribute.Value; } } //Quote parameter XmlNode paraNode = doc.DocumentElement.SelectSingleNode("Quote"); if (null != paraNode) { foreach (XmlAttribute attribute in paraNode.Attributes) { switch (attribute.Name) { case "Symbol": Parameter.Symbol = attribute.Value.Replace("-", "_"); break; case "BaseVolume": Parameter.BaseVolume = double.Parse(attribute.Value); break; case "QuoteVolume": Parameter.QuoteVolume = double.Parse(attribute.Value); break; case "QuoteVolumeRatioThreshold": Parameter.QuoteVolumeRatioThreshold = double.Parse(attribute.Value); break; case "QuotePriceSpreadRatio": Parameter.QuotePriceSpreadRatio = double.Parse(attribute.Value); break; case "QuotePriceRatioThreshold": Parameter.QuotePriceRatioThreshold = double.Parse(attribute.Value); break; case "AutoHedgeVolumeThreshold": Parameter.AutoHedgeVolumeThreshold = double.Parse(attribute.Value); break; default: break; } } } } }