Qluxzz / avanza

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

Error placing a order #24

Closed thebadone111 closed 3 years ago

thebadone111 commented 3 years ago

requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://www.avanza.se/_api/order

this is the error I get every time I place a order through the API. I thought it was the 2 click buying window that appears, but turning it off on Avanza's website didn't help.

I'm happy sending the rest of the error message but this is probably just me being a little dumb ass so please enlighten me where what I am doing wrong. This is the code that calls the buy order: buy = a.place_order('ACC_ID', 'ORDERBOOK_ID', OrderType.BUY, float(price), date.fromisoformat('2021-11-11'), 1)

Qluxzz commented 3 years ago

Just tried this myself and it works as expected:

result = avanza.place_order(
    account_id=account_id,
    order_book_id='5345',
    order_type=OrderType.BUY,
    price=0.0886,
    valid_until=date.fromisoformat("2021-03-13"),
    volume=1
)

Does the API work otherwise, have you tried the other examples in the README?