-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unprocessed Data #203
Comments
Same for me. Order in paper mode: orderType: ibOrderType.MKT,
orderId: IBTransport.getReqId(),
totalQuantity: pendingOrder.lots,
action,
tif: TimeInForce.IOC,
transmit: true, Fix via: #208 |
Hello, |
I am also getting the error on version 1.3.19 in the following code snippet: createOrder(req: any) {
const options = req.body.options;
// Preparing the contract based on request options
let contract: Contract;
if (options.secId) {
// If secType is FIGI, use this specific contract definition
contract = {
secIdType: "FIGI",
secId: options.secId,
exchange: options.exchange,
};
} else {
// Default contract definition for other secTypes
contract = {
symbol: options.symbol,
exchange: options.exchange,
currency: options.currency,
secType: this.getSecType(req),
};
}
// Handling specific contract attributes based on secType
if (contract.secType === "STK" && options.primaryExch) {
contract.primaryExch = options.primaryExch;
}
// Futures
if (contract.secType === "FUT" && options.lastTradeDateOrContractMonth) {
contract.lastTradeDateOrContractMonth =
options.lastTradeDateOrContractMonth;
}
if (contract.secType === "FUT" && options.localSymbol) {
contract.localSymbol = options.localSymbol;
}
if (contract.secType === "FUT" && options.multiplier) {
contract.multiplier = options.multiplier;
}
// Single order
const singleOrder: Order = {
orderId: this.nextOrderId++,
action:
options.orderAction === "BUY" ? OrderAction.BUY : OrderAction.SELL,
orderType: this.getOrderType(req),
totalQuantity: options.quantity,
lmtPrice: options.orderType === "LMT" ? options.lmtPrice : undefined,
auxPrice: options.orderType.startsWith("STP")
? options.auxPrice
: undefined,
account: this.account,
transmit: true,
tif: options.tif,
};
// Placing the single order
this.ib.placeOrder(singleOrder.orderId!, contract, singleOrder);
winston.log("info", `Order placed with ID: ${singleOrder.orderId}`);
} When sending this: {
"bracketOrder": false,
"options": {
"orderAction": "BUY",
"symbol": "SPY",
"exchange": "SMART",
"lmtPrice": 1,
"takeProfitLimitPrice": 1.2,
"stopLossPrice": 0.9,
"currency": "USD",
"quantity": 1.0,
"secType": "STK",
"tif": "GTC",
"orderType": "LMT"
}
} |
Thanks. |
Thank you for answering. It looks like the order id is set correctly and increases with incoming signals. The order is also being placed in TWS, but the error remains. Here is my complete log (I changed the account number):
And the complete implementation (I removed the createBracketOrder()-, getSecType()- and getOrderType()-functions for simplicity): import * as dotenv from "dotenv";
dotenv.config({ path: __dirname + "/.env" });
import {
IBApi,
EventName,
ErrorCode,
Contract,
SecType,
Order,
OrderType,
OrderAction,
} from "@stoqey/ib";
import winston from "../config/winston";
class Broker {
clientId: number;
account: string;
ib: IBApi;
nextOrderId: number;
constructor(_mode: string) {
this.account =
_mode === "LIVE"
? String(process.env.TWS_LIVE_ACCOUNT)
: String(process.env.TWS_PAPER_ACCOUNT);
this.clientId =
_mode === "LIVE"
? Number(process.env.TWS_LIVE_CLIENT_ID)
: Number(process.env.TWS_PAPER_CLIENT_ID);
this.ib = new IBApi({
port:
_mode === "LIVE"
? Number(process.env.TWS_LIVE_PORT)
: Number(process.env.TWS_PAPER_PORT),
});
this.connect();
this.nextOrderId = 0;
this.setupListeners();
}
connect() {
this.ib
.connect(this.clientId)
.on(EventName.connected, () => console.log("Broker connected"));
}
disconnect() {
this.ib.disconnect();
console.log("Broker disconnected");
}
setupListeners() {
this.ib
.on(EventName.nextValidId, (orderId) => {
this.nextOrderId = orderId;
console.log(`Next valid order ID: ${orderId}`);
})
.on(EventName.error, (err: Error, code: ErrorCode, reqId: number) => {
console.error(`Error code ${code} for reqId ${reqId}: ${err.message}`);
})
.on(EventName.orderStatus, (orderId: number, status: string) => {
winston.log("info", `Order ${orderId} status: ${status}`);
if (status === "Submitted" || status === "Filled") {
console.log(`Order ${orderId} processed with status: ${status}`);
}
});
}
createOrder(req: any) {
const options = req.body.options;
// Preparing the contract based on request options
let contract: Contract;
if (options.secId) {
contract = {
secIdType: "FIGI",
secId: options.secId,
exchange: options.exchange,
};
} else {
// Default contract definition for other secTypes
contract = {
symbol: options.symbol,
exchange: options.exchange,
currency: options.currency,
secType: this.getSecType(req),
};
}
// Handling specific contract attributes based on secType
if (contract.secType === "STK" && options.primaryExch) {
contract.primaryExch = options.primaryExch;
}
// Futures
if (contract.secType === "FUT" && options.lastTradeDateOrContractMonth) {
contract.lastTradeDateOrContractMonth =
options.lastTradeDateOrContractMonth;
}
if (contract.secType === "FUT" && options.localSymbol) {
contract.localSymbol = options.localSymbol;
}
if (contract.secType === "FUT" && options.multiplier) {
contract.multiplier = options.multiplier;
}
// Single order
const singleOrder: Order = {
orderId: Number(this.nextOrderId++),
action:
options.orderAction === "BUY" ? OrderAction.BUY : OrderAction.SELL,
orderType: this.getOrderType(req),
totalQuantity: Number(options.quantity),
lmtPrice: options.orderType === "LMT" ? Number(options.lmtPrice) : undefined,
auxPrice: options.orderType.startsWith("STP")
? options.auxPrice
: undefined,
account: this.account,
transmit: true,
tif: options.tif,
};
winston.log('info', 'Contract Data: '+JSON.stringify(contract))
winston.log('info', 'Order Data: '+JSON.stringify(singleOrder))
// Placing the single order
winston.log('info', 'singleOrder.orderId! ' +singleOrder.orderId!)
this.ib.placeOrder(singleOrder.orderId!, contract, singleOrder);
winston.log("info", `Order placed with ID: ${singleOrder.orderId}`);
}
}
module.exports = Broker; |
Hello,
I called |
The error started appearing again (for any orders) after the recent TWS update. |
Could you please confirm which release you are using? |
Module version: "1.3.21" TWS 1.30.0.16 |
What is |
My bad, TWS 10.30.1a Jun 10, 2024 |
Issue Unprocessed Data #203 bug fix (server version >= 177)
The issue is still here :( |
Hello, I have a similar problem since today after I reinstalled my PC and had to do use I am using TWS build 10.29.1h, Jun 5, 2024 10:53:32 PM here is the program output with order and other details aswell:
|
Sorry but once again I can't reproduce the problem:
on TWS If somebody can contact me via PM and give me an access to his API maybe I would be able to reproduce this bug. |
The order above shows |
Thanks for your report.
Could you maybe provide some more information about the exec env: OS, arch, Node release, IB GW or TWS release number, ... also I am available for a joint debug session on your environment. |
My test env: 64-bit Windows 10, Intel CPU, NodeJS v20.12.2, TWS Build 10.30.1j |
I have the same issue both on live and paper mode. happens on gateway and TWS
|
Hi everyone,
Getting this error: Error: Decoding error on OPEN_ORDER: unprocessed data left on queue (["","","","",null]).
How can I debug this?
The text was updated successfully, but these errors were encountered: