*H
The problem you face is due to the short leakage time indicated by the ‘after’ parameter. When you use FetchmyRades
, the result will be obtained to a certain point, but it may not include all deals from this point on.
In order to derive transactions for more than 3 months, you must use the parameter before 'with the parameters of" from "and" restriction ". Here is an example fragment of code:
Python
Import mandatory libraries
Import CCXT
Initialize API connection to Binance
binance = ccxt.binance ({
‘apikey’: ‘your_api_key’,
‘Apisecret’: ‘your_api_secret’
})
Set the initial result of transactions to bring for a period of 3 months (994 893 transactions)
Result = Binance.fetchmyTrades (‘BTC/USDT’, since = = 1588669559517, Limit = 10000)
Print all deals from the previous 3 months
For trading in a result:
print (trade [‘id’], trade [‘time’], trade [‘symbol’])
`
In this example:
- We initialize
binance
with your Binance API identification data.
- We determine the initial result of transactions to bring for a 3-month period (994 893 transactions) using the parameter
, the set of '1588669559517
. This corresponds to January 1, 2020, at 10:35 h. UTC.
- We use the
Limit
parameter, set to 10000 to extract only the first 10,000 transactions from this point forward (ie within the last 3 months).
- Finally, we repeat each commercial result and print all the appropriate information, including the commercial identifier, time and symbol.
Note: The number of deals derived will depend on the API speed limit. To avoid hitting the speed limit, you can set a “limit” parameter, which is a little smaller than the results you want. In addition, keep in mind that obtaining transactions for up to 3 months may not include all transactions from that moment ahead due to the limits of trade history.
Alternative solution:
To extract deals earlier than 3 months, using only FetchmyTrades
, you can use a combination of parameters” and “before. Here is an alternative solution:
`Python
Initialize API connection to Binance
binance = ccxt.binance ({
‘apikey’: ‘your_api_key’,
‘Apisecret’: ‘your_api_secret’
})
Set the initial result of transactions to bring for a period of 3 months (994 893 transactions)
Result = Binance.fetchmyTrades (‘BTC/USDT’, since = = 158669559517)
Calculate the maximum possible trading time
max_time = int ((score [‘trades’] [0] [‘TIME’] – result [‘trades’] [1] [‘TIME’]). Total_seconds () / 60)
Move through each trade and print all the appropriate information
For trading in a result:
print (trade [‘id’], trade [‘time’], trade [‘symbol’])
`
In this example, we calculate the maximum possible trading time by removing the latest trading time from the last trading time. Then we repeat each commercial result and print all the appropriate information.
Keep in mind that both solutions will still have restrictions due to API speed limitations. In order to avoid hitting these boundaries, it is recommended to use the Limit parameter with the parameters before ‘and’ when she is acquired.