I used this code: import time
from binance.client import Client
from binance.enums import *
from binance.exceptions import BinanceAPIException
from binance.helpers import round_step_size
import pandas as pd
import json
import numpy as np
import pytz
import datetime as dt
import ccxt
from decimal import Decimal
import requests
import hmac
import hashlib
import ntplib
import os
import ta
import ta.volatility
API_KEY = ''
API_SECRET = ''

client = Client(API_KEY, API_SECRET)

# Set the endpoint and parameters for the request
url = "https://fapi.binance.com/fapi/v2/account"
timestamp = int(time.time() * 1000) - 500 # subtract 500ms from local time to account for clock-drift
recv_window = 60000 # increased recv_window value
params = {
"timestamp": timestamp,
"recvWindow": recv_window
}

# Define the sync_time() function
def sync_time():
    ntp_client = ntplib.NTPClient()
    response = ntp_client.request('pool.ntp.org', version=3)
    now = time.time()
    offset = response.offset
    new_time = now + offset
    # Set the system clock to the new time
    os.system(f'sudo date -s @{int(new_time)}')
    print(f'New time: {dt.datetime.now()}')
# Sync your local time with the server time
sync_time()

# Sign the message using the Client’s secret key
message = "&".join([f"{k}={v}" for k, v in params.items()])
signature = hmac.new(API_SECRET.encode(), message.encode(), hashlib.sha256).hexdigest()
params['signature'] = signature
leverage = 100

# Send the request using the requests library
response = requests.get(url, params=params, headers={'X-MBX-APIKEY': API_KEY})
account_info = response.json()

# Get the USDT balance and calculate the max trade size based on the leverage
try:
    usdt_balance = next((item for item in account_info['accountBalance'] if item["asset"] == "USDT"), {"free": 0})['free']
except KeyError:
    usdt_balance = 0
    print("Error: Could not retrieve USDT balance from API response.")

max_trade_size = float(usdt_balance) * leverage

# Get the current time and timestamp
now = dt.datetime.now()
date = now.strftime("%m/%d/%Y %H:%M:%S")
print(date)

timestamp = int(time.time() * 1000)

STOP_LOSS_PERCENTAGE = -50
TAKE_PROFIT_PERCENTAGE = 100
MAX_TRADE_QUANTITY_PERCENTAGE = 100
POSITION_SIDE_SHORT = 'SELL'
POSITION_SIDE_LONG = 'BUY'
quantity = 1
symbol = 'BTC/USDT'
order_type = 'market'
leverage = 100
max_trade_quantity_percentage = 1
binance_futures = ccxt.binance({
    'apiKey': API_KEY,
    'secret': API_SECRET,
    'enableRateLimit': True, # enable rate limitation
    'options': {
    'defaultType': 'future',
    'adjustForTimeDifference': True
    },'future': {
    'sideEffectType': 'MARGIN_BUY', # MARGIN_BUY, AUTO_REPAY, etc…
}
})
# Load the market symbols
exchange = ccxt.binance({
    'apiKey': API_KEY,
    'secret': API_SECRET,
    'enableRateLimit': True,
})
symbol = 'BTC/USDT'
orderbook = exchange.fetch_order_book(symbol)
current_price = (orderbook['bids'][0][0] + orderbook['asks'][0][0]) / 2

def get_server_time():
    ntp_client = ntplib.NTPClient()
    response = ntp_client.request('pool.ntp.org', version=3)
    now = time.time()
    offset = response.offset
    new_time = now + offset
    # Set the system clock to the new time
    os.system(f'sudo date -s @{int(new_time)}')
    print(f'New time: {dt.datetime.now()}')


params = {
"timestamp": timestamp,
"recvWindow": recv_window
}
try:
    markets = binance_futures.load_markets()
except ccxt.BaseError as e:
    print(f'Error fetching markets: {e}')
    markets = []

if symbol in markets:
    print(f"{symbol} found in the market")
else:
    print(f"{symbol} not found in the market")

# Get server time and time difference

def get_server_time(exchange):
    return exchange.fetch_time()

def get_time_difference():
    server_time = get_server_time(binance_futures)
    local_time = int(time.time() * 1000)
    time_difference = local_time - server_time
    return time_difference

time.sleep(1)
def get_klines(symbol, interval, lookback):
    url = "https://fapi.binance.com/fapi/v1/klines"
    end_time = int(time.time() * 1000) # end time is now
    start_time = end_time - (lookback * 60 * 1000) # start time is lookback minutes ago
    symbol = symbol.replace("/", "") # remove slash from symbol
    query_params = f"?symbol={symbol}&interval={interval}&startTime={start_time}&endTime={end_time}"
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'
    }
    response = requests.get(url + query_params, headers=headers)
    response.raise_for_status()
    data = response.json()
    if not data: # if data is empty, return None
        print('No data found for the given timeframe and symbol')
        return None
    ohlc = []
    for d in data:
        timestamp = dt.datetime.fromtimestamp(d[0]/1000).strftime('%Y-%m-%d %H:%M:%S')
        ohlc.append({
            'Open time': timestamp,
            'Open': float(d[1]),
            'High': float(d[2]),
            'Low': float(d[3]),
            'Close': float(d[4]),
            'Volume': float(d[5])
        })
    df = pd.DataFrame(ohlc)
    df.set_index('Open time', inplace=True)
    return df
df = get_klines(symbol, '1m', 44640)

def signal_generator(df):
    # Calculate EMA and MA lines
    df['EMA5'] = df['Close'].ewm(span=5, adjust=False).mean()
    df['EMA10'] = df['Close'].ewm(span=10, adjust=False).mean()
    df['EMA20'] = df['Close'].ewm(span=20, adjust=False).mean()
    df['EMA50'] = df['Close'].ewm(span=50, adjust=False).mean()
    df['EMA100'] = df['Close'].ewm(span=100, adjust=False).mean()
    df['EMA200'] = df['Close'].ewm(span=200, adjust=False).mean()
    df['MA10'] = df['Close'].rolling(window=10).mean()
    df['MA20'] = df['Close'].rolling(window=20).mean()
    df['MA50'] = df['Close'].rolling(window=50).mean()
    df['MA100'] = df['Close'].rolling(window=100).mean()
    open = df.Open.iloc[-1]
    close = df.Close.iloc[-1]
    previous_open = df.Open.iloc[-2]
    previous_close = df.Close.iloc[-2]
    # Calculate the last candlestick
    last_candle = df.iloc[-1]
    current_price = df.Close.iloc[-1]
    # Calculate MACD indicators
    ema_12 = df['Close'].ewm(span=12, adjust=False).mean()
    ema_26 = df['Close'].ewm(span=26, adjust=False).mean()
    macd_line = ema_12 - ema_26
    signal_line = macd_line.ewm(span=9, adjust=False).mean()
    histogram = macd_line - signal_line

    ema_analysis = ''
    candle_analysis = ''
    macd_analysis = ''

    # EMA crossover - buy signal
    if df.EMA10.iloc[-1] > df.EMA50.iloc[-1] and current_price > last_candle[['EMA10', 'EMA50']].iloc[-1].min():
        ema_analysis = 'buy'

    # EMA crossover - sell signal
    elif df.EMA10.iloc[-1] < df.EMA50.iloc[-1] and current_price < last_candle[['EMA10', 'EMA50']].iloc[-1].max():
        ema_analysis = 'sell'

    # EMA crossover - buy signal
    if df.EMA20.iloc[-1] > df.EMA200.iloc[-1] and current_price > last_candle[['EMA20', 'EMA200']].iloc[-1].min():
        ema_analysis = 'buy'

    # EMA crossover - sell signal
    elif df.EMA20.iloc[-1] < df.EMA200.iloc[-1] and current_price < last_candle[['EMA20', 'EMA200']].iloc[-1].max():
        ema_analysis = 'sell'

    # Check for bullish trends
    elif current_price > last_candle[['EMA5', 'EMA20', 'EMA50', 'EMA100', 'EMA200']].iloc[-1].max():
        ema_analysis = 'buy'

    # Check for bearish trends
    elif current_price < last_candle[['EMA5', 'EMA20', 'EMA50', 'EMA100', 'EMA200']].iloc[-1].min():
        ema_analysis = 'sell'

    # Check for bullish candlestick pattern
    if (open<close and
    previous_open>previous_close and
    close>previous_open and
    open<=previous_close):
        candle_analysis = 'buy'

    # Check for bearish candlestick pattern
    elif (open>close and
    previous_open<previous_close and
    close<previous_open and
    open>=previous_close):
        candle_analysis = 'sell'
    
     # MACD trading strategy - buy signal
    if macd_line.iloc[-1] > signal_line.iloc[-1] and histogram.iloc[-1] > 0:
        macd_analysis = 'buy'

    # MACD trading strategy - sell signal
    elif macd_line.iloc[-1] < signal_line.iloc[-1] and histogram.iloc[-1] < 0:
        macd_analysis = 'sell'

    # Check if both analyses are the same
    if ema_analysis == candle_analysis == macd_analysis and ema_analysis != '':
        return ema_analysis

    # If no signal is found, return an empty string
    return ''
df =  get_klines(symbol, '1m', 44640)
But I getting ERROR: Traceback (most recent call last):
  File "C:\Users\Alan\AppData\Roaming\Python\Python311\site-packages\ccxt\base\exchange.py", line 560, in fetch
    response.raise_for_status()
  File "C:\Users\Alan\AppData\Roaming\Python\Python311\site-packages\requests\models.py", line 1021, in raise_for_status     
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error:  for url: https://api.binance.com/sapi/v1/capital/config/getall?timestamp=1687338253719&recvWindow=10000&signature=75cc3503713eb9eb853f3d21646317a24b565fc323782f3e62f123a6b16293d9

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Alan\.vscode\jew_bot\jew_bot\jew_bot.py", line 101, in <module>
    orderbook = exchange.fetch_order_book(symbol)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Alan\AppData\Roaming\Python\Python311\site-packages\ccxt\binance.py", line 2636, in fetch_order_book        
    self.load_markets()
  File "C:\Users\Alan\AppData\Roaming\Python\Python311\site-packages\ccxt\base\exchange.py", line 1391, in load_markets      
    currencies = self.fetch_currencies()
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Alan\AppData\Roaming\Python\Python311\site-packages\ccxt\binance.py", line 1707, in fetch_currencies        
    response = self.sapiGetCapitalConfigGetall(params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Alan\AppData\Roaming\Python\Python311\site-packages\ccxt\base\types.py", line 25, in unbound_method
    return _self.request(self.path, self.api, self.method, params, config=self.config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Alan\AppData\Roaming\Python\Python311\site-packages\ccxt\binance.py", line 7409, in request
    response = self.fetch2(path, api, method, params, headers, body, config)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Alan\AppData\Roaming\Python\Python311\site-packages\ccxt\base\exchange.py", line 2819, in fetch2
    return self.fetch(request['url'], request['method'], request['headers'], request['body'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Alan\AppData\Roaming\Python\Python311\site-packages\ccxt\base\exchange.py", line 576, in fetch
    skip_further_error_handling = self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Alan\AppData\Roaming\Python\Python311\site-packages\ccxt\binance.py", line 7386, in handle_errors
    self.throw_exactly_matched_exception(self.exceptions['exact'], error, feedback)
  File "C:\Users\Alan\AppData\Roaming\Python\Python311\site-packages\ccxt\base\exchange.py", line 3169, in throw_exactly_matched_exception
    raise exact[string](message)
ccxt.base.errors.InvalidNonce: binance {"code":-1021,"msg":"Timestamp for this request was 1000ms ahead of the server's time."}