reqMatchingSymbols does not show the warrant problem
Hi guys,
I try to use the?IBApi::EClient::reqMatchingSymbols?-?IBApi::EWrapper::symbolSamples pair to search for whether there is any warrant for a given stock ticker. For example in the case of 'ACAH' if I search for it using the IBKR contract and security search on the web I can see that there are two 'Stock' type? item and a 'Warrants' type item with Conids:?484239734,?474641211 and?484239792 (warrant) respectively. However if I search using ?IBApi::EClient::reqMatchingSymbols I can only see the following response in gateway:?
484239734-ACAH-STK-NASDAQ.SCM-USD-1-WAR-474641211-ACAHU-STK-NASDAQ.SCM-USD-0-489363740-ACAH.SEP-STK-CORPACT-USD-0- which does not show the warrant's Conid (but interestingly it shows another additional Conid - which is not a warrant). Would you mind giving a hint how can I find out the warrants's Conid (if there is any) knowing only the stock ticker? Any help appreciated. Thanks
?
|
Re: Commission report never called back.
Are you sure your ITradeReportHandler class does process commissionReport() callbacks? Yeah, I set a breakpoint inside the method and it never gets called. My TWS is 972.1v. tradeReport is called just fine though. I'm going to assume that commissionReport ought to be called prior to tradeReportEnd(). Semaphore barrier = new Semaphore(0); Map<String, SingleExecution> result = new HashMap<>(); ibCon.reqExecutions(new ExecutionFilter() { }, new ITradeReportHandler() { @Override public void tradeReport(String tradeKey, Contract contract, Execution execution) { result.computeIfAbsent(tradeKey, k -> new SingleExecution()).set(tradeKey, contract, execution); } @Override public void commissionReport(String tradeKey, CommissionReport commissionReport) { result.computeIfAbsent(tradeKey, k -> new SingleExecution()).set(commissionReport); } @Override public void tradeReportEnd() { barrier.release(); } }); barrier.acquire(); I suppose if you're getting called back reliably, then that gives me hope that it's me and not them and I can sort it out. Cheers, G. On Mon, 26 Jul 2021 15:22:23 -0700 "JR" <TwsApiOnGroupsIo@...> wrote: We use (a pimped version) of ApiController as well, but trade and commission reports come in reliably. That is true both for historical executions (if there are some) the client receives right after reqExecutions() as well as executions caused by client order activities later on/
We are on API 9.81.01 (MAX_VERSION 157) and TWS 981.2w but I don't recall any issues with 9.76.01.
JR
On Mon, Jul 26, 2021 at 02:54 PM, Graham Bygrave wrote:
Hey,
I'm never getting called back with any commission reports when I request a list of executions from the TWS client.
I call: ApiController.reqExecutions(new ExecutionFilter(), new ITradeReportHandler() {...})
I get my tradeReport method called back just fine, but I never get my comissionReport called back and I want to see the commissions to cross check against my own figures.
How come I don't get called back?
API_Version=9.76.01
Cheers, G.
|
Re: Commission report never called back.
We use (a pimped version) of ApiController as well, but trade and commission reports come in reliably. That is true both for historical executions (if there are some) the client receives right after reqExecutions() as well as executions caused by client order activities later on/
We are on API 9.81.01 (MAX_VERSION 157) and TWS 981.2w but I don't recall any issues with 9.76.01.
Are you sure your ITradeReportHandler class does process commissionReport() callbacks?
JR
toggle quoted message
Show quoted text
On Mon, Jul 26, 2021 at 02:54 PM, Graham Bygrave wrote:
Hey,
?
I'm never getting called back with any commission reports when I request a list of executions from the TWS client.
?
I call: ApiController.reqExecutions(new ExecutionFilter(), new ITradeReportHandler() {...})
?
I get my tradeReport method called back just fine, but I never get my comissionReport called back and I want to see the commissions to cross check against my own figures.
?
How come I don't get called back?
?
API_Version=9.76.01
?
Cheers,
G.
?
|
Commission report never called back.
Hey,
I'm never getting called back with any commission reports when I request a list of executions from the TWS client.
I call: ApiController.reqExecutions(new ExecutionFilter(), new ITradeReportHandler() {...})
I get my tradeReport method called back just fine, but I never get my comissionReport called back and I want to see the commissions to cross check against my own figures.
How come I don't get called back?
API_Version=9.76.01
Cheers, G.
|
Re: Insufficient memory when trying to start TWS on headless remote machine
A little update. I contacted IB support about this. You probably would guess, that the answers are not very helpful. And you'd be right
I have been told, that I should install on a real machine (because they are not sure it works in a virtual machine) and that I should increase RAM until the system requirements are met.?Thank you very much :-D
When I find the time, I'll start over with ib-container, which Hartmut suggested. If until then I solve my current problem, I'll let you know what the solution was
Sandro
|
Re: reqSecDefOptParams() hangs for some futures symbols but not others.
So as to not abuse this list, for any interested in using Racket IBKRE please feel free to contact me off list.? My email is at the top of the mini-tutorial that starts with getting positions and account navs:
If there is enough demand I will create a Discord or IRC to be able to quickly answer any questions.
There is a TON of doc for the Racket Universe and please do not be scared of a Lisp.? If you can deal with Python, you can deal with Racket without issue.
The jumping off point is the language home page: In the upper right of the home page there is a link regarding some new Racket books.? Some are online and free .
The Racket language and library documentation is extensive: the two core docs are the Guide and the Reference along with tutorials, getting started guide etc. The home page for the documentation is:
The Getting Started: The Guide:
Depending on your programming experience scanning through the Getting Started and the Guide should be adequate.? For new programmers one of the books may be an easier on-ramp.? I can't really recommend one over the other.
Racket comes with its own built-in in IDE (or you can use your editor of choice).? But the Emacs racket-mode and the IDE itself are really nice. If you are a novice programmer the IDE is a godsend and will really help you out.
I'd say the signature capability of Racket is the ability to define your own languages and DSLs in Racket.? Like DotNet, DSLs, Languages and Racket can all interact and work together.? My IBKRE library is based on the outstanding Actor library called Syndicate by Tony G.??
Syndicate is far more than an Actor Library, but for doing basic IBK API stuff in the beginning you won't need much more.?? Defining and using Actors in Syndicate is the same basic pattern over and over.? Once you do a couple it is almost brainless.
Syndicate itself is a DSL in Racket.? I mention this because as you read the Racket doc you won't see much Syndicate stuff.? You need to go to the Syndicate doc.?? But you can say code up some Pivot Point logic in Racket and have an IBKRE Actor use the Pivot Point logic in a Marketdata fetching Actor without any problem.
To repeat, as to not abuse this list, please feel free to contact me off list.
toggle quoted message
Show quoted text
ray is a simple?racket getting started guide for python devs and no knowledge of ?lisp ?
I apologize ahead of time for the blurb.? One time happening out of respect for the list.? But since someone asked ...
This is the Interactive Brokers Reactive Engine, aka IBKRE.?
Scroll down and at least read the description of the first code example.
Given a list of stocks and exchanges, get the con-id for each stock, for each stock/exchange combo get the possible strikes (the option chains via the infamous Sec Def Params API), and finally to verify the option chains invokes contract details for filter the possible option chain from Sef Def Params to the actual valid available options. Oh and all while this is going on it is also getting market data for open, close, last, volume, implied volatilities or whatever.
This is A LOT of API calls.? The key point of this example is to show how IBKRE is performing all of this stuff concurrently, all at the same time.? It will run through 100s even 1000s of option chains in a reasonable period of time (constrained by IBK's API rate limits).? CAVEAT: This example has an "api rate limiter" in the code that has a bug as I was in the middle of changing to another approach.?
About Racket:
While it is Lisp, it is in Racket (a variant) and not Common Lisp or Scheme.? Frankly it is probably one of the best languages out there.? It has been around for a long time and has a very stable core of maintainers, many of them professors, grad students, academics, hardcore developers.? One of the core leaders won the Turing Award from CS (the Nobel Prize of CS) a few years back partly for Racket. It is very stable, maintained and active.? It is not a one man fly-by-night hobby language by any means.
Racket Highlights:
- Native compilation like C or Java granting decent performance.
- High level like Python or Ruby. - Cross platform.? Runs on Mac, Linux, Windows, ARM (Raspberry Pi). - Pretty decent GUI set for graphical programs that runs cross platform as well.? i.e. Your graphics gui programs, plots etc will run on Mac, Linux and Windows. - Bug reports are addressed very quickly with pretty much immediate turn around. - Robust plotting library for graphs and charts.
About the IBKRE Library.
My first iteration took a standard approach to concurrency using async code, futures, thread queues, CML constructs, condition variables etc.? And while it worked OK I found I was spending too much time dealing with machinery and not enough time with my stock trading logic. The IBKRE is a Actor based approach that personally I think has been the perfect fit for working with the IBK API and is MUCH easier to use.
Library Caveats:
- Alpha / Early Beta code. - Some aspects of the library have not seen widespread code use so may have an issue here or there. - I have deliberately NOT added any of the code for order placement at this time.? (Soon)? I did not want someone placing orders and having it go wrong for them on my karma balance until things were shaken down.
I do use it all the time and someone can expect a quick fix for any bug etc.
ray what library is this?
?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 371749798)) ?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 383974339)) does not?look like python is it lisp? and if so how do ?you access twsapi via lisp?
For both calls:
?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 371749798)) ?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 383974339))
Seeing normal msg response in the sense of a series of 75 msg, followed by a 76.? The Sec Def Opt Param and Sec Def Opt Param End msgs.? No obvious difference in the data returned with regard to formatting.
Note I am not utilizing the Python lib, but invoking the API via a different library.? So from the API req/rsp msg layer seems ok on the surface as of time of writing.
When calling reqSecDefOptParams() on ES futures, it's possible to see it inexplicably hang.
Given the call:
- reqSecDefOptParamsAsync(**{'underlyingSymbol': 'ES', 'futFopExchange': 'GLOBEX', 'underlyingSecType': 'FUT', 'underlyingConId': 371749798})
Where the conId is for ESU0, the call will hang, however given the call:
- reqSecDefOptParamsAsync(**{'underlyingSymbol': 'ES', 'futFopExchange': 'GLOBEX', 'underlyingSecType': 'FUT', 'underlyingConId': 383974339})
Where the conId is for ESZ0, the call returns data as expected.
I'm using ib_insync, but this doesn't appear to be a bug with that library
Additionally when calling it for ESZ0, only some expiries are not being returned. I can see dates in the TWS option chain that do not show up in the API response.
Has anyone played with this before?
I know about the reqContractDetails() approach, but that is good for 1 option chain call seemingly per minute. For ES it returns 11000 rows
|
Re: reqSecDefOptParams() hangs for some futures symbols but not others.
ray is a simple?racket getting started guide for python devs and no knowledge of ?lisp ?
toggle quoted message
Show quoted text
I apologize ahead of time for the blurb.? One time happening out of respect for the list.? But since someone asked ...
This is the Interactive Brokers Reactive Engine, aka IBKRE.?
Found here:
It has a couple of examples here:
There is a brief, rough draft "tutorial" (with a bunch of typos), on how to use IBKRE.? Check it out!! : Scroll down and at least read the description of the first code example.
Here is another example for some code invoking market data, getting con ids, option chains via Sec Def Parameters, etc found here:
Given a list of stocks and exchanges, get the con-id for each stock, for each stock/exchange combo get the possible strikes (the option chains via the infamous Sec Def Params API), and finally to verify the option chains invokes contract details for filter the possible option chain from Sef Def Params to the actual valid available options. Oh and all while this is going on it is also getting market data for open, close, last, volume, implied volatilities or whatever.
This is A LOT of API calls.? The key point of this example is to show how IBKRE is performing all of this stuff concurrently, all at the same time.? It will run through 100s even 1000s of option chains in a reasonable period of time (constrained by IBK's API rate limits).? CAVEAT: This example has an "api rate limiter" in the code that has a bug as I was in the middle of changing to another approach.?
About Racket:
While it is Lisp, it is in Racket (a variant) and not Common Lisp or Scheme.? Frankly it is probably one of the best languages out there.? It has been around for a long time and has a very stable core of maintainers, many of them professors, grad students, academics, hardcore developers.? One of the core leaders won the Turing Award from CS (the Nobel Prize of CS) a few years back partly for Racket. It is very stable, maintained and active.? It is not a one man fly-by-night hobby language by any means.
You can read all about Racket here:
Racket Highlights:
- AMAZINGLY well documented. See - Native compilation like C or Java granting decent performance.
- High level like Python or Ruby. - Cross platform.? Runs on Mac, Linux, Windows, ARM (Raspberry Pi). - Pretty decent GUI set for graphical programs that runs cross platform as well.? i.e. Your graphics gui programs, plots etc will run on Mac, Linux and Windows. - Bug reports are addressed very quickly with pretty much immediate turn around. - Robust plotting library for graphs and charts. - Batteries included core of libraries found here:
About the IBKRE Library.
My first iteration took a standard approach to concurrency using async code, futures, thread queues, CML constructs, condition variables etc.? And while it worked OK I found I was spending too much time dealing with machinery and not enough time with my stock trading logic. The IBKRE is a Actor based approach that personally I think has been the perfect fit for working with the IBK API and is MUCH easier to use.
Library Caveats:
- Alpha / Early Beta code. - Some aspects of the library have not seen widespread code use so may have an issue here or there. - I have deliberately NOT added any of the code for order placement at this time.? (Soon)? I did not want someone placing orders and having it go wrong for them on my karma balance until things were shaken down.
I do use it all the time and someone can expect a quick fix for any bug etc.
ray what library is this?
?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 371749798)) ?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 383974339)) does not?look like python is it lisp? and if so how do ?you access twsapi via lisp?
For both calls:
?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 371749798)) ?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 383974339))
Seeing normal msg response in the sense of a series of 75 msg, followed by a 76.? The Sec Def Opt Param and Sec Def Opt Param End msgs.? No obvious difference in the data returned with regard to formatting.
Note I am not utilizing the Python lib, but invoking the API via a different library.? So from the API req/rsp msg layer seems ok on the surface as of time of writing.
When calling reqSecDefOptParams() on ES futures, it's possible to see it inexplicably hang.
Given the call:
- reqSecDefOptParamsAsync(**{'underlyingSymbol': 'ES', 'futFopExchange': 'GLOBEX', 'underlyingSecType': 'FUT', 'underlyingConId': 371749798})
Where the conId is for ESU0, the call will hang, however given the call:
- reqSecDefOptParamsAsync(**{'underlyingSymbol': 'ES', 'futFopExchange': 'GLOBEX', 'underlyingSecType': 'FUT', 'underlyingConId': 383974339})
Where the conId is for ESZ0, the call returns data as expected.
I'm using ib_insync, but this doesn't appear to be a bug with that library
Additionally when calling it for ESZ0, only some expiries are not being returned. I can see dates in the TWS option chain that do not show up in the API response.
Has anyone played with this before?
I know about the reqContractDetails() approach, but that is good for 1 option chain call seemingly per minute. For ES it returns 11000 rows
|
Re: reqSecDefOptParams() hangs for some futures symbols but not others.
thanks?ray will start using immediately? i was wondering if you have ibkr tws v 972 windows or mac available? for download?if so do you mind sharing it please
toggle quoted message
Show quoted text
I apologize ahead of time for the blurb.? One time happening out of respect for the list.? But since someone asked ...
This is the Interactive Brokers Reactive Engine, aka IBKRE.?
Found here:
It has a couple of examples here:
There is a brief, rough draft "tutorial" (with a bunch of typos), on how to use IBKRE.? Check it out!! : Scroll down and at least read the description of the first code example.
Here is another example for some code invoking market data, getting con ids, option chains via Sec Def Parameters, etc found here:
Given a list of stocks and exchanges, get the con-id for each stock, for each stock/exchange combo get the possible strikes (the option chains via the infamous Sec Def Params API), and finally to verify the option chains invokes contract details for filter the possible option chain from Sef Def Params to the actual valid available options. Oh and all while this is going on it is also getting market data for open, close, last, volume, implied volatilities or whatever.
This is A LOT of API calls.? The key point of this example is to show how IBKRE is performing all of this stuff concurrently, all at the same time.? It will run through 100s even 1000s of option chains in a reasonable period of time (constrained by IBK's API rate limits).? CAVEAT: This example has an "api rate limiter" in the code that has a bug as I was in the middle of changing to another approach.?
About Racket:
While it is Lisp, it is in Racket (a variant) and not Common Lisp or Scheme.? Frankly it is probably one of the best languages out there.? It has been around for a long time and has a very stable core of maintainers, many of them professors, grad students, academics, hardcore developers.? One of the core leaders won the Turing Award from CS (the Nobel Prize of CS) a few years back partly for Racket. It is very stable, maintained and active.? It is not a one man fly-by-night hobby language by any means.
You can read all about Racket here:
Racket Highlights:
- AMAZINGLY well documented. See - Native compilation like C or Java granting decent performance.
- High level like Python or Ruby. - Cross platform.? Runs on Mac, Linux, Windows, ARM (Raspberry Pi). - Pretty decent GUI set for graphical programs that runs cross platform as well.? i.e. Your graphics gui programs, plots etc will run on Mac, Linux and Windows. - Bug reports are addressed very quickly with pretty much immediate turn around. - Robust plotting library for graphs and charts. - Batteries included core of libraries found here:
About the IBKRE Library.
My first iteration took a standard approach to concurrency using async code, futures, thread queues, CML constructs, condition variables etc.? And while it worked OK I found I was spending too much time dealing with machinery and not enough time with my stock trading logic. The IBKRE is a Actor based approach that personally I think has been the perfect fit for working with the IBK API and is MUCH easier to use.
Library Caveats:
- Alpha / Early Beta code. - Some aspects of the library have not seen widespread code use so may have an issue here or there. - I have deliberately NOT added any of the code for order placement at this time.? (Soon)? I did not want someone placing orders and having it go wrong for them on my karma balance until things were shaken down.
I do use it all the time and someone can expect a quick fix for any bug etc.
ray what library is this?
?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 371749798)) ?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 383974339)) does not?look like python is it lisp? and if so how do ?you access twsapi via lisp?
For both calls:
?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 371749798)) ?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 383974339))
Seeing normal msg response in the sense of a series of 75 msg, followed by a 76.? The Sec Def Opt Param and Sec Def Opt Param End msgs.? No obvious difference in the data returned with regard to formatting.
Note I am not utilizing the Python lib, but invoking the API via a different library.? So from the API req/rsp msg layer seems ok on the surface as of time of writing.
When calling reqSecDefOptParams() on ES futures, it's possible to see it inexplicably hang.
Given the call:
- reqSecDefOptParamsAsync(**{'underlyingSymbol': 'ES', 'futFopExchange': 'GLOBEX', 'underlyingSecType': 'FUT', 'underlyingConId': 371749798})
Where the conId is for ESU0, the call will hang, however given the call:
- reqSecDefOptParamsAsync(**{'underlyingSymbol': 'ES', 'futFopExchange': 'GLOBEX', 'underlyingSecType': 'FUT', 'underlyingConId': 383974339})
Where the conId is for ESZ0, the call returns data as expected.
I'm using ib_insync, but this doesn't appear to be a bug with that library
Additionally when calling it for ESZ0, only some expiries are not being returned. I can see dates in the TWS option chain that do not show up in the API response.
Has anyone played with this before?
I know about the reqContractDetails() approach, but that is good for 1 option chain call seemingly per minute. For ES it returns 11000 rows
|
ib gateway or tws v 972 mac windows linux
does someone have v 972 from 3 years ago? and doesnt mind sharing it as i m trying to run a piece?of code that works only w 972 thanks much appreciated?
|
Re: Margin for generic orders basket, multiple legs
Hi QuanTrader,
I'm troubled by the same problem (the margin impact of a more complex spread than the supported native ones). Did you find a solution?
|
Re: reqSecDefOptParams() hangs for some futures symbols but not others.
I apologize ahead of time for the blurb.? One time happening out of respect for the list.? But since someone asked ...
This is the Interactive Brokers Reactive Engine, aka IBKRE.?
Found here:
It has a couple of examples here:
There is a brief, rough draft "tutorial" (with a bunch of typos), on how to use IBKRE.? Check it out!! : Scroll down and at least read the description of the first code example.
Here is another example for some code invoking market data, getting con ids, option chains via Sec Def Parameters, etc found here:
Given a list of stocks and exchanges, get the con-id for each stock, for each stock/exchange combo get the possible strikes (the option chains via the infamous Sec Def Params API), and finally to verify the option chains invokes contract details for filter the possible option chain from Sef Def Params to the actual valid available options. Oh and all while this is going on it is also getting market data for open, close, last, volume, implied volatilities or whatever.
This is A LOT of API calls.? The key point of this example is to show how IBKRE is performing all of this stuff concurrently, all at the same time.? It will run through 100s even 1000s of option chains in a reasonable period of time (constrained by IBK's API rate limits).? CAVEAT: This example has an "api rate limiter" in the code that has a bug as I was in the middle of changing to another approach.?
About Racket:
While it is Lisp, it is in Racket (a variant) and not Common Lisp or Scheme.? Frankly it is probably one of the best languages out there.? It has been around for a long time and has a very stable core of maintainers, many of them professors, grad students, academics, hardcore developers.? One of the core leaders won the Turing Award from CS (the Nobel Prize of CS) a few years back partly for Racket. It is very stable, maintained and active.? It is not a one man fly-by-night hobby language by any means.
You can read all about Racket here:
Racket Highlights:
- AMAZINGLY well documented. See - Native compilation like C or Java granting decent performance.
- High level like Python or Ruby. - Cross platform.? Runs on Mac, Linux, Windows, ARM (Raspberry Pi). - Pretty decent GUI set for graphical programs that runs cross platform as well.? i.e. Your graphics gui programs, plots etc will run on Mac, Linux and Windows. - Bug reports are addressed very quickly with pretty much immediate turn around. - Robust plotting library for graphs and charts. - Batteries included core of libraries found here:
About the IBKRE Library.
My first iteration took a standard approach to concurrency using async code, futures, thread queues, CML constructs, condition variables etc.? And while it worked OK I found I was spending too much time dealing with machinery and not enough time with my stock trading logic. The IBKRE is a Actor based approach that personally I think has been the perfect fit for working with the IBK API and is MUCH easier to use.
Library Caveats:
- Alpha / Early Beta code. - Some aspects of the library have not seen widespread code use so may have an issue here or there. - I have deliberately NOT added any of the code for order placement at this time.? (Soon)? I did not want someone placing orders and having it go wrong for them on my karma balance until things were shaken down.
I do use it all the time and someone can expect a quick fix for any bug etc.
toggle quoted message
Show quoted text
ray what library is this?
?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 371749798)) ?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 383974339)) does not?look like python is it lisp? and if so how do ?you access twsapi via lisp?
For both calls:
?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 371749798)) ?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 383974339))
Seeing normal msg response in the sense of a series of 75 msg, followed by a 76.? The Sec Def Opt Param and Sec Def Opt Param End msgs.? No obvious difference in the data returned with regard to formatting.
Note I am not utilizing the Python lib, but invoking the API via a different library.? So from the API req/rsp msg layer seems ok on the surface as of time of writing.
When calling reqSecDefOptParams() on ES futures, it's possible to see it inexplicably hang.
Given the call:
- reqSecDefOptParamsAsync(**{'underlyingSymbol': 'ES', 'futFopExchange': 'GLOBEX', 'underlyingSecType': 'FUT', 'underlyingConId': 371749798})
Where the conId is for ESU0, the call will hang, however given the call:
- reqSecDefOptParamsAsync(**{'underlyingSymbol': 'ES', 'futFopExchange': 'GLOBEX', 'underlyingSecType': 'FUT', 'underlyingConId': 383974339})
Where the conId is for ESZ0, the call returns data as expected.
I'm using ib_insync, but this doesn't appear to be a bug with that library
Additionally when calling it for ESZ0, only some expiries are not being returned. I can see dates in the TWS option chain that do not show up in the API response.
Has anyone played with this before?
I know about the reqContractDetails() approach, but that is good for 1 option chain call seemingly per minute. For ES it returns 11000 rows
|
Re: reqSecDefOptParams() hangs for some futures symbols but not others.
ray what library is this?
?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 371749798)) ?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 383974339)) does not?look like python is it lisp? and if so how do ?you access twsapi via lisp?
toggle quoted message
Show quoted text
For both calls:
?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 371749798)) ?(sec-def-opt-params-req (gen-rid) 'ES "GLOBEX" 'FUT 383974339))
Seeing normal msg response in the sense of a series of 75 msg, followed by a 76.? The Sec Def Opt Param and Sec Def Opt Param End msgs.? No obvious difference in the data returned with regard to formatting.
Note I am not utilizing the Python lib, but invoking the API via a different library.? So from the API req/rsp msg layer seems ok on the surface as of time of writing.
When calling reqSecDefOptParams() on ES futures, it's possible to see it inexplicably hang.
Given the call:
- reqSecDefOptParamsAsync(**{'underlyingSymbol': 'ES', 'futFopExchange': 'GLOBEX', 'underlyingSecType': 'FUT', 'underlyingConId': 371749798})
Where the conId is for ESU0, the call will hang, however given the call:
- reqSecDefOptParamsAsync(**{'underlyingSymbol': 'ES', 'futFopExchange': 'GLOBEX', 'underlyingSecType': 'FUT', 'underlyingConId': 383974339})
Where the conId is for ESZ0, the call returns data as expected.
I'm using ib_insync, but this doesn't appear to be a bug with that library
Additionally when calling it for ESZ0, only some expiries are not being returned. I can see dates in the TWS option chain that do not show up in the API response.
Has anyone played with this before?
I know about the reqContractDetails() approach, but that is good for 1 option chain call seemingly per minute. For ES it returns 11000 rows
|
Re: How can I pull my account value in as an object to help calculate my contract quantity size?
?how can I pull in my account size as a value to help calc the quantity of my contract size?? ?For instance, if I have a $50K account and I want to only risk 5% on any trade, I would like to do something like:?
quantity = np.floor(account value/contract price)?
simply by avoiding using python- Using ib-ruby? you would end with this (using the gateway framework) () u= G.clients.first five_percent = u.account_data_scan( /NetLiquidation$/).value.first.to_f / 5 stock =? IB::Stock.new symbol: 'TSLA' market_price = stock.market_price u.place contract: stock, order: Limit.order( size: (five_percent / market_price).to_i , price: (market_price - 10).round(2), action: :buy) simple, but effective. No spaghetti code anymore, it simply works. hartmut
|
Re: Template for Downloading Historical Options Data to Pandas Dataframe and CSV
Here is a revised version - i deleted the extraneous links to websites that are not needed.
toggle quoted message
Show quoted text
Here is a template to download?Historical Options Data to Pandas Dataframe and CSV.? Enjoy!
import pandas as pd from ibapi.utils import iswrapper from ibapi.client import EClient from ibapi.wrapper import EWrapper # types from ibapi.common import * # @UnusedWildImport from ibapi.contract import * # @UnusedWildImport
class TestApp(EWrapper, EClient): def __init__(self): EWrapper.__init__(self) EClient.__init__(self, wrapper=self) self.data = [] # Initialize variable to store candle self.contract = Contract()
def nextValidId(self, orderId: int): # we can start now self.start()
def start(self): self.historicalDataOperations_req() print("Executing requests ... finished")
def historicalDataOperations_req(self): self.contract.symbol = "TQQQ" self.contract.secType = "OPT" self.contract.exchange = "SMART" self.contract.currency = "USD" self.contract.lastTradeDateOrContractMonth = "20210730" self.contract.strike = 128 self.contract.right = "C" self.contract.multiplier = "100"
self.reqHistoricalData(4103, self.contract, '', "2 D", "1 hour", "MIDPOINT", 1, 1, False, [])
def historicalData(self, reqId: int, bar: BarData): self.data.append([reqId, bar]) #print("HistoricalData. ReqId:", reqId, "BarData.", bar)
df = pd.DataFrame(self.data) print(df) df.to_csv('history.csv') self.disconnect()
def main(): app = TestApp() app.connect("127.0.0.1", port=7497, clientId=102) print("serverVersion:%s connectionTime:%s" % (app.serverVersion(), app.twsConnectionTime())) app.run()
if __name__ == "__main__": main()
|
Re: order - close position by time condition
ok, thank you very much! I'll go over it.
|
Re: order - close position by time condition
I don't do Python and my code heavily relies upon our Java framework. So it won't help you. Looking at your code a few things come to mind:
- the date is missing a colon between minute and second. It should be %H:%M:%S
- there is no Time In Force called 'GAT' it should be 'GTC' (good until canceled)
- I place all four orders into a single list with the three orders that make up the bracket order first and the GAT order last. The transmit flag is false for the first three and true for the last (GAT). All four orders are being placed together.
- I do not manage the OCA group myself and let IB do that
toggle quoted message
Show quoted text
On Sat, Jul 24, 2021 at 11:30 PM, <refael.lasry@...> wrote:
my code (which not working):? "original_order" is the brackets order (LMT + stop loss + take profit)
|
Re: order - close position by time condition
my code (which not working):? "original_order" is the brackets order (LMT + stop loss + take profit)
|
Re: order - close position by time condition
beautiful!
?
In this case, I conclude I might have a problem with my code.?
?
If it's possible from your side to share your code, I'll be thankful (totally understood if not).
|
Re: order - close position by time condition
Does your GAT get rejected when you place the orders? In that case you might want to check your code again, Just tried a bracket plus GAT and it placed without an error or warning (though markets are closed). 
toggle quoted message
Show quoted text
On Sat, Jul 24, 2021 at 04:06 PM, <refael.lasry@...> wrote:
thank you for your precise answer!
?
It took me quite some time to understands what did you mean. Also, GAT order doesn't work with brackets, I have no idea why.?
|
Re: How can I pull my account value in as an object to help calculate my contract quantity size?
Maybe you are looking for something like this:?i
There is a code to get positions and NAVs for your account(s)
|