Exemple #1
0
            public NDAXTrade ToExchangeTrade()
            {
                var isBuy = TakerSide == TakerSide.Buy;

                return(new NDAXTrade()
                {
                    Amount = Quantity,
                    Id = TradeId.ToStringInvariant(),
                    Price = Price,
                    IsBuy = isBuy,
                    Timestamp = TradeTime.UnixTimeStampToDateTimeMilliseconds(),
                    Flags = isBuy ? ExchangeTradeFlags.IsBuy : default,
Exemple #2
0
            public ExchangeTrade ToExchangeTrade()
            {
                var isBuy = Side.Equals("buy", StringComparison.InvariantCultureIgnoreCase);

                return(new ExchangeTrade()
                {
                    Amount = Quantity,
                    Id = TradeId.ToStringInvariant(),
                    Price = Price,
                    IsBuy = isBuy,
                    Timestamp = TradeTime.UnixTimeStampToDateTimeMilliseconds(),
                    Flags = isBuy ? ExchangeTradeFlags.IsBuy : default
                });
Exemple #3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hash = 17;
         hash = hash * 29 + Symbol.GetHashCode();
         hash = hash * 29 + CorrectionType.GetHashCode();
         hash = hash * 29 + TradeDate.GetHashCode();
         hash = hash * 29 + TradeTime.GetHashCode();
         hash = hash * 29 + TradePrice.GetHashCode();
         hash = hash * 29 + TradeSize.GetHashCode();
         hash = hash * 29 + TickId.GetHashCode();
         hash = hash * 29 + TradeConditions.GetHashCode();
         hash = hash * 29 + TradeMarketCentre.GetHashCode();
         return(hash);
     }
 }
        public override int GetHashCode()
        {
            unchecked
            {
                var hash = 17;
                hash = hash * 29 + RequestId != null?RequestId.GetHashCode() : 0;

                hash = hash * 29 + Symbol.GetHashCode();
                hash = hash * 29 + ExchangeId.GetHashCode();
                hash = hash * 29 + SecurityType.GetHashCode();
                hash = hash * 29 + (Last.HasValue ? Last.GetHashCode() : 0);
                hash = hash * 29 + (TradeSize.HasValue ? TradeSize.GetHashCode() : 0);
                hash = hash * 29 + (TradedMarket.HasValue ? TradedMarket.GetHashCode() : 0);
                hash = hash * 29 + (TradeDate.HasValue ? TradeDate.GetHashCode() : 0);
                hash = hash * 29 + (TradeTime.HasValue ? TradeTime.GetHashCode() : 0);
                hash = hash * 29 + (Open.HasValue ? Open.GetHashCode() : 0);
                hash = hash * 29 + (High.HasValue ? High.GetHashCode() : 0);
                hash = hash * 29 + (Low.HasValue ? Low.GetHashCode() : 0);
                hash = hash * 29 + (Close.HasValue ? Close.GetHashCode() : 0);
                hash = hash * 29 + (Bid.HasValue ? Bid.GetHashCode() : 0);
                hash = hash * 29 + (BidMarket.HasValue ? BidMarket.GetHashCode() : 0);
                hash = hash * 29 + (BidSize.HasValue ? BidSize.GetHashCode() : 0);
                hash = hash * 29 + (Ask.HasValue ? Ask.GetHashCode() : 0);
                hash = hash * 29 + (AskMarket.HasValue ? AskMarket.GetHashCode() : 0);
                hash = hash * 29 + (AskSize.HasValue ? AskSize.GetHashCode() : 0);
                hash = hash * 29 + (Volume.HasValue ? Volume.GetHashCode() : 0);
                hash = hash * 29 + (PDayVolume.HasValue ? PDayVolume.GetHashCode() : 0);
                hash = hash * 29 + (UpVolume.HasValue ? UpVolume.GetHashCode() : 0);
                hash = hash * 29 + (DownVolume.HasValue ? DownVolume.GetHashCode() : 0);
                hash = hash * 29 + (NeutralVolume.HasValue ? NeutralVolume.GetHashCode() : 0);
                hash = hash * 29 + (TradeCount.HasValue ? TradeCount.GetHashCode() : 0);
                hash = hash * 29 + (UpTrades.HasValue ? UpTrades.GetHashCode() : 0);
                hash = hash * 29 + (DownTrades.HasValue ? DownTrades.GetHashCode() : 0);
                hash = hash * 29 + (NeutralTrades.HasValue ? NeutralTrades.GetHashCode() : 0);
                hash = hash * 29 + (VWAP.HasValue ? VWAP.GetHashCode() : 0);
                hash = hash * 29 + (MutualDiv.HasValue ? MutualDiv.GetHashCode() : 0);
                hash = hash * 29 + (SevenDayYield.HasValue ? SevenDayYield.GetHashCode() : 0);
                hash = hash * 29 + (OpenInterest.HasValue ? OpenInterest.GetHashCode() : 0);
                hash = hash * 29 + (Settlement.HasValue ? Settlement.GetHashCode() : 0);
                hash = hash * 29 + (SettlementDate.HasValue ? SettlementDate.GetHashCode() : 0);
                hash = hash * 29 + (ExpirationDate.HasValue ? ExpirationDate.GetHashCode() : 0);
                hash = hash * 29 + (Strike.HasValue ? Strike.GetHashCode() : 0);
                return(hash);
            }
        }
Exemple #5
0
        /// <summary>
        /// 组装客户信息
        /// </summary>
        /// <param name="Mobile">手机号</param>
        /// <param name="IDNumber">身份证号</param>
        /// <param name="Tag">输出的客户信息</param>
        /// <returns>组装结果</returns>
        private int AssembleCustomerInfo(String Mobile, String IDNumber, out PersonTag Tag)
        {
            Tag             = new PersonTag();
            Tag.TradeInfos  = new List <TradeInfo>();
            Tag.DemandInfos = new List <DemandInfo>();

            DataSet ResultSet = new DataSet();

            //按给定的Mobile和IDNumber查询客户信息
            try
            {
                ResultSet = new DbHelperSQLP(ConnStringCustomerInfo).RunProcedure("P_QueryCustomerInfo",
                                                                                  new IDataParameter[] { new SqlParameter("@Mobile", Mobile), new SqlParameter("@IDNumber", IDNumber) }
                                                                                  , "noname");
            }
            catch (Exception)
            {
                Tag = null;
                return(-1);
            }

            //没有查到
            if (ResultSet.Tables[0].Rows.Count == 0 &&
                ResultSet.Tables[1].Rows.Count == 0 &&
                ResultSet.Tables[2].Rows.Count == 0 &&
                ResultSet.Tables[3].Rows.Count == 0)
            {
                Tag = null;
                return(-3);
            }

            Tag.Mobile   = Mobile;
            Tag.IDNumber = IDNumber;


            //同时提供手机号和身份证号时
            if (!String.IsNullOrEmpty(IDNumber) && !String.IsNullOrEmpty(Mobile))
            {
                //检查同时提供手机号和身份证号时,是否与库中数据匹配
                bool MobileMatchesIDNumber = false;
                for (int i = 0; i < ResultSet.Tables[1].Rows.Count; i++)
                {
                    String CheckStringMobile   = ResultSet.Tables[1].Rows[i]["mobile"].ToString();
                    String CheckStringIDNumber = ResultSet.Tables[1].Rows[i]["id_number"].ToString();

                    if (CheckStringMobile.Length == 11 && CheckStringIDNumber.Length >= 15 &&
                        CheckStringMobile == Mobile && CheckStringIDNumber == IDNumber)
                    {
                        MobileMatchesIDNumber = true;
                        break;
                    }
                }
                if (MobileMatchesIDNumber == false)
                {
                    return(-2);
                }
            }

            if (String.IsNullOrWhiteSpace(Mobile))
            {
                Tag.Mobile = GetSpecificInfoFromDataset(ResultSet,
                                                        1, "mobile", DataSetResultQueryType.MostOccuredValue);
            }

            if (String.IsNullOrWhiteSpace(IDNumber))
            {
                Tag.IDNumber = GetSpecificInfoFromDataset(ResultSet,
                                                          1, "id_number", DataSetResultQueryType.MostOccuredValue);
            }

            Tag.Name = GetSpecificInfoFromDataset(ResultSet,
                                                  1, "customer_name", DataSetResultQueryType.MostOccuredValue);

            Tag.Sex = GetSpecificInfoFromDataset(ResultSet,
                                                 1, "sex", DataSetResultQueryType.MostOccuredValue);
            if (String.IsNullOrWhiteSpace(Tag.Sex) && !String.IsNullOrWhiteSpace(Tag.IDNumber))
            {
                Tag.Sex = GetSexFromIDNumber(Tag.IDNumber);
            }

            Tag.Age = "";
            if (!String.IsNullOrWhiteSpace(Tag.IDNumber))
            {
                int IDNumberAge = GetAgeFromIDNumber(Tag.IDNumber);
                if (IDNumberAge >= 0)
                {
                    Tag.Age = IDNumberAge.ToString();
                }
            }

            Tag.RegisterCity = GetSpecificInfoFromDataset(ResultSet,
                                                          1, "census_register", DataSetResultQueryType.MostOccuredValue);

            Tag.Profession = GetSpecificInfoFromDataset(ResultSet,
                                                        3, "industry", DataSetResultQueryType.CommaSeparatedValues, 2);

            Tag.Interests = GetSpecificInfoFromDataset(ResultSet,
                                                       3, "tags", DataSetResultQueryType.CommaSeparatedValues, 3);

            Tag.FamilyIncome = GetSpecificInfoFromDataset(ResultSet,
                                                          3, "family_income", DataSetResultQueryType.MostOccuredValue);

            Tag.Marriage = GetSpecificInfoFromDataset(ResultSet,
                                                      3, "marry", DataSetResultQueryType.MostOccuredValue);

            Tag.FamilyStatus = GetSpecificInfoFromDataset(ResultSet,
                                                          3, "family_structure", DataSetResultQueryType.MostOccuredValue);

            Tag.ChildrenStatus = GetSpecificInfoFromDataset(ResultSet,
                                                            3, "children_info", DataSetResultQueryType.MostOccuredValue);

            //解析家庭
            if (ResultSet.Tables[2].Rows.Count > 1)
            {
                //载入性别年龄
                List <int>    Ages  = new List <int>();
                List <String> Sexes = new List <string>();
                for (int i = 0; i < ResultSet.Tables[2].Rows.Count; i++)
                {
                    int    Age = GetAgeFromIDNumber(ResultSet.Tables[2].Rows[i]["id_number"].ToString());
                    String Sex = GetSexFromIDNumber(ResultSet.Tables[2].Rows[i]["id_number"].ToString());

                    if (Age >= 0 && (Sex == "男" || Sex == "女"))
                    {
                        Ages.Add(Age);
                        Sexes.Add(Sex);
                    }
                }

                ////2异性一代人 异性且年龄差<18
                ////2同性一代人 同性且年龄差<18
                ////2两代人 年龄差≥18
                ////3一代人 年龄极差<18
                ////3两代人 年龄极差≥18且存在两个年龄相差<18
                ////3三代人 任意两年龄极差≥18
                ////4一代人 年龄极差<18
                ////4两代人 年龄极差≥18且任意年龄值的min{ 该年龄值与两个极值的差值的绝对值}<18
                ////4三代人 年龄极差≥18且存在一个年龄值min{ 该年龄值与两个极值的差值的绝对值}≥18
                ////    且存在一个年龄值min{ 该年龄值与其他三个的差值的绝对值}<18
                ////4四代人 任意两年龄极差≥18  任意两年龄极差≥18
                ////≥5                      署名人数≥5

                //2人情况
                if (Ages.Count == 2)
                {
                    if (Math.Abs(Ages[0] - Ages[1]) < 18)
                    {
                        if (Sexes[0] != Sexes[1])
                        {
                            Tag.FamilyStatus = "2人,异性,一代人";
                            if (Math.Abs(Ages[0] - Ages[1]) <= 5)
                            {
                                Tag.Marriage = "已婚";
                            }
                        }
                        else
                        {
                            Tag.FamilyStatus = "2人,同性,一代人";
                        }
                    }
                    else
                    {
                        Tag.FamilyStatus = "2人,两代人";
                        if (Ages[0] < 18 || Ages[1] < 18)
                        {
                            Tag.FamilyStatus += ",有未成年子女";
                        }
                    }
                }

                int MaxAge = Ages.Max();
                int MinAge = Ages.Min();

                //3人情况
                if (Ages.Count == 3)
                {
                    if (MaxAge - MinAge < 18)
                    {
                        Tag.FamilyStatus = "3人,一代人";
                    }

                    if (MaxAge - MinAge >= 18)
                    {
                        for (int i = 0; i < Ages.Count; i++)
                        {
                            if (Math.Abs(Ages[0] - Ages[1]) < 18 ||
                                Math.Abs(Ages[1] - Ages[2]) < 18 ||
                                Math.Abs(Ages[0] - Ages[2]) < 18)
                            {
                                Tag.FamilyStatus = "3人,两代人";
                                if (MinAge < 18)
                                {
                                    Tag.FamilyStatus += ",有未成年子女";
                                }
                            }
                        }
                    }

                    if (Math.Abs(Ages[0] - Ages[1]) >= 18 &&
                        Math.Abs(Ages[2] - Ages[1]) >= 18 &&
                        Math.Abs(Ages[0] - Ages[2]) >= 18)
                    {
                        Tag.FamilyStatus = "3人,三代人";
                        if (MinAge < 18)
                        {
                            Tag.FamilyStatus += ",有未成年子女";
                        }
                    }
                }

                //4人情况
                if (Ages.Count == 4)
                {
                    if (MaxAge - MinAge < 18)
                    {
                        Tag.FamilyStatus = "4人,一代人";
                    }

                    //排序,从小到大
                    List <int> SortedAges = Ages.ToList <int>();
                    SortedAges.Sort();

                    if (SortedAges[3] - SortedAges[0] >= 18 &&
                        SortedAges[3] - SortedAges[2] < 18 &&
                        SortedAges[1] - SortedAges[0] < 18)
                    {
                        Tag.FamilyStatus = "4人,两代人";
                    }

                    if (SortedAges[3] - SortedAges[0] >= 18 && (
                            (SortedAges[3] - SortedAges[2] < 18 && SortedAges[2] - SortedAges[1] >= 18 &&
                             SortedAges[1] - SortedAges[0] >= 18) ||
                            (SortedAges[3] - SortedAges[2] >= 18 && SortedAges[2] - SortedAges[1] >= 18 &&
                             SortedAges[1] - SortedAges[0] < 18)))
                    {
                        Tag.FamilyStatus = "4人,三代人";
                    }

                    if (SortedAges[3] - SortedAges[2] >= 18 && SortedAges[2] - SortedAges[1] >= 18 &&
                        SortedAges[1] - SortedAges[0] >= 18)
                    {
                        Tag.FamilyStatus = "4人,四代人";
                    }
                }

                if (Ages.Count > 5)
                {
                    Tag.FamilyStatus = "多人共同居住";
                }
            }

            //需求和成交记录
            for (int i = 0; i < ResultSet.Tables[0].Rows.Count; i++)
            {
                DemandInfo DI = new DemandInfo();

                DateTime DemandTime;
                if (DateTime.TryParse(ResultSet.Tables[0].Rows[i]["demand_time"].ToString(), out DemandTime) == false)
                {
                    continue;
                }

                //保护最近180天需求数据
                //if ((DateTime.Now - DemandTime).TotalDays <= 180)
                //{
                //    continue;
                //}

                DI.DemandDate    = DemandTime.ToString("yyyy-MM-dd");
                DI.DemandCity    = ResultSet.Tables[0].Rows[i]["city"].ToString();
                DI.DemandGrade   = ResultSet.Tables[0].Rows[i]["buy_grade"].ToString();
                DI.DemandProject = ResultSet.Tables[0].Rows[i]["project_name"].ToString();
                DI.DemandPurpose = ResultSet.Tables[0].Rows[i]["buy_purpose"].ToString();

                //查重
                bool IsExisted = false;
                for (int j = 0; j < Tag.DemandInfos.Count; j++)
                {
                    if (Tag.DemandInfos[j].DemandCity == DI.DemandCity &&
                        Tag.DemandInfos[j].DemandDate == DI.DemandDate &&
                        Tag.DemandInfos[j].DemandGrade == DI.DemandGrade &&
                        Tag.DemandInfos[j].DemandProject == DI.DemandProject &&
                        Tag.DemandInfos[j].DemandPurpose == DI.DemandPurpose)
                    {
                        IsExisted = true;
                        break;
                    }
                }

                if (!IsExisted)
                {
                    Tag.DemandInfos.Add(DI);
                }
            }

            for (int i = 0; i < ResultSet.Tables[1].Rows.Count; i++)
            {
                TradeInfo TI = new TradeInfo();

                DateTime TradeTime;
                if (DateTime.TryParse(ResultSet.Tables[1].Rows[i]["trade_date"].ToString(), out TradeTime) == false)
                {
                    continue;
                }

                //保护最近720天成交数据
                //if ((DateTime.Now - TradeTime).TotalDays <= 720)
                //{
                //    continue;
                //}

                TI.TradeDate    = TradeTime.ToString("yyyy-MM-dd");
                TI.TradeCity    = ResultSet.Tables[1].Rows[i]["trade_city"].ToString();
                TI.TradeGrade   = ResultSet.Tables[1].Rows[i]["trade_project_grade"].ToString();
                TI.TradeProject = ResultSet.Tables[1].Rows[i]["trade_project_name"].ToString();
                TI.TradePurpose = ResultSet.Tables[1].Rows[i]["trade_project_purpose"].ToString();

                bool IsExisted = false;
                for (int j = 0; j < Tag.TradeInfos.Count; j++)
                {
                    if (Tag.TradeInfos[j].TradeCity == TI.TradeCity &&
                        Tag.TradeInfos[j].TradeDate == TI.TradeDate &&
                        Tag.TradeInfos[j].TradeGrade == TI.TradeGrade &&
                        Tag.TradeInfos[j].TradeProject == TI.TradeProject &&
                        Tag.TradeInfos[j].TradePurpose == TI.TradePurpose)
                    {
                        IsExisted = true;
                        break;
                    }
                }

                if (!IsExisted)
                {
                    Tag.TradeInfos.Add(TI);
                }
            }

            return(0);
        }
Exemple #6
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (BrokerId.Length != 0)
            {
                hash ^= BrokerId.GetHashCode();
            }
            if (InvestorId.Length != 0)
            {
                hash ^= InvestorId.GetHashCode();
            }
            if (InstrumentId.Length != 0)
            {
                hash ^= InstrumentId.GetHashCode();
            }
            if (OrderRef.Length != 0)
            {
                hash ^= OrderRef.GetHashCode();
            }
            if (UserId.Length != 0)
            {
                hash ^= UserId.GetHashCode();
            }
            if (TradeId.Length != 0)
            {
                hash ^= TradeId.GetHashCode();
            }
            if (Direction != 0)
            {
                hash ^= Direction.GetHashCode();
            }
            if (OffsetFlag != 0)
            {
                hash ^= OffsetFlag.GetHashCode();
            }
            if (HedgeFlag != 0)
            {
                hash ^= HedgeFlag.GetHashCode();
            }
            if (Price != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Price);
            }
            if (Volume != 0)
            {
                hash ^= Volume.GetHashCode();
            }
            if (TradeDate.Length != 0)
            {
                hash ^= TradeDate.GetHashCode();
            }
            if (TradeTime.Length != 0)
            {
                hash ^= TradeTime.GetHashCode();
            }
            if (OrderLocalId.Length != 0)
            {
                hash ^= OrderLocalId.GetHashCode();
            }
            if (TradingDay.Length != 0)
            {
                hash ^= TradingDay.GetHashCode();
            }
            if (BrokerOrderSeq != 0)
            {
                hash ^= BrokerOrderSeq.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }