You’ll need to leverage a few different endpoints to achieve your objective of fetching your trades, balances and earnings. In regards to the code in your post, the trades endpoint will return recent public trades, not your own personal trades. Additionally you’re missing the required parameter: symbol, eg. $url = "https://data.binance.com/api/v3/trades?symbol=BTCUSDT". Additionally, it isn’t required to pass signature for market-data endpoints.
For your intended purposes I suggest starting by taking a look at the endpoints below: