Qluxzz / avanza

A Python library for the unofficial Avanza API
https://qluxzz.github.io/avanza/
MIT License
85 stars 40 forks source link

405 Client Error when placing order #47

Closed RagnarHagberg closed 2 years ago

RagnarHagberg commented 2 years ago

Placing an order gives an error. Error: requests.exceptions.HTTPError: 405 Client Error: Method Not Allowed for url: https://www.avanza.se/_api/order

URI: | /_api/order Status: 405 Message: Request method 'GET' not supported

with this data: account_id="XXXXXXX", order_book_id=290011 order_type=OrderType.SELL, price=79.6, valid_until=2022-02-17 volume=1.0

AmirEghbali commented 2 years ago

Same problem. But a different error message.

code to run:

result = avanza.place_order(account_id=avz_account_id, order_book_id=stock_id, order_type=OrderType.BUY, price=price, valid_until=datetime.date.today(), volume=volume)

error: HTTPError: 405 Client Error: Method Not Allowed for url: https://www.avanza.se/_api/order

RagnarHagberg commented 2 years ago

I got the same error but I wrote what was in the link. Avanza might have changed their API which would lead to this not working.

AmirEghbali commented 2 years ago

It is possible to read prices etc but order placement does not work apparently today.

Alexey-Klechikov commented 2 years ago

Hej guys. The fix for the issue is to replace an endpoint for order creation in the constants.py. Row 96: "ORDER_PLACE_PATH = '/_cqbe/trading/order/new'"

Could the author make a fix?

AmirEghbali commented 2 years ago

This places only sell... even if you choose buy

tux2000 commented 2 years ago

Fixed in my branch, see pull request...

Alexey-Klechikov commented 2 years ago

Addition to my last comment to fix the order type - update avanza.py, Row 1528: " 'side': order_type.value," -

Qluxzz commented 2 years ago

I have published a new version, 3.0.1 which includes these changes.