コード例 #1
0
        /// <summary>
        /// 获取套利品种默认设定。
        /// </summary>
        /// <returns></returns>
        public ArbitrageCombineOrderSetting GetCombineOrderSetting(string brokerId, string account, string productCode)
        {
            string fileName = GetArbitrageOrderSettingsFileFullName(brokerId, account);

            if (File.Exists(fileName) == false)
            {
                return(null);
            }
            else
            {
                try
                {
                    List <ArbitrageCombineOrderSetting> list = USeXmlSerializer.LoadFromXml <List <ArbitrageCombineOrderSetting> >(fileName);
                    foreach (ArbitrageCombineOrderSetting item in list)
                    {
                        if (item.Product.ProductCode == productCode)
                        {
                            return(item);
                        }
                    }

                    return(null);
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("GetCombineOrderSettings failed,FilePath:{0},Error:{1}", fileName, ex.Message));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 获取套利品种默认设定。
        /// </summary>
        /// <returns></returns>
        public List <ArbitrageCombineOrderSetting> GetCombineOrderSettings(string brokerId, string account)
        {
            List <ArbitrageCombineOrderSetting> list = new List <ArbitrageCombineOrderSetting>();

            string        ArbitrageOrderSettingsFilePath    = GetArbitrageOrderSettingsFilePath(brokerId, account);
            DirectoryInfo ArbitrageOrderSettingsFilePathDir = new DirectoryInfo(ArbitrageOrderSettingsFilePath);

            if (ArbitrageOrderSettingsFilePathDir.Exists == false)
            {
                return(list);  // 目录不存在
            }
            FileInfo[] fileArray = ArbitrageOrderSettingsFilePathDir.GetFiles("ArbitrageOrderSettings.xml");
            if (fileArray == null || fileArray.Length <= 0)
            {
                return(list);  // 目录无文件
            }

            foreach (FileInfo fileInfo in ArbitrageOrderSettingsFilePathDir.GetFiles())
            {
                try
                {
                    List <ArbitrageCombineOrderSetting> combineOrderSettingList = USeXmlSerializer.LoadFromXml <List <ArbitrageCombineOrderSetting> >(fileInfo.FullName);
                    list = combineOrderSettingList;
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("GetCombineOrderSettings failed,FilePath:{0},Error:{1}", fileInfo.FullName, ex.Message));
                }
            }

            return(list);
        }
コード例 #3
0
        /// <summary>
        /// 获取历史完成套利单。
        /// </summary>
        /// <returns></returns>
        /// <param name="brokerId">经纪商ID。</param>
        /// <param name="account">资金帐号。</param>
        /// <param name="beginTime">起始时间。</param>
        /// <param name="endTime">截至时间。</param>
        public List <USeArbitrageOrder> GetHistoryArbitrageOrders(string brokerId, string account, DateTime?beginTime, DateTime?endTime)
        {
            List <USeArbitrageOrder> list = new List <USeArbitrageOrder>();

            string        finishOrderPath = GetFinishOrderPath(brokerId, account);
            DirectoryInfo finishOrderDir  = new DirectoryInfo(finishOrderPath);

            if (finishOrderDir.Exists == false)
            {
                return(list);  // 目录不存在
            }

            FileInfo[] fileArray = finishOrderDir.GetFiles("ArbitrageOrder_*.xml");
            if (fileArray == null || fileArray.Length <= 0)
            {
                return(list);  // 目录无文件
            }

            foreach (FileInfo fileInfo in finishOrderDir.GetFiles())
            {
                try
                {
                    ArbitrageOrderKey orderKey = ArbitrageOrderKey.Create(fileInfo.FullName);
                    if (beginTime.HasValue)
                    {
                        Debug.Assert(orderKey.FinishTime.HasValue);
                        //过滤结束时间小于开始时间的
                        if (orderKey.FinishTime.Value < beginTime)
                        {
                            continue;
                        }
                    }
                    if (endTime.HasValue)
                    {
                        // 过滤创建时间大于截止时间的
                        if (orderKey.CreateTime > endTime)
                        {
                            continue;
                        }
                    }

                    XmlAttributeOverrides xmlOverrides   = CreateArbitrageOrderXMLOverrides();
                    USeArbitrageOrder     arbitrageOrder = USeXmlSerializer.LoadFromXml <USeArbitrageOrder>(fileInfo.FullName, xmlOverrides);
                    list.Add(arbitrageOrder);
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("GetHistoryArbitrageOrders failed,FilePath:{0},Error:{1}", fileInfo.FullName, ex.Message));
                }
            }

            return(list);
        }
コード例 #4
0
        /// <summary>
        /// 获取前置服务配置信息。
        /// </summary>
        /// <returns></returns>
        public GlobalFontServerConfig GetGlobalFontServerConfig()
        {
            GlobalFontServerConfig config = null;

            try
            {
                if (File.Exists(this.GlobalFontServerConfigFilePath) == false)
                {
                    config = new GlobalFontServerConfig();
                    config.DefaultBrokerId = "9999";

                    //FrontSeverConfig guoTaiJunAnConfigItem = new FrontSeverConfig() {
                    //    BrokerID = "2071",
                    //    BrokerName = "国泰君安(模拟)",
                    //    QuoteFrontAddress = "180.169.77.111",
                    //    QuoteFrontPort = 42213,
                    //    TradeFrontAddress = "180.169.77.111",
                    //    TradeFrontPort = 42205
                    //};

                    FrontSeverConfig simNowConfigItem = new FrontSeverConfig()
                    {
                        BrokerID          = "9999",
                        BrokerName        = "SimNow",
                        QuoteFrontAddress = "180.168.146.187",
                        QuoteFrontPort    = 10010,
                        TradeFrontAddress = "180.168.146.187",
                        TradeFrontPort    = 10000
                    };

                    //config.ServerList = new List<FrontSeverConfig>() { simNowConfigItem, guoTaiJunAnConfigItem };
                    config.ServerList = new List <FrontSeverConfig>()
                    {
                        simNowConfigItem
                    };
                }
                else
                {
                    config = USeXmlSerializer.LoadFromXml <GlobalFontServerConfig>(this.GlobalFontServerConfigFilePath);
                }
                return(config);
            }
            catch (Exception ex)
            {
                throw new Exception("GetGlobalFontServerConfig failed,Error:" + ex.Message);
            }
        }
コード例 #5
0
        /// <summary>
        /// 获取所有未完成套利单。
        /// </summary>
        /// <param name="brokerId">经纪商ID。</param>
        /// <param name="account">资金帐号。</param>
        /// <returns></returns>
        public List <USeArbitrageOrder> GetUnfinishArbitrageOrders(string brokerId, string account)
        {
            List <USeArbitrageOrder> list = new List <USeArbitrageOrder>();

            string        unFinishOrderPath = GetUnFinishOrderPath(brokerId, account);
            DirectoryInfo unFinishOrderDir  = new DirectoryInfo(unFinishOrderPath);

            if (unFinishOrderDir.Exists == false)
            {
                return(list);
            }

            FileInfo[] fileArray = unFinishOrderDir.GetFiles("ArbitrageOrder_*.xml");
            if (fileArray == null || fileArray.Length <= 0)
            {
                return(list);
            }

            XmlAttributeOverrides xmlOverrides = CreateArbitrageOrderXMLOverrides();

            foreach (FileInfo fileInfo in fileArray)
            {
                try
                {
                    USeArbitrageOrder unFinishOrder = USeXmlSerializer.LoadFromXml <USeArbitrageOrder>(fileInfo.FullName, xmlOverrides);
                    if (unFinishOrder != null)
                    {
                        list.Add(unFinishOrder);
                    }
                    else
                    {
                        Debug.Assert(false);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("GetUnfinishArbitrageOrders failed,FileName:{0},Error:{1}", fileInfo.FullName, ex.Message));
                }
            }

            return(list);
        }
コード例 #6
0
        /// <summary>
        /// 获取系统配置信息。
        /// </summary>
        /// <returns></returns>
        public USeSystemSetting GetUseSystemSetting()
        {
            USeSystemSetting setting = null;

            try
            {
                if (File.Exists(this.SystemConfigFilePath) == false)
                {
                    setting = null;
                }
                else
                {
                    setting = USeXmlSerializer.LoadFromXml <USeSystemSetting>(this.SystemConfigFilePath);
                }
                return(setting);
            }
            catch (Exception ex)
            {
                throw new Exception("GetUseSystemConfig failed,Error:" + ex.Message);
            }
        }
コード例 #7
0
        /// <summary>
        /// 获取用户配置信息。
        /// </summary>
        /// <returns></returns>
        public UserDefineSetting GetUserDefineSetting()
        {
            UserDefineSetting userConfig = null;

            try
            {
                if (File.Exists(this.UserDefineSettingFilePath) == false)
                {
                    userConfig = new UserDefineSetting();
                }
                else
                {
                    userConfig = USeXmlSerializer.LoadFromXml <UserDefineSetting>(this.UserDefineSettingFilePath);
                }
                return(userConfig);
            }
            catch (Exception ex)
            {
                throw new Exception("GetUserDefineSetting failed,Error:" + ex.Message);
            }
        }