UNPKG

jspurefix

Version:
61 lines 2.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TradeCaptureClient = void 0; const transport_1 = require("../../../transport"); const types_1 = require("../../../types"); const trade_factory_1 = require("./trade-factory"); class TradeCaptureClient extends transport_1.AsciiSession { constructor(config) { var _a, _b; super(config); this.config = config; this.logReceivedMsgs = true; this.reports = new Map(); this.fixLog = config.logFactory.plain(`jsfix.${(_b = (_a = config === null || config === void 0 ? void 0 : config.description) === null || _a === void 0 ? void 0 : _a.application) === null || _b === void 0 ? void 0 : _b.name}.txt`); this.logger = config.logFactory.logger(`${this.me}:TradeCaptureClient`); } onApplicationMsg(msgType, view) { this.logger.info(`${view.toJson()}`); switch (msgType) { case types_1.MsgType.TradeCaptureReport: { const tc = view.toObject(); this.reports.set(tc.TradeReportID, tc); this.logger.info(`[reports: ${this.reports.size}] received tc ExecID = ${tc.ExecID} TradeReportID = ${tc.TradeReportID} Symbol = ${tc.Instrument.Symbol} ${tc.LastQty} @ ${tc.LastPx}`); break; } case types_1.MsgType.TradeCaptureReportRequestAck: { const tc = view.toObject(); this.logger.info(`received tcr ack ${tc.TradeRequestID} ${tc.TradeRequestStatus}`); break; } } } onStopped() { this.logger.info('stopped'); } onDecoded(_, txt) { this.fixLog.info(txt); } onEncoded(_, txt) { this.fixLog.info(txt); } logoutTimer(logoutSeconds = 32) { setTimeout(() => { this.done(); }, logoutSeconds * 1000); } onReady(view) { this.logger.info('ready'); const tcr = trade_factory_1.TradeFactory.tradeCaptureReportRequest('all-trades', new Date()); this.send(types_1.MsgType.TradeCaptureReportRequest, tcr); const logoutSeconds = 32; this.logger.info(`will logout after ${logoutSeconds}`); this.logoutTimer(); } onLogon(view, user, password) { this.logger.info(`onLogon user ${user} ${password === null || password === void 0 ? void 0 : password.length}`); return true; } } exports.TradeCaptureClient = TradeCaptureClient; //# sourceMappingURL=trade-capture-client.js.map