UNPKG

@reactivemarkets/switchboard-api

Version:

Generated api for Reactive Markets Switchboard network

260 lines (259 loc) 9.45 kB
"use strict"; // automatically generated by the FlatBuffers compiler, do not modify var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.MarketDataSnapshot = exports.MDEntry = void 0; const flatbuffers = __importStar(require("flatbuffers")); const Enum_generated_js_1 = require("./Enum_generated.js"); class MDEntry { constructor() { this.bb = null; this.bb_pos = 0; } __init(i, bb) { this.bb_pos = i; this.bb = bb; return this; } /** * Bitset describing conditions of the quote. */ conditions() { return this.bb.readUint16(this.bb_pos); } /** * Size of the MDEntry. */ size() { return this.bb.readFloat64(this.bb_pos + 8); } /** * Price of the MDEntry. */ price() { return this.bb.readFloat64(this.bb_pos + 16); } /** * Forward points of the MDEntry. */ fwdPoints() { return this.bb.readFloat64(this.bb_pos + 24); } /** * Reserved for future use. */ reserved() { return this.bb.readFloat64(this.bb_pos + 32); } static sizeOf() { return 40; } static createMDEntry(builder, conditions, size, price, fwd_points, reserved) { builder.prep(8, 40); builder.writeFloat64(reserved); builder.writeFloat64(fwd_points); builder.writeFloat64(price); builder.writeFloat64(size); builder.pad(6); builder.writeInt16(conditions); return builder.offset(); } } exports.MDEntry = MDEntry; class MarketDataSnapshot { constructor() { this.bb = null; this.bb_pos = 0; } __init(i, bb) { this.bb_pos = i; this.bb = bb; return this; } static getRootAsMarketDataSnapshot(bb, obj) { return (obj || new MarketDataSnapshot()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsMarketDataSnapshot(bb, obj) { bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); return (obj || new MarketDataSnapshot()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } /** * Source system timestamp. */ origTime() { const offset = this.bb.__offset(this.bb_pos, 4); return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); } account(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 6); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } symbol(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 8); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } venue(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 10); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } tenor(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 12); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } /** * Security Type. defaults to Spot. */ securityType() { const offset = this.bb.__offset(this.bb_pos, 14); return offset ? this.bb.readInt16(this.bb_pos + offset) : Enum_generated_js_1.SecurityType.Spot; } /** * Quote or liquidity type. */ quoteType() { const offset = this.bb.__offset(this.bb_pos, 16); return offset ? this.bb.readInt16(this.bb_pos + offset) : Enum_generated_js_1.QuoteType.None; } /** * The fixing date in YYYYMMDD format. */ fixingDate() { const offset = this.bb.__offset(this.bb_pos, 18); return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; } /** * The settlement date in YYYYMMDD format. */ settlementDate() { const offset = this.bb.__offset(this.bb_pos, 20); return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; } quoteId(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 22); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } /** * Bid market data entries. */ bid(index, obj) { const offset = this.bb.__offset(this.bb_pos, 24); return offset ? (obj || new MDEntry()).__init(this.bb.__vector(this.bb_pos + offset) + index * 40, this.bb) : null; } bidLength() { const offset = this.bb.__offset(this.bb_pos, 24); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } /** * Offer market data entries. */ offer(index, obj) { const offset = this.bb.__offset(this.bb_pos, 26); return offset ? (obj || new MDEntry()).__init(this.bb.__vector(this.bb_pos + offset) + index * 40, this.bb) : null; } offerLength() { const offset = this.bb.__offset(this.bb_pos, 26); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } /** * Dodd-Frank mid price. */ midPrice() { const offset = this.bb.__offset(this.bb_pos, 28); return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; } static startMarketDataSnapshot(builder) { builder.startObject(13); } static addOrigTime(builder, origTime) { builder.addFieldInt64(0, origTime, BigInt('0')); } static addAccount(builder, accountOffset) { builder.addFieldOffset(1, accountOffset, 0); } static addSymbol(builder, symbolOffset) { builder.addFieldOffset(2, symbolOffset, 0); } static addVenue(builder, venueOffset) { builder.addFieldOffset(3, venueOffset, 0); } static addTenor(builder, tenorOffset) { builder.addFieldOffset(4, tenorOffset, 0); } static addSecurityType(builder, securityType) { builder.addFieldInt16(5, securityType, Enum_generated_js_1.SecurityType.Spot); } static addQuoteType(builder, quoteType) { builder.addFieldInt16(6, quoteType, Enum_generated_js_1.QuoteType.None); } static addFixingDate(builder, fixingDate) { builder.addFieldInt32(7, fixingDate, 0); } static addSettlementDate(builder, settlementDate) { builder.addFieldInt32(8, settlementDate, 0); } static addQuoteId(builder, quoteIdOffset) { builder.addFieldOffset(9, quoteIdOffset, 0); } static addBid(builder, bidOffset) { builder.addFieldOffset(10, bidOffset, 0); } static startBidVector(builder, numElems) { builder.startVector(40, numElems, 8); } static addOffer(builder, offerOffset) { builder.addFieldOffset(11, offerOffset, 0); } static startOfferVector(builder, numElems) { builder.startVector(40, numElems, 8); } static addMidPrice(builder, midPrice) { builder.addFieldFloat64(12, midPrice, 0.0); } static endMarketDataSnapshot(builder) { const offset = builder.endObject(); builder.requiredField(offset, 6); // account builder.requiredField(offset, 8); // symbol builder.requiredField(offset, 10); // venue return offset; } static createMarketDataSnapshot(builder, origTime, accountOffset, symbolOffset, venueOffset, tenorOffset, securityType, quoteType, fixingDate, settlementDate, quoteIdOffset, bidOffset, offerOffset, midPrice) { MarketDataSnapshot.startMarketDataSnapshot(builder); MarketDataSnapshot.addOrigTime(builder, origTime); MarketDataSnapshot.addAccount(builder, accountOffset); MarketDataSnapshot.addSymbol(builder, symbolOffset); MarketDataSnapshot.addVenue(builder, venueOffset); MarketDataSnapshot.addTenor(builder, tenorOffset); MarketDataSnapshot.addSecurityType(builder, securityType); MarketDataSnapshot.addQuoteType(builder, quoteType); MarketDataSnapshot.addFixingDate(builder, fixingDate); MarketDataSnapshot.addSettlementDate(builder, settlementDate); MarketDataSnapshot.addQuoteId(builder, quoteIdOffset); MarketDataSnapshot.addBid(builder, bidOffset); MarketDataSnapshot.addOffer(builder, offerOffset); MarketDataSnapshot.addMidPrice(builder, midPrice); return MarketDataSnapshot.endMarketDataSnapshot(builder); } } exports.MarketDataSnapshot = MarketDataSnapshot;