areed1192 / interactive-broker-python-api

A python packaged used to interact with the Interactive Brokers REST API.
MIT License
374 stars 122 forks source link

api for BONDS ? #17

Closed AshiHarel closed 3 years ago

AshiHarel commented 3 years ago

Hi, I am trying to get BONDS info using this api with no success:

  1. When preforming symbol_search for symbols I get items restricted as BONDS for example with symbol MNSB: Return object: [ {...}, { "issuers": [ { "id": "e3298009", "name": "MainStreet Bank" } ], "conid": 2147483647, "companyHeader": "MainStreet Bank", "companyName": "None", "symbol": "MNSB", "description": "None", "restricted": "BOND", "fop": "None", "opt": "None", "war": "None", "sections": [ { "secType": "BOND" } ] } ]

But I failed to use the object values to receive usable data about the bond. The conid: 2147483647 is the same one for all bonds in IB so no success..

  1. In TWS api - https://interactivebrokers.github.io/tws-api/basic_contracts.html#Bonds Bond api is documented but is not mentioned in the our limited api - https://interactivebrokers.com/api/doc.html
    I did try to use to get bonds info using the CONTRACT endpoint, for example using CUSIP as symbol (as mentioned in TWS api), but with no luck.

Am I missing something? Appreciate any help I can get!

Thanks, Ashi

AshiHarel commented 3 years ago

I managed to solved this issue myself, with the following request: https://localhost:5000/v1/api/iserver/secdef/info?conid=037833100&sectype=BOND&issuerId=e1432232&symbol=AAPL

conid=037833100 -is AAPL CUSIP, I just googled it. sectype=BOND, issuerId=e1432232 are taken from https://localhost:5000/v1/api/iserver/secdef/search request symbol=AAPL is needed as well.

Hope this helps others. Please advise if you would like a pull request to be made with this url request.

Matb85 commented 12 months ago

Hi @AshiHarel, A rookie question, do you happen to know how to get the price of the bond? When I try to get "the contract info", I do get a lot of fields, but there isn't anything like a "price" fields. Thank you in advance!

Screenshot 2023-07-10 at 12 24 41