34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
import asyncio
|
|
import os
|
|
from dotenv import load_dotenv
|
|
from mexc_trading import MexcTradingClient
|
|
|
|
# Load environment variables
|
|
load_dotenv()
|
|
|
|
async def test_trading_client():
|
|
"""Test the MexcTradingClient functionality"""
|
|
print("Initializing MexcTradingClient...")
|
|
client = MexcTradingClient(symbol="ETH/USDT")
|
|
|
|
# Test getting market price
|
|
print("Testing get_market_price...")
|
|
price = await client.get_market_price()
|
|
print(f"Current ETH/USDT price: {price}")
|
|
|
|
# If API keys are provided, test account balance
|
|
if os.getenv('MEXC_API_KEY') and os.getenv('MEXC_SECRET_KEY'):
|
|
print("Testing fetch_account_balance...")
|
|
balance = await client.fetch_account_balance()
|
|
print(f"Account balance: {balance} USDT")
|
|
|
|
print("Testing fetch_open_positions...")
|
|
positions = await client.fetch_open_positions()
|
|
print(f"Open positions: {positions}")
|
|
else:
|
|
print("No API keys provided. Skipping private endpoint tests.")
|
|
|
|
print("MexcTradingClient test completed!")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(test_trading_client()) |