/// <summary> /// /// </summary> /// <returns></returns> internal List<Business.IGroupSymbol> GetAllIGroupSymbol() { List<Business.IGroupSymbol> Result = new List<Business.IGroupSymbol>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.IGroupSymbolTableAdapter adap = new DSTableAdapters.IGroupSymbolTableAdapter(); DSTableAdapters.IGroupSymbolConfigTableAdapter adapIGroupSymbolConfig = new DSTableAdapters.IGroupSymbolConfigTableAdapter(); DS.IGroupSymbolDataTable tbIGroupSymbol = new DS.IGroupSymbolDataTable(); DS.IGroupSymbolConfigDataTable tbIGroupSymbolConfig = new DS.IGroupSymbolConfigDataTable(); try { conn.Open(); adap.Connection = conn; adapIGroupSymbolConfig.Connection = conn; tbIGroupSymbol = adap.GetData(); if (tbIGroupSymbol != null) { int count = tbIGroupSymbol.Count; for (int i = 0; i < count; i++) { Business.IGroupSymbol newIGroupSymbol = new Business.IGroupSymbol(); newIGroupSymbol.IGroupSymbolID = tbIGroupSymbol[i].IGroupSymbolID; newIGroupSymbol.SymbolID = tbIGroupSymbol[i].SymbolID; newIGroupSymbol.InvestorGroupID = tbIGroupSymbol[i].InvestorGroupID; tbIGroupSymbolConfig = adapIGroupSymbolConfig.GetIGroupSymbolConfigByIGroupSymbolID(tbIGroupSymbol[i].IGroupSymbolID); if (tbIGroupSymbolConfig != null) { int countIGroupSymbolConfig = tbIGroupSymbolConfig.Count; for (int j = 0; j < countIGroupSymbolConfig; j++) { Business.ParameterItem newParameterItem = new Business.ParameterItem(); newParameterItem.ParameterItemID = tbIGroupSymbolConfig[j].IGroupSymbolConfigID; newParameterItem.SecondParameterID = tbIGroupSymbolConfig[j].IGroupSymbolID; newParameterItem.CollectionValue = new List<Business.ParameterItem>(); newParameterItem.Name = tbIGroupSymbolConfig[j].Name; newParameterItem.Code = tbIGroupSymbolConfig[j].Code; newParameterItem.BoolValue = tbIGroupSymbolConfig[j].BoolValue; newParameterItem.StringValue = tbIGroupSymbolConfig[j].StringValue; newParameterItem.NumValue = tbIGroupSymbolConfig[j].NumValue; newParameterItem.DateValue = tbIGroupSymbolConfig[j].DateValue; if (newIGroupSymbol.IGroupSymbolConfig == null) newIGroupSymbol.IGroupSymbolConfig = new List<Business.ParameterItem>(); newIGroupSymbol.IGroupSymbolConfig.Add(newParameterItem); } } //newIGroupSymbol.IGroupSymbolConfig = TradingServer.Facade.FacadeGetIGroupSymbolConfigByIGroupSymbolID(tbIGroupSymbol[i].IGroupSymbolID); Result.Add(newIGroupSymbol); } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="SecurityConfigID"></param> /// <param name="SecurityID"></param> /// <param name="CollectionValue"></param> /// <param name="Name"></param> /// <param name="Code"></param> /// <param name="NumValue"></param> /// <param name="StringValue"></param> /// <param name="DateValue"></param> /// <param name="BoolValue"></param> public bool UpdateSecurityConfig(int SecurityConfigID, int SecurityID, int CollectionValue, string Name, string Code, string NumValue, string StringValue, DateTime DateValue, int BoolValue) { bool Result = false; Business.ParameterItem oldSecurityConfig = new Business.ParameterItem(); oldSecurityConfig = SecurityConfigInstance.GetSecurityConfigBySecurityConfigID(SecurityConfigID); Result = SecurityConfigInstance.UpdateSecurityConfig(SecurityConfigID, SecurityID, CollectionValue, Name, Code, NumValue, StringValue, DateValue, BoolValue); List<Business.ParameterItem> newLSecurityConfig = new List<ParameterItem>(); newLSecurityConfig = Security.SecurityConfigInstance.GetSecurityConfigBySecurityID(SecurityID); if (Market.SecurityList != null) { int count = Market.SecurityList.Count; for (int i = 0; i < count; i++) { if (Market.SecurityList[i].SecurityID == SecurityID) { Market.SecurityList[i].ParameterItems = newLSecurityConfig; break; } } if (SecurityID != oldSecurityConfig.SecondParameterID) { List<Business.ParameterItem> oldLSecurityConfig = new List<ParameterItem>(); oldLSecurityConfig = Security.SecurityConfigInstance.GetSecurityConfigBySecurityID(oldSecurityConfig.SecondParameterID); for (int i = 0; i < count; i++) { if (Market.SecurityList[i].SecurityID == oldSecurityConfig.SecondParameterID) { Market.SecurityList[i].ParameterItems = oldLSecurityConfig; } } } } return Result; }
/// <summary> /// /// </summary> /// <param name="MarketAreaID"></param> /// <returns></returns> internal List<Business.ParameterItem> GetMarketAreaConfigByMarketAreaID(int MarketAreaID) { List<Business.ParameterItem> Result = new List<Business.ParameterItem>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.MarketAreaConfigTableAdapter adap = new DSTableAdapters.MarketAreaConfigTableAdapter(); DS.MarketAreaConfigDataTable tbMarketAreaConfig = new DS.MarketAreaConfigDataTable(); try { conn.Open(); adap.Connection = conn; tbMarketAreaConfig = adap.GetMarketAreaConfigByMarketAreaID(MarketAreaID); if (tbMarketAreaConfig != null) { int count = tbMarketAreaConfig.Count; for (int i = 0; i < count; i++) { Business.ParameterItem newParameterItem = new Business.ParameterItem(); newParameterItem.ParameterItemID = tbMarketAreaConfig[i].MarketAreaConfigID; newParameterItem.SecondParameterID = tbMarketAreaConfig[i].MarketAreaID; newParameterItem.Code = tbMarketAreaConfig[i].Code; newParameterItem.Name = tbMarketAreaConfig[i].Name; newParameterItem.BoolValue = tbMarketAreaConfig[i].BoolValue; newParameterItem.StringValue = tbMarketAreaConfig[i].StringValue; newParameterItem.NumValue = tbMarketAreaConfig[i].NumValue; newParameterItem.DateValue = tbMarketAreaConfig[i].DateValue; Result.Add(newParameterItem); } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <returns></returns> internal List<Business.InvestorGroup> GetAllInvestorGroup() { List<Business.InvestorGroup> Result = new List<Business.InvestorGroup>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorGroupTableAdapter adap = new DSTableAdapters.InvestorGroupTableAdapter(); DSTableAdapters.InvestorGroupConfigTableAdapter adapInvestorGroupConfig = new DSTableAdapters.InvestorGroupConfigTableAdapter(); DS.InvestorGroupDataTable tbInvestorGroup = new DS.InvestorGroupDataTable(); DS.InvestorGroupConfigDataTable tbInvestorGroupConfig = new DS.InvestorGroupConfigDataTable(); try { conn.Open(); adap.Connection = conn; adapInvestorGroupConfig.Connection = conn; tbInvestorGroup = adap.GetData(); if (tbInvestorGroup != null) { int count = tbInvestorGroup.Count; for (int i = 0; i < count; i++) { Business.InvestorGroup newInvestorGroup = new Business.InvestorGroup(); newInvestorGroup.DefautDeposite = tbInvestorGroup[i].DefautDeposite; newInvestorGroup.InvestorGroupID = tbInvestorGroup[i].InvestorGroupID; newInvestorGroup.Name = tbInvestorGroup[i].Name; newInvestorGroup.Owner = tbInvestorGroup[i].Owner; //newInvestorGroup.ParameterItems = DBWInvestorGroup.DBWInvestorGroupConfigInstance.GetInvestorGroupConfigByInvestorGroupID(tbInvestorGroup[i].InvestorGroupID); tbInvestorGroupConfig = adapInvestorGroupConfig.GetInvestorGroupConfigByInvestorGroupID(tbInvestorGroup[i].InvestorGroupID); if (tbInvestorGroupConfig != null) { int countInvestorGroupConfig = tbInvestorGroupConfig.Count; for (int j = 0; j < countInvestorGroupConfig; j++) { Business.ParameterItem newParameterItem = new Business.ParameterItem(); newParameterItem.BoolValue = tbInvestorGroupConfig[j].BoolValue; newParameterItem.Code = tbInvestorGroupConfig[j].Code; newParameterItem.DateValue = tbInvestorGroupConfig[j].DateValue; newParameterItem.NumValue = tbInvestorGroupConfig[j].NumValue; newParameterItem.ParameterItemID = tbInvestorGroupConfig[j].InvestorGroupConfigID; newParameterItem.SecondParameterID = tbInvestorGroupConfig[j].InvestorGroupID; newParameterItem.Name = tbInvestorGroupConfig[j].Name; newParameterItem.StringValue = tbInvestorGroupConfig[j].StringValue; if (tbInvestorGroupConfig[j].Code == "G01") { bool isEnable = false; if (tbInvestorGroupConfig[j].BoolValue == 1) isEnable = true; newInvestorGroup.IsEnable = isEnable; } if (tbInvestorGroupConfig[j].Code == "G26") { newInvestorGroup.FreeMargin = tbInvestorGroupConfig[j].StringValue; } if (tbInvestorGroupConfig[j].Code == "G19") { double MarginCallLevel = 0; double.TryParse(tbInvestorGroupConfig[j].NumValue, out MarginCallLevel); newInvestorGroup.MarginCall = MarginCallLevel; } if (tbInvestorGroupConfig[j].Code == "G20") { double MarginStopOutLevel = 0; double.TryParse(tbInvestorGroupConfig[j].NumValue, out MarginStopOutLevel); newInvestorGroup.MarginStopOut = MarginStopOutLevel; } if (tbInvestorGroupConfig[j].Code == "G38") { if (tbInvestorGroupConfig[j].BoolValue == 1) newInvestorGroup.IsManualStopOut = true; } if (newInvestorGroup.ParameterItems == null) newInvestorGroup.ParameterItems = new List<Business.ParameterItem>(); newInvestorGroup.ParameterItems.Add(newParameterItem); } } //if (newInvestorGroup.ParameterItems != null) //{ // int countParameter = newInvestorGroup.ParameterItems.Count; // for (int j = 0; j < countParameter; j++) // { // if (newInvestorGroup.ParameterItems[j].Code == "G26") // { // newInvestorGroup.FreeMargin = newInvestorGroup.ParameterItems[j].StringValue; // } // if (newInvestorGroup.ParameterItems[j].Code == "G19") // { // double MarginCallLevel=0; // double.TryParse(newInvestorGroup.ParameterItems[j].NumValue, out MarginCallLevel); // newInvestorGroup.MarginCall = MarginCallLevel; // } // if (newInvestorGroup.ParameterItems[j].Code == "G20") // { // double MarginStopOutLevel = 0; // double.TryParse(newInvestorGroup.ParameterItems[j].NumValue, out MarginStopOutLevel); // newInvestorGroup.MarginStopOut = MarginStopOutLevel; // } // } //} Result.Add(newInvestorGroup); } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); adapInvestorGroupConfig.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <returns></returns> internal List<Business.ParameterItem> GetAllMarketConfig() { List<Business.ParameterItem> Result = new List<Business.ParameterItem>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.MarketConfigTableAdapter adap = new DSTableAdapters.MarketConfigTableAdapter(); DS.MarketConfigDataTable tbMarketConfig = new DS.MarketConfigDataTable(); try { conn.Open(); adap.Connection = conn; tbMarketConfig = adap.GetData(); if (tbMarketConfig != null) { int count = tbMarketConfig.Count; for (int i = 0; i < count; i++) { if (tbMarketConfig[i].Code == "C36") { if (tbMarketConfig[i].BoolValue == 1) Business.Market.IsConnectMT4 = true; else Business.Market.IsConnectMT4 = false; } if (tbMarketConfig[i].Code == "C44") Business.Market.ScalperTimeValue = int.Parse(tbMarketConfig[i].NumValue); if (tbMarketConfig[i].Code == "C45") Business.Market.ScalperPipValue = int.Parse(tbMarketConfig[i].NumValue); if (tbMarketConfig[i].Code == "C36") Business.Market.CompanyWebsite = tbMarketConfig[i].StringValue; if (tbMarketConfig[i].Code == "C37") Business.Market.AccessLink = tbMarketConfig[i].StringValue; if (tbMarketConfig[i].Code == "C38") Business.Market.ServiceName = tbMarketConfig[i].StringValue; if (tbMarketConfig[i].Code == "C39") Business.Market.MailSupport = tbMarketConfig[i].StringValue; if (tbMarketConfig[i].Code == "C40") Business.Market.MailContact = tbMarketConfig[i].StringValue; if (tbMarketConfig[i].Code == "C41") Business.Market.CompanyName = tbMarketConfig[i].StringValue; if (tbMarketConfig[i].Code == "C42") Business.Market.About = tbMarketConfig[i].StringValue; if (tbMarketConfig[i].Code == "C43") Business.Market.CompanyCopyright = tbMarketConfig[i].StringValue; Business.ParameterItem newParameterItem = new Business.ParameterItem(); newParameterItem.ParameterItemID = tbMarketConfig[i].MarketConfigID; newParameterItem.Name = tbMarketConfig[i].Name; newParameterItem.Code = tbMarketConfig[i].Code; newParameterItem.BoolValue = tbMarketConfig[i].BoolValue; newParameterItem.StringValue = tbMarketConfig[i].StringValue; newParameterItem.NumValue = tbMarketConfig[i].NumValue; newParameterItem.DateValue = tbMarketConfig[i].DateValue; Result.Add(newParameterItem); } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="MarketAreaConfigID"></param> /// <returns></returns> internal Business.ParameterItem GetMarketAreaConfigByID(int MarketAreaConfigID) { Business.ParameterItem Result = new Business.ParameterItem(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.MarketAreaConfigTableAdapter adap = new DSTableAdapters.MarketAreaConfigTableAdapter(); DS.MarketAreaConfigDataTable tbMarketAreaConfig = new DS.MarketAreaConfigDataTable(); try { conn.Open(); adap.Connection = conn; tbMarketAreaConfig = adap.GetMarketAreaConfigByID(MarketAreaConfigID); if (tbMarketAreaConfig != null) { Result.ParameterItemID = tbMarketAreaConfig[0].MarketAreaConfigID; Result.SecondParameterID = tbMarketAreaConfig[0].MarketAreaID; Result.Code = tbMarketAreaConfig[0].Code; Result.Name = tbMarketAreaConfig[0].Name; Result.BoolValue = tbMarketAreaConfig[0].BoolValue; Result.StringValue = tbMarketAreaConfig[0].StringValue; Result.NumValue = tbMarketAreaConfig[0].NumValue; Result.DateValue = tbMarketAreaConfig[0].DateValue; } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <returns></returns> internal List<Business.Security> GetAllSecurity() { List<Business.Security> Result = new List<Business.Security>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.SecurityTableAdapter adap = new DSTableAdapters.SecurityTableAdapter(); DSTableAdapters.SecurityConfigTableAdapter adapSecurityConfig = new DSTableAdapters.SecurityConfigTableAdapter(); DSTableAdapters.SymbolTableAdapter adapSymbol = new DSTableAdapters.SymbolTableAdapter(); DSTableAdapters.TradingConfigTableAdapter adapTradingConfig = new DSTableAdapters.TradingConfigTableAdapter(); DS.SymbolDataTable tbSymbol = new DS.SymbolDataTable(); DS.TradingConfigDataTable tbTradingConfig = new DS.TradingConfigDataTable(); DS.SecurityDataTable tbSecurity = new DS.SecurityDataTable(); DS.SecurityConfigDataTable tbSecurityConfig = new DS.SecurityConfigDataTable(); try { conn.Open(); adap.Connection = conn; adapSecurityConfig.Connection = conn; adapSymbol.Connection = conn; adapTradingConfig.Connection = conn; tbSecurity = adap.GetData(); if (tbSecurity != null) { int count = tbSecurity.Count; for (int i = 0; i < count; i++) { Business.Security newSecurity = new Business.Security(); newSecurity.ParameterItems = new List<Business.ParameterItem>(); newSecurity.SymbolGroup = new List<Business.Symbol>(); newSecurity.SecurityID = tbSecurity[i].SecurityID; newSecurity.Name = tbSecurity[i].Name; newSecurity.Description = tbSecurity[i].Description; newSecurity.MarketAreaID = tbSecurity[i].MarketAreaID; #region GET SECURITY CONFIG BY SECURITY ID //GET SECURITY CONFIG BY SECURITY ID tbSecurityConfig = adapSecurityConfig.GetSecurityConfigBySecurityID(newSecurity.SecurityID); if (tbSecurityConfig != null) { int countSecurityConfig = tbSecurityConfig.Count; for (int j = 0; j < countSecurityConfig; j++) { Business.ParameterItem newParameterItem = new Business.ParameterItem(); newParameterItem.ParameterItemID = tbSecurityConfig[j].SecurityConfigID; newParameterItem.SecondParameterID = tbSecurityConfig[j].SecurityID; newParameterItem.Name = tbSecurityConfig[j].Name; newParameterItem.Code = tbSecurityConfig[j].Code; newParameterItem.NumValue = tbSecurityConfig[j].NumValue; newParameterItem.StringValue = tbSecurityConfig[j].StringValue; newParameterItem.DateValue = tbSecurityConfig[j].DateValue; newParameterItem.BoolValue = tbSecurityConfig[j].BoolValue; Result[i].ParameterItems.Add(newParameterItem); } } #endregion #region GET SYMBOL BY SECURITY ID tbSymbol = adapSymbol.GetSymbolBySecurityID(newSecurity.SecurityID); if (tbSymbol != null) { int countSymbol = tbSymbol.Count; for (int j = 0; j < countSymbol; j++) { Business.Symbol newSymbol = new Business.Symbol(); newSymbol.ParameterItems = new List<Business.ParameterItem>(); if (Business.Market.MarketArea != null) { int countMarket = Business.Market.MarketArea.Count; for (int n = 0; n < countMarket; n++) { if (Business.Market.MarketArea[n].IMarketAreaID == tbSymbol[j].MarketAreaID) { newSymbol.MarketAreaRef = Business.Market.MarketArea[n]; break; } } } newSymbol.Name = tbSymbol[j].Name; newSymbol.SecurityID = tbSymbol[j].SecurityID; newSymbol.SymbolID = tbSymbol[j].SymbolID; tbTradingConfig = adapTradingConfig.GetTradingConfigBySymbolID(tbSymbol[j].SymbolID); if (tbTradingConfig != null) { int countTradingConfig = tbTradingConfig.Count; for (int n = 0; n < countTradingConfig; n++) { Business.ParameterItem newParameter = new Business.ParameterItem(); newParameter.BoolValue = tbTradingConfig[n].BoolValue; newParameter.Code = tbTradingConfig[n].Code; newParameter.DateValue = tbTradingConfig[n].DateValue; newParameter.NumValue = tbTradingConfig[n].NumValue; newParameter.ParameterItemID = tbTradingConfig[n].TradingConfigID; newParameter.SecondParameterID = tbTradingConfig[n].SymbolID; newSymbol.ParameterItems.Add(newParameter); } } newSecurity.SymbolGroup.Add(newSymbol); } } #endregion Result.Add(newSecurity); } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); adapSecurityConfig.Connection.Close(); adapSymbol.Connection.Close(); adapTradingConfig.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="tbVirtualDealerConfig"></param> /// <returns></returns> private List<Business.ParameterItem> MapVirtualDealerConfig(DS.VirtualDealerConfigDataTable tbVirtualDealerConfig) { List<Business.ParameterItem> result = new List<Business.ParameterItem>(); if (tbVirtualDealerConfig != null) { int count = tbVirtualDealerConfig.Count; for (int i = 0; i < count; i++) { Business.ParameterItem newParamerter = new Business.ParameterItem(); newParamerter.BoolValue = tbVirtualDealerConfig[i].BoolValue; newParamerter.Code = tbVirtualDealerConfig[i].Code; newParamerter.DateValue = tbVirtualDealerConfig[i].DateValue; newParamerter.Name = tbVirtualDealerConfig[i].Name; newParamerter.NumValue = tbVirtualDealerConfig[i].NumValue; newParamerter.ParameterItemID = tbVirtualDealerConfig[i].VirtualDealerConfigID; newParamerter.SecondParameterID = tbVirtualDealerConfig[i].VirtualDealID; newParamerter.StringValue = tbVirtualDealerConfig[i].StringValue; result.Add(newParamerter); } } return result; }
/// <summary> /// Get Investor Group Config By Investor Group Config ID /// Using List Result Call Function Delete In Table InvestorGroupConfig /// </summary> /// <param name="InvestorGroupConfigID">int InvestorGroupConfigID</param> /// <returns>List<Business.ParameterItem></returns> internal List<Business.ParameterItem> GetInvestorGroupConfigByID(int InvestorGroupConfigID) { List<Business.ParameterItem> Result = new List<Business.ParameterItem>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.InvestorGroupConfigTableAdapter adap = new DSTableAdapters.InvestorGroupConfigTableAdapter(); DS.InvestorGroupConfigDataTable tbInvestorGroupConfig = new DS.InvestorGroupConfigDataTable(); try { conn.Open(); adap.Connection = conn; tbInvestorGroupConfig = adap.GetInvestorGroupConfigByID(InvestorGroupConfigID); if (tbInvestorGroupConfig != null) { Business.ParameterItem newParameterItem = new Business.ParameterItem(); newParameterItem.BoolValue = tbInvestorGroupConfig[0].BoolValue; newParameterItem.Code = tbInvestorGroupConfig[0].Code; newParameterItem.DateValue = tbInvestorGroupConfig[0].DateValue; newParameterItem.SecondParameterID = tbInvestorGroupConfig[0].InvestorGroupID; newParameterItem.Name = tbInvestorGroupConfig[0].Name; newParameterItem.NumValue = tbInvestorGroupConfig[0].NumValue; newParameterItem.ParameterItemID = tbInvestorGroupConfig[0].InvestorGroupConfigID; newParameterItem.StringValue = tbInvestorGroupConfig[0].StringValue; newParameterItem.CollectionValue = this.GetInvestorGroupConfigByCollectionValue(tbInvestorGroupConfig[0].InvestorGroupConfigID); Result.Add(newParameterItem); } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <returns></returns> internal List<Business.IGroupSecurity> GetAllIGroupSecurity() { List<Business.IGroupSecurity> Result = new List<Business.IGroupSecurity>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.IGroupSecurityTableAdapter adap = new DSTableAdapters.IGroupSecurityTableAdapter(); DSTableAdapters.IGroupSecurityConfigTableAdapter adapIGroupSecurityConfig = new DSTableAdapters.IGroupSecurityConfigTableAdapter(); DS.IGroupSecurityDataTable tbIGroupSecurity = new DS.IGroupSecurityDataTable(); DS.IGroupSecurityConfigDataTable tbIGroupSecurityConfig = new DS.IGroupSecurityConfigDataTable(); try { conn.Open(); adap.Connection = conn; adapIGroupSecurityConfig.Connection = conn; tbIGroupSecurity= adap.GetData(); if (tbIGroupSecurity != null) { int count = tbIGroupSecurity.Count; for (int i = 0; i < count; i++) { Business.IGroupSecurity newIGroupSymbol = new Business.IGroupSecurity(); newIGroupSymbol.IGroupSecurityID = tbIGroupSecurity[i].IGroupSecurityID; newIGroupSymbol.InvestorGroupID = tbIGroupSecurity[i].InvestorGroupID; newIGroupSymbol.SecurityID = tbIGroupSecurity[i].SecurityID; tbIGroupSecurityConfig = adapIGroupSecurityConfig.GetIGroupSecurityConfigByIGroupSecurity(tbIGroupSecurity[i].IGroupSecurityID); //newIGroupSymbol.IGroupSecurityConfig = DBWIGroupSecurity.DBWIGroupSecurityConfigInstance.GetIGroupSecurityConfigByIGroupSecurity(tbIGroupSecurity[i].IGroupSecurityID); if (tbIGroupSecurityConfig != null) { int countIGroupSecurityConfig = tbIGroupSecurityConfig.Count; for (int j = 0; j < countIGroupSecurityConfig; j++) { Business.ParameterItem newParameter = new Business.ParameterItem(); newParameter.BoolValue = tbIGroupSecurityConfig[j].BoolValue; newParameter.Code = tbIGroupSecurityConfig[j].Code; newParameter.DateValue = tbIGroupSecurityConfig[j].DateValue; newParameter.NumValue = tbIGroupSecurityConfig[j].NumValue; newParameter.ParameterItemID = tbIGroupSecurityConfig[j].IGroupSecurityConfigID; newParameter.SecondParameterID = tbIGroupSecurityConfig[j].IGroupSecurityID; newParameter.StringValue = tbIGroupSecurityConfig[j].StringValue; if (newIGroupSymbol.IGroupSecurityConfig == null) newIGroupSymbol.IGroupSecurityConfig = new List<Business.ParameterItem>(); newIGroupSymbol.IGroupSecurityConfig.Add(newParameter); } } Result.Add(newIGroupSymbol); } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); adapIGroupSecurityConfig.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="SecurityConfigID"></param> /// <returns></returns> internal Business.ParameterItem GetSecurityConfigBySecurityConfigID(int SecurityConfigID) { Business.ParameterItem result = new Business.ParameterItem(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.SecurityConfigTableAdapter adap = new DSTableAdapters.SecurityConfigTableAdapter(); DS.SecurityConfigDataTable tbSecurityConfig = new DS.SecurityConfigDataTable(); try { conn.Open(); adap.Connection = conn; tbSecurityConfig = adap.GetSecurityConfigBySecurityConfigID(SecurityConfigID); if (tbSecurityConfig != null) { result.ParameterItemID = tbSecurityConfig[0].SecurityConfigID; result.SecondParameterID = tbSecurityConfig[0].SecurityID; result.Name = tbSecurityConfig[0].Name; result.Code = tbSecurityConfig[0].Code; result.NumValue = tbSecurityConfig[0].NumValue; result.StringValue = tbSecurityConfig[0].StringValue; result.DateValue = tbSecurityConfig[0].DateValue; result.BoolValue = tbSecurityConfig[0].BoolValue; result.CollectionValue = this.GetSecurityConfigByCollectionValue(tbSecurityConfig[0].SecurityConfigID, adap); } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return result; }
/// <summary> /// /// </summary> /// <param name="CollectionValue"></param> /// <returns></returns> internal List<Business.ParameterItem> GetSecurityConfigByCollectionValue(int CollectionValue, DSTableAdapters.SecurityConfigTableAdapter adap) { List<Business.ParameterItem> Result = new List<Business.ParameterItem>(); DS.SecurityConfigDataTable tbSecurityConfig = new DS.SecurityConfigDataTable(); try { tbSecurityConfig = adap.GetSecurityConfigByCollectionValue(CollectionValue); if (tbSecurityConfig != null) { int count = tbSecurityConfig.Count; for (int i = 0; i < count; i++) { Business.ParameterItem newParameterItem = new Business.ParameterItem(); newParameterItem.ParameterItemID = tbSecurityConfig[i].SecurityConfigID; newParameterItem.SecondParameterID = tbSecurityConfig[i].SecurityID; newParameterItem.Name = tbSecurityConfig[i].Name; newParameterItem.Code = tbSecurityConfig[i].Code; newParameterItem.NumValue = tbSecurityConfig[i].NumValue; newParameterItem.StringValue = tbSecurityConfig[i].StringValue; newParameterItem.DateValue = tbSecurityConfig[i].DateValue; newParameterItem.BoolValue = tbSecurityConfig[i].BoolValue; newParameterItem.CollectionValue = this.GetSecurityConfigByCollectionValue(tbSecurityConfig[i].SecurityConfigID, adap); Result.Add(newParameterItem); } } } catch (Exception ex) { return null; } return Result; }
/// <summary> /// /// </summary> /// <returns></returns> internal List<Business.ParameterItem> GetAllSecurityConfig() { List<Business.ParameterItem> Result = new List<Business.ParameterItem>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.SecurityConfigTableAdapter adap = new DSTableAdapters.SecurityConfigTableAdapter(); DS.SecurityConfigDataTable tbSecurityConfig = new DS.SecurityConfigDataTable(); try { conn.Open(); adap.Connection = conn; tbSecurityConfig = adap.GetData(); if (tbSecurityConfig != null) { int count = tbSecurityConfig.Count; for (int i = 0; i < count; i++) { Business.ParameterItem newSecurityConfig = new Business.ParameterItem(); newSecurityConfig.ParameterItemID = tbSecurityConfig[i].SecurityConfigID; newSecurityConfig.SecondParameterID = tbSecurityConfig[i].SecurityID; newSecurityConfig.Name = tbSecurityConfig[i].Name; newSecurityConfig.Code = tbSecurityConfig[i].Code; newSecurityConfig.NumValue = tbSecurityConfig[i].NumValue; newSecurityConfig.StringValue = tbSecurityConfig[i].StringValue; newSecurityConfig.DateValue = tbSecurityConfig[i].DateValue; newSecurityConfig.BoolValue = tbSecurityConfig[i].BoolValue; newSecurityConfig.CollectionValue = this.GetSecurityConfigByCollectionValue(tbSecurityConfig[i].SecurityConfigID, adap); Result.Add(newSecurityConfig); } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <param name="SecurityID"></param> /// <returns></returns> internal List<Business.Symbol> GetSymbolBySecurityID(int SecurityID) { List<Business.Symbol> Result = new List<Business.Symbol>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.SymbolTableAdapter adap = new DSTableAdapters.SymbolTableAdapter(); DSTableAdapters.TradingConfigTableAdapter adapTradingConfig = new DSTableAdapters.TradingConfigTableAdapter(); DS.SymbolDataTable tbSymbol = new DS.SymbolDataTable(); DS.TradingConfigDataTable tbTradingConfig = new DS.TradingConfigDataTable(); try { conn.Open(); adap.Connection = conn; adapTradingConfig.Connection = conn; tbSymbol= adap.GetSymbolBySecurityID(SecurityID); if (tbSymbol != null) { int count = tbSymbol.Count; for (int i = 0; i < count; i++) { Business.Symbol newSymbol = new Business.Symbol(); if (Business.Market.MarketArea != null) { int countMarket = Business.Market.MarketArea.Count; for (int j = 0; j < countMarket; j++) { if (Business.Market.MarketArea[j].IMarketAreaID == tbSymbol[i].MarketAreaID) { newSymbol.MarketAreaRef = Business.Market.MarketArea[j]; break; } } } newSymbol.Name = tbSymbol[i].Name; newSymbol.SecurityID = tbSymbol[i].SecurityID; newSymbol.SymbolID = tbSymbol[i].SymbolID; newSymbol.RefSymbol = this.GetSymbolByRefSymbolID(tbSymbol[i].SymbolID); tbTradingConfig = adapTradingConfig.GetTradingConfigBySymbolID(tbSymbol[i].SymbolID); if (tbTradingConfig != null) { int countTradingConfig = tbTradingConfig.Count; for (int j = 0; j < countTradingConfig; j++) { Business.ParameterItem newParameter = new Business.ParameterItem(); newParameter.BoolValue = tbTradingConfig[j].BoolValue; newParameter.Code = tbTradingConfig[j].Code; newParameter.DateValue = tbTradingConfig[j].DateValue; newParameter.NumValue = tbTradingConfig[j].NumValue; newParameter.ParameterItemID = tbTradingConfig[j].TradingConfigID; newParameter.SecondParameterID = tbTradingConfig[j].SymbolID; if (newSymbol.ParameterItems == null) newSymbol.ParameterItems = new List<Business.ParameterItem>(); newSymbol.ParameterItems.Add(newParameter); } } //newSymbol.ParameterItems = DBWSymbol.TradingConfigInstance.GetParameterItemBySymbolID(tbSymbol[i].SymbolID); Result.Add(newSymbol); } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); adapTradingConfig.Connection.Close(); conn.Close(); } return Result; }
/// <summary> /// /// </summary> /// <returns></returns> internal List<Business.Symbol> GetAllSymbol() { List<Business.Symbol> Result = new List<Business.Symbol>(); List<Business.Tick> listTickTemp = new List<Business.Tick>(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DBConnection.DBConnection.Connection); DSTableAdapters.SymbolTableAdapter adap = new DSTableAdapters.SymbolTableAdapter(); DSTableAdapters.TradingConfigTableAdapter adapTradingConfig = new DSTableAdapters.TradingConfigTableAdapter(); DS.SymbolDataTable tbSymbol = new DS.SymbolDataTable(); DS.TradingConfigDataTable tbTradingConfig = new DS.TradingConfigDataTable(); try { conn.Open(); adap.Connection = conn; adapTradingConfig.Connection = conn; tbSymbol = adap.GetData(); #region GET TICK FROM SERVER ANOTHER try { string[] tickData = new string[] { }; tickData = Business.Market.client.ServerCommandList("GetTickOnline", ""); if (tickData != null) { int countTick = tickData.Count(); for (int j = 0; j < countTick; j++) { string message = tickData[j]; string[] splipTick = message.Split('▼'); if (splipTick.Length == 6) { Business.Tick newTick = new Business.Tick(); newTick.Bid = double.Parse(splipTick[0]); newTick.TickTime = DateTime.Parse(splipTick[1]); newTick.SymbolName = splipTick[2]; newTick.HighInDay = double.Parse(splipTick[3]); newTick.LowInDay = double.Parse(splipTick[4]); newTick.Status = splipTick[5]; listTickTemp.Add(newTick); } } } } catch (Exception ex) { } #endregion if (tbSymbol != null) { int count = tbSymbol.Count; for (int i = 0; i < count; i++) { if (tbSymbol[i].RefSymbolID == -1) { Business.Symbol newSymbol = new Business.Symbol(); newSymbol.Name = tbSymbol[i].Name; newSymbol.SymbolID = tbSymbol[i].SymbolID; newSymbol.SecurityID = tbSymbol[i].SecurityID; #region GET SPREAD DIFFERENCE SET TO SPREAD DIFFERENCE OF SYMBOL if (Business.Market.IGroupSecurityList != null) { int countIGroupSecurity = Business.Market.IGroupSecurityList.Count; for (int n = 0; n < countIGroupSecurity; n++) { if (Business.Market.IGroupSecurityList[n].SecurityID == newSymbol.SecurityID) { if (Business.Market.IGroupSecurityList[n].IGroupSecurityConfig != null) { int countIGroupSecurityConfig = Business.Market.IGroupSecurityList[n].IGroupSecurityConfig.Count; for (int m = 0; m < countIGroupSecurityConfig; m++) { if (Business.Market.IGroupSecurityList[n].IGroupSecurityConfig[m].Code == "B04") { newSymbol.SpreadDifference = double.Parse(Business.Market.IGroupSecurityList[n].IGroupSecurityConfig[m].NumValue); break; } } } break; } } } #endregion newSymbol.RefSymbol = this.GetSymbolReference(newSymbol.SymbolID, tbSymbol); //newSymbol.ParameterItems = DBWSymbol.TradingConfigInstance.GetParameterItemBySymbolID(tbSymbol[i].SymbolID); tbTradingConfig = adapTradingConfig.GetTradingConfigBySymbolID(tbSymbol[i].SymbolID); if (tbTradingConfig != null) { int countTradingConfig = tbTradingConfig.Count; for (int j = 0; j < countTradingConfig; j++) { Business.ParameterItem newParameter = new Business.ParameterItem(); newParameter.ParameterItemID = tbTradingConfig[j].TradingConfigID; newParameter.BoolValue = tbTradingConfig[j].BoolValue; newParameter.Code = tbTradingConfig[j].Code; newParameter.DateValue = tbTradingConfig[j].DateValue; newParameter.NumValue = tbTradingConfig[j].NumValue; newParameter.SecondParameterID = tbTradingConfig[j].SymbolID; newParameter.StringValue = tbTradingConfig[j].StringValue; newParameter.Name = tbTradingConfig[j].Name; if (newSymbol.ParameterItems == null) newSymbol.ParameterItems = new List<Business.ParameterItem>(); newSymbol.ParameterItems.Add(newParameter); #region GET DIGIT SET TO DIGIT OF SYMBOL if (tbTradingConfig[j].Code == "S003") { int Digit = 0; int.TryParse(tbTradingConfig[j].NumValue, out Digit); newSymbol.Digit = Digit; } #endregion #region GET CURRENCY SET TO CURRENCY OF SYMBOL if (tbTradingConfig[j].Code == "S007") { newSymbol.Currency = tbTradingConfig[j].StringValue; } #endregion #region GET ISTRADE SET TO TRADE OF SYMBOL if (tbTradingConfig[j].Code == "S008") { newSymbol.Trade = tbTradingConfig[j].StringValue; } #endregion #region GET SPREAD BY DEFAULT SET TO SPREAD BY DEFAULT OF SYMBOL if (tbTradingConfig[j].Code == "S013") { double SpreadByDefault = 0; double.TryParse(tbTradingConfig[j].NumValue, out SpreadByDefault); newSymbol.SpreadByDefault = SpreadByDefault; } #endregion #region GET LONG ONLY SET TO LONG ONLY OF SYMBOL if (tbTradingConfig[j].Code == "S014") { if (tbTradingConfig[j].BoolValue == 0) { newSymbol.LongOnly = false; } else { newSymbol.LongOnly = true; } } #endregion #region GET LIMIT STOP LEVEL SET TO LIMIT STOP LEVEL OF SYMBOL if (tbTradingConfig[j].Code == "S015") { int LimitLevel = 0; int.TryParse(tbTradingConfig[j].NumValue, out LimitLevel); newSymbol.LimitLevel = LimitLevel; } if (tbTradingConfig[j].Code == "S046") { int StopLevel = 0; int.TryParse(tbTradingConfig[j].NumValue, out StopLevel); newSymbol.StopLevel = StopLevel; } if (tbTradingConfig[j].Code == "S047") { int SLTP = 0; int.TryParse(tbTradingConfig[j].NumValue, out SLTP); newSymbol.StopLossTakeProfitLevel = SLTP; } #endregion #region GET SPREAD BALANCE SET TO SPREAD BALANCE OF SYMBOL if (tbTradingConfig[j].Code == "S016") { double SpreadBalace = 0; if (tbTradingConfig[j].NumValue != "NaN") { double.TryParse(tbTradingConfig[j].NumValue, out SpreadBalace); } newSymbol.SpreadBalace = SpreadBalace; } #endregion #region GET FREEZE LEVEL SET TO FREEZE LEVEL TO SYMBOL if (tbTradingConfig[j].Code == "S017") { int FreezeLevel = 0; int.TryParse(tbTradingConfig[j].NumValue, out FreezeLevel); newSymbol.FreezeLevel = FreezeLevel; } #endregion #region GET ALLOW READ TIME SET TO ALLOW READ TIME OF SYMBOL if (tbTradingConfig[j].Code == "S018") { if (tbTradingConfig[j].BoolValue == 0) { newSymbol.AllowReadTime = false; } else { newSymbol.AllowReadTime = true; } } #endregion #region GET FILTTRATIONS LEVEL SET TO FILTRATIONS OF SYMBOL if (tbTradingConfig[j].Code == "S020") { int FiltrationLevel = 0; int.TryParse(tbTradingConfig[j].NumValue, out FiltrationLevel); newSymbol.FiltrationsLevel = FiltrationLevel; } #endregion #region GET AUTO LIMIT SET TO AUTO LIMIT OF SYMBOL if (tbTradingConfig[j].Code == "S021") { newSymbol.AutoLimit = tbTradingConfig[j].StringValue; } #endregion #region GET FILTER SET TO FILTER OF SYMBOL if (tbTradingConfig[j].Code == "S022") { int Filter = 0; int.TryParse(tbTradingConfig[j].NumValue, out Filter); newSymbol.Filter = Filter; } #endregion #region GET CONTRACT SIZE SET TO CONTRACT SIZE OF SYMBOL if (tbTradingConfig[j].Code == "S025") { double ContractSize = 0; double.TryParse(tbTradingConfig[j].NumValue, out ContractSize); newSymbol.ContractSize = ContractSize; } #endregion #region GET TICK SIZE SET TO TICK SIZE OF SYMBOL if (tbTradingConfig[j].Code == "S029") { double TickSize = 0; double.TryParse(tbTradingConfig[j].NumValue, out TickSize); newSymbol.TickSize = TickSize; } #endregion #region GET TICK PRICE SET TO TICK PRICE OF SYMBOL if (tbTradingConfig[j].Code == "S030") { double TickPrice = 0; double.TryParse(tbTradingConfig[j].NumValue, out TickPrice); newSymbol.TickPrice = TickPrice; } #endregion #region GET PROFIT CALCULATION SET TO PROFIT CALCULATION OF SYMBOL if (tbTradingConfig[j].Code == "S033") { newSymbol.ProfitCalculation = tbTradingConfig[j].StringValue; } #endregion #region GET ISHEDGED SET TO ISHEDGED OF SYMBOL if (tbTradingConfig[j].Code == "S034") { if (tbTradingConfig[j].BoolValue == 0) { newSymbol.IsHedged = false; } else { newSymbol.IsHedged = true; } } #endregion #region GET TIME CLOSE ONLY OF SYMBOL FUTURE if (tbTradingConfig[j].Code == "S044") { newSymbol.TimeCloseOnly = tbTradingConfig[j].DateValue; } #endregion #region GET TIME EXP OF SYMBOL FUTURE if (tbTradingConfig[j].Code == "S045") { newSymbol.TimeExp = tbTradingConfig[j].DateValue; } #endregion #region GET APPLY SPREAD OF SYMBOL if (tbTradingConfig[j].Code == "S050") { if (tbTradingConfig[j].BoolValue == 1) { newSymbol.ApplySpread = true; } } #endregion #region GET FREEZE MARGIN if (tbTradingConfig[j].Code == "S051") { bool useFreezeLevel = false; if (tbTradingConfig[j].BoolValue == 1) useFreezeLevel = true; newSymbol.IsEnableFreezeMargin = useFreezeLevel; } #endregion #region GET USE FREEZE MARGIN if (tbTradingConfig[j].Code == "S052") { double freezeMargin = 0; double.TryParse(tbTradingConfig[j].NumValue.ToString(), out freezeMargin); newSymbol.FreezeMargin = freezeMargin; } #endregion #region GET FREEZE MARGIN HEDGED if (tbTradingConfig[j].Code == "S053") { double freezeMarginH = 0; double.TryParse(tbTradingConfig[j].NumValue, out freezeMarginH); newSymbol.FreezeMarginHedged = freezeMarginH; } #endregion #region GET MARGIN HEDGED if (tbTradingConfig[j].Code == "S028") { double marginH = 0; double.TryParse(tbTradingConfig[j].NumValue, out marginH); newSymbol.MarginHedged = marginH; } #endregion #region GET INIT MARGIN if (tbTradingConfig[j].Code == "S026") { double initMargin = 0; double.TryParse(tbTradingConfig[j].NumValue, out initMargin); newSymbol.InitialMargin = initMargin; } #endregion } } bool flagTick = false; if (listTickTemp != null) { int countTick = listTickTemp.Count; for (int j = 0; j < countTick; j++) { if (listTickTemp[j].SymbolName == tbSymbol[i].Name) { if (newSymbol.TickValue == null) newSymbol.TickValue = new Business.Tick(); //newSymbol.TickValue.Ask = Math.Round(newSymbol.CreateAskPrices(listTickTemp[j].Bid, newSymbol.SpreadByDefault, newSymbol.Digit, int.Parse(newSymbol.SpreadDifference.ToString())), newSymbol.Digit); //Apply Spread Change Function CreateAskPrices newSymbol.TickValue.Ask = Math.Round(newSymbol.CreateAskPrices(newSymbol.Digit,int.Parse(newSymbol.SpreadDifference.ToString()),listTickTemp[j].Ask),newSymbol.Digit); newSymbol.TickValue.Bid = listTickTemp[j].Bid; newSymbol.TickValue.Status = listTickTemp[j].Status; newSymbol.TickValue.SymbolID = newSymbol.SymbolID; newSymbol.TickValue.SymbolName = newSymbol.Name; newSymbol.TickValue.TickTime = listTickTemp[j].TickTime; newSymbol.TickValue.TimeCurrent = listTickTemp[j].TickTime; newSymbol.TickValue.HighInDay = listTickTemp[j].HighInDay; newSymbol.TickValue.LowInDay = listTickTemp[j].LowInDay; newSymbol.ArchiveTick(newSymbol.TickValue); #region BUILD HIGH LOW if (newSymbol.TickCurrent == null) newSymbol.TickCurrent = new Business.TickLog(); newSymbol.TickCurrent.Close = listTickTemp[j].Bid; newSymbol.TickCurrent.Date = listTickTemp[j].TickTime; newSymbol.TickCurrent.HighBid = listTickTemp[j].HighInDay; newSymbol.TickCurrent.LowBid = listTickTemp[j].LowInDay; newSymbol.TickCurrent.Name = listTickTemp[j].SymbolName; newSymbol.TickCurrent.Open = listTickTemp[j].Bid; //newSymbol.TickValue.HighAsk = Math.Round(newSymbol.CreateAskPrices(listTickTemp[j].HighInDay, newSymbol.SpreadByDefault, newSymbol.Digit, int.Parse(newSymbol.SpreadDifference.ToString())), newSymbol.Digit); newSymbol.TickValue.HighAsk = Math.Round(newSymbol.CreateAskPrices(newSymbol.Digit, int.Parse(newSymbol.SpreadDifference.ToString()), listTickTemp[j].HighAsk), newSymbol.Digit); //newSymbol.TickValue.HighAsk = ResultDataLog.HighAsk; //newSymbol.TickValue.HighInDay = ResultDataLog.High; //newSymbol.TickValue.LowAsk = Math.Round(newSymbol.CreateAskPrices(listTickTemp[j].LowInDay, newSymbol.SpreadByDefault, newSymbol.Digit, int.Parse(newSymbol.SpreadDifference.ToString())), newSymbol.Digit); newSymbol.TickValue.LowAsk = Math.Round(newSymbol.CreateAskPrices(newSymbol.Digit, int.Parse(newSymbol.SpreadDifference.ToString()), listTickTemp[j].LowAsk), newSymbol.Digit); //newSymbol.TickValue.LowAsk = ResultDataLog.LowAsk; //newSymbol.TickValue.LowInDay = ResultDataLog.Low; newSymbol.TickCurrent.HighAsk = newSymbol.TickValue.HighAsk; newSymbol.TickCurrent.LowAsk = newSymbol.TickValue.LowAsk; int tickID = ProcessQuoteLibrary.FacadeDataLog.AddNewDataLog(listTickTemp[j].TickTime, listTickTemp[j].Bid, listTickTemp[j].HighInDay, listTickTemp[j].LowInDay, listTickTemp[j].HighAsk, listTickTemp[j].LowAsk, listTickTemp[j].Bid, listTickTemp[j].SymbolName); newSymbol.TickCurrent.ID = tickID; newSymbol.TickValue.ID = tickID; #endregion flagTick = true; break; } } } if (!flagTick) { #region GET TICK OF SYMBOL ProcessQuoteLibrary.Business.BarTick resultTick = ProcessQuoteLibrary.FacadeDataLog.FacadeGetClosePriceBySymbol(newSymbol.Name); if (resultTick != null && resultTick.ID > 0) { if (newSymbol.TickValue == null) newSymbol.TickValue = new Business.Tick(); //newSymbol.TickValue.Ask = Math.Round(newSymbol.CreateAskPrices(resultTick.Close, newSymbol.SpreadByDefault, newSymbol.Digit, int.Parse(newSymbol.SpreadDifference.ToString())), newSymbol.Digit); newSymbol.TickValue.Ask = Math.Round(newSymbol.CreateAskPrices(newSymbol.Digit, int.Parse(newSymbol.SpreadDifference.ToString()), resultTick.Close), newSymbol.Digit); newSymbol.TickValue.Bid = resultTick.Close; newSymbol.TickValue.Status = "up"; newSymbol.TickValue.SymbolID = newSymbol.SymbolID; newSymbol.TickValue.SymbolName = newSymbol.Name; newSymbol.TickValue.TickTime = resultTick.Time; newSymbol.TickValue.TimeCurrent = resultTick.Time; newSymbol.ArchiveTick(newSymbol.TickValue); } else { if (newSymbol.TickValue == null) newSymbol.TickValue = new Business.Tick(); //newSymbol.TickValue.Ask = Math.Round(newSymbol.CreateAskPrices(resultTick.Close, newSymbol.SpreadByDefault, newSymbol.Digit, int.Parse(newSymbol.SpreadDifference.ToString())), newSymbol.Digit); newSymbol.TickValue.Ask = 0; newSymbol.TickValue.Bid = 0; newSymbol.TickValue.Status = "down"; newSymbol.TickValue.SymbolID = newSymbol.SymbolID; newSymbol.TickValue.SymbolName = newSymbol.Name; newSymbol.TickValue.TickTime = DateTime.Now; newSymbol.TickValue.TimeCurrent = DateTime.Now; } #endregion #region GET DATA HIGH LOW IN DAY SET TO DATA HIGH LOW OF SYMBOL ProcessQuoteLibrary.Business.BarTick ResultDataLog = new ProcessQuoteLibrary.Business.BarTick(); ResultDataLog = ProcessQuoteLibrary.FacadeDataLog.FacadeGetDataLogByName(newSymbol.Name); if (ResultDataLog.Time.Day == DateTime.Now.Day) { if (ResultDataLog != null && ResultDataLog.High != 0) { if (newSymbol.TickValue == null) newSymbol.TickValue = new Business.Tick(); if (newSymbol.TickCurrent == null) newSymbol.TickCurrent = new Business.TickLog(); newSymbol.TickCurrent.Close = ResultDataLog.Close; newSymbol.TickCurrent.Date = ResultDataLog.Time; newSymbol.TickCurrent.HighBid = ResultDataLog.High; newSymbol.TickCurrent.ID = ResultDataLog.ID; newSymbol.TickValue.ID = ResultDataLog.ID; newSymbol.TickCurrent.LowBid = ResultDataLog.Low; newSymbol.TickCurrent.Name = ResultDataLog.Symbol; newSymbol.TickCurrent.Open = ResultDataLog.Open; //newSymbol.TickValue.HighAsk = Math.Round(newSymbol.CreateAskPrices(resultTick.High, newSymbol.SpreadByDefault, newSymbol.Digit, int.Parse(newSymbol.SpreadDifference.ToString())), newSymbol.Digit); newSymbol.TickValue.HighAsk = Math.Round(newSymbol.CreateAskPrices(newSymbol.Digit,int.Parse(newSymbol.SpreadDifference.ToString()),resultTick.High)); //newSymbol.TickValue.HighAsk = ResultDataLog.HighAsk; newSymbol.TickValue.HighInDay = ResultDataLog.High; //newSymbol.TickValue.LowAsk = Math.Round(newSymbol.CreateAskPrices(resultTick.Low, newSymbol.SpreadByDefault, newSymbol.Digit, int.Parse(newSymbol.SpreadDifference.ToString())), newSymbol.Digit); newSymbol.TickValue.LowAsk = Math.Round(newSymbol.CreateAskPrices(newSymbol.Digit,int.Parse(newSymbol.SpreadDifference.ToString()),resultTick.Low),newSymbol.Digit); //newSymbol.TickValue.LowAsk = ResultDataLog.LowAsk; newSymbol.TickValue.LowInDay = ResultDataLog.Low; newSymbol.TickCurrent.HighAsk = ResultDataLog.HighAsk; newSymbol.TickCurrent.LowAsk = ResultDataLog.LowAsk; } } #endregion } #region FIND IMARKET AREA AND ADD TO SYMBOL //Find IMarketArea if (Business.Market.MarketArea != null) { int countMarketArea = Business.Market.MarketArea.Count; for (int j = 0; j < countMarketArea; j++) { if (Business.Market.MarketArea[j].IMarketAreaID == tbSymbol[i].MarketAreaID) { newSymbol.MarketAreaRef = Business.Market.MarketArea[j]; //Add Symbol To MarketArea if (Business.Market.MarketArea[j].ListSymbol == null) Business.Market.MarketArea[j].ListSymbol = new List<Business.Symbol>(); Business.Market.MarketArea[j].ListSymbol.Add(newSymbol); break; } } } #endregion Result.Add(newSymbol); } } } } catch (Exception ex) { return null; } finally { adap.Connection.Close(); adapTradingConfig.Connection.Close(); conn.Close(); } return Result; }