UNPKG

@reactivemarkets/switchboard-api

Version:

Generated api for Reactive Markets Switchboard network

358 lines (357 loc) 12.7 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.Quote = exports.QuoteEntry = void 0; const flatbuffers = __importStar(require("flatbuffers")); const Enum_generated_js_1 = require("./Enum_generated.js"); class QuoteEntry { 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 QuoteEntry. */ size() { return this.bb.readFloat64(this.bb_pos + 8); } /** * Price of the QuoteEntry. */ price() { return this.bb.readFloat64(this.bb_pos + 16); } /** * Forward points of the QuoteEntry. */ fwdPoints() { return this.bb.readFloat64(this.bb_pos + 24); } /** * Swap only, far leg size. */ farSize() { return this.bb.readFloat64(this.bb_pos + 32); } /** * Swap only, far leg price. */ farPrice() { return this.bb.readFloat64(this.bb_pos + 40); } /** * Swap only, far leg forward points. */ farFwdPoints() { return this.bb.readFloat64(this.bb_pos + 48); } /** * Swap points of the QuoteEntry. */ swapPoints() { return this.bb.readFloat64(this.bb_pos + 56); } static sizeOf() { return 64; } static createQuoteEntry(builder, conditions, size, price, fwd_points, far_size, far_price, far_fwd_points, swap_points) { builder.prep(8, 64); builder.writeFloat64(swap_points); builder.writeFloat64(far_fwd_points); builder.writeFloat64(far_price); builder.writeFloat64(far_size); builder.writeFloat64(fwd_points); builder.writeFloat64(price); builder.writeFloat64(size); builder.pad(6); builder.writeInt16(conditions); return builder.offset(); } } exports.QuoteEntry = QuoteEntry; class Quote { constructor() { this.bb = null; this.bb_pos = 0; } __init(i, bb) { this.bb_pos = i; this.bb = bb; return this; } static getRootAsQuote(bb, obj) { return (obj || new Quote()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsQuote(bb, obj) { bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); return (obj || new Quote()).__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; } tenor(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 10); 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, 12); return offset ? this.bb.readInt16(this.bb_pos + offset) : Enum_generated_js_1.SecurityType.Spot; } reqId(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 14); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } quoteId(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 16); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } venue(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 18); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } /** * Quote expiry time. */ expiryTime() { const offset = this.bb.__offset(this.bb_pos, 20); return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); } ccy(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 22); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } entryId(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 24); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } /** * The fixing date in YYYYMMDD format. */ fixingDate() { const offset = this.bb.__offset(this.bb_pos, 26); 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, 28); return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; } /** * Swaps only, fixing date in YYYYMMDD format. */ farFixingDate() { const offset = this.bb.__offset(this.bb_pos, 30); return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; } /** * The settlement date in YYYYMMDD format. */ farSettlementDate() { const offset = this.bb.__offset(this.bb_pos, 32); return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; } farTenor(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 34); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } /** * Bid quote entries. */ bid(index, obj) { const offset = this.bb.__offset(this.bb_pos, 36); return offset ? (obj || new QuoteEntry()).__init(this.bb.__vector(this.bb_pos + offset) + index * 64, this.bb) : null; } bidLength() { const offset = this.bb.__offset(this.bb_pos, 36); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } /** * Offer quote entries. */ offer(index, obj) { const offset = this.bb.__offset(this.bb_pos, 38); return offset ? (obj || new QuoteEntry()).__init(this.bb.__vector(this.bb_pos + offset) + index * 64, this.bb) : null; } offerLength() { const offset = this.bb.__offset(this.bb_pos, 38); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } /** * Dodd-Frank mid price. */ midPrice() { const offset = this.bb.__offset(this.bb_pos, 40); return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; } /** * Swaps only, far leg Dodd-Frank mid price */ farMidPrice() { const offset = this.bb.__offset(this.bb_pos, 42); return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; } /** * Swaps only, Dodd-Frank mid swap points */ midSwapPoints() { const offset = this.bb.__offset(this.bb_pos, 44); return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; } static startQuote(builder) { builder.startObject(21); } 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 addTenor(builder, tenorOffset) { builder.addFieldOffset(3, tenorOffset, 0); } static addSecurityType(builder, securityType) { builder.addFieldInt16(4, securityType, Enum_generated_js_1.SecurityType.Spot); } static addReqId(builder, reqIdOffset) { builder.addFieldOffset(5, reqIdOffset, 0); } static addQuoteId(builder, quoteIdOffset) { builder.addFieldOffset(6, quoteIdOffset, 0); } static addVenue(builder, venueOffset) { builder.addFieldOffset(7, venueOffset, 0); } static addExpiryTime(builder, expiryTime) { builder.addFieldInt64(8, expiryTime, BigInt('0')); } static addCcy(builder, ccyOffset) { builder.addFieldOffset(9, ccyOffset, 0); } static addEntryId(builder, entryIdOffset) { builder.addFieldOffset(10, entryIdOffset, 0); } static addFixingDate(builder, fixingDate) { builder.addFieldInt32(11, fixingDate, 0); } static addSettlementDate(builder, settlementDate) { builder.addFieldInt32(12, settlementDate, 0); } static addFarFixingDate(builder, farFixingDate) { builder.addFieldInt32(13, farFixingDate, 0); } static addFarSettlementDate(builder, farSettlementDate) { builder.addFieldInt32(14, farSettlementDate, 0); } static addFarTenor(builder, farTenorOffset) { builder.addFieldOffset(15, farTenorOffset, 0); } static addBid(builder, bidOffset) { builder.addFieldOffset(16, bidOffset, 0); } static startBidVector(builder, numElems) { builder.startVector(64, numElems, 8); } static addOffer(builder, offerOffset) { builder.addFieldOffset(17, offerOffset, 0); } static startOfferVector(builder, numElems) { builder.startVector(64, numElems, 8); } static addMidPrice(builder, midPrice) { builder.addFieldFloat64(18, midPrice, 0.0); } static addFarMidPrice(builder, farMidPrice) { builder.addFieldFloat64(19, farMidPrice, 0.0); } static addMidSwapPoints(builder, midSwapPoints) { builder.addFieldFloat64(20, midSwapPoints, 0.0); } static endQuote(builder) { const offset = builder.endObject(); builder.requiredField(offset, 6); // account builder.requiredField(offset, 8); // symbol builder.requiredField(offset, 14); // req_id builder.requiredField(offset, 18); // venue return offset; } static createQuote(builder, origTime, accountOffset, symbolOffset, tenorOffset, securityType, reqIdOffset, quoteIdOffset, venueOffset, expiryTime, ccyOffset, entryIdOffset, fixingDate, settlementDate, farFixingDate, farSettlementDate, farTenorOffset, bidOffset, offerOffset, midPrice, farMidPrice, midSwapPoints) { Quote.startQuote(builder); Quote.addOrigTime(builder, origTime); Quote.addAccount(builder, accountOffset); Quote.addSymbol(builder, symbolOffset); Quote.addTenor(builder, tenorOffset); Quote.addSecurityType(builder, securityType); Quote.addReqId(builder, reqIdOffset); Quote.addQuoteId(builder, quoteIdOffset); Quote.addVenue(builder, venueOffset); Quote.addExpiryTime(builder, expiryTime); Quote.addCcy(builder, ccyOffset); Quote.addEntryId(builder, entryIdOffset); Quote.addFixingDate(builder, fixingDate); Quote.addSettlementDate(builder, settlementDate); Quote.addFarFixingDate(builder, farFixingDate); Quote.addFarSettlementDate(builder, farSettlementDate); Quote.addFarTenor(builder, farTenorOffset); Quote.addBid(builder, bidOffset); Quote.addOffer(builder, offerOffset); Quote.addMidPrice(builder, midPrice); Quote.addFarMidPrice(builder, farMidPrice); Quote.addMidSwapPoints(builder, midSwapPoints); return Quote.endQuote(builder); } } exports.Quote = Quote;