def filter_symbols():
search_text = entry_search.get().lower()
filtered_symbols = [symbol for symbol in symbols if search_text in symbol.lower()]
menu = symbol_menu[‘menu’]
menu.delete(0, ‘end’)
for symbol in filtered_symbols:
menu.add_command(label=symbol, command=lambda value=symbol: selected_symbol.set(value) or update_units())
if filtered_symbols:
selected_symbol.set(filtered_symbols[0])
update_units()
The error message "mexc does not have market symbol" you encountered indicates that the trading bot is attempting to access market data for a symbol that the MEXC exchange does not recognize or have available. Here are some steps that you can take to troubleshoot and resolve this issue:
Check Symbol List: Ensure that you are selecting a symbol that is available on the MEXC exchange. The symbols list should contain all the valid trading pairs. Double-check that you are choosing from these valid symbols when making API calls.
Функция для обновления минимального объема торговли
def update_min_trade_volume(symbol):
try:
market = exchange.market(symbol)
min_volume = market[‘limits’][‘amount’][‘min’]
label_min_volume.config(text=f"Мин. объем для {symbol}: {min_volume}”)
except Exception as e:
logging.error(“Ошибка получения минимального объема: %s”, e)
label_min_volume.config(text=“Ошибка получения минимального объема”)
Функция для обновления UI
def update_ui():
symbol = selected_symbol.get()
current_price = get_current_price(symbol)
if current_price:
label_current_price.config(text=f"Текущая цена: {current_price:.2f}“)
if session_start_time:
elapsed_time = datetime.now() - session_start_time
label_session_time.config(text=f"Время сессии: {str(elapsed_time).split(‘.’)[0]}”)
connection_status.config(bg=“green” if connected else “red”)
update_open_positions_display()
root.after(1000, update_ui)
if amount_units < min_volume:
messagebox.showerror(“Ошибка”, f"Минимальный объем для торговли: {min_volume}. Невозможно купить на {amount_units}.“)
return None
Повторная проверка объема
if amount_units <= 0:
messagebox.showerror(“Ошибка”, “Количество единиц должно быть положительным.”)
return None
if amount_units < min_volume:
messagebox.showerror(“Ошибка”, f"Минимальный объем для торговли: {min_volume}. Невозможно продать {amount_units}.“)
return None
Повторная проверка объема
if amount_units <= 0:
messagebox.showerror(“Ошибка”, “Количество единиц должно быть положительным.”)
return None
def save_trade_state(action, order, profit=0):
with open(‘trading_bot_state.log’, ‘a’) as f:
f.write(f"{action},{order[‘symbol’]},{order[‘amount’]},{order[‘price’]},{profit}\n")
Загрузка состояния торговли из логов
def load_trade_state():
global session_profit, open_positions
try:
with open(‘trading_bot_state.log’, ‘r’) as f:
lines = f.readlines()
open_positions = []
for line in lines:
action, symbol, amount, price, profit = line.strip().split(‘,’)
if action == ‘buy’:
open_positions.append({‘symbol’: symbol, ‘amount’: float(amount), ‘price’: float(price)})
session_profit += float(profit)
except FileNotFoundError:
logging.info(“Лог состояния торговли не найден.”)
def update_trade_history_display():
text_history.delete(1.0, tk.END)
for trade in trade_history:
text_history.insert(tk.END, f"{trade[‘timestamp’]} {trade[‘action’].upper()} {trade[‘amount’]} {trade[‘symbol’]} @ {trade[‘price’]} Profit: {trade[‘profit’]}\n")
Функция для обновления открытых позиций
def update_open_positions_display():
open_orders_text.delete(1.0, tk.END)
for position in open_positions:
current_profit = calculate_current_profit(position)
open_orders_text.insert(tk.END, f"{position[‘symbol’]} {position[‘amount’]} @ {position[‘price’]} Current Profit: {current_profit:.2f}\n")
label_amount = tk.Label(root, text=‘Сумма (в фиатной или криптовалюте):’)
label_amount.pack()
entry_amount = tk.Entry(root)
entry_amount.pack()
entry_amount.insert(tk.END, ‘10’) # Пример значения суммы
update_ui()
root.mainloop() ERROR:root:Ошибка при получении текущей цены: mexc does not have market symbol
ERROR:root:Ошибка при получении текущей цены: mexc does not have market symbol yf heccrjv jndtnm
Refresh Market Data: Ensure that your market data is up-to-date. The line markets = exchange.load_markets() should be re-executed when necessary to refresh the list of available symbols from MEXC.
User Selection: Verify that your GUI (Graphical User Interface) allows the user to select only valid symbols. The symbol_menu should be populated correctly with these symbols.
Debug Logging: Consider adding additional logging to trace which symbol is being selected or used when the error occurs. For example, add logging.debug(f"Selected symbol: {selected_symbol.get()}") before API calls involving a symbol.
Error Handling: Improve error handling by checking if the symbol is valid before making API calls. This can be done by comparing the selected symbol against the markets list to ensure it's included.
Update ccxt: Ensure that you are running the latest version of the ccxt library, as newer versions might have updates or bug fixes. You can update the package using pip install --upgrade ccxt.
Locale and Encoding: Ensure that any non-ASCII characters in your code, like strings in comments, error messages, or logging messages, are handled correctly. Encoding issues can sometimes cause unexpected breakdowns in adjacent functionality.
By going through these steps, you should be able to identify the specific symbol or logic causing the error, and correct the issue in your bot's operation.