vekonyz / fast-protocol

FAST streaming protocol for Node.js
MIT License
5 stars 2 forks source link

Problem with stop-bit (I guess) #5

Closed SoleSS closed 3 years ago

SoleSS commented 4 years ago

Hi, and thanks for your module!

And here's a problem: I'm trying to decode MOEX fast stream (i have a buffer):

(templateId = 17) [192, 145, 200, 35, 113, 20, 30, 85, 107, 99, 230, 207, 78, 66, 90, 176, 176, 208, 164, 209, 140, 209, 142, 209, 135, 208, 181, 209, 128, 209, 129, 208, 189, 209, 139, 208, 185, 32, 208, 186, 208, 190, 208, 189, 209, 130, 209, 128, 208, 176, 208, 186, 209, 130, 32, 78, 66, 82, 45, 49, 50, 46, 50, 48, 47, 73, 228, 78, 66, 82, 45, 49, 50, 46, 50, 176, 184, 128, 70, 88, 88, 88, 88, 216, 128, 130, 129, 146, 85, 83, 196, 198, 130, 79, 224, 128, 133, 70, 85, 84, 45, 66, 79, 79, 75, 45, 177, 130, 130, 70, 85, 84, 45, 66, 79, 79, 75, 45, 181, 134, 131, 70, 85, 84, 45, 66, 79, 79, 75, 45, 50, 176, 149, 131, 70, 85, 84, 45, 66, 79, 79, 75, 45, 53, 176, 179, 131, 70, 85, 84, 45, 84, 82, 65, 68, 69, 211, 128, 128, 130, 78, 66, 210, 128, 128, 251, 91, 118, 232, 251, 126, 56, 45, 168, 251, 7, 232, 251, 46, 43, 163, 254, 0, 105, 2, 140, 254, 0, 101, 127, 220, 128, 128, 128, 128, 128, 128, 128, 128, 131, 135, 9, 80, 125, 241, 35, 113, 26, 34, 49, 105, 121, 128, 133, 9, 80, 123, 211, 35, 113, 19, 125, 93, 0, 25, 128, 9, 80, 125, 171, 100, 17, 49, 129, 0, 244];

RIGHT decoded example:

TemplateID=17 ApplVerID[1128]=9 MessageType[35]=d SenderCompID[49]=MOEX MsgSeqNum[34]=16 SendingTime[52]=20200921160046862 TotNumReports[911]=79 Symbol[55]=RIM1 SecurityDesc[107]=Фьючерсный контракт RTS-6.21 SecurityID[48]=779504 SecurityIDSource[22]=8 SecurityAltID[455]=RTS-6.21 SecurityAltIDSource[456]=8 CFICode[461]=FXXXXX ContractMultiplier[231]=1 SecurityTradingStatus[326]=17 Currency[15]=USD MarketID[1301]=MOEX MarketSegmentID[1300]=F TradingSessionID[336]=5 ExchangeTradingSessionID[5842]=10206

MDFeedTypes[]=Sequence: NoMDFeedTypes[1141] = 5 {

  [0]:  MDFeedType[1022]=FUT-BOOK-1 MarketDepth[264]=1 MDBookType[1021]=1

  [1]:  MDFeedType[1022]=FUT-BOOK-5 MarketDepth[264]=5 MDBookType[1021]=2

  [2]:  MDFeedType[1022]=FUT-BOOK-20 MarketDepth[264]=20 MDBookType[1021]=2

  [3]:  MDFeedType[1022]=FUT-BOOK-50 MarketDepth[264]=50 MDBookType[1021]=2

  [4]:  MDFeedType[1022]=FUT-TRADES

  }

Underlyings[]=Sequence: NoUnderlyings[711] = 1 {

  [0]:  UnderlyingSymbol[311]=RTS

  }

HighLimitPx[1149]=123180 LowLimitPx[1148]=107000 MinPriceIncrement[969]=10 MinPriceIncrementAmount[1146]=15.2654 InitialMarginOnBuy[20002]=26736.05 InitialMarginOnSell[20000]=27669.5

EvntGrp[]=Sequence: NoEvents[864] = 2 {

  [0]:  EventType[865]=7 EventDate[866]=20210617 EventTime[1145]=20210616210000000

  [1]:  EventType[865]=5 EventDate[866]=20200915 EventTime[1145]=20200914210000000

  }

