コード例 #1
0
ファイル: Decode_S37.cs プロジェクト: mirror222/ZeroSystem
        /*
         *  指數計算及補價資訊:(<stockid:2>=999x...)
         *  <data:N> = {<subId:1> <值:n1>}重覆直到封包結尾...
         */
        /// <summary>
        ///    大盤指數計算及補價資訊
        /// </summary>
        private static void Decoder(int StockId, MitakeIndex index, Mitake.Sockets.Data.PacketBuffer Buffer)
        {
            uint uValue = 0;
            bool bNegative = false;
            byte bMode = 0, bFlag = 0, bModule = 0;

            int iSize = Buffer.Length - 2;

            Buffer.Position = 7;

            do
            {
                //取得subId旗標
                bFlag = Buffer[0];
                ++Buffer.Position;

                //取得量價格式
                bMode   = BitConvert.GetValue(bFlag, 6, 2);
                bModule = BitConvert.GetValue(bFlag, 0, 6);

                switch (StockId)
                {
                case 9999:
                    uValue = Volumn.GetVolumn(bMode, Buffer);

                    Decoder_Index_9999(index, bModule, uValue);
                    break;

                case 10000:
                    if ((Buffer[0] & 0x80) == 0)
                    {
                        bNegative = false;                                                     //正號
                    }
                    else
                    {
                        bNegative = true;                                                      //負號
                        Buffer.Data[Buffer.Position] &= 0x7f;                                  //取消負號旗標
                    }

                    uValue = Volumn.GetVolumn(bMode, Buffer);

                    Decoder_Index_10000(index, bModule, uValue, bNegative);
                    break;

                default:
                    Volumn.GetVolumn(bMode, Buffer);
                    break;
                }
            } while (Buffer.Position < iSize);            //end while

            ++index.UpdateCount;
        }
コード例 #2
0
ファイル: Decode_S36.cs プロジェクト: mirror222/ZeroSystem
        internal static void Decode(MitakeIndex index, Mitake.Sockets.Data.PacketBuffer Buffer)
        {
            int  iSize = 0;
            byte bMode = 0, bType = 0, bFlag = 0;

            iSize = Buffer.Length - 2;

            //移動至資料結構(時間欄位)
            Buffer.Position = 7;

            do
            {
                //取得Format旗標
                bFlag = Buffer[0];
                ++Buffer.Position;

                //取得家數大小(1~4 Byte 不固定)
                bMode = BitConvert.GetValue(bFlag, 6, 2);

                //取得家數代號(有持平家數,上漲家數,下跌家數 等......)
                bType = BitConvert.GetValue(bFlag, 0, 6);

                switch (bType)
                {
                case 0:                         //持平家數
                    index.持平家數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 1:                         //未成交家數
                    index.未成交家數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 2:                         //上漲家數
                    index.漲家數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 3:                         //下跌家數
                    index.跌家數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 4:                         //漲停家數
                    index.漲停家數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 5:                         //跌停家數
                    index.跌停家數 = Volumn.GetVolumn(bMode, Buffer);
                    break;
                }
            } while (Buffer.Position < iSize);            //End While

            ++index.UpdateCount;
        }
コード例 #3
0
ファイル: Decode_S33.cs プロジェクト: mirror222/ZeroSystem
        internal static void Decode(MitakeIndex index, PacketBuffer Buffer)
        {
            byte            bMode = 0, bFlag = 0;
            MitakeIndexTick cTick = null;

            //移動至資料結構
            Buffer.Position = 7;

            DateTime cTime = Time.GetTime(Buffer);             //取得時間
            bool     bHave = index.GetMitakeTick(cTime, ref cTick);

            cTick.SetFlag(2);

            MitakeIndexTick cPrevTick = null;

            if (index.ComplementStatus != ComplementStatus.NotComplement)
            {
                cPrevTick = index.GetPreviousTick(cTime, 2);
                if (cPrevTick != null)
                {
                    cTick.Clone(cPrevTick);
                }
            }

            //取得format
            bFlag = Buffer[0];
            ++Buffer.Position;

            //取得成交總額
            bMode = BitConvert.GetValue(bFlag, 6, 2);

            uint uVolume = Volumn.GetVolumn(bMode, Buffer);

            cTick.Volume = uVolume;
            if (uVolume > index.成交總額)
            {
                index.成交總額 = uVolume;
            }

            //取得成交張數
            bMode      = BitConvert.GetValue(bFlag, 4, 2);
            cTick.成交張數 = Volumn.GetVolumn(bMode, Buffer);

            //取得成交筆數
            bMode      = BitConvert.GetValue(bFlag, 2, 2);
            cTick.成交筆數 = Volumn.GetVolumn(bMode, Buffer);

            CalculateSingle(cTick, cPrevTick);
            ++index.UpdateCount;
        }
コード例 #4
0
ファイル: Decode_SB3.cs プロジェクト: mirror222/ZeroSystem
        internal static void Decode(MitakeIndex index, Mitake.Sockets.Data.PacketBuffer Buffer)
        {
            int             iSize = 0;
            uint            uValue = 0;
            byte            bMode = 0, bIType = 0, bFlag = 0;
            MitakeIndexTick cTick = null;

            iSize           = Buffer.Length - 2;
            Buffer.Position = 7;                      //移動至資料結構(時間欄位)

            DateTime cTime = Time.GetTime(Buffer);    //取得時間
            bool     bHave = index.GetMitakeTick(cTime, ref cTick);

            cTick.SetFlag(8);

            if (index.ComplementStatus != ComplementStatus.NotComplement)
            {
                MitakeIndexTick cPrevTick = index.GetPreviousTick(cTime, 8);
                if (cPrevTick != null)
                {
                    cTick.Clone(cPrevTick);
                }
            }

            do
            {
                //取得價量旗標
                bFlag = Buffer[0];
                ++Buffer.Position;

                //取得指數代號(有加權指數,不含金融 等......)
                bIType = Buffer[0];
                ++Buffer.Position;

                //取得類股成交金額
                bMode  = BitConvert.GetValue(bFlag, 6, 2);
                uValue = Volumn.GetVolumn(bMode, Buffer);

                cTick.Classifys[bIType].Amount = uValue;

                //取得類股成交量
                bMode = BitConvert.GetValue(bFlag, 4, 2);

                uValue = Volumn.GetVolumn(bMode, Buffer);
                cTick.Classifys[bIType].Totals = uValue;
            } while (Buffer.Position < iSize);           //End While

            ++index.UpdateCount;
        }
コード例 #5
0
ファイル: Decode_S3D.cs プロジェクト: mirror222/ZeroSystem
        internal static void Decode(MitakeQuote stock, Mitake.Sockets.Data.PacketBuffer Buffer)
        {
            int  iSize  = Buffer.Length - 2;
            byte bSType = Buffer.Data[6];

            Buffer.Position = 9;

            //取得時間
            //if ((bSType & 0x80) == 0) {
            //        iTime = Time.GetTime(Buffer);
            //} else {
            //        iTime = Time.GetOther(Buffer);
            //}

            //取得價量旗標與戳合類型
            byte bFlag = Buffer[0];

            ++Buffer.Position;

            stock.戳合類型 = BitConvert.GetValue(bFlag, 2, 2);
        }
コード例 #6
0
        internal static void Decode(MitakeQuote stock, Mitake.Sockets.Data.PacketBuffer Buffer)
        {
            float fReferPrice = 0;
            byte  bMode = 0, bFlag = 0;

            Buffer.Position = 7;                               //移動至資料結構
            bFlag           = Buffer.Data[Buffer.Position];
            ++Buffer.Position;

            //取得參考價模式
            bMode            = BitConvert.GetValue(bFlag, 6, 2);
            stock.ReferPrice = Price.GetPrice(bMode, Buffer, ref fReferPrice);

            //取得參考價模式
            bMode     = BitConvert.GetValue(bFlag, 4, 2);
            stock.漲停價 = Price.GetPrice(bMode, Buffer, ref fReferPrice);

            //取得參考價模式
            bMode     = BitConvert.GetValue(bFlag, 2, 2);
            stock.跌停價 = Price.GetPrice(bMode, Buffer, ref fReferPrice);

            ++stock.UpdateCount;
        }
コード例 #7
0
        internal static void Decode(MitakeIndex index, Mitake.Sockets.Data.PacketBuffer Buffer)
        {
            float           fIndex = 0;
            byte            bMode = 0, bIType = 0, bFlag = 0;
            MitakeIndexTick cTick = null;

            int iSize = Buffer.Length - 2;

            Buffer.Position = 7;                      //移動至資料結構(時間欄位)

            DateTime cTime = Time.GetTime(Buffer);    //取得時間
            bool     bHave = index.GetMitakeTick(cTime, ref cTick);

            cTick.SetFlag(1);

            if (index.ComplementStatus != ComplementStatus.NotComplement)
            {
                MitakeIndexTick cPrevTick = index.GetPreviousTick(cTime, 1);
                if (cPrevTick != null)
                {
                    cTick.Clone(cPrevTick);
                }
            }

            do
            {
                //取得價量旗標
                bFlag = Buffer[0];
                ++Buffer.Position;

                //取得指數大小(1~4 Byte 不固定)
                bMode = BitConvert.GetValue(bFlag, 6, 2);

                //取得指數代號(有加權指數,不含金融 等......)
                bIType = BitConvert.GetValue(bFlag, 0, 6);
                fIndex = (float)(Volumn.GetVolumn(bMode, Buffer) * 0.01);

                if (Time.ConvertForTotalSeconds(cTime) == 32400)             //09:00 開盤會送出昨日收盤價
                {
                    index.ReferPrices[bIType] = fIndex;                      //昨天收盤指數
                }
                else
                {
                    if (fIndex > 0)
                    {
                        cTick.Classifys[bIType].IndexValue = fIndex;

                        switch (bIType)
                        {
                        case 0:                                 //加權指數
                            cTick.Ask = new DOMPrice(fIndex, cTick.Ask.Size);
                            cTick.Bid = new DOMPrice(fIndex, cTick.Bid.Size);
                            CalculatePrice(index, cTime, fIndex);

                            if (cTime >= index.即時資訊.Time)
                            {
                                index.Close = fIndex;

                                if (index.Serial == 9999)
                                {
                                    index.加權指數價差 = fIndex - index.ReferPrices[0];
                                }
                                else if (index.Serial == 9998)
                                {
                                    index.OTC指數價差 = fIndex - index.ReferPrices[0];
                                }
                            }
                            break;

                        case 9:                                 //不含金融
                            if (index.Serial == 9999)
                            {
                                if (cTime >= index.即時資訊.Time)
                                {
                                    index.含金融價差 = fIndex - index.ReferPrices[9];
                                }
                            }
                            break;

                        default:
                            break;
                        }
                    }
                }
            } while (Buffer.Position < iSize);            //End While

            if (cTime > index.即時資訊.Time)
            {
                index.即時資訊 = cTick;
            }
            ++index.UpdateCount;
        }
