jspurefix 5.11.3 → 5.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +4 -0
- package/dist/buffer/index.d.ts +6 -0
- package/dist/buffer/index.js +6 -0
- package/dist/buffer/index.js.map +1 -1
- package/dist/collections/index.d.ts +1 -0
- package/dist/collections/index.js +16 -0
- package/dist/collections/index.js.map +1 -1
- package/dist/dictionary/contained/index.d.ts +3 -0
- package/dist/dictionary/contained/index.js +3 -0
- package/dist/dictionary/contained/index.js.map +1 -1
- package/dist/dictionary/index.d.ts +5 -0
- package/dist/dictionary/index.js +5 -0
- package/dist/dictionary/index.js.map +1 -1
- package/dist/generator/applicability.d.ts +3 -0
- package/dist/generator/applicability.js +48 -0
- package/dist/generator/applicability.js.map +1 -0
- package/dist/generator/case-builder.d.ts +34 -0
- package/dist/generator/case-builder.js +111 -0
- package/dist/generator/case-builder.js.map +1 -0
- package/dist/generator/corpus-store.d.ts +43 -0
- package/dist/generator/corpus-store.js +115 -0
- package/dist/generator/corpus-store.js.map +1 -0
- package/dist/generator/index.d.ts +12 -0
- package/dist/generator/index.js +29 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/instrument-universe.d.ts +54 -0
- package/dist/generator/instrument-universe.js +286 -0
- package/dist/generator/instrument-universe.js.map +1 -0
- package/dist/generator/layout.d.ts +46 -0
- package/dist/generator/layout.js +208 -0
- package/dist/generator/layout.js.map +1 -0
- package/dist/generator/market-context.d.ts +64 -0
- package/dist/generator/market-context.js +119 -0
- package/dist/generator/market-context.js.map +1 -0
- package/dist/generator/outcome.d.ts +16 -0
- package/dist/generator/outcome.js +71 -0
- package/dist/generator/outcome.js.map +1 -0
- package/dist/generator/realistic-generator.d.ts +53 -0
- package/dist/generator/realistic-generator.js +275 -0
- package/dist/generator/realistic-generator.js.map +1 -0
- package/dist/generator/rng.d.ts +12 -0
- package/dist/generator/rng.js +60 -0
- package/dist/generator/rng.js.map +1 -0
- package/dist/generator/scatter.d.ts +50 -0
- package/dist/generator/scatter.js +285 -0
- package/dist/generator/scatter.js.map +1 -0
- package/dist/generator/scenarios.d.ts +13 -0
- package/dist/generator/scenarios.js +139 -0
- package/dist/generator/scenarios.js.map +1 -0
- package/dist/generator/value-conventions.d.ts +15 -0
- package/dist/generator/value-conventions.js +217 -0
- package/dist/generator/value-conventions.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/jsfix-cmd.d.ts +5 -0
- package/dist/jsfix-cmd.js +161 -0
- package/dist/jsfix-cmd.js.map +1 -1
- package/dist/store/fix-msg-ascii-store-resend.js +2 -2
- package/dist/store/fix-msg-ascii-store-resend.js.map +1 -1
- package/dist/store/fix-msg-store-record.d.ts +1 -1
- package/dist/store/fix-msg-store-record.js.map +1 -1
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.js +1 -0
- package/dist/store/index.js.map +1 -1
- package/dist/transport/index.d.ts +7 -0
- package/dist/transport/index.js +7 -0
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/session/index.d.ts +1 -0
- package/dist/transport/session/index.js +1 -0
- package/dist/transport/session/index.js.map +1 -1
- package/docs/generated-cases.md +237 -0
- package/docs/scattered-components.md +60 -5
- package/jsfix.test_client.txt +62 -62
- package/jsfix.test_server.txt +72 -72
- package/package.json +5 -2
- package/src/buffer/index.ts +6 -0
- package/src/collections/index.ts +1 -1
- package/src/dictionary/contained/index.ts +3 -0
- package/src/dictionary/index.ts +5 -0
- package/src/generator/applicability.ts +87 -0
- package/src/generator/case-builder.ts +167 -0
- package/src/generator/corpus-store.ts +166 -0
- package/src/generator/index.ts +12 -0
- package/src/generator/instrument-universe.ts +347 -0
- package/src/generator/layout.ts +279 -0
- package/src/generator/market-context.ts +207 -0
- package/src/generator/outcome.ts +102 -0
- package/src/generator/realistic-generator.ts +404 -0
- package/src/generator/rng.ts +92 -0
- package/src/generator/scatter.ts +432 -0
- package/src/generator/scenarios.ts +167 -0
- package/src/generator/value-conventions.ts +295 -0
- package/src/index.ts +12 -0
- package/src/jsfix-cmd.ts +204 -0
- package/src/store/fix-msg-ascii-store-resend.ts +2 -1
- package/src/store/fix-msg-store-record.ts +4 -1
- package/src/store/index.ts +1 -0
- package/src/transport/index.ts +10 -0
- package/src/transport/session/index.ts +1 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Scenarios = void 0;
|
|
4
|
+
const instrument_universe_1 = require("./instrument-universe");
|
|
5
|
+
const NoLegs = '555';
|
|
6
|
+
const NoSides = '552';
|
|
7
|
+
const NoPartyIDs = '453';
|
|
8
|
+
const NoUnderlyings = '711';
|
|
9
|
+
const NoMDEntries = '268';
|
|
10
|
+
const NoAllocs = '78';
|
|
11
|
+
const NoRelatedSym = '146';
|
|
12
|
+
const scenarios = [
|
|
13
|
+
{
|
|
14
|
+
name: 'spread-trade-capture',
|
|
15
|
+
description: 'ICE Brent calendar spread, parent plus two legs, both sides with parties',
|
|
16
|
+
msgType: 'AE',
|
|
17
|
+
options: {
|
|
18
|
+
instrument: 'BRN JAN26-FEB26',
|
|
19
|
+
include: [NoLegs, NoSides, NoPartyIDs],
|
|
20
|
+
density: 0.5,
|
|
21
|
+
maxGroupInstances: 2
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'crack-spread-capture',
|
|
26
|
+
description: 'ICE Brent/Gasoil crack spread trade capture with legs and underlyings',
|
|
27
|
+
msgType: 'AE',
|
|
28
|
+
options: {
|
|
29
|
+
instrument: 'BRN-GAS CRACK',
|
|
30
|
+
include: [NoLegs, NoSides, NoPartyIDs, NoUnderlyings],
|
|
31
|
+
density: 0.5,
|
|
32
|
+
maxGroupInstances: 2
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'equity-fill',
|
|
37
|
+
description: 'partial fill on a listed equity order, with the executing parties',
|
|
38
|
+
msgType: '8',
|
|
39
|
+
options: {
|
|
40
|
+
instrument: 'AAPL',
|
|
41
|
+
assetClass: instrument_universe_1.AssetClass.Equity,
|
|
42
|
+
include: [NoPartyIDs],
|
|
43
|
+
density: 0.5
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'equity-order',
|
|
48
|
+
description: 'plain new order single into a lit venue',
|
|
49
|
+
msgType: 'D',
|
|
50
|
+
options: {
|
|
51
|
+
instrument: 'VOD.L',
|
|
52
|
+
assetClass: instrument_universe_1.AssetClass.Equity,
|
|
53
|
+
density: 0.4
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'future-order',
|
|
58
|
+
description: 'new order single on a listed future, give-up parties attached',
|
|
59
|
+
msgType: 'D',
|
|
60
|
+
options: {
|
|
61
|
+
instrument: 'BRN',
|
|
62
|
+
assetClass: instrument_universe_1.AssetClass.Future,
|
|
63
|
+
include: [NoPartyIDs],
|
|
64
|
+
density: 0.45
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'bond-trade-capture',
|
|
69
|
+
description: 'treasury trade capture - the one case where the fixed income half of Instrument belongs',
|
|
70
|
+
msgType: 'AE',
|
|
71
|
+
options: {
|
|
72
|
+
instrument: 'US91282CLW12',
|
|
73
|
+
assetClass: instrument_universe_1.AssetClass.Bond,
|
|
74
|
+
include: [NoSides, NoPartyIDs],
|
|
75
|
+
density: 0.6
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'option-order',
|
|
80
|
+
description: 'listed option order carrying strike and expiry',
|
|
81
|
+
msgType: 'D',
|
|
82
|
+
options: {
|
|
83
|
+
instrument: 'ESZ5 C6000',
|
|
84
|
+
assetClass: instrument_universe_1.AssetClass.Option,
|
|
85
|
+
density: 0.45
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'md-incremental',
|
|
90
|
+
description: 'incremental market data refresh, several entries against one book',
|
|
91
|
+
msgType: 'X',
|
|
92
|
+
options: {
|
|
93
|
+
instrument: 'ESZ5',
|
|
94
|
+
assetClass: instrument_universe_1.AssetClass.Future,
|
|
95
|
+
include: [NoMDEntries],
|
|
96
|
+
density: 0.35,
|
|
97
|
+
maxGroupInstances: 4
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'md-request',
|
|
102
|
+
description: 'market data request over a small watch list',
|
|
103
|
+
msgType: 'V',
|
|
104
|
+
options: {
|
|
105
|
+
assetClass: instrument_universe_1.AssetClass.Equity,
|
|
106
|
+
include: [NoRelatedSym],
|
|
107
|
+
density: 0.6,
|
|
108
|
+
maxGroupInstances: 3
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: 'block-allocation',
|
|
113
|
+
description: 'allocation instruction breaking a block across accounts',
|
|
114
|
+
msgType: 'J',
|
|
115
|
+
options: {
|
|
116
|
+
instrument: 'AAPL',
|
|
117
|
+
assetClass: instrument_universe_1.AssetClass.Equity,
|
|
118
|
+
include: [NoAllocs, NoPartyIDs],
|
|
119
|
+
density: 0.45,
|
|
120
|
+
maxGroupInstances: 3
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
];
|
|
124
|
+
exports.Scenarios = {
|
|
125
|
+
all: scenarios,
|
|
126
|
+
get(name) {
|
|
127
|
+
return scenarios.find(s => s.name === name);
|
|
128
|
+
},
|
|
129
|
+
names() {
|
|
130
|
+
return scenarios.map(s => s.name);
|
|
131
|
+
},
|
|
132
|
+
describe() {
|
|
133
|
+
const width = Math.max(...scenarios.map(s => s.name.length));
|
|
134
|
+
return scenarios
|
|
135
|
+
.map(s => ` ${s.name.padEnd(width)} ${s.msgType.padEnd(2)} ${s.description}`)
|
|
136
|
+
.join('\n');
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=scenarios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenarios.js","sourceRoot":"","sources":["../../src/generator/scenarios.ts"],"names":[],"mappings":";;;AACA,+DAAkD;AA2BlD,MAAM,MAAM,GAAG,KAAK,CAAA;AACpB,MAAM,OAAO,GAAG,KAAK,CAAA;AACrB,MAAM,UAAU,GAAG,KAAK,CAAA;AACxB,MAAM,aAAa,GAAG,KAAK,CAAA;AAC3B,MAAM,WAAW,GAAG,KAAK,CAAA;AACzB,MAAM,QAAQ,GAAG,IAAI,CAAA;AACrB,MAAM,YAAY,GAAG,KAAK,CAAA;AAE1B,MAAM,SAAS,GAAyB;IACtC;QACE,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EAAE,0EAA0E;QACvF,OAAO,EAAE,IAAI;QACb,OAAO,EAAE;YACP,UAAU,EAAE,iBAAiB;YAC7B,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC;YACtC,OAAO,EAAE,GAAG;YACZ,iBAAiB,EAAE,CAAC;SACrB;KACF;IACD;QACE,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EAAE,uEAAuE;QACpF,OAAO,EAAE,IAAI;QACb,OAAO,EAAE;YACP,UAAU,EAAE,eAAe;YAC3B,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC;YACrD,OAAO,EAAE,GAAG;YACZ,iBAAiB,EAAE,CAAC;SACrB;KACF;IACD;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,mEAAmE;QAChF,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE;YACP,UAAU,EAAE,MAAM;YAClB,UAAU,EAAE,gCAAU,CAAC,MAAM;YAC7B,OAAO,EAAE,CAAC,UAAU,CAAC;YACrB,OAAO,EAAE,GAAG;SACb;KACF;IACD;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,yCAAyC;QACtD,OAAO,EAAE,G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G;YACZ,iBAAiB,EAAE,CAAC;SACrB;KACF;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,yDAAyD;QACtE,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE;YACP,UAAU,EAAE,MAAM;YAClB,UAAU,EAAE,gCAAU,CAAC,MAAM;YAC7B,OAAO,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC;YAC/B,OAAO,EAAE,IAAI;YACb,iBAAiB,EAAE,CAAC;SACrB;KACF;CACF,CAAA;AAEY,QAAA,SAAS,GAAG;IACvB,GAAG,EAAE,SAAS;IAEd,GAAG,CAAE,IAAY;QACf,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;IAC7C,CAAC;IAED,KAAK;QACH,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IACnC,CAAC;IAED,QAAQ;QACN,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;QAC5D,OAAO,SAAS;aACb,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;aAC/E,IAAI,CAAC,IAAI,CAAC,CAAA;IACf,CAAC;CACF,CAAA","sourcesContent":["import { IGeneratorOptions } from './realistic-generator'\nimport { AssetClass } from './instrument-universe'\n\n/**\n * Named shapes of traffic, so that asking for something realistic does not mean\n * knowing which tags to force on.\n *\n * A scenario is only a bundle of generator options - it has no logic of its own, and\n * anything it does can be done on the command line instead. Its value is that the\n * combination which produces a *convincing* message is not obvious: a multileg trade\n * capture needs legs, sides and parties present together, and a bond one needs the\n * fixed income half of `Instrument` that the applicability gate would otherwise\n * suppress.\n *\n * Fields are forced by **tag**, not by name, because the name is not portable. The\n * repository rendering calls the leg group `TrdInstrmtLegGrp` and QuickFIX calls it\n * `NoLegs`; both agree it is 555. A scenario therefore runs against any dictionary\n * that carries the message at all.\n */\n\nexport interface IScenario {\n readonly name: string\n readonly description: string\n /** as it appears on the wire in tag 35 */\n readonly msgType: string\n readonly options: IGeneratorOptions\n}\n\nconst NoLegs = '555'\nconst NoSides = '552'\nconst NoPartyIDs = '453'\nconst NoUnderlyings = '711'\nconst NoMDEntries = '268'\nconst NoAllocs = '78'\nconst NoRelatedSym = '146'\n\nconst scenarios: readonly IScenario[] = [\n {\n name: 'spread-trade-capture',\n description: 'ICE Brent calendar spread, parent plus two legs, both sides with parties',\n msgType: 'AE',\n options: {\n instrument: 'BRN JAN26-FEB26',\n include: [NoLegs, NoSides, NoPartyIDs],\n density: 0.5,\n maxGroupInstances: 2\n }\n },\n {\n name: 'crack-spread-capture',\n description: 'ICE Brent/Gasoil crack spread trade capture with legs and underlyings',\n msgType: 'AE',\n options: {\n instrument: 'BRN-GAS CRACK',\n include: [NoLegs, NoSides, NoPartyIDs, NoUnderlyings],\n density: 0.5,\n maxGroupInstances: 2\n }\n },\n {\n name: 'equity-fill',\n description: 'partial fill on a listed equity order, with the executing parties',\n msgType: '8',\n options: {\n instrument: 'AAPL',\n assetClass: AssetClass.Equity,\n include: [NoPartyIDs],\n density: 0.5\n }\n },\n {\n name: 'equity-order',\n description: 'plain new order single into a lit venue',\n msgType: 'D',\n options: {\n instrument: 'VOD.L',\n assetClass: AssetClass.Equity,\n density: 0.4\n }\n },\n {\n name: 'future-order',\n description: 'new order single on a listed future, give-up parties attached',\n msgType: 'D',\n options: {\n instrument: 'BRN',\n assetClass: AssetClass.Future,\n include: [NoPartyIDs],\n density: 0.45\n }\n },\n {\n name: 'bond-trade-capture',\n description: 'treasury trade capture - the one case where the fixed income half of Instrument belongs',\n msgType: 'AE',\n options: {\n instrument: 'US91282CLW12',\n assetClass: AssetClass.Bond,\n include: [NoSides, NoPartyIDs],\n density: 0.6\n }\n },\n {\n name: 'option-order',\n description: 'listed option order carrying strike and expiry',\n msgType: 'D',\n options: {\n instrument: 'ESZ5 C6000',\n assetClass: AssetClass.Option,\n density: 0.45\n }\n },\n {\n name: 'md-incremental',\n description: 'incremental market data refresh, several entries against one book',\n msgType: 'X',\n options: {\n instrument: 'ESZ5',\n assetClass: AssetClass.Future,\n include: [NoMDEntries],\n density: 0.35,\n maxGroupInstances: 4\n }\n },\n {\n name: 'md-request',\n description: 'market data request over a small watch list',\n msgType: 'V',\n options: {\n assetClass: AssetClass.Equity,\n include: [NoRelatedSym],\n density: 0.6,\n maxGroupInstances: 3\n }\n },\n {\n name: 'block-allocation',\n description: 'allocation instruction breaking a block across accounts',\n msgType: 'J',\n options: {\n instrument: 'AAPL',\n assetClass: AssetClass.Equity,\n include: [NoAllocs, NoPartyIDs],\n density: 0.45,\n maxGroupInstances: 3\n }\n }\n]\n\nexport const Scenarios = {\n all: scenarios,\n\n get (name: string): IScenario | undefined {\n return scenarios.find(s => s.name === name)\n },\n\n names (): string[] {\n return scenarios.map(s => s.name)\n },\n\n describe (): string {\n const width = Math.max(...scenarios.map(s => s.name.length))\n return scenarios\n .map(s => ` ${s.name.padEnd(width)} ${s.msgType.padEnd(2)} ${s.description}`)\n .join('\\n')\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SimpleFieldDefinition } from '../dictionary/definition';
|
|
2
|
+
import { MarketContext } from './market-context';
|
|
3
|
+
export interface IFieldContext {
|
|
4
|
+
readonly path: readonly string[];
|
|
5
|
+
readonly instance: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class ValueConventions {
|
|
8
|
+
readonly market: MarketContext;
|
|
9
|
+
constructor(market: MarketContext);
|
|
10
|
+
static knows(tag: number): boolean;
|
|
11
|
+
value(sf: SimpleFieldDefinition, ctx: IFieldContext): any;
|
|
12
|
+
private enumValue;
|
|
13
|
+
private conform;
|
|
14
|
+
private byType;
|
|
15
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValueConventions = void 0;
|
|
4
|
+
const tag_type_1 = require("../buffer/tag/tag-type");
|
|
5
|
+
const market_context_1 = require("./market-context");
|
|
6
|
+
const mics = ['XLON', 'XNAS', 'XNYS', 'XETR', 'IFEU', 'XCME', 'XOFF'];
|
|
7
|
+
const currencies = ['USD', 'EUR', 'GBP', 'JPY', 'CHF'];
|
|
8
|
+
const sessions = ['DAY', 'REG', 'ELECTRONIC', 'AFTERHOURS'];
|
|
9
|
+
const ratings = ['AAA', 'AA+', 'A', 'BBB+', 'BB-'];
|
|
10
|
+
const countries = ['US', 'GB', 'DE', 'NL', 'JP'];
|
|
11
|
+
const ordinalName = /(Type|Status|Reason|Indicator|Action|Capacity|Method|Mode|Level)$/;
|
|
12
|
+
const byTag = new Map([
|
|
13
|
+
[1, m => m.account],
|
|
14
|
+
[6, m => m.avgPx],
|
|
15
|
+
[11, (m, ctx) => (ctx.instance > 0 ? `${m.clOrdId}-${ctx.instance}` : m.clOrdId)],
|
|
16
|
+
[14, m => m.cumQty],
|
|
17
|
+
[15, m => m.instrument.currency],
|
|
18
|
+
[17, m => `${m.execId}-${m.nextSeq()}`],
|
|
19
|
+
[22, m => m.current().securityIdSource],
|
|
20
|
+
[30, m => m.instrument.securityExchange],
|
|
21
|
+
[31, m => m.lastPx],
|
|
22
|
+
[32, m => m.lastQty],
|
|
23
|
+
[37, (m, ctx) => (ctx.instance > 0 ? `${m.orderId}-${ctx.instance}` : m.orderId)],
|
|
24
|
+
[38, m => m.orderQty],
|
|
25
|
+
[41, m => m.origClOrdId],
|
|
26
|
+
[44, m => m.price],
|
|
27
|
+
[48, m => m.current().securityId],
|
|
28
|
+
[54, (m, ctx) => (ctx.instance % 2 === 0 ? m.side : (m.side === '1' ? '2' : '1'))],
|
|
29
|
+
[55, m => m.current().symbol],
|
|
30
|
+
[58, m => m.text()],
|
|
31
|
+
[60, m => m.transactTime],
|
|
32
|
+
[64, m => m.settlDate],
|
|
33
|
+
[75, m => m.tradeDate],
|
|
34
|
+
[76, m => m.firms[0].id],
|
|
35
|
+
[100, m => m.instrument.securityExchange],
|
|
36
|
+
[107, m => m.instrument.name],
|
|
37
|
+
[110, m => m.instrument.lotSize],
|
|
38
|
+
[151, m => m.leavesQty],
|
|
39
|
+
[167, m => m.current().securityType],
|
|
40
|
+
[200, m => { var _a; return (_a = m.current().maturityMonthYear) !== null && _a !== void 0 ? _a : m.instrument.maturityMonthYear; }],
|
|
41
|
+
[201, m => m.instrument.putOrCall],
|
|
42
|
+
[202, m => m.instrument.strikePrice],
|
|
43
|
+
[207, m => m.instrument.securityExchange],
|
|
44
|
+
[231, m => m.instrument.contractMultiplier],
|
|
45
|
+
[336, m => m.rng.pick(sessions)],
|
|
46
|
+
[375, m => m.firms[2].id],
|
|
47
|
+
[381, m => m.grossAmount()],
|
|
48
|
+
[447, (m, ctx) => m.party(ctx.instance).idSource],
|
|
49
|
+
[448, (m, ctx) => m.party(ctx.instance).id],
|
|
50
|
+
[452, (m, ctx) => m.party(ctx.instance).role],
|
|
51
|
+
[460, m => m.instrument.product],
|
|
52
|
+
[461, m => m.instrument.cfiCode],
|
|
53
|
+
[541, m => m.instrument.maturityDate],
|
|
54
|
+
[571, m => m.tradeId],
|
|
55
|
+
[255, m => m.rng.pick(ratings)],
|
|
56
|
+
[470, m => m.rng.pick(countries)],
|
|
57
|
+
[472, m => m.rng.pick(countries)],
|
|
58
|
+
[65, () => undefined],
|
|
59
|
+
[572, m => `${m.tradeId}-REF`],
|
|
60
|
+
[600, m => m.current().symbol],
|
|
61
|
+
[602, m => m.current().securityId],
|
|
62
|
+
[603, m => m.current().securityIdSource],
|
|
63
|
+
[609, m => m.current().securityType],
|
|
64
|
+
[610, m => m.current().maturityMonthYear],
|
|
65
|
+
[623, m => { var _a, _b; return (_b = (_a = m.leg) === null || _a === void 0 ? void 0 : _a.ratio) !== null && _b !== void 0 ? _b : 1; }],
|
|
66
|
+
[624, m => { var _a, _b; return (_b = (_a = m.leg) === null || _a === void 0 ? void 0 : _a.side) !== null && _b !== void 0 ? _b : m.side; }],
|
|
67
|
+
[566, m => m.priceNear()],
|
|
68
|
+
[637, m => m.priceNear()],
|
|
69
|
+
[687, m => { var _a, _b; return m.lastQty * ((_b = (_a = m.leg) === null || _a === void 0 ? void 0 : _a.ratio) !== null && _b !== void 0 ? _b : 1); }],
|
|
70
|
+
[311, m => { var _a, _b; return (_b = (_a = m.underlying) === null || _a === void 0 ? void 0 : _a.symbol) !== null && _b !== void 0 ? _b : m.instrument.symbol; }],
|
|
71
|
+
[309, m => { var _a, _b; return (_b = (_a = m.underlying) === null || _a === void 0 ? void 0 : _a.securityId) !== null && _b !== void 0 ? _b : m.instrument.securityId; }],
|
|
72
|
+
[305, m => { var _a, _b; return (_b = (_a = m.underlying) === null || _a === void 0 ? void 0 : _a.securityIdSource) !== null && _b !== void 0 ? _b : m.instrument.securityIdSource; }],
|
|
73
|
+
[79, m => m.account],
|
|
74
|
+
[80, m => m.lastQty],
|
|
75
|
+
[270, m => m.priceNear()],
|
|
76
|
+
[271, m => m.quantity()],
|
|
77
|
+
[272, m => m.tradeDate],
|
|
78
|
+
[273, m => m.transactTime],
|
|
79
|
+
[346, m => m.rng.int(1, 25)]
|
|
80
|
+
]);
|
|
81
|
+
const nameRules = [
|
|
82
|
+
{ test: /(Type|Source|Status|Reason|Indicator|Capacity|Restrictions)$/, apply: () => undefined },
|
|
83
|
+
{ test: /(Px|Price)$/, apply: m => m.priceNear() },
|
|
84
|
+
{ test: /(Qty|Quantity|Shares|Size|Volume)$/, apply: m => m.quantity() },
|
|
85
|
+
{ test: /(Currency|Ccy)$/, apply: m => m.rng.pick(currencies) },
|
|
86
|
+
{ test: /Symbol$/, apply: m => m.current().symbol },
|
|
87
|
+
{ test: /(Exchange|Mkt|Market)$/, apply: m => m.rng.pick(mics) },
|
|
88
|
+
{ test: /SecurityID$/, apply: m => m.current().securityId },
|
|
89
|
+
{ test: /(MonthYear)$/, apply: m => { var _a; return (_a = m.current().maturityMonthYear) !== null && _a !== void 0 ? _a : m.instrument.maturityMonthYear; } },
|
|
90
|
+
{ test: /(Amt|Amount|Notional|Consideration)$/, apply: m => m.grossAmount() },
|
|
91
|
+
{ test: /(Rate|Yield|Coupon)$/, apply: m => Number((m.rng.int(1, 800) / 10000).toFixed(5)) },
|
|
92
|
+
{ test: /(Percent|Pct|Ratio)$/, apply: m => Number((m.rng.int(0, 10000) / 100).toFixed(2)) },
|
|
93
|
+
{ test: /Account$/, apply: m => m.account },
|
|
94
|
+
{ test: /(Desk|Division)$/, apply: m => m.desk },
|
|
95
|
+
{ test: /(Text|Desc|Description|Comment|Instructions)$/, apply: m => m.text() },
|
|
96
|
+
{ test: /(Timestamp|Time)$/, apply: m => m.transactTime },
|
|
97
|
+
{ test: /Date$/, apply: m => m.tradeDate },
|
|
98
|
+
{ test: /(Broker|Firm)$/, apply: (m, ctx) => m.party(ctx.instance).id },
|
|
99
|
+
{ test: /(Trader|User|Operator)$/, apply: m => m.traders[0].id }
|
|
100
|
+
];
|
|
101
|
+
function initials(name) {
|
|
102
|
+
const caps = name.replace(/[^A-Z]/g, '');
|
|
103
|
+
if (caps.length >= 2)
|
|
104
|
+
return caps.substring(0, 4);
|
|
105
|
+
return name.substring(0, 3).toUpperCase();
|
|
106
|
+
}
|
|
107
|
+
class ValueConventions {
|
|
108
|
+
constructor(market) {
|
|
109
|
+
this.market = market;
|
|
110
|
+
}
|
|
111
|
+
static knows(tag) {
|
|
112
|
+
return byTag.has(tag);
|
|
113
|
+
}
|
|
114
|
+
value(sf, ctx) {
|
|
115
|
+
const exact = byTag.get(sf.tag);
|
|
116
|
+
if (exact) {
|
|
117
|
+
const v = exact(this.market, ctx, sf);
|
|
118
|
+
if (v != null)
|
|
119
|
+
return this.conform(sf, v);
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
if (sf.isEnum()) {
|
|
123
|
+
return this.enumValue(sf);
|
|
124
|
+
}
|
|
125
|
+
for (const rule of nameRules) {
|
|
126
|
+
if (!rule.test.test(sf.name))
|
|
127
|
+
continue;
|
|
128
|
+
const v = rule.apply(this.market, ctx, sf);
|
|
129
|
+
if (v == null)
|
|
130
|
+
break;
|
|
131
|
+
return this.conform(sf, v);
|
|
132
|
+
}
|
|
133
|
+
return this.byType(sf, ctx);
|
|
134
|
+
}
|
|
135
|
+
enumValue(sf) {
|
|
136
|
+
const keys = Array.from(sf.enums.keys());
|
|
137
|
+
if (keys.length === 0)
|
|
138
|
+
return undefined;
|
|
139
|
+
const choice = keys[this.market.rng.frontBiased(keys.length)];
|
|
140
|
+
switch (sf.tagType) {
|
|
141
|
+
case tag_type_1.TagType.Int: return parseInt(choice, 10);
|
|
142
|
+
case tag_type_1.TagType.Float: return parseFloat(choice);
|
|
143
|
+
case tag_type_1.TagType.Boolean: return choice === 'Y';
|
|
144
|
+
default: return choice;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
conform(sf, v) {
|
|
148
|
+
switch (sf.tagType) {
|
|
149
|
+
case tag_type_1.TagType.RawData: {
|
|
150
|
+
if (Buffer.isBuffer(v))
|
|
151
|
+
return v;
|
|
152
|
+
return Buffer.from(String(v));
|
|
153
|
+
}
|
|
154
|
+
case tag_type_1.TagType.Int:
|
|
155
|
+
case tag_type_1.TagType.Length: {
|
|
156
|
+
if (typeof v === 'number')
|
|
157
|
+
return Math.round(v);
|
|
158
|
+
const n = parseInt(String(v), 10);
|
|
159
|
+
return isNaN(n) ? undefined : n;
|
|
160
|
+
}
|
|
161
|
+
case tag_type_1.TagType.Float: {
|
|
162
|
+
if (typeof v === 'number')
|
|
163
|
+
return v;
|
|
164
|
+
const f = parseFloat(String(v));
|
|
165
|
+
return isNaN(f) ? undefined : f;
|
|
166
|
+
}
|
|
167
|
+
case tag_type_1.TagType.Boolean: {
|
|
168
|
+
if (typeof v === 'boolean')
|
|
169
|
+
return v;
|
|
170
|
+
return String(v) === 'Y' || String(v) === 'true';
|
|
171
|
+
}
|
|
172
|
+
case tag_type_1.TagType.String: {
|
|
173
|
+
if (v instanceof Date)
|
|
174
|
+
return market_context_1.MarketContext.yyyymmdd(v);
|
|
175
|
+
return String(v);
|
|
176
|
+
}
|
|
177
|
+
default:
|
|
178
|
+
return v;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
byType(sf, ctx) {
|
|
182
|
+
const m = this.market;
|
|
183
|
+
const rng = m.rng;
|
|
184
|
+
switch (sf.tagType) {
|
|
185
|
+
case tag_type_1.TagType.String:
|
|
186
|
+
if (ordinalName.test(sf.name))
|
|
187
|
+
return String(rng.int(0, 4));
|
|
188
|
+
return `${initials(sf.name)}-${rng.int(1000, 99999)}`;
|
|
189
|
+
case tag_type_1.TagType.Int:
|
|
190
|
+
return ordinalName.test(sf.name) ? rng.int(0, 4) : rng.int(1, 500);
|
|
191
|
+
case tag_type_1.TagType.Float:
|
|
192
|
+
return Number((rng.int(1, 100000) / 100).toFixed(2));
|
|
193
|
+
case tag_type_1.TagType.Length:
|
|
194
|
+
return undefined;
|
|
195
|
+
case tag_type_1.TagType.Boolean:
|
|
196
|
+
return rng.bool(0.5);
|
|
197
|
+
case tag_type_1.TagType.UtcTimestamp:
|
|
198
|
+
return m.transactTime;
|
|
199
|
+
case tag_type_1.TagType.UtcTimeOnly: {
|
|
200
|
+
const t = m.transactTime;
|
|
201
|
+
return new Date(Date.UTC(0, 0, 0, t.getUTCHours(), t.getUTCMinutes(), t.getUTCSeconds(), 0));
|
|
202
|
+
}
|
|
203
|
+
case tag_type_1.TagType.UtcDateOnly:
|
|
204
|
+
return m.tradeDate;
|
|
205
|
+
case tag_type_1.TagType.LocalDate: {
|
|
206
|
+
const d = m.tradeDate;
|
|
207
|
+
return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), 0, 0, 0, 0);
|
|
208
|
+
}
|
|
209
|
+
case tag_type_1.TagType.RawData:
|
|
210
|
+
return Buffer.from(`${initials(sf.name)}:${m.tradeId}:${ctx.instance}`);
|
|
211
|
+
default:
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
exports.ValueConventions = ValueConventions;
|
|
217
|
+
//# sourceMappingURL=value-conventions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-conventions.js","sourceRoot":"","sources":["../../src/generator/value-conventions.ts"],"names":[],"mappings":";;;AACA,qDAAgD;AAChD,qDAAgD;AAgChD,MAAM,IAAI,GAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AACxF,MAAM,UAAU,GAAsB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;AACzE,MAAM,QAAQ,GAAsB,CAAC,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC,CAAA;AAC9E,MAAM,OAAO,GAAsB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AACrE,MAAM,SAAS,GAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAGnE,MAAM,WAAW,GAAG,mEAAmE,CAAA;AASvF,MAAM,KAAK,GAAyB,IAAI,GAAG,CAAkB;IAC3D,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IACnB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACjB,CAAC,EAAE,EAAE,CAAC,C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AM,CAAC,GAAG,CAAC,CAAC,YAAY,CAAA;gBACxB,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;YAC9F,CAAC;YACD,KAAK,kBAAO,CAAC,WAAW;gBACtB,OAAO,CAAC,CAAC,SAAS,CAAA;YACpB,KAAK,kBAAO,CAAC,SAAS,CAAC,CAAC,CAAC;gBACvB,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAA;gBACrB,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;YAClF,CAAC;YACD,KAAK,kBAAO,CAAC,OAAO;gBAClB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAA;YACzE;gBACE,OAAO,SAAS,CAAA;QACpB,CAAC;IACH,CAAC;CACF;AAjID,4CAiIC","sourcesContent":["import { SimpleFieldDefinition } from '../dictionary/definition'\nimport { TagType } from '../buffer/tag/tag-type'\nimport { MarketContext } from './market-context'\n\n/**\n * How a tag gets a value that looks like the thing it names.\n *\n * Three layers, tried in order, and the ordering is the design:\n *\n * 1. a table of tags whose meaning the generator actually knows, read off the\n * `MarketContext` so they agree with each other;\n * 2. conventions over the field *name* - anything ending `Px`, `Qty`, `Currency`,\n * `Date` and so on - which is what lets an unfamiliar message type, or a broker\n * dialect nobody here has seen, still come out readable;\n * 3. the type, as a last resort, but with ranges a trader would not blink at rather\n * than a signed float with seven decimal places.\n *\n * Layer 2 is doing most of the work. FIX field naming is remarkably disciplined -\n * `LegLastPx`, `UnderlyingSettlPrice`, `AllocSettlCurrency` - so a suffix is very nearly\n * a type declaration, and treating it as one covers thousands of fields for the cost of\n * a dozen rules.\n *\n * Which *instrument* a value is read from is not decided here. The walker moves\n * `MarketContext.leg` and `.underlying` as it descends, so `LegPrice` inside the second\n * leg resolves against that leg without this layer knowing where it is.\n */\n\nexport interface IFieldContext {\n /** set names from the message down to the field, e.g. ['TrdCapRptSideGrp', 'Parties'] */\n readonly path: readonly string[]\n /** index within the nearest enclosing group instance, 0 when not in a group */\n readonly instance: number\n}\n\nconst mics: readonly string[] = ['XLON', 'XNAS', 'XNYS', 'XETR', 'IFEU', 'XCME', 'XOFF']\nconst currencies: readonly string[] = ['USD', 'EUR', 'GBP', 'JPY', 'CHF']\nconst sessions: readonly string[] = ['DAY', 'REG', 'ELECTRONIC', 'AFTERHOURS']\nconst ratings: readonly string[] = ['AAA', 'AA+', 'A', 'BBB+', 'BB-']\nconst countries: readonly string[] = ['US', 'GB', 'DE', 'NL', 'JP']\n/** a field named for a classification but with no enumeration behind it in this\n * dictionary - still a small ordinal, not a five digit number */\nconst ordinalName = /(Type|Status|Reason|Indicator|Action|Capacity|Method|Mode|Level)$/\n\ntype Handler = (m: MarketContext, ctx: IFieldContext, sf: SimpleFieldDefinition) => any\n\n/**\n * Tags the generator understands well enough to keep consistent with the rest of the\n * message. Everything absent from here still gets a plausible value from the name\n * conventions below - it just is not tied to the trade.\n */\nconst byTag: Map<number, Handler> = new Map<number, Handler>([\n [1, m => m.account],\n [6, m => m.avgPx],\n [11, (m, ctx) => (ctx.instance > 0 ? `${m.clOrdId}-${ctx.instance}` : m.clOrdId)],\n [14, m => m.cumQty],\n [15, m => m.instrument.currency],\n [17, m => `${m.execId}-${m.nextSeq()}`],\n [22, m => m.current().securityIdSource],\n [30, m => m.instrument.securityExchange],\n [31, m => m.lastPx],\n [32, m => m.lastQty],\n [37, (m, ctx) => (ctx.instance > 0 ? `${m.orderId}-${ctx.instance}` : m.orderId)],\n [38, m => m.orderQty],\n [41, m => m.origClOrdId],\n [44, m => m.price],\n [48, m => m.current().securityId],\n [54, (m, ctx) => (ctx.instance % 2 === 0 ? m.side : (m.side === '1' ? '2' : '1'))],\n [55, m => m.current().symbol],\n [58, m => m.text()],\n [60, m => m.transactTime],\n [64, m => m.settlDate],\n [75, m => m.tradeDate],\n [76, m => m.firms[0].id],\n [100, m => m.instrument.securityExchange],\n [107, m => m.instrument.name],\n [110, m => m.instrument.lotSize],\n [151, m => m.leavesQty],\n [167, m => m.current().securityType],\n [200, m => m.current().maturityMonthYear ?? m.instrument.maturityMonthYear],\n [201, m => m.instrument.putOrCall],\n [202, m => m.instrument.strikePrice],\n [207, m => m.instrument.securityExchange],\n [231, m => m.instrument.contractMultiplier],\n [336, m => m.rng.pick(sessions)],\n [375, m => m.firms[2].id],\n [381, m => m.grossAmount()],\n [447, (m, ctx) => m.party(ctx.instance).idSource],\n [448, (m, ctx) => m.party(ctx.instance).id],\n [452, (m, ctx) => m.party(ctx.instance).role],\n [460, m => m.instrument.product],\n [461, m => m.instrument.cfiCode],\n [541, m => m.instrument.maturityDate],\n [571, m => m.tradeId],\n [255, m => m.rng.pick(ratings)],\n [470, m => m.rng.pick(countries)],\n [472, m => m.rng.pick(countries)],\n [65, () => undefined],\n [572, m => `${m.tradeId}-REF`],\n\n // legs - resolved through current(), which the walker has already pointed at the leg\n [600, m => m.current().symbol],\n [602, m => m.current().securityId],\n [603, m => m.current().securityIdSource],\n [609, m => m.current().securityType],\n [610, m => m.current().maturityMonthYear],\n [623, m => m.leg?.ratio ?? 1],\n [624, m => m.leg?.side ?? m.side],\n [566, m => m.priceNear()],\n [637, m => m.priceNear()],\n [687, m => m.lastQty * (m.leg?.ratio ?? 1)],\n\n // underlyings\n [311, m => m.underlying?.symbol ?? m.instrument.symbol],\n [309, m => m.underlying?.securityId ?? m.instrument.securityId],\n [305, m => m.underlying?.securityIdSource ?? m.instrument.securityIdSource],\n\n // allocation\n [79, m => m.account],\n [80, m => m.lastQty],\n\n // market data\n [270, m => m.priceNear()],\n [271, m => m.quantity()],\n [272, m => m.tradeDate],\n [273, m => m.transactTime],\n [346, m => m.rng.int(1, 25)]\n])\n\ninterface INameRule {\n readonly test: RegExp\n readonly apply: Handler\n}\n\n/**\n * Suffix first, then a few prefixes. Order matters - `PriceType` must not be caught by\n * the `Price` rule, so the more specific patterns are listed above the general ones.\n */\nconst nameRules: readonly INameRule[] = [\n { test: /(Type|Source|Status|Reason|Indicator|Capacity|Restrictions)$/, apply: () => undefined },\n\n { test: /(Px|Price)$/, apply: m => m.priceNear() },\n { test: /(Qty|Quantity|Shares|Size|Volume)$/, apply: m => m.quantity() },\n { test: /(Currency|Ccy)$/, apply: m => m.rng.pick(currencies) },\n { test: /Symbol$/, apply: m => m.current().symbol },\n { test: /(Exchange|Mkt|Market)$/, apply: m => m.rng.pick(mics) },\n { test: /SecurityID$/, apply: m => m.current().securityId },\n { test: /(MonthYear)$/, apply: m => m.current().maturityMonthYear ?? m.instrument.maturityMonthYear },\n { test: /(Amt|Amount|Notional|Consideration)$/, apply: m => m.grossAmount() },\n { test: /(Rate|Yield|Coupon)$/, apply: m => Number((m.rng.int(1, 800) / 10000).toFixed(5)) },\n { test: /(Percent|Pct|Ratio)$/, apply: m => Number((m.rng.int(0, 10000) / 100).toFixed(2)) },\n { test: /Account$/, apply: m => m.account },\n { test: /(Desk|Division)$/, apply: m => m.desk },\n { test: /(Text|Desc|Description|Comment|Instructions)$/, apply: m => m.text() },\n { test: /(Timestamp|Time)$/, apply: m => m.transactTime },\n { test: /Date$/, apply: m => m.tradeDate },\n { test: /(Broker|Firm)$/, apply: (m, ctx) => m.party(ctx.instance).id },\n { test: /(Trader|User|Operator)$/, apply: m => m.traders[0].id }\n]\n\nfunction initials (name: string): string {\n const caps = name.replace(/[^A-Z]/g, '')\n if (caps.length >= 2) return caps.substring(0, 4)\n return name.substring(0, 3).toUpperCase()\n}\n\nexport class ValueConventions {\n constructor (public readonly market: MarketContext) {\n }\n\n /**\n * whether this tag is one the generator understands rather than merely guesses at.\n * The field walker reads it as a proxy for \"would a real message of this type carry\n * this field\", which is a crude signal but a better one than the tag number alone.\n */\n public static knows (tag: number): boolean {\n return byTag.has(tag)\n }\n\n /**\n * a value for this field, or undefined if the caller should leave the tag out\n */\n public value (sf: SimpleFieldDefinition, ctx: IFieldContext): any {\n const exact = byTag.get(sf.tag)\n if (exact) {\n const v = exact(this.market, ctx, sf)\n if (v != null) return this.conform(sf, v)\n // a handler declining - e.g. StrikePrice on a future - is a reason to omit, not\n // a reason to fall through and invent one\n return undefined\n }\n if (sf.isEnum()) {\n return this.enumValue(sf)\n }\n for (const rule of nameRules) {\n if (!rule.test.test(sf.name)) continue\n const v = rule.apply(this.market, ctx, sf)\n if (v == null) break\n return this.conform(sf, v)\n }\n return this.byType(sf, ctx)\n }\n\n /**\n * Dictionaries list enumerated values roughly in order of how ordinary they are, so a\n * front biased pick lands on Side 1 or 2 far more often than on the twenty exotics\n * below them. Not true universally, but true often enough to be worth more than a\n * uniform draw, and it stays deterministic.\n */\n private enumValue (sf: SimpleFieldDefinition): any {\n const keys = Array.from(sf.enums.keys())\n if (keys.length === 0) return undefined\n const choice = keys[this.market.rng.frontBiased(keys.length)]\n switch (sf.tagType) {\n case TagType.Int: return parseInt(choice, 10)\n case TagType.Float: return parseFloat(choice)\n case TagType.Boolean: return choice === 'Y'\n default: return choice\n }\n }\n\n /**\n * a value supplied by tag or by name may not be of the type the dictionary declares -\n * `SecurityIDSource` is a String in one dictionary and an Int in another - so coerce\n * rather than emit something the encoder will mangle\n */\n private conform (sf: SimpleFieldDefinition, v: any): any {\n switch (sf.tagType) {\n case TagType.RawData: {\n // a name rule may well have produced a perfectly good string for EncodedText,\n // but the encoder writes the preceding Length only when handed a Buffer, and a\n // raw field arriving without its length is unparseable\n if (Buffer.isBuffer(v)) return v\n return Buffer.from(String(v))\n }\n case TagType.Int:\n case TagType.Length: {\n if (typeof v === 'number') return Math.round(v)\n const n = parseInt(String(v), 10)\n return isNaN(n) ? undefined : n\n }\n case TagType.Float: {\n if (typeof v === 'number') return v\n const f = parseFloat(String(v))\n return isNaN(f) ? undefined : f\n }\n case TagType.Boolean: {\n if (typeof v === 'boolean') return v\n return String(v) === 'Y' || String(v) === 'true'\n }\n case TagType.String: {\n if (v instanceof Date) return MarketContext.yyyymmdd(v)\n return String(v)\n }\n default:\n return v\n }\n }\n\n private byType (sf: SimpleFieldDefinition, ctx: IFieldContext): any {\n const m = this.market\n const rng = m.rng\n switch (sf.tagType) {\n case TagType.String:\n if (ordinalName.test(sf.name)) return String(rng.int(0, 4))\n // identifier shaped, and carrying the field it came from, so a message can be\n // read back to the dictionary by eye\n return `${initials(sf.name)}-${rng.int(1000, 99999)}`\n case TagType.Int:\n return ordinalName.test(sf.name) ? rng.int(0, 4) : rng.int(1, 500)\n case TagType.Float:\n return Number((rng.int(1, 100000) / 100).toFixed(2))\n case TagType.Length:\n // written by the encoder from the RawData it precedes\n return undefined\n case TagType.Boolean:\n return rng.bool(0.5)\n case TagType.UtcTimestamp:\n return m.transactTime\n case TagType.UtcTimeOnly: {\n const t = m.transactTime\n return new Date(Date.UTC(0, 0, 0, t.getUTCHours(), t.getUTCMinutes(), t.getUTCSeconds(), 0))\n }\n case TagType.UtcDateOnly:\n return m.tradeDate\n case TagType.LocalDate: {\n const d = m.tradeDate\n return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), 0, 0, 0, 0)\n }\n case TagType.RawData:\n return Buffer.from(`${initials(sf.name)}:${m.tradeId}:${ctx.instance}`)\n default:\n return undefined\n }\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,3 +4,9 @@ export * from './buffer';
|
|
|
4
4
|
export * from './transport';
|
|
5
5
|
export * from './config';
|
|
6
6
|
export * from './types';
|
|
7
|
+
export * from './collections';
|
|
8
|
+
export * from './store';
|
|
9
|
+
export * from './util/definition-factory';
|
|
10
|
+
export * from './util/dictionary-path';
|
|
11
|
+
export type { IStandardHeader, IHop } from './types/FIX4.4/repo';
|
|
12
|
+
export type { IStandardHeader as IFixmlStandardHeader } from './types/FIXML50SP2';
|
package/dist/index.js
CHANGED
|
@@ -20,4 +20,8 @@ __exportStar(require("./buffer"), exports);
|
|
|
20
20
|
__exportStar(require("./transport"), exports);
|
|
21
21
|
__exportStar(require("./config"), exports);
|
|
22
22
|
__exportStar(require("./types"), exports);
|
|
23
|
+
__exportStar(require("./collections"), exports);
|
|
24
|
+
__exportStar(require("./store"), exports);
|
|
25
|
+
__exportStar(require("./util/definition-factory"), exports);
|
|
26
|
+
__exportStar(require("./util/dictionary-path"), exports);
|
|
23
27
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,+CAA4B;AAC5B,2CAAwB;AACxB,8CAA2B;AAC3B,2CAAwB;AACxB,0CAAuB","sourcesContent":["export * from './runtime'\nexport * from './dictionary'\nexport * from './buffer'\nexport * from './transport'\nexport * from './config'\nexport * from './types'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,+CAA4B;AAC5B,2CAAwB;AACxB,8CAA2B;AAC3B,2CAAwB;AACxB,0CAAuB;AACvB,gDAA6B;AAC7B,0CAAuB;AACvB,4DAAyC;AACzC,yDAAsC","sourcesContent":["export * from './runtime'\nexport * from './dictionary'\nexport * from './buffer'\nexport * from './transport'\nexport * from './config'\nexport * from './types'\nexport * from './collections'\nexport * from './store'\nexport * from './util/definition-factory'\nexport * from './util/dictionary-path'\n\n// These live in the generated dictionaries but appear in the public signature of\n// the session message factory, so an application overriding logon() or header()\n// has to be able to name them. Without this it can only reach them behind a\n// dist/ path, which is what drove the module augmentation in issue #85. The\n// FIXML one is aliased because both dictionaries call theirs IStandardHeader.\nexport type { IStandardHeader, IHop } from './types/FIX4.4/repo'\nexport type { IStandardHeader as IFixmlStandardHeader } from './types/FIXML50SP2'\n"]}
|
package/dist/jsfix-cmd.d.ts
CHANGED
|
@@ -31,6 +31,11 @@ export declare class JsfixCmd {
|
|
|
31
31
|
exec(): Promise<any>;
|
|
32
32
|
private firstMessage;
|
|
33
33
|
protected generate(): Promise<void>;
|
|
34
|
+
private generateCase;
|
|
35
|
+
private static generatorOverrides;
|
|
36
|
+
private addToCorpus;
|
|
37
|
+
private reportRoundTrip;
|
|
38
|
+
private parseOnce;
|
|
34
39
|
private single;
|
|
35
40
|
private script;
|
|
36
41
|
private unitTest;
|