MaturityDate[541]=20210616 MaturityTime[1079]=210000000 Flags[20008]=115

But your module returns me partial data (look at SecurityID - always 80 (but have to be long) and SecurityDesc):

{
  ApplVerID: '9',
  MessageType: 'd',
  SenderCompID: 'MOEX',
  MsgSeqNum: 15,
  SendingTime: '20200921162843938',
  TotNumReports: 79,
  Symbol: 'GUH1',
  SecurityDesc: '0',
  SecurityID: '80',
  SecurityIDSource: 8,
  SecurityAltID: '$',
  SecurityAltIDSource: 'Q',
  SecurityType: '\f',
  CFICode: 'Q',
  StrikePrice: '-47e13',
  ContractMultiplier: '-48e6',
  SecurityTradingStatus: 52,
  Currency: 'Q',
  MarketID: 'MOEX',
  MarketSegmentID: '',
  TradingSessionID: 80,
  ExchangeTradingSessionID: 0,
  Volatility: '61e-48',
  Underlyings: [],
  HighLimitPx: '0e0',
  LowLimitPx: '0e0',
  MinPriceIncrement: '0e0',
  MinPriceIncrementAmount: '0e0',
  InitialMarginOnBuy: '0e0',
  InitialMarginOnSell: '0e0',
  InitialMarginSyntetic: '0e0',
  QuotationList: '',
  TheorPrice: '0e0',
  TheorPriceLimit: '0e0',
  InstrumentLegs: [],
  InstrumentAttributes: [],
  UnderlyingQty: '0e0',
  UnderlyingCurrency: '',
  EvntGrp: [],
  MaturityDate: -1,
  MaturityTime: -1,
  Flags: '0'
}

code usage example:

      const decoder = new fastProtocol.Decoder(appDir + '/server/templates.xml');
      try {
        decoder.decode(stdBuffer, function (msg, name) {
          console.log(msg);
        });
      } catch (error) {
        console.error(error.toString());
      }

here's a decoding template:

<templates xmlns="http://www.fixprotocol.org/ns/fast/td/1.1">

    <template name="DefaultIncrementalRefreshMessage" id="19">
        <string name="ApplVerID" id="1128">
            <constant value="9"/>
        </string>
        <string name="MessageType" id="35">
            <constant value="X"/>
        </string>
        <string name="SenderCompID" id="49">
            <constant value="MOEX"/>
        </string>
        <uInt32 name="MsgSeqNum" id="34"/>
        <uInt64 name="SendingTime" id="52"/>
        <uInt32 name="LastFragment" id="893" presence="optional"/>
        <sequence name="MDEntries">
            <length name="NoMDEntries" id="268"/>
            <uInt32 name="MDUpdateAction" id="279"/>
            <string name="MDEntryType" id="269"/>
            <uInt64 name="SecurityID" id="48" presence="optional"/>
            <uInt32 name="SecurityIDSource" id="22">
                <constant value="8"/>
            </uInt32>
            <string name="Symbol" id="55" presence="optional"/>
            <string name="SecurityGroup" id="1151" presence="optional"/>
            <uInt32 name="ExchangeTradingSessionID" id="5842" presence="optional"/>
            <uInt32 name="RptSeq" id="83"/>
            <uInt32 name="MarketDepth" id="264" presence="optional"/>
            <uInt32 name="MDPriceLevel" id="1023" presence="optional"/>
            <int64 name="MDEntryID" id="278" presence="optional"/>
            <decimal name="MDEntryPx" id="270" presence="optional"/>
            <int64 name="MDEntrySize" id="271" presence="optional"/>
            <uInt32 name="MDEntryDate" id="272" presence="optional"/>
            <uInt64 name="MDEntryTime" id="273"/>
            <int32 name="NumberOfOrders" id="346" presence="optional"/>
            <string name="MDEntryTradeType" id="20003" presence="optional"/>
            <int32 name="TrdType" id="828" presence="optional"/>
            <decimal name="LastPx" id="31" presence="optional"/>
            <int32 name="MDFlags" id="20017" presence="optional"/>
            <string name="Currency" id="15" presence="optional"/>
            <uInt64 name="Revision" id="20018" presence="optional"/>
            <string name="OrderSide" id="10504" presence="optional"/>
            <int64 name="MDEntrySyntheticSize" id="20039" presence="optional"/>
        </sequence>
    </template>

    <template name="DefaultSnapshotMessage" id="20">
        <string name="ApplVerID" id="1128">
            <constant value="9"/>
        </string>
        <string name="MessageType" id="35">
            <constant value="W"/>
        </string>
        <string name="SenderCompID" id="49">
            <constant value="MOEX"/>
        </string>
        <uInt32 name="MsgSeqNum" id="34"/>
        <uInt64 name="SendingTime" id="52"/>
        <uInt32 name="LastFragment" id="893" presence="optional"/>
        <uInt32 name="RptSeq" id="83"/>
        <uInt32 name="TotNumReports" id="911"/>
        <uInt32 name="LastMsgSeqNumProcessed" id="369"/>
        <uInt64 name="SecurityID" id="48" presence="optional"/>
        <uInt32 name="SecurityIDSource" id="22">
            <constant value="8"/>
        </uInt32>
        <string name="Symbol" id="55" presence="optional"/>
        <string name="SecurityGroup" id="1151" presence="optional"/>
        <sequence name="MDEntries">
            <length name="NoMDEntries" id="268"/>
            <string name="MDEntryType" id="269"/>
            <uInt32 name="ExchangeTradingSessionID" id="5842" presence="optional"/>
            <int64 name="MDEntryID" id="278" presence="optional"/>
            <uInt32 name="MarketDepth" id="264" presence="optional"/>
            <decimal name="MDEntryPx" id="270" presence="optional"/>
            <uInt32 name="MDEntryDate" id="272" presence="optional"/>
            <uInt64 name="MDEntryTime" id="273"/>
            <int64 name="MDEntrySize" id="271" presence="optional"/>
            <uInt32 name="MDPriceLevel" id="1023" presence="optional"/>
            <int32 name="NumberOfOrders" id="346" presence="optional"/>
            <string name="MDEntryTradeType" id="20003" presence="optional"/>
            <int32 name="TrdType" id="828" presence="optional"/>
            <int32 name="MDFlags" id="20017" presence="optional"/>
            <string name="Currency" id="15" presence="optional"/>
            <string name="OrderSide" id="10504" presence="optional"/>
            <int64 name="MDEntrySyntheticSize" id="20039" presence="optional"/>
        </sequence>
    </template>

    <template name="SecurityDefinition" id="17">
        <string name="ApplVerID" id="1128">
            <constant value="9"/>
        </string>
        <string name="MessageType" id="35">
            <constant value="d"/>
        </string>
        <string name="SenderCompID" id="49">
            <constant value="MOEX"/>
        </string>
        <uInt32 name="MsgSeqNum" id="34"/>
        <uInt64 name="SendingTime" id="52"/>
        <!-- Total count of SecurityDefinition messages -->
        <uInt32 name="TotNumReports" id="911"/>
        <string name="Symbol" id="55"/>
        <string name="SecurityDesc" id="107" presence="optional" charset="unicode"/>
        <!-- Unique among all instruments; primary key -->
        <uInt64 name="SecurityID" id="48"/>
        <uInt32 name="SecurityIDSource" id="22">
            <constant value="8"/>
        </uInt32>
        <string name="SecurityAltID" id="455" presence="optional"/>
        <string name="SecurityAltIDSource" id="456" presence="optional"/>
        <!-- Type of instrument -->
        <string name="SecurityType" id="167" presence="optional"/>
        <string name="CFICode" id="461" presence="optional"/>
        <decimal name="StrikePrice" id="202" presence="optional"/>
        <decimal name="ContractMultiplier" id="231" presence="optional"/>
        <uInt32 name="SecurityTradingStatus" id="326" presence="optional"/>
        <string name="Currency" id="15" presence="optional"/>
        <string name="MarketID" id="1301">
            <constant value="MOEX"/>
        </string>
        <string name="MarketSegmentID" id="1300"/>
        <uInt32 name="TradingSessionID" id="336" presence="optional"/>
        <uInt32 name="ExchangeTradingSessionID" id="5842" presence="optional"/>
        <decimal name="Volatility" id="5678" presence="optional"/>
        <sequence name="MDFeedTypes">
            <length name="NoMDFeedTypes" id="1141"/>
            <string name="MDFeedType" id="1022"/>
            <uInt32 name="MarketDepth" id="264" presence="optional"/>
            <uInt32 name="MDBookType" id="1021" presence="optional"/>
        </sequence>
        <sequence name="Underlyings" presence="optional">
            <length name="NoUnderlyings" id="711"/>
            <string name="UnderlyingSymbol" id="311"/>
            <uInt64 name="UnderlyingSecurityID" id="309" presence="optional"/>
            <uInt64 name="UnderlyingFutureID" id="2620" presence="optional"/>
        </sequence>
        <decimal name="HighLimitPx" id="1149" presence="optional"/>
        <decimal name="LowLimitPx" id="1148" presence="optional"/>
        <decimal name="MinPriceIncrement" id="969" presence="optional"/>
        <decimal name="MinPriceIncrementAmount" id="1146" presence="optional"/>
        <decimal name="InitialMarginOnBuy" id="20002" presence="optional"/>
        <decimal name="InitialMarginOnSell" id="20000" presence="optional"/>
        <decimal name="InitialMarginSyntetic" id="20001" presence="optional"/>
        <string name="QuotationList" id="20005" presence="optional"/>
        <decimal name="TheorPrice" id="20006" presence="optional"/>
        <decimal name="TheorPriceLimit" id="20007" presence="optional"/>
        <sequence name="InstrumentLegs" presence="optional">
            <length name="NoLegs" id="555"/>
            <string name="LegSymbol" id="600"/>
            <uInt64 name="LegSecurityID" id="602"/>
            <decimal name="LegRatioQty" id="623"/>
        </sequence>
        <sequence name="InstrumentAttributes" presence="optional">
            <length name="NoInstrAttrib" id="870"/>
            <int32 name="InstrAttribType" id="871"/>
            <string name="InstrAttribValue" id="872"/>
        </sequence>
        <decimal name="UnderlyingQty" id="879" presence="optional"/>
        <string name="UnderlyingCurrency" id="318" presence="optional"/>
        <sequence name="EvntGrp" presence="optional">
            <length name="NoEvents" id="864"/>
            <int32 name="EventType" id="865"/>
            <uInt32 name="EventDate" id="866"/>
            <uInt64 name="EventTime" id="1145"/>
        </sequence>
        <!-- UTC Date Only YYYYMMDD -->
        <uInt32 name="MaturityDate" id="541" presence="optional"/>
        <!-- UTC Time. HHMMSSsss -->
        <uInt32 name="MaturityTime" id="1079" presence="optional"/>
        <int64 name="Flags" id="20008" presence="optional"/>
    </template>

    <template name="SecurityDefinitionUpdateReport" id="4">
        <string name="ApplVerID" id="1128">
            <constant value="9"/>
        </string>
        <string name="MessageType" id="35">
            <constant value="BP"/>
        </string>
        <string name="SenderCompID" id="49">
            <constant value="MOEX"/>
        </string>
        <uInt32 name="MsgSeqNum" id="34"/>
        <uInt64 name="SendingTime" id="52"/>
        <!-- Unique among all instruments; primary key -->
        <uInt64 name="SecurityID" id="48"/>
        <uInt32 name="SecurityIDSource" id="22">
            <constant value="8"/>
        </uInt32>
        <decimal name="Volatility" id="5678" presence="optional"/>
        <decimal name="TheorPrice" id="20006" presence="optional"/>
        <decimal name="TheorPriceLimit" id="20007" presence="optional"/>
    </template>

    <template name="SecurityStatus" id="5">
        <string name="ApplVerID" id="1128">
            <constant value="9"/>
        </string>
        <string name="MessageType" id="35">
            <constant value="f"/>
        </string>
        <string name="SenderCompID" id="49">
            <constant value="MOEX"/>
        </string>
        <uInt32 name="MsgSeqNum" id="34"/>
        <uInt64 name="SendingTime" id="52"/>
        <!-- Unique among all instruments; primary key -->
        <uInt64 name="SecurityID" id="48"/>
        <uInt32 name="SecurityIDSource" id="22">
            <constant value="8"/>
        </uInt32>
        <string name="Symbol" id="55"/>
        <uInt32 name="SecurityTradingStatus" id="326" presence="optional"/>
        <decimal name="HighLimitPx" id="1149" presence="optional"/>
        <decimal name="LowLimitPx" id="1148" presence="optional"/>
        <decimal name="InitialMarginOnBuy" id="20002" presence="optional"/>
        <decimal name="InitialMarginOnSell" id="20000" presence="optional"/>
        <decimal name="InitialMarginSyntetic" id="20001" presence="optional"/>
    </template>

    <template name="Heartbeat" id="6">
        <string name="ApplVerID" id="1128">
            <constant value="9"/>
        </string>
        <string name="MessageType" id="35">
            <constant value="0"/>
        </string>
        <string name="SenderCompID" id="49">
            <constant value="MOEX"/>
        </string>
        <uInt32 name="MsgSeqNum" id="34"/>
        <uInt64 name="SendingTime" id="52"/>
    </template>

    <template name="SequenceReset" id="7">
        <string name="ApplVerID" id="1128">
            <constant value="9"/>
        </string>
        <string name="MessageType" id="35">
            <constant value="4"/>
        </string>
        <string name="SenderCompID" id="49">
            <constant value="MOEX"/>
        </string>
        <uInt32 name="MsgSeqNum" id="34"/>
        <uInt64 name="SendingTime" id="52"/>
        <uInt32 name="NewSeqNo" id="36"/>
    </template>

    <template name="TradingSessionStatus" id="8">
        <string name="ApplVerID" id="1128">
            <constant value="9"/>
        </string>
        <string name="MessageType" id="35">
            <constant value="h"/>
        </string>
        <string name="SenderCompID" id="49">
            <constant value="MOEX"/>
        </string>
        <uInt32 name="MsgSeqNum" id="34"/>
        <uInt64 name="SendingTime" id="52"/>
        <uInt64 name="TradSesOpenTime" id="342"/>
        <uInt64 name="TradSesCloseTime" id="344"/>
        <uInt64 name="TradSesIntermClearingStartTime" id="5840" presence="optional"/>
        <uInt64 name="TradSesIntermClearingEndTime" id="5841" presence="optional"/>
        <uInt32 name="TradingSessionID" id="336"/>
        <uInt32 name="ExchangeTradingSessionID" id="5842" presence="optional"/>
        <uInt32 name="TradSesStatus" id="340"/>
        <string name="MarketID" id="1301">
            <constant value="MOEX"/>
        </string>
        <string name="MarketSegmentID" id="1300"/>
        <int32 name="TradSesEvent" id="1368" presence="optional"/>
    </template>

    <template name="News" id="9">
        <string name="ApplVerID" id="1128">
            <constant value="9"/>
        </string>
        <string name="MessageType" id="35">
            <constant value="B"/>
        </string>
        <string name="SenderCompID" id="49">
            <constant value="MOEX"/>
        </string>
        <uInt32 name="MsgSeqNum" id="34"/>
        <uInt64 name="SendingTime" id="52"/>
        <uInt32 name="LastFragment" id="893" presence="optional"/>
        <string name="NewsId" id="1472" presence="optional"/>
        <uInt64 name="OrigTime" id="42" presence="optional"/>
        <string name="LanguageCode" id="1474" presence="optional"/>
        <uInt32 name="Urgency" id="61" presence="optional"/>
        <string name="Headline" id="148" charset="unicode"/>
        <string name="MarketID" id="1301">
            <constant value="MOEX"/>
        </string>
        <string name="MarketSegmentID" id="1300" presence="optional"/>
        <sequence name="NewsText">
            <length name="NoLinesOfText" id="33"/>
            <string name="Text" id="58" charset="unicode"/>
        </sequence>
    </template>

    <template name="OrdersLogMessage" id="14">
        <string name="ApplVerID" id="1128">
          <constant value="9"/>
        </string>
        <string name="MessageType" id="35">
          <constant value="X"/>
        </string>
        <string name="SenderCompID" id="49">
          <constant value="MOEX"/>
        </string>
        <uInt32 name="MsgSeqNum" id="34"/>
        <uInt64 name="SendingTime" id="52"/>
        <uInt32 name="LastFragment" id="893"/>
        <sequence name="MDEntries">
            <length name="NoMDEntries" id="268"/>
            <uInt32 name="MDUpdateAction" id="279"/>
            <string name="MDEntryType" id="269"/>
            <int64 name="MDEntryID" id="278" presence="optional"/>
            <uInt64 name="SecurityID" id="48" presence="optional"/>
            <uInt32 name="SecurityIDSource" id="22">
              <constant value="8"/>
            </uInt32>
            <uInt32 name="RptSeq" id="83" presence="optional"/>
            <uInt32 name="MDEntryDate" id="272" presence="optional"/>
            <uInt64 name="MDEntryTime" id="273"/>
            <decimal name="MDEntryPx" id="270" presence="optional"/>
            <int64 name="MDEntrySize" id="271" presence="optional"/>
            <decimal name="LastPx" id="31" presence="optional"/>
            <int64 name="LastQty" id="32" presence="optional"/>
            <int64 name="TradeID" id="1003" presence="optional"/>
            <uInt32 name="ExchangeTradingSessionID" id="5842" presence="optional"/>
            <int64 name="MDFlags" id="20017" presence="optional"/>
            <uInt64 name="Revision" id="20018" presence="optional"/>
        </sequence>
    </template>

    <template name="QuotesLogMessage" id="18">
        <string name="ApplVerID" id="1128">
            <constant value="9"/>
        </string>
        <string name="MessageType" id="35">
            <constant value="X"/>
        </string>
        <string name="SenderCompID" id="49">
            <constant value="MOEX"/>
        </string>
        <uInt32 name="MsgSeqNum" id="34"/>
        <uInt64 name="SendingTime" id="52"/>
        <uInt32 name="LastFragment" id="893"/>
        <sequence name="MDEntries">
            <length name="NoMDEntries" id="268"/>
            <uInt32 name="MDUpdateAction" id="279"/>
            <string name="MDEntryType" id="269"/>
            <int64 name="MDEntryID" id="278" presence="optional"/>
            <uInt64 name="SecurityID" id="48" presence="optional"/>
            <uInt32 name="SecurityIDSource" id="22">
                <constant value="8"/>
            </uInt32>
            <uInt32 name="RptSeq" id="83" presence="optional"/>
            <uInt32 name="MDEntryDate" id="272" presence="optional"/>
            <uInt64 name="MDEntryTime" id="273"/>
            <decimal name="MDEntryPx" id="270" presence="optional"/>
            <int64 name="MDEntrySize" id="271" presence="optional"/>
            <decimal name="LastPx" id="31" presence="optional"/>
            <int64 name="LastQty" id="32" presence="optional"/>
            <int64 name="TradeID" id="1003" presence="optional"/>
            <uInt32 name="ExchangeTradingSessionID" id="5842" presence="optional"/>
            <int64 name="MDFlags" id="20017" presence="optional"/>
            <uInt64 name="Revision" id="20018" presence="optional"/>
            <uInt64 name="OrderID" id="37" presence="optional"/>
            <uInt64 name="TrdMatchID" id="880" presence="optional"/>
        </sequence>
    </template>

    <template name="BookMessage" id="15">
        <string name="ApplVerID" id="1128">
            <constant value="9"/>
        </string>
        <string name="MessageType" id="35">
            <constant value="W"/>
        </string>
        <string name="SenderCompID" id="49">
            <constant value="MOEX"/>
        </string>
        <uInt32 name="MsgSeqNum" id="34"/>
        <uInt64 name="SendingTime" id="52"/>
        <uInt32 name="LastMsgSeqNumProcessed" id="369"/>
        <uInt32 name="RptSeq" id="83" presence="optional"/>
        <uInt32 name="LastFragment" id="893"/>
        <uInt32 name="RouteFirst" id="7944"/> 
        <uInt32 name="ExchangeTradingSessionID" id="5842"/>
        <uInt64 name="SecurityID" id="48" presence="optional"/>
        <uInt32 name="SecurityIDSource" id="22">
            <constant value="8"/>
        </uInt32>
        <sequence name="MDEntries">
            <length name="NoMDEntries" id="268"/>
            <string name="MDEntryType" id="269"/>
            <int64 name="MDEntryID" id="278" presence="optional"/>
            <uInt32 name="MDEntryDate" id="272" presence="optional"/>
            <uInt64 name="MDEntryTime" id="273"/>
            <decimal name="MDEntryPx" id="270" presence="optional"/>
            <int64 name="MDEntrySize" id="271" presence="optional"/>
            <int64 name="TradeID" id="1003" presence="optional"/>
            <int64 name="MDFlags" id="20017" presence="optional"/>
        </sequence>
    </template>

    <template name="Logon" id="1000">
        <string name="ApplVerID" id="1128">
            <constant value="9"/>
        </string>
        <string name="MessageType" id="35">
            <constant value="A"/>
        </string>
        <string name="SenderCompID" id="49">
            <constant value="MOEX"/>
        </string>
        <uInt32 name="MsgSeqNum" id="34"/>
        <uInt64 name="SendingTime" id="52"/>
    </template>

    <template name="Logout" id="1001">
        <string name="ApplVerID" id="1128">
            <constant value="9"/>
        </string>
        <string name="MessageType" id="35">
            <constant value="5"/>
        </string>
        <string name="SenderCompID" id="49">
            <constant value="MOEX"/>
        </string>
        <uInt32 name="MsgSeqNum" id="34"/>
        <uInt64 name="SendingTime" id="52"/>
        <string name="Text" id="58" presence="optional"/>
    </template>