コード例 #8
0
        internal static void Decode(int serial, PacketBuffer buffer)
        {
            byte bSize = 0, bMark = 0, bFlag = 0, bTemp = 0;
            MitakeSymbolInformation cSymbolInfo = new MitakeSymbolInformation();

            bSize           = buffer.Data[3];
            buffer.Position = 7;             //移動至資料結構

            //判斷股票別(如果為0 表示無此資料)
            bFlag = buffer[0];

            //取得市場別(0=集中市場 1=上櫃 2=期貨 3=興櫃)
            cSymbolInfo.市場別 = BitConvert.GetValue(bFlag, 6, 2);

            //取得是否為警示股
            bTemp          = BitConvert.GetValue(bFlag, 5, 1);
            cSymbolInfo.警示 = ((bTemp == 1) ? true : false);

            //取得是否為下市股票(五個交易日後移除)
            bTemp         = BitConvert.GetValue(bFlag, 4, 1);
            cSymbolInfo.市 = ((bTemp == 1) ? true : false);

            //取得市場分類(參閱解碼表代號)
            cSymbolInfo.市場分類 = BitConvert.GetValue(bFlag, 0, 4);
            ++buffer.Position;

            //取得股票代號(舊格式股票代號)
            cSymbolInfo.SymbolId = Encoding.UTF8.GetString(buffer.Data, buffer.Position, 5).Trim();
            buffer.Position     += 5;

            //取得股票名稱
            cSymbolInfo.SymbolName = Encoding.UTF8.GetString(buffer.Data, buffer.Position, 9).Replace("\0", string.Empty);
            buffer.Position       += 9;

            //期貨擴充(1:一般, 2:現月, 3:次月  PS:股票無使用)
            bMark = buffer[0];
            cSymbolInfo.FutureMark = bMark;
            ++buffer.Position;

            string sSymbolId = string.Empty;

            if (cSymbolInfo.市場別 == 2)               //判斷是否為期貨
            {
                if (cSymbolInfo.市場分類 == 2)
                {
                    //如果市場分類 == 2,則可能是選擇權(SID2 = 10Bytes)
                    sSymbolId        = Encoding.UTF8.GetString(buffer.Data, buffer.Position, 10).Trim('\0', ' ');
                    buffer.Position += 10;
                }
                else
                {
                    sSymbolId        = Encoding.UTF8.GetString(buffer.Data, buffer.Position, 13).Trim('\0', ' ');
                    buffer.Position += 13;
                }
            }
            else
            {
                //取得SID2
                sSymbolId        = Encoding.UTF8.GetString(buffer.Data, buffer.Position, 6).Trim('\0', ' ');
                buffer.Position += 6;

                //取得個股產業類別
                cSymbolInfo.產業別  = Encoding.UTF8.GetString(buffer.Data, buffer.Position, 2);
                buffer.Position += 2;

                //取得個股證券類別
                cSymbolInfo.證券別  = Encoding.UTF8.GetString(buffer.Data, buffer.Position, 2);
                buffer.Position += 2;
            }

            if (sSymbolId.Length > 0)
            {
                //轉換為標準台股商品代號格式
                string[] sSymbolIds = MitakeSymbolManager.Convert(cSymbolInfo.SymbolId, sSymbolId, (cSymbolInfo.市場別 == 2) ? cSymbolInfo.市場分類 : 0);
                if (sSymbolIds != null)
                {
                    cSymbolInfo.SymbolId = sSymbolIds[0];

                    if (!MitakeSymbolManager.IsExist(sSymbolIds[0]))
                    {
                        AddProductToExchange(cSymbolInfo, sSymbolIds[1]);                          //將股票代號更新至交易所內
                    }
                    MitakeSymbolManager.AddQuoteSymbolInformation(serial, cSymbolInfo);            //將基本資訊加入代號管理員內
                }
            }
        }
コード例 #9
0
        internal static void Decode(MitakeQuote stock, PacketBuffer buffer)
        {
            DateTime        cTime;
            bool            isHave = false;
            int             iSerial = 0;
            float           fReferPrice = 0;
            byte            bType = 0, bMode = 0, bVType = 0, bFlag = 0;
            MitakeQuoteTick cTick = null;

            int  iSize  = buffer.Length - 2;
            byte bSType = buffer.Data[6];

            buffer.Position = 7;

            if ((bSType & 0xf) == 11)
            {
                iSerial         = ((buffer[0] << 8) + buffer[1]);
                buffer.Position = 9;
            }
            else
            {
                iSerial         = (buffer[0] << 16) + (buffer[1] << 8) + buffer[2];
                buffer.Position = 10;
            }

            do
            {
                if (bSType == 0x42)
                {
                    bType = 1;
                    cTime = Time.GetSpecial(buffer);
                }
                else
                {
                    //取得類型
                    bType = BitConvert.GetValue(buffer[0], 7, 1);

                    //取得時間
                    if ((bSType & 0x80) == 0)
                    {
                        cTime = Time.GetTime(buffer);
                    }
                    else
                    {
                        cTime = Time.GetOther(buffer);
                    }
                }

                isHave     = stock.GetMitakeTick(iSerial, ref cTick);
                cTick.Time = cTime;

                bFlag = buffer[0];                 //取得價量旗標
                ++buffer.Position;

                cTick.類型 = bType;                  //類型  0=即時  1=盤後(此封包為盤後封包)

                //買賣型態(0=無法區分  1=買盤量  2=賣盤量)
                bVType    = BitConvert.GetValue(bFlag, 2, 2);
                cTick.買賣盤 = bVType;

                //取得成交價模式
                bMode       = BitConvert.GetValue(bFlag, 6, 2);
                cTick.Price = Price.GetPrice(bMode, buffer, ref fReferPrice);
                Decode_S31.CalculatePrice(stock, iSerial, cTick.Price);                 //計算 開盤 最高 最低

                //取得單量模式
                bMode        = BitConvert.GetValue(bFlag, 4, 2);
                cTick.Single = Volumn.GetVolumn(bMode, buffer);

                //取得委買價
                cTick.Bid = new DOMPrice(cTick.Price - EntrustPrice(BitConvert.GetValue(bFlag, 1, 1), buffer), cTick.Bid.Size);

                //取得委賣價
                cTick.Ask = new DOMPrice(cTick.Price + EntrustPrice(BitConvert.GetValue(bFlag, 0, 1), buffer), cTick.Ask.Size);

                //修正總成交量(伺服器會傳輸回補修正封包, 需要重新修正總成交量)
                MitakeQuoteTick cPrevTick = stock.GetPreviousTick(iSerial);
                cTick.Volume = ((cPrevTick == null) ? 0d : cPrevTick.Volume) + cTick.Single;

                if (!isHave)
                {
                    stock.今日總成交額 += cTick.Price * cTick.Single;
                }
                ++iSerial;
            } while (buffer.Position < iSize);            //End While
        }
コード例 #10
0
ファイル: Decode_S3C.cs プロジェクト: mirror222/ZeroSystem
        internal static void Decode(MitakeQuote stock, Mitake.Sockets.Data.PacketBuffer Buffer)
        {
            int iSize = 0;

            float fPeferPrice = 0;
            byte  bNumber = 0, bMode = 0, bFlag = 0, bBuyFlag = 0;

            iSize           = Buffer.Length - 2;
            Buffer.Position = 7;              //移動至資料結構

            int iCount = MitakeEntrust.MAX_DOM_COUNT;

            for (int i = 1; i < iCount; i++)
            {
                stock.委買委賣資訊.Ask[i] = DOMPrice.EMPTY;
                stock.委買委賣資訊.Bid[i] = DOMPrice.EMPTY;
            }

            do
            {
                //取得價量旗標
                bFlag = Buffer[0];
                ++Buffer.Position;

                bNumber = BitConvert.GetValue(bFlag, 0, 3);
                ++bNumber;

                //買賣型態(0=委買量  1=委賣量)
                bBuyFlag = BitConvert.GetValue(bFlag, 3, 1);

                double dPrice = 0, dVolume = 0;
                if (bBuyFlag == 0)
                {
                    //取得委買價模式
                    bMode  = BitConvert.GetValue(bFlag, 6, 2);
                    dPrice = Price.GetPrice(bMode, Buffer, ref fPeferPrice);

                    //取得委買量模式
                    bMode   = BitConvert.GetValue(bFlag, 4, 2);
                    dVolume = Volumn.GetVolumn(bMode, Buffer);

                    if (bNumber < MitakeEntrust.MAX_DOM_COUNT)
                    {
                        stock.委買委賣資訊.Bid[bNumber] = new DOMPrice(dPrice, dVolume);
                    }
                }
                else
                {
                    //取得委賣價模式
                    bMode  = BitConvert.GetValue(bFlag, 6, 2);
                    dPrice = Price.GetPrice(bMode, Buffer, ref fPeferPrice);

                    //取得委賣量模式
                    bMode   = BitConvert.GetValue(bFlag, 4, 2);
                    dVolume = Volumn.GetVolumn(bMode, Buffer);

                    if (bNumber < MitakeEntrust.MAX_DOM_COUNT)
                    {
                        stock.委買委賣資訊.Ask[bNumber] = new DOMPrice(dPrice, dVolume);
                    }
                }
            } while (Buffer.Position < iSize);             //End While

            ++stock.UpdateCount;
        }
