-
Notifications
You must be signed in to change notification settings - Fork 30
place_order is failing #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, thank you for reporting. I didn't run into this yet. Would you be able to share a minimal code example that demonstrates the issue? |
Sure no problem. Right now away from my computer, but will later create a few lines that can recreate the problem. Not sure relevant, but using a paper trade account for now with oauth and my broker is IBKR Ireland |
hey @jbaron thanks for reporting 👍 IBind should send conid as either str or int, depending on what you provide. Can you share the code you use to place orders? Are you placing it with a string conid? |
from time import sleep
from dotenv import load_dotenv
load_dotenv()
from ibind import IbkrClient, OrderRequest
def main():
client = IbkrClient(use_oauth=True, use_session=True)
ok = client.check_health()
assert ok, "health not ok"
sleep(1)
accounts = {}
while not accounts:
accounts = client.receive_brokerage_accounts().data
sleep(1)
account_id = accounts["accounts"][0] # type: ignore
client.account_id = account_id
conid = '80986742'
req = OrderRequest(conid=conid, side="BUY", quantity=1, order_type="MKT", acct_id=str(client.account_id)) # type: ignore
result = client.place_order(req, {})
print(result)
if __name__ == "__main__":
main() The above will fail. If I change the |
I agree, we should cast to int here. Indeed IBKR sometimes works with one, sometimes the other. I'll change the conid field in OrderRequest to be only int. Thanks for your example @jbaron 👍 |
hey @jbaron please try |
Thanks !!! Seems to be fixed, although outside trading hours some of my test fail due to unexpected responses. So will try it a bit more tomorrow. |
Last few days it is working great. Thanks for this creating this nice library. |
hey @jbaron great news! Thanks for your patience and for reporting this 🙌 |
When I try to place an order I get an exception:
:: 400 :: Bad Request :: {"error":"orders request includes parameter with incorrect type"}
The reason I figured out through some trial and error is that we send the
conid
as a string and it expects it to be an int. This simple snippet is working:The text was updated successfully, but these errors were encountered: