-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix.test.ts
More file actions
36 lines (34 loc) · 890 Bytes
/
Copy pathfix.test.ts
File metadata and controls
36 lines (34 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { reqToFIX, SOH } from "fix";
import { APISymbol, Side } from "orders";
const convertSOH = (fixMsg: string): string =>
fixMsg.replace(new RegExp(SOH, "g"), "|");
describe("reqToFIX", () => {
it("converts new order single JSON to valid fix message", () => {
expect(
convertSOH(
reqToFIX({
requestID: "123ABC",
symbol: APISymbol.AAPL,
quantity: 100,
price: 135.5,
side: Side.BUY,
})
)
).toEqual(
"8=FIX.4.2|9=46|35=D|50=123ABC|55=AAPL|38=100|44=135.5|54=buy|10=130|"
);
expect(
convertSOH(
reqToFIX({
requestID: "A12345",
symbol: APISymbol.AAPL,
quantity: 10,
price: 105,
side: Side.SELL,
})
)
).toEqual(
"8=FIX.4.2|9=44|35=D|50=A12345|55=AAPL|38=10|44=105|54=sell|10=046|"
);
});
});