コード例 #11
0
ファイル: Decode_S37.cs プロジェクト: mirror222/ZeroSystem
        private static void Decoder(MitakeQuote stock, Mitake.Sockets.Data.PacketBuffer Buffer)
        {
            float fReferPrice = 0;
            byte  bMode = 0, bModule = 0, bPVFlag = 0, bFlag = 0;

            int iSize = Buffer.Length - 2;

            Buffer.Position = 7;

            do
            {
                bFlag = Buffer[0];                  //移動至資料結構
                ++Buffer.Position;

                //取得(價/量)旗標 0=量  1=價
                bPVFlag = BitConvert.GetValue(bFlag, 5, 1);

                //取得參考價或是成交量模式
                bMode   = BitConvert.GetValue(bFlag, 6, 2);
                bModule = BitConvert.GetValue(bFlag, 0, 6);

                switch (bModule)
                {
                case 2:                         //累計買量
                    stock.累計買量 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 3:                         //累計賣量
                    stock.累計賣量 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 4:                         //即時單筆買進巨量
                    stock.單筆買進巨量 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 5:                         //即時單筆賣出巨量
                    stock.單筆賣出巨量 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 6:                         //(即時)累計買進巨量
                    stock.累計買進巨量 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 7:                         //(即時)累計賣出巨量
                    stock.累計賣出巨量 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 8:                         //即時)量幅,小數兩位(每3筆送一次)
                    stock.即時量幅 = (float)(Volumn.GetVolumn(bMode, Buffer) * 0.01);
                    break;

                case 9:                         //(即時)買氣,0~100,賣氣=100-買氣(每3筆送一次)
                    stock.買進量百分比 = (byte)Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 15:                         //昨日總成交量
                    stock.昨日總成交量 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 17:                         //買進成交筆數(股票與選擇權共用)
                    stock.買進成交筆數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 18:                         //賣出成交筆數(股票與選擇權共用)
                    stock.賣出成交筆數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 19:                         //總成交合約數(股票與選擇權共用)
                    stock.總成交合約數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 20:                         //買進累計委託筆數
                    stock.買進累計委託筆數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 21:                         //買進累計委託合約量
                    stock.買進累計委託合約量 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 22:                         //賣出累計委託筆數
                    stock.賣出累計委託筆數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 23:                         //賣出累計委託合約量
                    stock.賣出累計委託合約量 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 24:                         //未平倉合約數(收盤後)
                    stock.未平倉合約數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 25:                         //選擇權:委託買進總口數
                    stock.委託買進總口數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 26:                         //選擇權:委託賣出總口數
                    stock.委託賣出總口數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 27:                         //選擇權:總成交筆數
                    stock.總成交筆數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 29:                         //盤前試戳成交量
                    stock.試戳成交量 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 32:                         //(即時)均價(每10筆送一次)
                    stock.即時均價 = Price.GetPrice(bMode, Buffer, ref fReferPrice);
                    break;

                case 40:                         //昨日最高價
                    stock.昨日最高價 = Price.GetPrice(bMode, Buffer, ref fReferPrice);
                    break;

                case 41:                         //昨日最低價
                    stock.昨日最低價 = Price.GetPrice(bMode, Buffer, ref fReferPrice);
                    break;

                case 42:                         //今日開盤價
                    stock.Open = Price.GetPrice(bMode, Buffer, ref fReferPrice);
                    break;

                case 43:                         //今日最高價
                    stock.High = Price.GetPrice(bMode, Buffer, ref fReferPrice);
                    break;

                case 44:                         //今日最低價
                    stock.Low = Price.GetPrice(bMode, Buffer, ref fReferPrice);
                    break;

                case 45:                         //今日收盤價
                    stock.Close = Price.GetPrice(bMode, Buffer, ref fReferPrice);
                    break;

                case 54:                         //結算價(收盤後)
                    stock.結算價 = Price.GetPrice(bMode, Buffer, ref fReferPrice);
                    break;

                case 55:                         //盤前試戳成交價
                    stock.試戳成交價 = Price.GetPrice(bMode, Buffer, ref fReferPrice);
                    break;

                default:                         //其他屬於盤後資料(已經不計入範圍內)
                    if (bPVFlag == 0)
                    {
                        Volumn.GetVolumn(bMode, Buffer);
                    }
                    else
                    {
                        Price.GetPrice(bMode, Buffer, ref fReferPrice);
                    }
                    break;
                }                              //end switch
            } while (Buffer.Position < iSize); //end while

            ++stock.UpdateCount;
        }
