mexc interface integrations REST API fixes
This commit is contained in:
97
get_mexc_exchange_info.py
Normal file
97
get_mexc_exchange_info.py
Normal file
@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Get MEXC Exchange Info for ETHUSDC
|
||||
"""
|
||||
|
||||
import requests
|
||||
import json
|
||||
|
||||
def get_mexc_exchange_info():
|
||||
"""Get detailed MEXC exchange information for ETHUSDC"""
|
||||
print("Getting MEXC Exchange Info for ETHUSDC...")
|
||||
print("=" * 50)
|
||||
|
||||
try:
|
||||
# Get exchange info from MEXC public API
|
||||
resp = requests.get('https://api.mexc.com/api/v3/exchangeInfo')
|
||||
data = resp.json()
|
||||
|
||||
# Find ETHUSDC symbol
|
||||
ethusdc_info = None
|
||||
for symbol_info in data.get('symbols', []):
|
||||
if symbol_info['symbol'] == 'ETHUSDC':
|
||||
ethusdc_info = symbol_info
|
||||
break
|
||||
|
||||
if not ethusdc_info:
|
||||
print("❌ ETHUSDC symbol not found")
|
||||
return
|
||||
|
||||
print("✅ Found ETHUSDC symbol information")
|
||||
print(f"Symbol: {ethusdc_info['symbol']}")
|
||||
print(f"Status: {ethusdc_info['status']}")
|
||||
print(f"Base Asset: {ethusdc_info['baseAsset']}")
|
||||
print(f"Quote Asset: {ethusdc_info['quoteAsset']}")
|
||||
print(f"Base Precision: {ethusdc_info['baseAssetPrecision']}")
|
||||
print(f"Quote Precision: {ethusdc_info['quoteAssetPrecision']}")
|
||||
|
||||
print("\nFilters:")
|
||||
print("-" * 20)
|
||||
|
||||
lot_size_filter = None
|
||||
min_notional_filter = None
|
||||
|
||||
for filter_info in ethusdc_info.get('filters', []):
|
||||
filter_type = filter_info['filterType']
|
||||
print(f"\n{filter_type}:")
|
||||
|
||||
if filter_type == 'LOT_SIZE':
|
||||
lot_size_filter = filter_info
|
||||
elif filter_type == 'MIN_NOTIONAL':
|
||||
min_notional_filter = filter_info
|
||||
|
||||
for key, value in filter_info.items():
|
||||
if key != 'filterType':
|
||||
print(f" {key}: {value}")
|
||||
|
||||
# Analyze requirements
|
||||
print("\n" + "=" * 50)
|
||||
print("ANALYSIS:")
|
||||
|
||||
if lot_size_filter:
|
||||
min_qty = float(lot_size_filter['minQty'])
|
||||
step_size = lot_size_filter['stepSize']
|
||||
|
||||
print(f"Minimum Quantity: {min_qty} ETH")
|
||||
print(f"Step Size: {step_size}")
|
||||
|
||||
# Check our test quantity
|
||||
test_qty = 0.009871
|
||||
print(f"\nOur quantity: {test_qty}")
|
||||
print(f"Meets minimum?: {'✅ Yes' if test_qty >= min_qty else '❌ No'}")
|
||||
|
||||
# Check step size compliance
|
||||
if '.' in step_size:
|
||||
decimal_places = len(step_size.split('.')[-1].rstrip('0'))
|
||||
properly_rounded = round(test_qty, decimal_places)
|
||||
print(f"Required decimals: {decimal_places}")
|
||||
print(f"Properly rounded: {properly_rounded}")
|
||||
|
||||
if min_notional_filter:
|
||||
min_notional = float(min_notional_filter['minNotional'])
|
||||
test_value = 0.009871 * 3031 # approximate price
|
||||
print(f"\nMinimum Order Value: ${min_notional}")
|
||||
print(f"Our order value: ${test_value:.2f}")
|
||||
print(f"Meets minimum?: {'✅ Yes' if test_value >= min_notional else '❌ No'}")
|
||||
|
||||
print("\n💡 RECOMMENDATIONS:")
|
||||
if lot_size_filter and min_notional_filter:
|
||||
safe_qty = max(float(lot_size_filter['minQty']) * 1.1, min_notional / 3000)
|
||||
print(f"Use quantity >= {safe_qty:.6f} ETH for safe trading")
|
||||
print(f"This equals ~${safe_qty * 3031:.2f} USD")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_mexc_exchange_info()
|
Reference in New Issue
Block a user