Skip to content
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

placeOrder returning 415 response #72

Open
rodrigobell opened this issue Apr 21, 2020 · 6 comments
Open

placeOrder returning 415 response #72

rodrigobell opened this issue Apr 21, 2020 · 6 comments
Labels
bug Concrete, reproducible bugs

Comments

@rodrigobell
Copy link

rodrigobell commented Apr 21, 2020

I'm not able to post a pace order request - getting a 415 response code ("unsupported media type"). I'm using the commented out test as reference. Is this not currently working?

c = td.TDClient()

order = '''
{
  "orderType": "MARKET",
  "session": "NORMAL",
  "duration": "DAY",
  "orderStrategyType": "SINGLE",
  "orderLegCollection": [
    {
      "instruction": "Buy",
      "quantity": 1,
      "instrument": {
        "symbol": "IMRN",
        "assetType": "EQUITY"
      }
    }
  ]
}
'''
print(c.accounts())
c.placeOrder(<accountId>, order)

EDIT: I tried adding extra header info for things like Content-Type and Accept with no luck. And yet hitting this API from https://developer.tdameritrade.com/ does work.

@rodrigobell
Copy link
Author

Correction, the snipped above is sending the raw string to the placeOrders API, but it's expecting a json value. Still, converting the string with j = json.loads(order) yields the same 415 response.

@dahifi
Copy link
Collaborator

dahifi commented Apr 22, 2020

Tim changed the order API, it broke mine as well and I haven't gotten around to updating it. I suggest going back to a previous version of the code. I reverted to bbf113c.

(Use git checkout bbf113 from your terminal.)

@timkpaine timkpaine added the bug Concrete, reproducible bugs label Apr 22, 2020
@rodrigobell
Copy link
Author

rodrigobell commented Apr 22, 2020

Ah that would explain it, thanks! I reverted to bbf113c and installed with python setup.py install but I'm not able to authenticate from this commit. I'm still able to authenticate and get account info from master.

I've got the same environment variables set up. Are you aware of any other setup that's needed for this commit?

EDIT: Never mind, my env variable was set to AMERITRADE_CLIENT_ID instead of TDAMERITRADE_CLIENT_ID

@wilfredcho
Copy link
Contributor

order should be pass as json=order in placeOrder

@JasonCrowe
Copy link

I am having this same error. I'm using the pip installed version, so I'm not sure how to specify a git version.

Is there a workaround?

@j20120307
Copy link

Just follow https://github.com/timkpaine/tdameritrade/blob/master/general.ipynb. However, I don't see manually configure content type as best practice.

@wilfredcho wilfredcho mentioned this issue Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Concrete, reproducible bugs
Projects
None yet
Development

No branches or pull requests

6 participants