mex api progress
This commit is contained in:
71
test_mexc_public_api.py
Normal file
71
test_mexc_public_api.py
Normal file
@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script for MEXC public API endpoints
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
|
||||
# Add project root to path
|
||||
sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
from NN.exchanges.mexc_interface import MEXCInterface
|
||||
|
||||
# Setup logging
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def test_mexc_public_api():
|
||||
"""Test MEXC public API endpoints"""
|
||||
print("="*60)
|
||||
print("TESTING MEXC PUBLIC API")
|
||||
print("="*60)
|
||||
|
||||
try:
|
||||
# Initialize MEXC interface without API keys (public access only)
|
||||
mexc = MEXCInterface()
|
||||
|
||||
print("\n1. Testing server connectivity...")
|
||||
try:
|
||||
# Test ping
|
||||
ping_result = mexc.ping()
|
||||
print(f"✅ Ping successful: {ping_result}")
|
||||
except Exception as e:
|
||||
print(f"❌ Ping failed: {e}")
|
||||
|
||||
print("\n2. Testing server time...")
|
||||
try:
|
||||
# Test server time
|
||||
time_result = mexc.get_server_time()
|
||||
print(f"✅ Server time: {time_result}")
|
||||
except Exception as e:
|
||||
print(f"❌ Server time failed: {e}")
|
||||
|
||||
print("\n3. Testing ticker data...")
|
||||
symbols_to_test = ['BTC/USDT', 'ETH/USDT']
|
||||
|
||||
for symbol in symbols_to_test:
|
||||
try:
|
||||
ticker = mexc.get_ticker(symbol)
|
||||
if ticker:
|
||||
print(f"✅ {symbol}: ${ticker['last']:.2f} (bid: ${ticker['bid']:.2f}, ask: ${ticker['ask']:.2f})")
|
||||
else:
|
||||
print(f"❌ {symbol}: No data returned")
|
||||
except Exception as e:
|
||||
print(f"❌ {symbol}: Error - {e}")
|
||||
|
||||
print("\n" + "="*60)
|
||||
print("PUBLIC API TEST COMPLETED")
|
||||
print("="*60)
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error initializing MEXC interface: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_mexc_public_api()
|
Reference in New Issue
Block a user