コード例 #12
0
ファイル: Decode_S34.cs プロジェクト: mirror222/ZeroSystem
        internal static void Decode(MitakeIndex index, Mitake.Sockets.Data.PacketBuffer Buffer)
        {
            int             iSize = 0;
            byte            bMode = 0, bType = 0, bFlag = 0;
            MitakeIndexTick cTick = null;

            iSize           = Buffer.Length - 2;
            Buffer.Position = 7;                     //移動至資料結構(時間欄位)

            DateTime cTime = Time.GetTime(Buffer);   //取得時間

            if (cTime.TimeOfDay == __c忽略報價時間)        //這個時間點可以直接忽略
            {
                return;
            }

            bool bHave = index.GetMitakeTick(cTime, ref cTick);

            cTick.SetFlag(4);

            if (index.ComplementStatus != ComplementStatus.NotComplement)
            {
                MitakeIndexTick cPrevTick = index.GetPreviousTick(cTime, 4);
                if (cPrevTick != null)
                {
                    cTick.Clone(cPrevTick);
                }
            }

            do
            {
                //取得Format旗標
                bFlag = Buffer[0];
                ++Buffer.Position;

                //取得委託張數大小(1~4 Byte 不固定)
                bMode = BitConvert.GetValue(bFlag, 6, 2);

                //取得委託代號(有委賣合計張數,委買合計張數 等......)
                bType = BitConvert.GetValue(bFlag, 0, 6);

                switch (bType)
                {
                case 0:                         //委買合計張數
                    cTick.Bid = new DOMPrice(cTick.Price, Volumn.GetVolumn(bMode, Buffer));
                    break;

                case 1:                         //委賣合計張數
                    cTick.Ask = new DOMPrice(cTick.Price, Volumn.GetVolumn(bMode, Buffer));
                    break;

                case 2:                         //委買合計筆數
                    cTick.委買合計筆數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 3:                         //委賣合計筆數
                    cTick.委賣合計筆數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 4:                         //委買總漲停張數
                    cTick.委買總漲停張數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 5:                         //委賣總漲停張數
                    cTick.委賣總漲停張數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 6:                         //委買總漲停筆數
                    cTick.委買總漲停筆數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 7:                         //委賣總漲停筆數
                    cTick.委賣總漲停筆數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 8:                         //委買總跌停張數
                    cTick.委買總跌停張數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 9:                         //委賣總跌停張數
                    cTick.委賣總跌停張數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 10:                         //委買總跌停筆數
                    cTick.委買總跌停筆數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                case 11:                         //委賣總跌停筆數
                    cTick.委賣總跌停筆數 = Volumn.GetVolumn(bMode, Buffer);
                    break;

                default:
                    Buffer.Position += (bMode + 1);
                    break;
                }                              //End Switch
            } while (Buffer.Position < iSize); //End While

            ++index.UpdateCount;
        }
