public void Update(StockPriceHistory entity)
        {
            var format = @"update stockpricehistory set `openprice` = {1}, `price` = {2}, `highestprice` = {3}, `lowestprice` = {4}, `ceilingprice` = {5}, `floorprice` = {6}, `yesterdaycloseprice` = {7}, `pricechangepercent` = {8}, `priceshakepercent` = {9}, `exchangerate` = {10}, `exchangeamountinhands` = {11}, `exchangeamountinrmb` = {12}, `pe` = {13}, `pb` = {14}, `flowablemarketvalue` = {15}, `totalmarketvalue` = {16}, `updatetime` = '{17}' where `id` = {0};";

            var f1 = entity.OpenPrice;
            var f2 = entity.Price;
            var f3 = entity.HighestPrice;
            var f4 = entity.LowestPrice;
            var f5 = entity.CeilingPrice;
            var f6 = entity.FloorPrice;
            var f7 = entity.YesterdayClosePrice;
            var f8 = entity.PriceChangePercent;
            var f9 = entity.PriceShakePercent;
            var f10 = entity.ExchangeRate;
            var f11 = entity.ExchangeAmountInHands;
            var f12 = entity.ExchangeAmountInRMB;
            var f13 = entity.PE;
            var f14 = entity.PB;
            var f15 = entity.FlowableMarketValue;
            var f16 = entity.TotalMarketValue;
            var f17 = DateTime.Now.ToString(Setting.Date_Format_4y_2M_2d_2H_2m_2s);

            var formatedSql = string.Format(format, entity.Id, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17);

            this.DbRequest.ExecuteNonQuery(this.ConnectionString, formatedSql, null, CommandType.Text);
        }
        public void Create(StockPriceHistory entity)
        {
            var sql = @"insert into stockpricehistory(openprice,price,highestprice,lowestprice,ceilingprice,floorprice,yesterdaycloseprice,pricechangepercent,priceshakepercent,exchangerate,exchangeamountinhands,exchangeamountinrmb,pe,pb,flowablemarketvalue,totalmarketvalue,createtime,updatetime,code,name,date) values(@openprice,@price,@highestprice,@lowestprice,@ceilingprice,@floorprice,@yesterdaycloseprice,@pricechangepercent,@priceshakepercent,@exchangerate,@exchangeamountinhands,@exchangeamountinrmb,@pe,@pb,@flowablemarketvalue,@totalmarketvalue,@createtime,@updatetime,@code,@name,@date);";
            var parameters = new IDataParameter[]
            {
                new MySqlParameter("@openprice",entity.OpenPrice),
                new MySqlParameter("@price",entity.Price),
                new MySqlParameter("@highestprice",entity.HighestPrice),
                new MySqlParameter("@lowestprice",entity.LowestPrice),
                new MySqlParameter("@ceilingprice",entity.CeilingPrice),
                new MySqlParameter("@floorprice",entity.FloorPrice),
                new MySqlParameter("@yesterdaycloseprice",entity.YesterdayClosePrice),
                new MySqlParameter("@pricechangepercent",entity.PriceChangePercent),
                new MySqlParameter("@priceshakepercent",entity.PriceShakePercent),
                new MySqlParameter("@exchangerate",entity.ExchangeRate),
                new MySqlParameter("@exchangeamountinhands",entity.ExchangeAmountInHands),
                new MySqlParameter("@exchangeamountinrmb",entity.ExchangeAmountInRMB),
                new MySqlParameter("@pe",entity.PE),
                new MySqlParameter("@pb",entity.PB),
                new MySqlParameter("@flowablemarketvalue",entity.FlowableMarketValue),
                new MySqlParameter("@totalmarketvalue",entity.TotalMarketValue),
                new MySqlParameter("@createtime",DateTime.Now),
                new MySqlParameter("@updatetime",DateTime.Now),
                new MySqlParameter("@code",entity.Code),
                new MySqlParameter("@name",entity.Name),
                new MySqlParameter("@date",entity.Date.ToString("yyyy-MM-dd"))
            };

            this.DbRequest.ExecuteNonQuery(this.ConnectionString, sql, parameters, CommandType.Text);
        }
Beispiel #3
0
        static StockPriceHistory CreateNewPriceItem(MarketStock stock, DateTime today)
        {
            // 从数据源获取最新的价格数据
            var pulse = _crawler.FetchRealtimePrice(stock.Market, stock.Code);

            if (pulse == null)
            {
                return null;
            }

            var priceItem = new StockPriceHistory()
            {
                Code = stock.Code,
                Name = stock.Name,
                Date = today,
                OpenPrice = pulse.F5_TodayOpenPrice ?? 0,
                Price = pulse.F3_CurrentPrice ?? 0,
                HighestPrice = pulse.F33_HighestPriceInToday ?? 0,
                LowestPrice = pulse.F34_LowestPriceInToday ?? 0,
                CeilingPrice = pulse.F47_CeilingPrice ?? 0,
                FloorPrice = pulse.F48_FloorPrice ?? 0,
                YesterdayClosePrice = pulse.F4_YesterdayClosePrice ?? 0,
                PriceChangePercent = pulse.F32_PriceChangePercent ?? 0,
                PriceShakePercent = pulse.F43_PriceShakePercent,
                ExchangeRate = pulse.F38_ExchangeHandsRatePercent ?? 0,
                ExchangeAmountInHands = pulse.F6_ExchangedNumbersInHands ?? 0,
                ExchangeAmountInRMB = pulse.F37_ExchangeAmountInRMBTenThousand ?? 0,
                PB = pulse.F46_PB ?? 0,
                PE = pulse.F39_DynamicPE ?? 0,
                FlowableMarketValue = pulse.F44_FlowableValue ?? 0,
                TotalMarketValue = pulse.F45_TotalValue ?? 0,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
            };

            return priceItem;
        }