Questions tagged [tws]

Trader Work-Station (TWS) API from Interactive Brokers

183 questions
0
votes
1 answer

Running reqHisorical data and updating csv file day during the day uninteruppted

Im at the beginning of the learing curve. Already have req historical data downloading req historical data in csv file. I want to keep this process running in the background, updating my historical data in CsV every minute. I would like it to run…
Zostrak
  • 1
  • 1
0
votes
0 answers

Should reqHistoricalTicks ever return 0 ticks if there are more left in the session?

I'm using app.reqHistoricalTicks() to fetch tick data. I sleep 10 seconds in between requests to satisfy restrictions and send another request based on the second of the last tick returned in the previous record set. This works great for Jan & Feb…
Coder1
  • 13,139
  • 15
  • 59
  • 89
0
votes
1 answer

Getting "ImportError: cannot import name ..." when importing variable from other script

I'm using python to connect to TWS API and pull values. My first script: #use option chain csv to get prics from datetime import datetime from threading import Thread import time from ibapi.client import EClient, Contract from ibapi.wrapper import…
Mitch
  • 553
  • 1
  • 9
  • 24
0
votes
1 answer

Interactive Brokers TWS: How to handle daily restart in python?

I've built an IB TWS application in python. All seems to work fine, but I'm struggling with one last element. TWS requires a daily logout or restart. I've opted for the daily restart at a set time so I could easily anticipate a restart of my…
Joris416
  • 4,751
  • 5
  • 32
  • 59
0
votes
1 answer

Unable to Retrieve Account Summary details from IBKR

This is my code: class TestApp(EWrapper, EClient): def __init__(self): EClient.__init__(self, self) self.nextOrderID = 0 # if this is init code put it in init def Error(self, reqID, errorCode, errorString): …
ComputerBoi
  • 37
  • 1
  • 1
  • 7
0
votes
2 answers

Stacked data using python IB API

I am downloading 15Y of data (daily close) for 5 stocks ('A','AAP','AAPL','ABBV','ABC'). The issue is that I got some repetitions. No issue for the first one ,'A', I got the right amount of data. For the second one,'AAP', I have twice the right…
Sara Mun
  • 73
  • 7
0
votes
0 answers

TWS-API Need help for connection and data fetch

I am an utter noob and need help. I managed to fetch options chain of a particular symbol and expiry from NSE, extracted it to excel. But I thought it would be better if I can use TWS API. Problem: Want to fetch normal data like Option chain for…
Comp1810
  • 11
  • 3
0
votes
0 answers

How to append to DataFrame inside function and return changes outside the function

I have a python script that creates a DataFrame df, conencts to an API, and appends data to the DataFrame in a function. However the dataframe is empty outside of the function. The function is "get_stock_price(client, ticker, option_dates,…
Mitch
  • 553
  • 1
  • 9
  • 24
0
votes
2 answers

Cannot connect to TWS using IBrokers with R

The output of my code: library(IBrokers) tws <- twsConnect(port=7496) Error in socketConnection(host = host, port = port, open = "ab", blocking = blocking) : cannot open the connection In addition: Warning message: In socketConnection(host =…
0
votes
1 answer

API IB TWS Python Bracket Problems

The order gets placed into tws but on activation it just cancels itself and the attached stop and target. Leaving me with no orders no pos. Is this because of the way I am attaching the parent and not setting transmit to false until target? I was…
0
votes
1 answer

IBapi want to read and use the error code generated in IBapi class

i am new to python and TWS API , my problem is that i want to use the error id which is generated with Error. Id: 441 Code: 200 Msg: No security definition has been found for the request although it is displayed in the terminal but i am not able to…
0
votes
1 answer

IB API: error when requesting historical data which don't exist

I get stuck in a sort of infinite loop when I am trying to get historical data on a contract for which there is no historical data. In the code below I am trying to get historical data on a single stock option for 3 strikes and one expiry. The…
Sara Mun
  • 73
  • 7
0
votes
1 answer

Error 201 interactive brokers tws while placing options order

I am trying to place an option order through TWS on a demo account. I followed the tutorial, but when I run the code, it gives me error 201, "The account number is invalid or is missing". I have spent some time trying to fix it but can't seem to…
user5631938
0
votes
1 answer

How to return specific results from class

I have a class "contractDetails" that I am printing. I want to get a specific result from it (the 5th element). Here is the code: from ibapi.client import EClient from ibapi.wrapper import EWrapper from ibapi.common import * from ibapi.contract…
Mitch
  • 553
  • 1
  • 9
  • 24
0
votes
2 answers

TWS IB Gateway (version 972/974) Client keeps disconnecting

I am trying to connect with IB Api to download some historical data. I have noticed that my client connects to the API, but then disconnects automatically in a very small period (~a few seconds). Here's the log in the server: socket connection for…
Amit Gupta
  • 451
  • 5
  • 18