コード例 #13
0
		internal static void Decode(MitakeQuote stock, Mitake.Sockets.Data.PacketBuffer Buffer) {
			DateTime cTime;
			float fReferPrice = 0;
			double dAskP = 0, dAskV = 0, dBidP = 0, dBidV = 0, dPrice = 0, dVolume = 0, dSingle = 0;
			byte bType = 0, bMode = 0, bPType = 0, bVType = 0, bFlag = 0, b類型 = 0, b買賣盤 = 0, b價格類型 = 0;

			int iSerial = 0, iSize = Buffer.Length - 2;
			byte bSType = Buffer.Data[6];

			Buffer.Position = 7;

			//取得序號
			if ((bSType & 0x31) == 0x31) {  //0x31 0xb1 與不等於 0x41 (夜盤) 序號都兩個位元組
				iSerial = (Buffer[0] << 8) + Buffer[1];
				Buffer.Position = 9;
			} else {  //其他類型序號都是三個位元組
				iSerial = (Buffer[0] << 16) + (Buffer[1] << 8) + Buffer[2];
				Buffer.Position = 10;
			}

			if (bSType == 0x41) {  //夜盤代號 0x41 (時間格式不同)
				bType = 0;
				cTime = Time.GetSpecial(Buffer);
			} else {
				//取得類型
				bType = BitConvert.GetValue(Buffer[0], 7, 1);

				//取得時間
				if ((bSType & 0x80) == 0) {
					cTime = Time.GetTime(Buffer);
				} else {
					cTime = Time.GetOther(Buffer);
				}
			}

			do {
				//取得價量旗標
				bFlag = Buffer[0];
				++Buffer.Position;

				b類型 = bType;  //類型  0=即時  1=盤後

				//判斷是否是單量(1110B)
				if (BitConvert.GetValue(bFlag, 0, 4) == 0xe) {
					//買賣型態(0=無法區分買賣盤量  1=買量  2=賣量)
					bVType = BitConvert.GetValue(bFlag, 6, 2);
					b買賣盤 = bVType;

					bMode = BitConvert.GetValue(bFlag, 4, 2);
					dSingle = Volumn.GetVolumn(bMode, Buffer);
				} else {
					//買賣型態(0=無法確定 1=買盤 2=賣盤 3=委託買賣)
					bVType = BitConvert.GetValue(bFlag, 2, 2);

					//價位型態(0=一般成交價 1=開 2=高 3=低)
					//如果買賣型態為委託買賣(0=委買 1=委賣)
					bPType = BitConvert.GetValue(bFlag, 0, 2);

					//取得成交價或委託價模式
					bMode = BitConvert.GetValue(bFlag, 6, 2);

					switch (bVType) {
						case 3: //委買委賣格式
							if (bPType == 0) {
								dBidP = Price.GetPrice(bMode, Buffer, ref fReferPrice);

								//取得委買量模式
								bMode = BitConvert.GetValue(bFlag, 4, 2);
								dBidV = Volumn.GetVolumn(bMode, Buffer);
							} else {
								dAskP = Price.GetPrice(bMode, Buffer, ref fReferPrice);

								//取得委賣量模式
								bMode = BitConvert.GetValue(bFlag, 4, 2);
								dAskV = Volumn.GetVolumn(bMode, Buffer);
							}
							break;
						default: //一般成交格式
							b價格類型 = bPType;
							dPrice = Price.GetPrice(bMode, Buffer, ref fReferPrice);

							CalculatePrice(stock, iSerial, dPrice);

							bMode = BitConvert.GetValue(bFlag, 4, 2);
							dVolume = Volumn.GetVolumn(bMode, Buffer);
							break;
					}
				}
			} while (Buffer.Position < iSize); //End While

			MitakeQuoteTick cTick = null;
			bool bHave = stock.GetMitakeTick(iSerial, ref cTick);
			MitakeQuoteTick cPrevTick = stock.GetPreviousTick(iSerial);
			if (bHave) {
				cTick.Time = cTime;
				cTick.Ask = new DOMPrice(dAskP, dAskV);
				cTick.Bid = new DOMPrice(dBidP, dBidV);
			} else {
				cTick.類型 = b類型;
				cTick.買賣盤 = b買賣盤;
				cTick.價格類型 = b價格類型;
				cTick.Time = cTime;
				cTick.Single = dSingle;
				cTick.Price = (dPrice == 0 && cPrevTick != null) ? cPrevTick.Price : dPrice;
				cTick.Volume = (dVolume == 0 && cPrevTick != null) ? cPrevTick.Volume : dVolume;
				cTick.Ask = (dAskP == 0 && dAskV == 0 && cPrevTick != null) ? cPrevTick.Ask : new DOMPrice(dAskP, dAskV);
				cTick.Bid = (dBidP == 0 && dBidV == 0 && cPrevTick != null) ? cPrevTick.Bid : new DOMPrice(dBidP, dBidV);

				if (dPrice > 0 && dVolume > 0) {  //如果有價量才計算成交金額與更換最新的即時資訊訊息
					stock.今日總成交額 += cTick.Price * (cTick.Volume - ((cPrevTick == null) ? 0d : cPrevTick.Volume));
					if (iSerial > stock.即時資訊.Serial) {
						stock.今日總成交量 = dVolume;
						stock.即時資訊 = cTick;
					}
				}
			}

			//填入委託價格第一檔
			CalculateEntrust(stock, cTick);

			//計算委託價格買賣盤
			MitakeEntrust.ComparePrice(cTick, cPrevTick);
			++stock.UpdateCount;
		}