Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
group_04_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jiayuan Hong
group_04_project
Commits
ef516447
Commit
ef516447
authored
1 year ago
by
Adrian Cheng
Browse files
Options
Downloads
Patches
Plain Diff
feat: added source and dest fields for orders and data requests
parent
a6f06882
Branches
main
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/netcap_api/prisma/schema.prisma
+4
-0
4 additions, 0 deletions
src/netcap_api/prisma/schema.prisma
src/netcap_api/src/rawpcap.service.ts
+42
-4
42 additions, 4 deletions
src/netcap_api/src/rawpcap.service.ts
src/netcap_api/src/types/RawPCAP.ts
+2
-0
2 additions, 0 deletions
src/netcap_api/src/types/RawPCAP.ts
with
48 additions
and
4 deletions
src/netcap_api/prisma/schema.prisma
+
4
−
0
View file @
ef516447
...
...
@@ -35,6 +35,8 @@ model PingPong {
model OrderRequests {
order_id String @id @unique @db.VarChar(50)
source String @db.VarChar(50)
destination String @db.VarChar(50)
ack_tstamp_sec BigInt @db.BigInt
ack_tstamp_nano BigInt @db.BigInt
gateway_in_sec BigInt @db.BigInt
...
...
@@ -51,6 +53,8 @@ model OrderRequests {
model DataRequests {
order_id String @id @unique @db.VarChar(50)
source String @db.VarChar(50)
destination String @db.VarChar(50)
ack_tstamp_sec BigInt @db.BigInt
ack_tstamp_nano BigInt @db.BigInt
gateway_in_sec BigInt @db.BigInt
...
...
This diff is collapsed.
Click to expand it.
src/netcap_api/src/rawpcap.service.ts
+
42
−
4
View file @
ef516447
...
...
@@ -61,7 +61,11 @@ export class RawPCAPService {
'tstamp_sec',
timestamp_sec,
'tstamp_nano',
timestamp_nano,
timestamp_nano,
'sender',
\`
raw_data
\`
->> '$.fix_sender_comp_id',
'target',
\`
raw_data
\`
->> '$.fix_target_comp_id',
'fix_type',
CASE
\`
raw_data
\`
->> '$.fix_msg_type' WHEN 'D' THEN 'ORDER' WHEN 'V' THEN 'MKT_REQ' WHEN '8' THEN 'EXEC_ORD' WHEN 'W' THEN 'MKT_RES' END,
'msg_state',
...
...
@@ -126,6 +130,8 @@ export class RawPCAPService {
.
map
((
packets
):
Prisma
.
OrderRequestsCreateInput
=>
{
let
order
:
Prisma
.
OrderRequestsCreateInput
=
{
order_id
:
''
,
source
:
''
,
destination
:
''
,
gateway_in_sec
:
0
,
gateway_in_nano
:
0
,
ack_tstamp_sec
:
0
,
...
...
@@ -141,8 +147,23 @@ export class RawPCAPService {
};
order
.
order_id
=
packets
.
order_id
;
const
traderRegex
=
/TRADER
\d
+/
;
const
exchangeRegex
=
/EXCHANGE
\d
+/
;
for
(
const
packet
of
packets
.
order_packets
)
{
if
(
!
order
.
source
)
{
if
(
traderRegex
.
test
(
packet
.
sender
))
order
.
source
=
packet
.
sender
;
if
(
traderRegex
.
test
(
packet
.
target
))
order
.
source
=
packet
.
target
;
}
if
(
!
order
.
destination
)
{
if
(
exchangeRegex
.
test
(
packet
.
target
))
order
.
destination
=
packet
.
target
;
if
(
exchangeRegex
.
test
(
packet
.
sender
))
order
.
destination
=
packet
.
sender
;
}
switch
(
packet
.
msg_state
)
{
case
'
GW_IN
'
:
order
.
gateway_in_sec
=
packet
.
tstamp_sec
;
...
...
@@ -174,7 +195,7 @@ export class RawPCAPService {
})
.
filter
((
order
)
=>
{
for
(
const
key
in
order
)
{
if
(
!
key
)
{
if
(
!
order
[
key
]
)
{
console
.
log
(
'
INCOMPLETE ORDER SKIPPING...
'
);
return
false
;
}
...
...
@@ -187,6 +208,8 @@ export class RawPCAPService {
.
map
((
packets
):
Prisma
.
DataRequestsCreateInput
=>
{
let
dataReq
:
Prisma
.
DataRequestsCreateInput
=
{
order_id
:
''
,
source
:
''
,
destination
:
''
,
gateway_in_sec
:
0
,
gateway_in_nano
:
0
,
ack_tstamp_sec
:
0
,
...
...
@@ -198,8 +221,23 @@ export class RawPCAPService {
};
dataReq
.
order_id
=
packets
.
order_id
;
const
traderRegex
=
/TRADER
\d
+/
;
const
exchangeRegex
=
/EXCHANGE
\d
+/
;
for
(
const
packet
of
packets
.
order_packets
)
{
if
(
!
dataReq
.
source
)
{
if
(
traderRegex
.
test
(
packet
.
sender
))
dataReq
.
source
=
packet
.
sender
;
if
(
traderRegex
.
test
(
packet
.
target
))
dataReq
.
source
=
packet
.
target
;
}
if
(
!
dataReq
.
destination
)
{
if
(
exchangeRegex
.
test
(
packet
.
target
))
dataReq
.
destination
=
packet
.
target
;
if
(
exchangeRegex
.
test
(
packet
.
sender
))
dataReq
.
destination
=
packet
.
sender
;
}
switch
(
packet
.
msg_state
)
{
case
'
GW_IN
'
:
dataReq
.
gateway_in_sec
=
packet
.
tstamp_sec
;
...
...
@@ -223,7 +261,7 @@ export class RawPCAPService {
})
.
filter
((
dataReq
)
=>
{
for
(
const
key
in
dataReq
)
{
if
(
!
key
)
{
if
(
!
dataReq
[
key
]
)
{
console
.
log
(
'
INCOMPLETE MARKET DATA REQUEST SKIPPING...
'
,
);
...
...
@@ -252,7 +290,7 @@ export class RawPCAPService {
dataRequestChanges
:
dataReqChanges
.
count
,
};
}
catch
(
error
)
{
console
.
log
(
'
Error
upd
ating records
:
skipping...
'
);
console
.
log
(
'
Error
occurred when cre
ating records
,
skipping...
'
);
}
return
ret
;
}
...
...
This diff is collapsed.
Click to expand it.
src/netcap_api/src/types/RawPCAP.ts
+
2
−
0
View file @
ef516447
...
...
@@ -61,6 +61,8 @@ export type SingleOrderPacket = {
id
:
number
;
fix_type
:
FixType
;
msg_state
:
MsgState
;
sender
:
string
;
target
:
string
;
tstamp_sec
:
number
;
tstamp_nano
:
number
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment