Questions tagged [tws]

Trader Work-Station (TWS) API from Interactive Brokers

183 questions
0
votes
1 answer

Using TWS API to get unrealised PnL of all subaccounts

I am trying to find the unrealised PnL of all the subaccounts in Interactive Brokers. As this is my first time using the TWS API, I am not sure what I am doing wrong. After reading through the API documentation, the reqPnL method on the EClient…
codelearner
  • 173
  • 8
0
votes
0 answers

Python IBKR twsapi reqcontractDetails return value

I am trying to return contractDetails.contract.primaryExchange to my contract object. I am isolating the string without problems but I am unable to se it outside of the definition. def contractDetails(self, reqId, contractDetails): …
BTT
  • 17
  • 4
0
votes
0 answers

How to define functions in TWS API (ib-api) using Python to avoid code duplication?

I want to create multiple orders to close my positions at the end of trading session. Below is one of the orders. This code is repeated multiple times (with the number "1" just replaced with different numbers). Can someone please suggest how to code…
0
votes
1 answer

TWS API frezee when receiving errors

I am writing a service to work through the TWS API based on the Python language. Faced a problem when getting historical data. The bottom line is that when you request app.reqHistoricalData() with the correct parameters, the script runs without…
Eldellano
  • 5
  • 2
0
votes
1 answer

TWS-API and ib_insync: Order Status is not updated properly

I'm trying to place an order using the TWS-API and the python package ib_insync. However, I recognize that the order status is not updated by TWS automatically. Please consider the following snippet: stock = Stock('BMW', 'SMART',…
0
votes
1 answer

Set Alerts on Indicators (Interactive Brokers Api)

Is it possible to access real time computed values of Indicators , inorder to set Alerts on them (eg. Stochastic D-K crossover)? The available Tick types (link) provided in Tws-api doesn't mention any way to access them.
srt111
  • 1,079
  • 11
  • 20
0
votes
1 answer

TWS API problem with dispinterface in Delphi

I'm writing a simple program in Delphi7 that uses a unit written by someone else (IB TWS API 9.71), and I can't handle passing values from that unit to my program. In the opposite direction, everything works without problems. Here is a piece of…
keymaker
  • 9
  • 2
0
votes
1 answer

Python - TWS Api reqMktData of options with delayed mkt data

I am trying to quote some options using reqMktData using the delayed data type. I keep receiving: Error 200, reqId 108: No security definition has been found for the request, contract: Contract(secType='OPT', symbol='qqq',…
0
votes
1 answer

TWS API reqScannerSubscription fails with std::bad_alloc

I’m using TWS API in a C++ implementation. I’m getting a bad memory allocation exception when running a market scanner. The code is designed to connect and then start a couple market scanners. Driver const unsigned MAX_ATTEMPTS = 50; const…
0
votes
1 answer

TWS API Python: How to extract API response into a variable (New version)

I am a beginner user of the TWS API for Python and I have been trying to store the information provided by the API response into a variable. For example, saving the lows of the day of a stock at a given time, to use it as the auxiliar price of a…
VV33
  • 11
  • 2
0
votes
1 answer

How to set and apply offset to parent order setting in bracket order for Interactive brokers python api?

From TWS, I can place a bracket order where I can place the takeprofit and stoploss order with a setting "apply offset to parent order". How do one apply same setting "apply offset to parent order" from python API while placing bracket order? My…
Ganesh S
  • 371
  • 6
  • 26
0
votes
1 answer

Can you tell whether market data is delayed in TWS API?

I've enabled delayed market data, using: ibClient.ClientSocket.reqMarketDataType(4); But then some of my market data will be delayed, and some will not be. Is there any way of telling which are delayed (and ideally by how much)?
Ben
  • 3
  • 3
0
votes
1 answer

how to get a open order or filled order's orderId with IB API?

I generated my trade system with IB API and C#. I'm wondering whether is there a function to get the open/filled orders' orderId?
David
  • 17
  • 3
0
votes
1 answer

IBKR TWS API - How to tell when reqOptionsMktData is complete for all strikes?

I am just getting started with IBKR API on Java. I am following the API sample code, specifically the options chain example, to figure out how to get options chains for specific stocks. The example works well for this, but I have one question - how…
h_k
  • 1,674
  • 1
  • 24
  • 46
0
votes
1 answer

Why can't I print the quantity of stock held using (IBKR's TWS) ib-api positions function? (partly solved)

I am trying to use the quantity of a particular stock held as a variable. My relevant code is: def position(self, account, contract, position, avgCost): super().position(account, contract, position, avgCost) print(contract,…