I used your code, but it giveing me ERROR, Code: import time
import requests
import hmac
import hashlib
import datetime as dt
import pandas as pd
API_KEY = ''
API_SECRET = ''

print({dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S')})

symbol = 'BCH/USDT'
interval = '1m'
lookback = 44640

def generate_signature(api_key, api_secret, endpoint, params):
    params_string = '&'.join([f'{key}={params[key]}' for key in params])
    payload = f'{endpoint}?{params_string}'
    signature = hmac.new(api_secret.encode('utf-8'), payload.encode('utf-8'), hashlib.sha256).hexdigest()
    return signature

def get_historical_data(symbol, interval, start_time, end_time):
    url ='https://www.mexc.com/open/api/v2/market/kline'
    params = {
        'symbol': symbol,
        'interval': interval,
        'start_time': start_time,
        'end_time': end_time
    }
    signature = generate_signature(API_KEY, API_SECRET, '/open/api/v2/market/kline', params)
    params['api_key'] = API_KEY
    params['sign'] = signature
    response = requests.get(url, params=params)
    if response.status_code == 200:
        data = response.json()['data']
        df = pd.DataFrame(data, columns=['time', 'open', 'high', 'low', 'close', 'volume'])
        df['time'] = pd.to_datetime(df['time'], unit='ms')
        df['volume'] = df['volume'].astype(float)
        return df
    else:
        return None

end_time = int(time.time() * 1000)
start_time = end_time - lookback * 60 * 1000
df = get_historical_data(symbol, interval, start_time, end_time)

def signal_generator(df):
    if df is None:
        return ''
    # 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()
    # Extract necessary prices from df
    open_price = df.open.iloc[-1]
    close_price = df.close.iloc[-1]
    previous_open = df.open.iloc[-2]
    previous_close = df.close.iloc[-2]

    # Calculate the last candlestick
    last_candle = df.Close.iloc[-1]
    current_price = df.Close.iloc[-1]

    # Initialize analysis variables
    ema_analysis = []
    candle_analysis = []

    if (
        df['EMA5'].iloc[-1] > df['EMA20'].iloc[-1] > df['EMA50'].iloc[-1] > df['EMA100'].iloc[-1] > df['EMA200'].iloc[-1] and
        df['EMA5'].iloc[-2] < df['EMA20'].iloc[-2] < df['EMA50'].iloc[-2] < df['EMA100'].iloc[-2] < df['EMA200'].iloc[-2]
    ):
        ema_analysis.append('golden_cross')
    elif (
        df['EMA5'].iloc[-1] < df['EMA20'].iloc[-1] < df['EMA50'].iloc[-1] < df['EMA100'].iloc[-1] < df['EMA200'].iloc[-1] and
        df['EMA5'].iloc[-2] > df['EMA20'].iloc[-2] > df['EMA50'].iloc[-2] > df['EMA100'].iloc[-2] > df['EMA200'].iloc[-2]
    ):
        ema_analysis.append('death_cross')

    if (
        open_price < close_price and
        previous_open > previous_close and
        close_price > previous_open and
        open_price <= previous_close
    ):
        candle_analysis.append('buy')
    elif (
        open_price > close_price and
        previous_open < previous_close and
        close_price < previous_open and
        open_price >= previous_close
    ):
        candle_analysis.append('sell')

    # Generate signal based on strategy
    if 'golden_cross' in ema_analysis and 'buy' in candle_analysis:
        final_signal = 'buy'
    elif 'death_cross' in ema_analysis and 'sell' in candle_analysis:
        final_signal = 'sell'
    else:
        final_signal = ''

    return final_signal

df = get_historical_data(symbol, interval, start_time, end_time)
while True:
    end_time = int(time.time() * 1000)
    start_time = end_time - lookback * 60 * 1000
    df = get_historical_data(symbol, interval, start_time, end_time)
    signal = signal_generator(df)
    if signal:
        print(f"The signal time is: {dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}:{signal}")
    else:
        print(f"No signal at: {dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
    time.sleep(1)
ERROR: {'2023-07-08 15:57:43'}
Traceback (most recent call last):
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connection.py", line 200, in _new_conn
    sock = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\connection.py", line 85, in create_connection
    raise err
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\connection.py", line 73, in create_connection
    sock.connect(sa)
TimeoutError: [WinError 10060] Попытка установить соединение была безуспешной, т.к. от другого компьютера за требуемое время не получен нужный отклик, или было разорвано уже установленное соединение из-за неверного отклика уже подключенного компьютера

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 790, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 491, in _make_request
    raise new_e
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 467, in _make_request
    self._validate_conn(conn)
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 1092, in _validate_conn
    conn.connect()
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connection.py", line 604, in connect
    self.sock = sock = self._new_conn()
                       ^^^^^^^^^^^^^^^^
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connection.py", line 209, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x0000021D79EAEA50>, 'Connection to www.mexc.com timed out. (connect timeout=None)')      

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 844, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\retry.py", line 515, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # 
type: ignore[arg-type]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^    
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.mexc.com', port=443): Max retries exceeded with url: /open/api/v2/market/kline?symbol=BCH%2FUSDT&interval=1m&start_time=1686142663640&end_time=1688821063640&api_key=mx0vgl44p77gAxNTdp&sign=c90808c21d4cf647929fdf57edf75ff21ef49b7c66c75cd6885a71c0294c4f6a (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000021D79EAEA50>, 'Connection to www.mexc.com timed out. (connect timeout=None)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\service\.vscode\jew_bot.py", line 45, in <module>
    df = get_historical_data(symbol, interval, start_time, 
end_time)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\service\.vscode\jew_bot.py", line 33, in get_historical_data
    response = requests.get(url, params=params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\api.py", line 73, in get  
    return request("get", url, params=params, **kwargs)    
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^    
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\service\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\adapters.py", line 507, in send
    raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='www.mexc.com', port=443): Max retries exceeded with url: /open/api/v2/market/kline?symbol=BCH%2FUSDT&interval=1m&start_time=1686142663640&end_time=1688821063640&api_key=mx0vgl44p77gAxNTdp&sign=c90808c21d4cf647929fdf57edf75ff21ef49b7c66c75cd6885a71c0294c4f6a (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000021D79EAEA50>, 'Connection to www.mexc.com timed out. (connect timeout=None)'))