</templates>
vekonyz commented 4 years ago

Hi, I will check; I guess the problem with SecurityDesc, because of the unicode encoding, unicode is still not supported. Can you maybe execute a test without unicode? If it works, we will know that it is related to the encoding. Meanwhile I will check, how to support unicode encoding...

SoleSS commented 4 years ago

Yes, i have checked on message without UTF8 strings and looks like everything is fine...

SoleSS commented 4 years ago

As a temporary workaround i can suggest add an option to ignore specified fields, and just dont't decode them ...

And as a solution i suggest:

  1. create buffer from message bytes array
  2. return as string new Buffer.from(partBytes[partId]).toString('utf-8');
vekonyz commented 4 years ago

@SoleSS unicode decode support added

vekonyz commented 4 years ago
Output message: { ApplVerID: '9',
  MessageType: 'd',
  SenderCompID: 'MOEX',
  MsgSeqNum: 72,
  SendingTime: '20200923053355494',
  TotNumReports: 79,
  Symbol: 'NBZ0',
  SecurityDesc: 'Фьючерсный контракт NBR-12.20',
  SecurityID: '779492',
  SecurityIDSource: 8,
  SecurityAltID: 'NBR-12.20',
  SecurityAltIDSource: '8',
  SecurityType: undefined,
  CFICode: 'FXXXXX',
  StrikePrice: undefined,
  ContractMultiplier: '1e1',
  SecurityTradingStatus: 17,
  Currency: 'USD',
  MarketID: 'MOEX',
  MarketSegmentID: 'F',
  TradingSessionID: 1,
  ExchangeTradingSessionID: 10207,
  Volatility: undefined,
  MDFeedTypes:
   [ { MDFeedType: 'FUT-BOOK-1', MarketDepth: 1, MDBookType: 1 },
     { MDFeedType: 'FUT-BOOK-5', MarketDepth: 5, MDBookType: 2 },
     { MDFeedType: 'FUT-BOOK-20', MarketDepth: 20, MDBookType: 2 },
     { MDFeedType: 'FUT-BOOK-50', MarketDepth: 50, MDBookType: 2 },
     { MDFeedType: 'FUT-TRADES',
       MarketDepth: undefined,
       MDBookType: undefined } ],
  Underlyings:
   [ { UnderlyingSymbol: 'NBR',
       UnderlyingSecurityID: undefined,
       UnderlyingFutureID: undefined } ],
  HighLimitPx: '-591000e-5',
  LowLimitPx: '-3271000e-5',
  MinPriceIncrement: '1000e-5',
  MinPriceIncrementAmount: '759203e-5',
  InitialMarginOnBuy: '1720588e-2',
  InitialMarginOnSell: '1671132e-2',
  InitialMarginSyntetic: undefined,
  QuotationList: undefined,
  TheorPrice: undefined,
  TheorPriceLimit: undefined,
  InstrumentLegs: undefined,
  InstrumentAttributes: undefined,
  UnderlyingQty: undefined,
  UnderlyingCurrency: undefined,
  EvntGrp:
   [ { EventType: 7,
       EventDate: 20201201,
       EventTime: '20201130210000000' },
     { EventType: 5,
       EventDate: 20200915,
       EventTime: '20200914210000000' } ],
  MaturityDate: 20201130,
  MaturityTime: 210000000,
  Flags: '115' }
SoleSS commented 4 years ago

Thx, looks like everything is working now...