TimelordUK / jspurefix

native typescript FIX engine
MIT License
58 stars 27 forks source link

Whole Objects & Delimiters #25

Closed lightTrader closed 2 years ago

lightTrader commented 2 years ago

I am seeing this thrown from ascii-encoder when using ITrdCapDtGrpNoDates[] in a TCR Request message

[23:15:37.752] [LOG] { TradeRequestID: 'all-trades', TradeRequestType: 1, SubscriptionRequestType: '1', TrdCapDtGrp: { NoDates: [ {TransactTime: [time]}, {TransactTime: [time]} ] } } 2021-11-30T23:15:37.755Z [lightTrader - client:FixSession] warn: tx error event: group instance with no delimiter field TradeDate Error: group instance with no delimiter field TradeDate at /light/brando/dist/buffer/ascii/ascii-encoder.js:98:27

As below, both DateTimes (60,70) are already shown as optional in the FIX spec, the error can be removed by adding TradeDate. But, the broker accepts only TransactTime

export interface ITrdCapDtGrpNoDates { TransactTime?: Date; // 60 TradeDate?: Date; // 75 }

TimelordUK commented 2 years ago

thanks it looks like a bug - it needs to find the first presented field in the object, i will take a look at it.

On Wed, 1 Dec 2021 at 11:40, lightTrader @.***> wrote:

I am seeing this thrown from ascii-encoder when using ITrdCapDtGrpNoDates[] in a TCR Request message

[23:15:37.752] [LOG] { TradeRequestID: 'all-trades', TradeRequestType: 1, SubscriptionRequestType: '1', TrdCapDtGrp: { NoDates: [ {TransactTime: [time]}, {TransactTime: [time]} ] } } 2021-11-30T23:15:37.755Z [lightTrader - client:FixSession] warn: tx error event: group instance with no delimiter field TradeDate Error: group instance with no delimiter field TradeDate at /light/brando/dist/buffer/ascii/ascii-encoder.js:98:27

As below, both DateTimes (60,70) are already shown as optional in the FIX spec, the error can be removed by adding TradeDate. But, the broker accepts only TransactTime

export interface ITrdCapDtGrpNoDates { TransactTime?: Date; // 60 TradeDate?: Date; // 75 }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/TimelordUK/jspurefix/issues/25, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXWJG2Y4IBBDSJPO72B2O3UOYCUVANCNFSM5JEH7Q5A .

lightTrader commented 2 years ago

I've had a go at fixing this, my first gitHub push - please take a look - i'll start testing too

TimelordUK commented 2 years ago

as checked into master now your above case should work

function getTCR1 (): ITradeCaptureReportRequest {
  const d0 = new Date(Date.UTC(2018, 11, 1, 0, 0, 0))
  const d1 = new Date(Date.UTC(2018, 11, 2, 0, 0, 0))
  const tcr = {
    TradeRequestID: 'all-trades',
    TradeRequestType: TradeRequestType.AllTrades,
    SubscriptionRequestType: SubscriptionRequestType.SnapshotPlusUpdates,
    TrdCapDtGrp : {
      NoDates: [
        {
          TransactTime: d0
        },
        {
          TransactTime: d1
        }
      ] as ITrdCapDtGrpNoDates[]
    }
  } as ITradeCaptureReportRequest
  return tcr
}

test('encode TradeCaptureReportRequest with TransactTime', () => {
  const tcr = getTCR1()
  const d = definitions.message.get('TradeCaptureReportRequest')
  const fix: string = toFix(tcr, d)
  expect(fix).toEqual('568=all-trades|569=0|263=1|580=2|60=20181201-00:00:00.000|60=20181202-00:00:00.000|')
})
TimelordUK commented 2 years ago

To confirm yes there is a bug and it is now fixed on master branch not yet released to npm.

Sent from my iPad

On 4 Dec 2021, at 15:21, lightTrader @.***> wrote:

 hmm.. will try again and check version. thx for looking

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

lightTrader commented 2 years ago

Thank you for the confirmation. Appreciated. i've updated the ascii encoder and elasticBuffer (eB was outdated) testing now

@TimelordUK excellent response all working as espected, update/TS in npm really useful vis a vis the demo version and source