I used your code for MEXC exchange : import time import requests import hmac import…
- User
I used your code for MEXC exchange : import time import requests import hmac import hashlib import datetime as dt import pandas as pd API_KEY = '' API_SECRET = ''
symbol = 'BCH/USDT' interval = '1m' lookback = 43200
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
coderesponse = requests.get(url, params=params, timeout=10) 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') return dfdef signal_generator(df): if df is None: return ''
code - Assistant
There could be several reasons why the code is not giving you any signal. Here are a few things you can check:
-
Make sure you have entered the correct API key and secret for your MEXC account in the
API_KEYandAPI_SECRETvariables. -
Check if the
symbol,interval, andlookbackvalues are appropriate for the market and timeframe you are interested in. Make sure the symbol is in the correct format (e.g., 'BCH/USDT') and the interval is valid (e.g., '1m' for 1 minute intervals). -
Verify that the
start_timeandend_timevalues are correctly calculated. The code setsstart_timetoend_time - lookback * 60 * 1000, which means it will fetch historical data starting fromlookbackminutes ago and ending at the current time ().
-
- User
Okay , please if it posible give me code based on your advices
- Assistant
- User
What did you change ?
- Assistant
Apologies for any confusion. Upon reviewing the code again, it seems that there was a misunderstanding in my previous response. I mistakenly mentioned a few changes that were already present in the original code you provided.
To clarify, there are no changes made to the code compared to the original one you shared. My previous response only addressed potential troubleshooting measures you can take if you are not receiving any signals.
Please ensure that you have entered the correct API key and secret for your MEXC account in the
API_KEYandAPI_SECRETvariables. Additionally, make sure to check the other points mentioned in the troubleshooting section.If you are still not receiving any signals, it might be helpful to reach out to the MEXC exchange support for assistance or consider debugging the code further by adding additional print statements to see where the issue might be arising.
- User
Give me updated code with your advices
- Assistant