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

PHA + OGN bitvavo.trades() not returning all trades #54

Open
yob1997 opened this issue Oct 30, 2024 · 9 comments
Open

PHA + OGN bitvavo.trades() not returning all trades #54

yob1997 opened this issue Oct 30, 2024 · 9 comments

Comments

@yob1997
Copy link

yob1997 commented Oct 30, 2024

Hi,

I have an issue with an order not showing up with the api.

In [8]: bitvavo.trades(f'PHA-EUR', {}) Out[8]: [{'id': 'f8f5641a-0414-4106-a1d1-a48d8f5d5de9', 'orderId': 'bc5a5c42-86fc-4876-ac9b-1dd99a2cad96', 'timestamp': 1632724443577, 'market': 'PHA-EUR', 'side': 'buy', 'amount': '69.09014454', 'price': '0.57751', 'taker': True, 'fee': '0.0997506267046', 'feeCurrency': 'EUR', 'settled': True}, {'id': '1baca795-ba86-4a31-870a-bd693b25443a', 'orderId': '31ecf531-dfaf-4d91-b2da-fd1ffbac376f', 'timestamp': 1631209301568, 'market': 'PHA-EUR', 'side': 'buy', 'amount': '52.83261748', 'price': '0.75522', 'taker': True, 'fee': '0.0997506267544', 'feeCurrency': 'EUR', 'settled': True}]

But I have made 3 trades on the PHA-EUR pair, but the last one is just not being returned to me.
I also just discovered that it is not available on the Advanced view which is strange..

image

Here in the simple viewer and in the phone app the trade is visible in the history.
image

Could you have a look into why this is happening, I hope it's only occuring for PHA.

Many thanks!

@yob1997
Copy link
Author

yob1997 commented Oct 30, 2024

it's also happening for OGN and DGB.

@yob1997 yob1997 changed the title PHA bitvavo.trades() not returning all trades PHA + OGN bitvavo.trades() not returning all trades Oct 30, 2024
@NilkOne
Copy link

NilkOne commented Nov 11, 2024

@yob1997 hello, I have the same problem. Did you find a solution ?

@yob1997
Copy link
Author

yob1997 commented Nov 11, 2024

@yob1997 hello, I have the same problem. Did you find a solution ?

Helloo, no I've not found a solution yet. Also don't think we can have a solution for this in our code. I'll make a ticket with the issue directly to BitVavo as there is a mismatch between the simple and advanced order list, which is really on their end to fix. I'll also mention that it impacts the API, but most likely if they fix the mismatch in the pages the API is also fixed by that extend. (The advanced view probably leverages the same endpoints as the python API).

@tdossche
Copy link

Same problem here, it seems like trades from the last month or so are not registered. I see them in the simple view, but when i use the api or advanced view in the browser they are not there. I have this for BTC, ADA, WIF

@tdossche
Copy link

This could be due to realease of bitvavo API v2.5.0:
Use the new Transaction History endpoint to retrieve the transaction history of your account. This endpoint allows you to filter transactions by type, and date range.

@yob1997
Copy link
Author

yob1997 commented Nov 17, 2024

There is no integration for the transaction end point. And it seems that setting end point parameters also doesn't work when using the python request library to fetch the data..

import hashlib
import hmac
import json
import requests
import time

class BitvavoRestClient:

    def __init__(self, api_key: str, api_secret: str, access_window: int = 10000):
        self.api_key = api_key
        self.api_secret = api_secret
        self.access_window = access_window
        self.base = "https://api.bitvavo.com/v2"

    def private_request(
        self, endpoint: str, body: dict | None = None, method: str = "GET",
    ):
        now = int(time.time() * 1000)
        sig = self.create_signature(now, method, endpoint, body)
        url = self.base + endpoint
        headers = {
            "bitvavo-access-key": self.api_key,
            "bitvavo-access-signature": sig,
            "bitvavo-access-timestamp": str(now),
            "bitvavo-access-window": str(self.access_window),
        }
        r = requests.request(method=method, url=url, headers=headers, json=body)
        return r.json()

    def create_signature(
        self, timestamp: int, method: str, url: str, body: dict | None
    ):
        string = str(timestamp) + method + "/v2" + url
        if (body is not None) and (len(body.keys()) != 0):
            string += json.dumps(body, separators=(",", ":"))
        signature = hmac.new(
            self.api_secret.encode("utf-8"), string.encode("utf-8"), hashlib.sha256
        ).hexdigest()
        return signature


from apps.core.models import Exchange
from django.contrib.auth.models import User
from python_bitvavo_api.bitvavo import Bitvavo

user = User.objects.all()[0]
exchange = Exchange.objects.get(user_id=user, broker="BitVavo")

def run():
    bitvavo = BitvavoRestClient(exchange.API_key, exchange.API_secret)
    response = bitvavo.private_request(endpoint="/account/history/", body={"type": "buy"})
    print(json.dumps(response, indent=2))

gives back

{
  "items": [
    {
      "transactionId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "executedAt": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "type": "staking",
      "receivedCurrency": "LTC",
      "receivedAmount": "0.xxxxxxxxxx",
      "address": null
    },
    {
      "transactionId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "executedAt": "xxxxxxxxxxxxxxxxxxxxxxx",
      "type": "staking",
      "receivedCurrency": "ETH",
      "receivedAmount": "0.xxxxxxxxxxxxxxxxx",
      "address": null
    },
    ...
    ...
    ...
  ],
  "currentPage": 1,
  "totalPages": 1,
  "maxItems": 100
}

@tdossche
Copy link

I did some testing too, and i found that i could get some of the 'buy transactions' that i could not find in /trades, but not all of them. Might be something on the side of Bitvavo. (Maybe also interesting to check why the advanced trading view does not show these aswell.)

@mstreutker
Copy link

I experience the same issue, some of the more recent 'buy' transactions do not show up when invoking 'trades'. I hope that this will get sorted out on the Bitvavo side.

@tdossche
Copy link

I had contact with the bitvavo support team, and this was their response:

What happened is that these trades were made under the 'price guarantee'. It is a new feature we recently put in place. More details here to activate or deactivate it: https://support.bitvavo.com/hc/en-us/articles/25974760217873-Price-Guarantee-for-trading#:~:text=Price%20guarantee%20allows%20our%20customers,markets%2C%20and%20sudden%20price%20deviations.
So, transactions made under price guarantee do not show up when calling bitvavo.trades() from python SDK. We are working to improve that. However, use the https://docs.bitvavo.com/#tag/Account-endpoints/paths/~1account~1history/get which returns all the full history of your transactions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants