MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / applyOrderHandlers

Function applyOrderHandlers

packages/ibkr/src/decoder/orders.ts:427–788  ·  view source on GitHub ↗
(decoder: Decoder)

Source from the content-addressed store, hash-verified

425// ---------------------------------------------------------------------------
426
427export function applyOrderHandlers(decoder: Decoder): void {
428 // -----------------------------------------------------------------------
429 // IN.ORDER_STATUS (3) — text
430 // -----------------------------------------------------------------------
431 decoder.registerText(IN.ORDER_STATUS, (d, fields) => {
432 decodeInt(fields) // msgId
433 if (d.serverVersion < MIN_SERVER_VER_MARKET_CAP_PRICE) {
434 decodeInt(fields) // version
435 }
436 const orderId = decodeInt(fields)
437 const status = decodeStr(fields)
438 const filled = decodeDecimal(fields)
439 const remaining = decodeDecimal(fields)
440 const avgFillPrice = decodeFloat(fields)
441
442 const permId = decodeInt(fields) // ver 2
443 const parentId = decodeInt(fields) // ver 3
444 const lastFillPrice = decodeFloat(fields) // ver 4
445 const clientId = decodeInt(fields) // ver 5
446 const whyHeld = decodeStr(fields) // ver 6
447
448 let mktCapPrice = 0
449 if (d.serverVersion >= MIN_SERVER_VER_MARKET_CAP_PRICE) {
450 mktCapPrice = decodeFloat(fields)
451 }
452
453 d.wrapper.orderStatus(
454 orderId, status, filled, remaining, avgFillPrice,
455 permId, parentId, lastFillPrice, clientId, whyHeld,
456 mktCapPrice,
457 )
458 })
459
460 // -----------------------------------------------------------------------
461 // IN.ORDER_STATUS (3) — protobuf
462 // -----------------------------------------------------------------------
463 decoder.registerProto(IN.ORDER_STATUS, (d, buf) => {
464 const proto = OrderStatusProto.decode(buf)
465
466 const orderId = proto.orderId ?? UNSET_INTEGER
467 const status = proto.status ?? ''
468 const filled = proto.filled !== undefined
469 ? new Decimal(proto.filled)
470 : UNSET_DECIMAL
471 const remaining = proto.remaining !== undefined
472 ? new Decimal(proto.remaining)
473 : UNSET_DECIMAL
474 const avgFillPrice = proto.avgFillPrice ?? UNSET_DOUBLE
475 const permId = proto.permId ?? UNSET_INTEGER
476 const parentId = proto.parentId ?? UNSET_INTEGER
477 const lastFillPrice = proto.lastFillPrice ?? UNSET_DOUBLE
478 const clientId = proto.clientId ?? UNSET_INTEGER
479 const whyHeld = proto.whyHeld ?? ''
480 const mktCapPrice = proto.mktCapPrice ?? UNSET_DOUBLE
481
482 d.wrapper.orderStatus(
483 orderId, status, filled, remaining, avgFillPrice,
484 permId, parentId, lastFillPrice, clientId, whyHeld,

Callers 1

applyAllHandlersFunction · 0.85

Calls 15

decodeOrderIdMethod · 0.95
decodeContractFieldsMethod · 0.95
decodeActionMethod · 0.95
decodeTotalQuantityMethod · 0.95
decodeOrderTypeMethod · 0.95
decodeLmtPriceMethod · 0.95
decodeAuxPriceMethod · 0.95
decodeTIFMethod · 0.95
decodeOcaGroupMethod · 0.95
decodeAccountMethod · 0.95
decodeOpenCloseMethod · 0.95
decodeOriginMethod · 0.95

Tested by

no test coverage detected