Qluxzz / avanza

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

404 error get_deals_and_orders(). #102

Closed AmirEghbali closed 3 months ago

AmirEghbali commented 4 months ago

Lately this does not work. Apparently sometimes but I am getting more and more errors.

Any alternative to get current open orders?

AmirEghbali commented 4 months ago

Does even this work?

**_ORDER_GET_PATH = '/_mobile/order/{}?accountId={}&orderId={}'_**

How to get details of ongoing order if we know the orderId?

Unt3r commented 3 months ago

It looks like the deals and orders are gone.

I found two new links. One for deals and one for orders. After adding the following new methods it kind of works. Instead of calling get_deals_and_orders() you either call get_deals() or get_orders()

Anyone with skill please make needed changes for the api.

constants.py DEALS_PATH = '/_api/trading/rest/deals' ORDERS_PATH = '/_api/trading/rest/orders'

avanza.py
def get_deals(self): """ Get currently active deals Returns:

        "deals":[
    {
    "id":str,
    "account": { 
                    "accountId": str,
        "name": { "value": str },
        "type": { "accountType": str },
        "urlParameterId": str"
    },
    "orderbookId": str,
    "volume": int,
    "price": float,
    "amount":float,
    "time": str,
    "side": str,
    "orderId": str,
    "orderbook": {
        "id": str,
        "name": str,
        "countryCode": str,
        "currency": str,
        "instrumentType": str,
        "volumeFactor": str,
        "isin": str, 
        "mic": str
    }
}
]
,"fundDeals":[]}
    """
        return self.__call(
        HttpMethod.GET,
        Route.DEALS_PATH.value
    )

def get_orders(self):
    """ Get currently active orders
    Returns:

    "deals":[
   {
"orders":[
{
"account":
    {
    "accountId":str,
    "name":{
        "value": str
        },
    "type":{"accountType": str},
    "urlParameterId": str
    },
"orderId": str,
"volume": int,
"price": float,
"amount" float,
"orderbookId": str,
"side": str,
"validUntil": str,
"created": str,
"deletable": bool,
"modifiable": bool,
"message": str,
"state": str,
"stateText": str,
"stateMessage": str,
"orderbook":{"id":str,"name":str,"countryCode":str,"currency":str,"instrumentType": str,"volumeFactor":str,"isin":str,"mic": str},
"additionalParameters":{}
}
]
,"fundDeals":[]}
"""
    return self.__call(
        HttpMethod.GET,
        Route.ORDERS_PATH.value
    )
AmirEghbali commented 3 months ago

It looks like the deals and orders are gone.

I found two new links. One for deals and one for orders. After adding the following new methods it kind of works. Instead of calling get_deals_and_orders() you either call get_deals() or get_orders()

Anyone with skill please make needed changes for the api.

constants.py DEALS_PATH = '/_api/trading/rest/deals' ORDERS_PATH = '/_api/trading/rest/orders'

avanza.py def get_deals(self): """ Get currently active deals Returns:

        "deals":[
    {
  "id":str,
  "account": { 
                    "accountId": str,
      "name": { "value": str },
      "type": { "accountType": str },
      "urlParameterId": str"
  },
  "orderbookId": str,
  "volume": int,
  "price": float,
  "amount":float,
  "time": str,
  "side": str,
  "orderId": str,
  "orderbook": {
      "id": str,
      "name": str,
      "countryCode": str,
      "currency": str,
      "instrumentType": str,
      "volumeFactor": str,
      "isin": str, 
      "mic": str
  }
}
]
,"fundDeals":[]}
    """
        return self.__call(
        HttpMethod.GET,
        Route.DEALS_PATH.value
    )

def get_orders(self):
    """ Get currently active orders
    Returns:

    "deals":[
   {
"orders":[
{
"account":
    {
    "accountId":str,
    "name":{
        "value": str
        },
    "type":{"accountType": str},
    "urlParameterId": str
    },
"orderId": str,
"volume": int,
"price": float,
"amount" float,
"orderbookId": str,
"side": str,
"validUntil": str,
"created": str,
"deletable": bool,
"modifiable": bool,
"message": str,
"state": str,
"stateText": str,
"stateMessage": str,
"orderbook":{"id":str,"name":str,"countryCode":str,"currency":str,"instrumentType": str,"volumeFactor":str,"isin":str,"mic": str},
"additionalParameters":{}
}
]
,"fundDeals":[]}
"""
    return self.__call(
        HttpMethod.GET,
        Route.ORDERS_PATH.value
    )

Great job! I tested these and they work.

If you managed to fix these I think you are skilled enough! Just add the changes to constants.py and avanza.py. Then make a pull request :)

Unt3r commented 3 months ago

Ok. I tried to make a pull request now.