-
Notifications
You must be signed in to change notification settings - Fork 0
/
orderstatus.js
57 lines (49 loc) · 1.42 KB
/
orderstatus.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const moment = require('moment');
var Fix = require('./fix.js');
var orderStatusWithClOrdId = {
BeginString: 'FIX.4.4',
BodyLength: '%l',
MsgType: 'H',
MsgSeqNum: 0,
SenderCompID: '',
SendingTime: moment().utc().format("YYYYMMDD-HH:mm:ss.SSS"),
TargetCompID: 'BTCM',
ClOrdID:'',
}
var orderStatusWithOrderId = {
BeginString: 'FIX.4.4',
BodyLength: '%l',
MsgType: 'H',
MsgSeqNum: 0,
SenderCompID: '',
SendingTime: moment().utc().format("YYYYMMDD-HH:mm:ss.SSS"),
TargetCompID: 'BTCM',
OrderID: ''
}
var apiKey
var connection
var logger
var Fix
function OrderStatus(apiKey, connection, logger) {
this.apiKey = apiKey
this.connection = connection
this.logger = logger
}
OrderStatus.prototype.sendOrderStatusWithClOrdId=function(clOrdId){
ordStatus = Object.assign({}, orderStatusWithClOrdId );
ordStatus.ClOrdID = clOrdId;
sendOrderStatus(this.connection, this.apiKey, this.logger, ordStatus);
}
OrderStatus.prototype.sendOrderStatusWithOrderId=function(orderId){
ordStatus = Object.assign({}, orderStatusWithOrderId );
ordStatus.OrderID = orderId;
sendOrderStatus(this.connection, this.apiKey, this.logger, ordStatus);
}
function sendOrderStatus (connection, apiKey, logger, ordStatus){
ordStatus.SenderCompID = apiKey;
ordStatus.MsgSeqNum = Fix.seqNum();
orderStatusMsg = Fix.message(ordStatus, true);
connection.write(orderStatusMsg);
logger.write('Outbound', Fix.read(orderStatusMsg));
}
module.exports=OrderStatus