sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
5.96k stars 2.19k forks source link

How to get list of trades tied to specific orderId. #1244

Open MomentumRising opened 2 years ago

MomentumRising commented 2 years ago

For using the API endpoint myTrades, the Binance API specifies that an orderId can be given in combination with symbol, to get all trades related to a specific orderId. This is what I need to do, as I need to combine the various fill prices of the various trades related to a specific order to come up with one accurate all encompassing average fill price for an order. I notice that in the source code of the app, it says that the params field is to be used like in "return self._get('myTrades', True, data=params)". My first question is, why does this API endpoint here seem to use params like this, but for other API endpoints, like get_exchange_info, it seems to rely on using the builtin functionality of doing: client = Client(api_value_1, api_value_2, tld="us", requests_params=[{"symbols": "BTCUSD"}]) ? My second question is, in the method definition of "def get_my_trades(self, params):" it says: :param symbol: required :type symbol: str :param startTime: optional :type startTime: int :param endTime: optional :type endTime: int :param limit: Default 500; max 1000. :type limit: int :param fromId: TradeId to fetch from. Default gets most recent trades. :type fromId: int :param recvWindow: the number of milliseconds the request is valid for :type recvWindow: int -why does it not have a field for orderId? Has nobody else ever needed to get the fill price of trades they have entered previously?

halfelf commented 2 years ago

I can hardly understand what you're asking about.

  1. Is there any must-have logical relationship between creating a client instance and making a Http request to binance?
  2. Indeed orderId param is missing in the code document. But that does not mean the API has no such field. For any question about an API, please refer to Binance official document first.