GithubHelp home page GithubHelp logo

Keep getting requests.exceptions.HTTPError: 400 Client Error: Bad Request for url when trying to place options order. about pyetrade HOT 8 OPEN

rockwoodquant avatar rockwoodquant commented on June 25, 2024
Keep getting requests.exceptions.HTTPError: 400 Client Error: Bad Request for url when trying to place options order.

from pyetrade.

Comments (8)

Robert-Zacchigna avatar Robert-Zacchigna commented on June 25, 2024 1

The client_order_id does need to be an int cast as a str. This is what i have working in my code without issue:

from random import randint

client_order_id = str(randint(1000000000, 9999999999))

from pyetrade.

rockwoodquant avatar rockwoodquant commented on June 25, 2024

I tried to use account_id instead of accountIdKey, i also tried to add in resp_type = "xml" in the function call. every time so far got to the same error...

from pyetrade.

xabaddonx1 avatar xabaddonx1 commented on June 25, 2024

Same issue here.

edit I figured it out, the expiry date format needs to be month-day-year

from pyetrade.

rockwoodquant avatar rockwoodquant commented on June 25, 2024

@xabaddonx1 I tried your suggestion, same error...

from pyetrade.

xabaddonx1 avatar xabaddonx1 commented on June 25, 2024

You must have another issue. I think the client order id needs to be unique for each order, i generate it with
clientOrderId = dt.datetime.timestamp(presentDate) * 1000000
maybe that's it.

from pyetrade.

rockwoodquant avatar rockwoodquant commented on June 25, 2024

Again, same error with this change... @xabaddonx1

from pyetrade.

xozxro avatar xozxro commented on June 25, 2024

Any update on this?

Running into the identical issue and have taken identical steps with no luck. Is this a bug in PyEtrade or picky E*Trade request formatting?

Odd that it works for some... @xabaddonx1 would you mind sharing your working request code and param formatting for option orders? Would be a large help.

from pyetrade.

xabaddonx1 avatar xabaddonx1 commented on June 25, 2024

Here's mine, a couple things I thought of:

It could be the clientOrderId needs to be an int.

    resp = orders.place_option_order(
        resp_format='xml',
        accountId=brokerageAccountIdKey,
        symbol=symbol,
        callPut=callPut,
        expiryDate=expiryDate,
        strikePrice=formatNumber(strikePrice),
        orderAction=action,
        clientOrderId=int(clientOrderId),
        priceType=priceType,
        limitPrice=limitPrice,
        allOrNone=False,
        quantity=quantity,
        orderTerm="GOOD_FOR_DAY",
        marketSession='REGULAR')

i'm running the code below on strikePrice, I ran into an issue where sometimes it would say 12.0 and the api doesn't like that :


def formatNumber(num):
  if num % 1 == 0:
    return int(num)
  else:
    return num

from pyetrade.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.