fixparser-plugin-messagestore-kdb 0.0.1-init
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/LICENSE.md +3656 -0
- package/README.md +118 -0
- package/build/cjs/MessageStoreKDB.js +4466 -0
- package/build/cjs/MessageStoreKDB.js.map +7 -0
- package/build/esm/MessageStoreKDB.mjs +4458 -0
- package/build/esm/MessageStoreKDB.mjs.map +7 -0
- package/kdb-files/json.k +21 -0
- package/kdb-files/kdb.sh +2 -0
- package/kdb-files/script.q +2 -0
- package/package.json +42 -0
- package/types/MessageStoreKDB.d.ts +96 -0
- package/types/index.d.ts +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# fixparser-plugin-messagestore-kdb
|
|
2
|
+
|
|
3
|
+
`fixparser-plugin-messagestore-kdb` is a FIXParser plugin designed for managing a message buffer in a KDB+ instance. It stores and retrieves FIX messages over a WebSocket connection to KDB+, providing an asynchronous interface for interacting with the data.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- **WebSocket Connection**: Connects to a KDB+ instance via WebSocket to send and receive messages.
|
|
7
|
+
- **Message Buffering**: Stores messages in a configurable buffer, with an option to limit the buffer size.
|
|
8
|
+
- **FIX Message Parsing**: Uses a provided FIX parser to serialize/deserialize FIX messages.
|
|
9
|
+
- **Asynchronous API**: Supports asynchronous operations for adding, retrieving, and managing messages.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
To install the dependencies, run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install fixparser-plugin-messagestore-kdb
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
To setup KDB+, copy the files in `kdb-files/` to the installation directory of KDB+, such as ~/q.
|
|
20
|
+
Edit `script.q` to configure the listening port.
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
chmod +x ./kdb.sh
|
|
24
|
+
./kdb.sh
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
### Creating a `MessageStoreKDB` Instance
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { FIXParser } from 'fixparser';
|
|
34
|
+
import { MessageStoreKDB } from 'fixparser-plugin-messagestore-kdb';
|
|
35
|
+
|
|
36
|
+
const fixParser = new FIXParser();
|
|
37
|
+
const store = new MessageStoreKDB({
|
|
38
|
+
host: 'localhost',
|
|
39
|
+
port: 1234,
|
|
40
|
+
parser: fixParser,
|
|
41
|
+
logger: fixParser.logger,
|
|
42
|
+
onReady: () => {
|
|
43
|
+
console.log('Connection to KDB+ established and ready.');
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
fixParser.connect({
|
|
48
|
+
host: 'localhost',
|
|
49
|
+
port: 9878,
|
|
50
|
+
protocol: 'tcp',
|
|
51
|
+
sender: SENDER,
|
|
52
|
+
target: TARGET,
|
|
53
|
+
messageStoreIn: store,
|
|
54
|
+
onOpen: () => {
|
|
55
|
+
console.log('Connection established.');
|
|
56
|
+
},
|
|
57
|
+
onMessage: (message: Message) => console.log('received message', message.description, message.messageString),
|
|
58
|
+
onClose: () => console.log('Disconnected'),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Adding a Message to the Buffer
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
const message = new Message(
|
|
67
|
+
new Field(Fields.BeginString, ApplVerID.FIX42),
|
|
68
|
+
new Field(Fields.MsgType, Messages.ExecutionReport),
|
|
69
|
+
new Field(Fields.SenderCompID, 'ABC'),
|
|
70
|
+
new Field(Fields.TargetCompID, 'XYZ'),
|
|
71
|
+
new Field(Fields.MsgSeqNum, fixParser.getNextTargetMsgSeqNum()),
|
|
72
|
+
new Field(Fields.ExecTransType, ExecTransType.New),
|
|
73
|
+
);
|
|
74
|
+
store.add(message)
|
|
75
|
+
.then(() => console.log('Message added to the buffer.'));
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Retrieving a Message by Sequence Number
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
store.getByMsgSequence(1)
|
|
82
|
+
.then((message) => {
|
|
83
|
+
if (message) {
|
|
84
|
+
console.log('Retrieved message:', message);
|
|
85
|
+
} else {
|
|
86
|
+
console.log('Message not found.');
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Getting the Buffer Size
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
store.size()
|
|
95
|
+
.then((size) => {
|
|
96
|
+
console.log('Current buffer size:', size);
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Clearing the Buffer
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
store.clear()
|
|
104
|
+
.then(() => console.log('Buffer cleared.'));
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Configuration Options
|
|
108
|
+
|
|
109
|
+
- `host` (string): The hostname of the KDB+ instance.
|
|
110
|
+
- `port` (number): The port on which the KDB+ instance is listening.
|
|
111
|
+
- `tableName` (string, optional): The table name in the KDB+ instance (default: `FIXParser`).
|
|
112
|
+
- `parser` (IFIXParser): The FIX parser used for encoding/decoding messages.
|
|
113
|
+
- `maxBufferSize` (number, optional): The maximum size of the message buffer (default: 2500).
|
|
114
|
+
- `logger` (Logger, optional): The logger for logging events and errors.
|
|
115
|
+
- `onReady` (function): A callback function that is called when the KDB+ connection is ready.
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
This project is licensed under a Commercial License - see the [LICENSE](https://gitlab.com/logotype/fixparser/-/blob/dev/LICENSE.md) file for details.
|