日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

从钱龙数据中读取股票权息信息导入到数据库

發布時間:2023/11/30 数据库 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 从钱龙数据中读取股票权息信息导入到数据库 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

從錢龍數據中讀取股票權息信息導入到數據庫
前面寫了如果讀股票代碼和日線數據,下面是如何讀股票的權息信息。

錢龍中權息數據存儲在QLDATA/history/shase/weight和QLDATA/history/sznse/weight目錄下,每個文件對應一只股票。

與前文一樣,只貼核心代碼:

??????? private static void ReadStockWeights(string strPath, string p_strMarket)
??????? {
??????????? string[] parts = strPath.Split('//');
??????????? string strStockCode = null;
??????????? for (int i = parts.Length - 1; i >= 0;i-- )
??????????? {
??????????????? string strTemp = parts[i];
??????????????? if (strTemp.ToUpper().EndsWith(".WGT"))
??????????????? {
??????????????????? strStockCode = strTemp.Substring(0, strTemp.Length - 4) ;
??????????????????? break;
??????????????? }
??????????? }
??????????? Debug.Assert(strStockCode != null);
??????????? Console.WriteLine("Read stock weight from file '" + strPath + "'");
??????????? FileStream stream = new FileStream(strPath, FileMode.Open, FileAccess.Read);
??????????? BinaryReader b_reader = new BinaryReader(stream);
??????????? List<StockWeightInfo> weightInfos = new List<StockWeightInfo>();
??????????? try
??????????? {
??????????????? while (stream.CanRead && stream.Position < stream.Length)
??????????????? {
??????????????????? int[] oneRow = new int[9];
??????????????????? for( int i=0;i<9;i++)
??????????????????? {
??????????????????????? oneRow[i] = b_reader.ReadInt32();
??????????????????? }//for
??????????????????? if (oneRow[8] != 0)
??????????????????? {
??????????????????????? throw new Exception("Last entry is not empty");
??????????????????? }
??????????????????? //read date
??????????????????? int nYear = oneRow[0] >> 20;
??????????????????? int nMon = (int)(((uint)(oneRow[0] << 12))>> 28);
??????????????????? int nDay = (oneRow[0] & 0xffff)>> 11;

??????????????????? DateTime wgtDate;
??????????????????? if (nYear == 0 && nMon == 0 && nDay == 0)
??????????????????????? wgtDate = DateTime.MinValue;
??????????????????? else
??????????????????????????? wgtDate = new DateTime(nYear, nMon, nDay);
??????????????????? StockWeightInfo wgtInfo = new StockWeightInfo();
??????????????????? wgtInfo.m_date = wgtDate;
??????????????????? wgtInfo.m_stockCountAsGift = oneRow[1];/**10000.0f;
??????????????????? wgtInfo.m_stockCountForSell = oneRow[2];/**10000.0f;
??????????????????? wgtInfo.m_priceForSell = oneRow[3];/**1000.0f;
??????????????????? wgtInfo.m_bonus = oneRow[4];/**1000.0f;
??????????????????? wgtInfo.m_stockCountOfIncreasement = oneRow[5];/**10000.0f;
??????????????????? wgtInfo.m_stockOwnership = (ulong)oneRow[6];
??????????????????? wgtInfo.m_freeStockCount = (ulong)oneRow[7];
??????????????????? if (!weightInfos.Contains(wgtInfo))
??????????????????? {
??????????????????????? weightInfos.Add(wgtInfo);
??????????????????????? //Console.WriteLine();
??????????????????????? //Console.Write(wgtInfo.ToString());
??????????????????? }
??????????????? }//while
??????????????? weightInfos.Sort();
??????????? }
??????????? catch (EndOfStreamException)
??????????? {
??????????????? Console.WriteLine("Unexpected end of stream");
??????????? }
??????????? catch (Exception ex)
??????????? {

??????????????? Console.WriteLine(ex.Message);
??????????????? throw;
??????????? }
??????????? finally
??????????? {
??????????????? stream.Close();
??????????? }
??????????? SqlCommand cmd = new SqlCommand("", m_conn);
??????????? cmd.Transaction = m_tran;
??????????? cmd.CommandText = "INSERT INTO [StockWeightInfos] ([StockCode] ,[Market] ,[Date] ,[StockCountAsGift] ,[StockCountForSell] ,[PriceForSell] ,[Bonus] ,[StockCountOfIncreasement] ,[StockOwnership] ,[FreeStockCount]) " +
?????????????????????????????? "VALUES (@StockCode, @Market ,@Date ,@StockCountAsGift ,@StockCountForSell ,@PriceForSell ,@Bonus ,@StockCountOfIncreasement ,@StockOwnership ,@FreeStockCount)";
??????????? cmd.Parameters.Add("@StockCode", SqlDbType.NVarChar, 50);
??????????? cmd.Parameters.Add("@Market", SqlDbType.NVarChar, 50);
??????????? cmd.Parameters.Add("@Date", SqlDbType.DateTime);
??????????? cmd.Parameters.Add("@StockCountAsGift", SqlDbType.Real);
??????????? cmd.Parameters.Add("@StockCountForSell", SqlDbType.Real);
??????????? cmd.Parameters.Add("@PriceForSell", SqlDbType.Real);
??????????? cmd.Parameters.Add("@Bonus", SqlDbType.Real);
??????????? cmd.Parameters.Add("@StockCountOfIncreasement", SqlDbType.Real);
??????????? cmd.Parameters.Add("@StockOwnership", SqlDbType.BigInt);
??????????? cmd.Parameters.Add("@FreeStockCount", SqlDbType.BigInt);
??????????? foreach(StockWeightInfo info in weightInfos)
??????????? {
??????????????? cmd.Parameters["@StockCode"].Value = strStockCode;
??????????????? cmd.Parameters["@Market"].Value = p_strMarket;
??????????????? cmd.Parameters["@Bonus"].Value = info.m_bonus / 1000.0;
??????????????? if (info.m_date != DateTime.MinValue)
??????????????????? cmd.Parameters["@Date"].Value = info.m_date;
??????????????? else
??????????????????? cmd.Parameters["@Date"].Value = DBNull.Value;
??????????????? cmd.Parameters["@FreeStockCount"].Value = info.m_freeStockCount;
??????????????? cmd.Parameters["@PriceForSell"].Value = info.m_priceForSell/1000.0;
??????????????? cmd.Parameters["@StockCountAsGift"].Value = info.m_stockCountAsGift/10000.0;
??????????????? cmd.Parameters["@StockCountForSell"].Value = info.m_stockCountForSell/10000.0;
??????????????? cmd.Parameters["@StockCountOfIncreasement"].Value = info.m_stockCountOfIncreasement/10000.0;
??????????????? cmd.Parameters["@StockOwnership"].Value = info.m_stockOwnership;
??????????????? int nCnt=cmd.ExecuteNonQuery();
??????????????? Debug.Assert(nCnt == 1);
??????????? }//foreach
??????? }//ReadStockWeights

總結

以上是生活随笔為你收集整理的从钱龙数据中读取股票权息信息导入到数据库的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。