Voyz / ibind

IBind is a REST and WebSocket client library for Interactive Brokers Client Portal Web API.
Apache License 2.0
91 stars 11 forks source link

incomplete implementation of live_marketdata_snapshot() ? #1

Closed Harald-F closed 4 months ago

Harald-F commented 4 months ago

Hi Voyz, amazing work you are doing here. After getting iBeam to work, i started to play with iBind. I succeeded several API calls, but not live_marketdata_snapshot(). It always returns with an Error 500.

Now I looked into your code. Isn't this function supposed to call /iserver/marketdata/snapshot? Yours calls iserver/secdef/search. While this must be possibly called as pre-flight call (for derivatives), to me it looks this function is not complete. There is also a mandatory pre-flight call for /iserver/accounts.

Let me know if this makes sense...

Voyz commented 4 months ago

Hey @HaSiMiPa, thank you for checking out IBind and creating the first Issue on this repo! πŸ₯³

Here's a celebratory GIF of a happy sheep for you:

happy-sheep

Many thanks for bringing that endpoint into my attention - must have gotten corrupted by accident at some point.

I've just released v0.1.1 with a fix - let me know if it works for you πŸ‘

Harald-F commented 4 months ago

thanks for the quick fix. After fixing my additional mistake by putting the arguments in list form, it seems to work. Thanks a lot!

Voyz commented 4 months ago

Glad to hear it worked πŸ‘

As for the mistake you mention - could you clarify it briefly? The live_marketdata_snapshot indeed expects a list of arguments. These then get merged together in the following fashion:

params = {
    'conids': ','.join(conids),
    'fields': ','.join(fields)
}

What was the issue you were experiencing?

Harald-F commented 4 months ago

I just put e.g. '31' as argument with missing quare brackets, instead of correctly ['31'] or ['31, ''80]. '31' resulted in a parameter like '3,1'

Voyz commented 4 months ago

Ahh, that's a bug too! Thanks for telling me this. The interface in fact supports providing both lists and single arguments. That endpoint was missing that functionality by accident. So yeah, thank you πŸ‘

akshayaradhya commented 4 months ago

@HaSiMiPa Would you mind sharing how you filter for required options from a ticker?

Harald-F commented 4 months ago

@akshayaradhya I don't fuly understand your question. If you ask for an example of the live_marketdata_snapshot(), here is a simple one: client.live_marketdata_snapshot('265598', ['31','55']).data Output below. 265598 is the conid for AAPL, 31 is the code for last price, 55 the ticker. You find the codes in the API manual or in the definition file.

{'55': 'AAPL',
  '6509': 'D',
  'conidEx': '265598',
  'conid': 265598,
  '_updated': 1716588856195,
  '6119': 'q0',
  'server_id': 'q0',
  '31': '189.99',
akshayaradhya commented 4 months ago

@HaSiMiPa This is for getting a snapshot. What I needed was, given a ticker - example AAPL, I want to first pull it’s conID (this is easy), after this I want to look for at the money options with same day expiry. And then, I would to find out the conID of a suitable option so I can subscribe to its data

Voyz commented 4 months ago

@HaSiMiPa thanks for your example! πŸ‘ @akshayaradhya please see my reply in https://github.com/Voyz/ibind/issues/3 regarding the options chain example, hope it helps

Harald-F commented 4 months ago

@akshayaradhya I see. I missunderstood and thought you we asking for options as function parameters :-) I am not trading options, so cannot help here. But Voyz has kindly provided an example already.