### Setup Bot Dependencies Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/examples/QUICKSTART.md Navigate to the examples folder and run this script to install necessary dependencies for the bot. ```bash # Navigate to examples folder cd examples # Run the setup script (installs dependencies) ./setup.sh ``` -------------------------------- ### Quick Development Setup Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/index.md Clone the repository, set up a virtual environment, activate it, and install the package with development dependencies. Run tests to verify the setup. ```bash git clone https://github.com/ChipaDevTeam/AxiomTradeAPI-py.git cd AxiomTradeAPI-py python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -e .[dev] pytest tests/ ``` -------------------------------- ### Quick Start Example for AxiomTradeAPI Trading Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/IMPLEMENTATION_COMPLETE.md Initialize the AxiomTradeClient, perform a token buy, check token balance, and execute a token sell. Ensure your private key and wallet address are correctly configured. The example handles potential errors and cleans up WebSocket connections. ```python import asyncio from axiomtradeapi import AxiomTradeClient async def main(): # Initialize client with your AxiomTrade credentials client = AxiomTradeClient( username="your_email@example.com", password="your_password" ) # Your Solana wallet private key (base58 encoded) private_key = "your_base58_private_key_here" # Token mint address you want to trade token_mint = "So11111111111111111111111111111111111111112" # Your wallet address wallet_address = "your_wallet_public_key" try: # Check your SOL balance balance = client.GetBalance(wallet_address) print(f"SOL Balance: {balance['sol']} SOL") # Buy 0.1 SOL worth of tokens buy_result = client.buy_token( private_key=private_key, token_mint=token_mint, amount_sol=0.1, slippage_percent=5.0 ) if buy_result["success"]: print(f"✅ Buy successful: {buy_result['signature']}") else: print(f"❌ Buy failed: {buy_result['error']}") # Check token balance after purchase token_balance = client.get_token_balance(wallet_address, token_mint) print(f"Token Balance: {token_balance}") # Sell some tokens (if you have any) if token_balance and token_balance > 0: sell_result = client.sell_token( private_key=private_key, token_mint=token_mint, amount_tokens=token_balance / 2, # Sell half slippage_percent=5.0 ) if sell_result["success"]: print(f"✅ Sell successful: {sell_result['signature']}") else: print(f"❌ Sell failed: {sell_result['error']}") except Exception as e: print(f"Error: {e}") finally: # Clean up WebSocket connection if hasattr(client, 'ws') and client.ws: await client.ws.close() # Run the trading example asyncio.run(main()) ``` -------------------------------- ### Install AxiomTradeAPI Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/README.md Install the library from PyPI. Development dependencies can be included with `[dev]`. Verify the installation by running a simple Python command. ```bash # Install from PyPI pip install axiomtradeapi # Or install with development dependencies pip install axiomtradeapi[dev] # Verify installation python -c "from axiomtradeapi import AxiomTradeClient; print('✅ Installation successful!')" ``` -------------------------------- ### Install AxiomTradeAPI-py and Verify Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/getting-started.md Install the AxiomTradeAPI-py library using pip and verify the installation by importing the client. ```bash # Install the latest version pip install axiomtradeapi # Verify installation python -c "from axiomtradeapi import AxiomTradeClient; print('✅ Installation successful!')" ``` -------------------------------- ### AxiomTradeAPI-py Installation Verification Script Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/installation.md A comprehensive Python script to test core functionalities including import, client initialization, balance queries, and WebSocket client setup. Save this as test_installation.py. ```python #!/usr/bin/env python3 """ AxiomTradeAPI-py Installation Verification Script Tests all core functionality to ensure proper installation """ import asyncio import logging from axiomtradeapi import AxiomTradeClient async def test_installation(): """Comprehensive installation test""" print("\ud83d\udc40 Testing AxiomTradeAPI-py Installation...") print("=" * 50) # Test 1: Basic import try: from axiomtradeapi import AxiomTradeClient print("✅ Import test: PASSED") except ImportError as e: print(f"❌ Import test: FAILED - {e}") return False # Test 2: Client initialization try: client = AxiomTradeClient(log_level=logging.WARNING) print("✅ Client initialization: PASSED") except Exception as e: print(f"❌ Client initialization: FAILED - {e}") return False # Test 3: Balance query (using public wallet) try: test_wallet = "BJBgjyDZx5FSsyJf6bFKVXuJV7DZY9PCSMSi5d9tcEVh" balance = client.GetBalance(test_wallet) print(f"✅ Balance query: PASSED - {balance['sol']} SOL") except Exception as e: print(f"❌ Balance query: FAILED - {e}") return False # Test 4: Batch balance query try: wallets = [ "BJBgjyDZx5FSsyJf6bFKVXuJV7DZY9PCSMSi5d9tcEVh", "Cpxu7gFhu3fDX1eG5ZVyiFoPmgxpLWiu5LhByNenVbPb" ] balances = client.GetBatchedBalance(wallets) print(f"✅ Batch query: PASSED - {len(balances)} wallets processed") except Exception as e: print(f"❌ Batch query: FAILED - {e}") return False # Test 5: WebSocket client initialization try: ws_client = client.ws print("✅ WebSocket client: PASSED") except Exception as e: print(f"❌ WebSocket client: FAILED - {e}") return False print("\n🎉 All tests passed! AxiomTradeAPI-py is ready for Solana trading!") print("\n📚 Next steps:") print(" 1. Check out the documentation: https://github.com/your-repo/docs/") print(" 2. Build your first trading bot: https://chipa.tech/product/create-your-bot/") print(" 3. Explore our shop: https://chipa.tech/shop/") return True if __name__ == "__main__": asyncio.run(test_installation()) ``` -------------------------------- ### Install AxiomTradeAPI-py Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/README.md Install the core SDK and optional browser login support using pip. For development, install with dev dependencies. ```bash pip install --upgrade axiomtradeapi pip install "axiomtradeapi[browser]" # adds nodriver ``` ```bash # Core SDK pip install axiomtradeapi # + browser login support (recommended) pip install "axiomtradeapi[browser]" # Or install with development dependencies pip install axiomtradeapi[dev] # Verify installation python -c "from axiomtradeapi import AxiomTradeClient; print('✅ Installation successful!')" ``` -------------------------------- ### Main Function and Bot Initialization Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/websocket-guide.md Example usage of the TokenSniperBot, demonstrating initialization with authentication tokens and starting the sniping process. ```python # Usage async def main(): # Initialize sniper bot sniper = TokenSniperBot( auth_token="your-auth-token", refresh_token="your-refresh-token" ) # Start sniping await sniper.start_sniping() if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Install AxiomTradeAPI from Source Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/installation.md Clone the repository and install the SDK in development mode to access the latest features. Includes running tests to ensure functionality. ```bash # Clone the repository git clone https://github.com/chipa-tech/AxiomTradeAPI-py.git cd AxiomTradeAPI-py # Install in development mode pip install -e . # Run tests to ensure everything works python -m pytest tests/ ``` -------------------------------- ### Bash Development Setup Script Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/README.md A bash script to set up the development environment for AxiomTradeAPI-py. It includes cloning the repository, creating a virtual environment, installing dependencies, and running tests. ```bash # Clone repository git clone https://github.com/ChipaDevTeam/AxiomTradeAPI-py.git cd AxiomTradeAPI-py # Create virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install development dependencies pip install -e .[dev] # Run tests pytest tests/ ``` -------------------------------- ### Complete Trading Example Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/TRADING_GUIDE.md A comprehensive example demonstrating the initialization of the AxiomTradeClient, checking balances, executing a buy order, and then selling a portion of the acquired tokens. ```APIDOC ## Complete Trading Example ### Description This example demonstrates a full trading workflow: initializing the client, checking balances, buying tokens, and then selling a portion of those tokens. ### Prerequisites - Install required dependencies: `pip install -r requirements.txt` - AxiomTrade account credentials - Solana wallet private key (base58 encoded) ### Code Example ```python import asyncio import logging from axiomtradeapi import AxiomTradeClient async def trading_example(): # Initialize client client = AxiomTradeClient( username="your_email@example.com", password="your_password" ) private_key = "your_base58_private_key" token_mint = "token_mint_address" wallet_address = "your_wallet_public_key" try: # Check current balances sol_balance = client.GetBalance(wallet_address) # Note: GetBalance might be a typo and should be get_balance based on typical Python conventions token_balance = client.get_token_balance(wallet_address, token_mint) print(f"SOL Balance: {sol_balance['sol'] if sol_balance else 'N/A'}") print(f"Token Balance: {token_balance if token_balance else 'N/A'}") # Buy tokens buy_result = client.buy_token( private_key=private_key, token_mint=token_mint, amount_sol=0.1, slippage_percent=5.0 ) if buy_result["success"]: print(f"✅ Buy successful: {buy_result['signature']}") else: print(f"❌ Buy failed: {buy_result['error']}") # Wait a moment, then sell await asyncio.sleep(5) # Check new token balance new_token_balance = client.get_token_balance(wallet_address, token_mint) if new_token_balance and new_token_balance > 0: # Sell half of the tokens sell_amount = new_token_balance / 2 sell_result = client.sell_token( private_key=private_key, token_mint=token_mint, amount_tokens=sell_amount, slippage_percent=5.0 ) if sell_result["success"]: print(f"✅ Sell successful: {sell_result['signature']}") else: print(f"❌ Sell failed: {sell_result['error']}") except Exception as e: print(f"Error: {e}") finally: if hasattr(client, 'ws') and client.ws: await client.ws.close() # Run the example asyncio.run(trading_example()) ``` ### Security Notes 1. **Never hardcode private keys** in your source code. 2. Use environment variables or secure key management. 3. Always test with small amounts first. 4. Be aware of slippage and market conditions. 5. Monitor your transactions on Solana explorers. ``` -------------------------------- ### Initialize AxiomTradeClient with Tokens Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/UPDATE_SUMMARY.md Initialize the AxiomTradeClient using authentication tokens loaded from environment variables. This example also demonstrates checking authentication status and starting WebSocket subscriptions. ```python from axiomtradeapi import AxiomTradeClient import os import dotenv dotenv.load_dotenv() # Initialize with tokens from .env client = AxiomTradeClient( auth_token=os.getenv("auth-access-token"), refresh_token=os.getenv("auth-refresh-token") ) # Check authentication if client.is_authenticated(): print("✓ Ready for trading!") # Use WebSocket features await client.subscribe_new_tokens(callback_function) await client.ws.start() ``` -------------------------------- ### Install AxiomTradeAPI-py Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/index.md Install the library using pip. Ensure you are using Python 3.8 or newer. ```bash pip install axiomtradeapi ``` -------------------------------- ### Install or Reinstall AxiomTradeAPI-py Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/troubleshooting.md Install the axiomtradeapi package or force a reinstallation if issues are suspected. ```bash pip install axiomtradeapi ``` ```bash pip install --force-reinstall axiomtradeapi ``` -------------------------------- ### Install AxiomTradeAPI-py in a New Virtual Environment Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/troubleshooting.md Create and activate a new virtual environment to avoid dependency conflicts and install axiomtradeapi. ```bash python -m venv clean-env source clean-env/bin/activate pip install axiomtradeapi ``` -------------------------------- ### Trading Example Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/PUMPPORTAL_TRADING.md A comprehensive Python example demonstrating how to initialize the AxiomTradeClient and perform both buy and sell operations. ```APIDOC ## Complete Trading Example ### Description This example shows how to initialize the `AxiomTradeClient` with authentication tokens and then use the `buy_token` and `sell_token` functions. It includes error handling and transaction monitoring. ### Code ```python from axiomtradeapi.client import AxiomTradeClient import os from dotenv import load_dotenv load_dotenv() # Initialize client with authentication client = AxiomTradeClient( auth_token=os.getenv('auth-access-token'), refresh_token=os.getenv('auth-refresh-token') ) # Your private key (keep secure!) private_key = os.getenv('PRIVATE_KEY') # Example: Buy a meme token token_mint = "ACTUAL_TOKEN_MINT_ADDRESS_HERE" # Buy 0.01 SOL worth of the token buy_result = client.buy_token( private_key=private_key, token_mint=token_mint, amount_sol=0.01, slippage_percent=5.0, priority_fee=0.005, pool="auto" ) if buy_result["success"]: print(f"✅ Buy successful!") print(f"Transaction: https://solscan.io/tx/{buy_result['signature']}") else: print(f"❌ Buy failed: {buy_result['error']}") # Sell 500 tokens sell_result = client.sell_token( private_key=private_key, token_mint=token_mint, amount_tokens=500, slippage_percent=5.0, priority_fee=0.005, pool="auto" ) if sell_result["success"]: print(f"✅ Sell successful!") print(f"Transaction: https://solscan.io/tx/{sell_result['signature']}") else: print(f"❌ Sell failed: {sell_result['error']}") ``` ``` -------------------------------- ### Install AxiomTrade API v1.0.3 Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/CHANGELOG.md Use this command to install version 1.0.3 of the AxiomTrade API Python library. ```bash pip install axiomtradeapi==1.0.3 ``` -------------------------------- ### Install Additional Dependencies Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/getting-started.md Install necessary additional Python packages for the tutorial, such as python-dotenv for environment variables and asyncio. ```bash pip install python-dotenv # For environment variables pip install asyncio # For async operations (usually included) ``` -------------------------------- ### Install AxiomTradeAPI with Performance Optimizations Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/installation.md Install the SDK with performance-focused dependencies for maximum speed in trading applications. This includes optimized libraries for JSON parsing and networking. ```bash pip install axiomtradeapi[fast] ``` -------------------------------- ### Basic Configuration and Client Initialization Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/installation.md Set up basic logging and initialize the AxiomTradeClient. This example demonstrates verifying the connection by fetching account balance. ```python # config.py - Basic setup for Solana trading bot import logging from axiomtradeapi import AxiomTradeClient # Configure logging for production trading logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', handlers=[ logging.FileHandler('trading_bot.log'), logging.StreamHandler() ] ) # Initialize the client client = AxiomTradeClient(log_level=logging.INFO) # Verify connection balance = client.GetBalance("BJBgjyDZx5FSsyJf6bFKVXuJV7DZY9PCSMSi5d9tcEVh") print(f"✅ Connection verified! Balance: {balance['sol']} SOL") ``` -------------------------------- ### Complete Trading Example with AxiomTradeClient Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/PUMPPORTAL_TRADING.md This example demonstrates initializing the AxiomTradeClient and performing both buy and sell operations. It includes error handling and transaction monitoring links. Ensure your private key and token mint address are correctly set, preferably using environment variables. ```python from axiomtradeapi.client import AxiomTradeClient import os from dotenv import load_dotenv load_dotenv() # Initialize client with authentication client = AxiomTradeClient( auth_token=os.getenv('auth-access-token'), refresh_token=os.getenv('auth-refresh-token') ) # Your private key (keep secure!) private_key = os.getenv('PRIVATE_KEY') # Example: Buy a meme token token_mint = "ACTUAL_TOKEN_MINT_ADDRESS_HERE" # Buy 0.01 SOL worth of the token buy_result = client.buy_token( private_key=private_key, token_mint=token_mint, amount_sol=0.01, slippage_percent=5.0, priority_fee=0.005, pool="auto" ) if buy_result["success"]: print(f"✅ Buy successful!") print(f"Transaction: https://solscan.io/tx/{buy_result['signature']}") else: print(f"❌ Buy failed: {buy_result['error']}") # Sell 500 tokens sell_result = client.sell_token( private_key=private_key, token_mint=token_mint, amount_tokens=500, slippage_percent=5.0, priority_fee=0.005, pool="auto" ) if sell_result["success"]: print(f"✅ Sell successful!") print(f"Transaction: https://solscan.io/tx/{sell_result['signature']}") else: print(f"❌ Sell failed: {sell_result['error']}") ``` -------------------------------- ### Full Login Example with Environment Variables Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/release-1-1-6.md A comprehensive example demonstrating how to load credentials from environment variables and perform a login, including optional IMAP support. This snippet shows the complete workflow for a first-time login. ```python import os from dotenv import load_dotenv from axiomtradeapi import AxiomTradeClient load_dotenv() client = AxiomTradeClient( username=os.getenv("AXIOM_EMAIL"), password=os.getenv("AXIOM_PASSWORD"), ) # login() is only needed the first time (or after refresh token expires). # Subsequent runs skip this entirely — saved tokens are used automatically. result = client.login( imap_password=os.getenv("AXIOM_IMAP_PASSWORD"), imap_user=os.getenv("AXIOM_IMAP_USER"), # omit if not an alias ) if result["success"]: balance = client.GetBalance("YOUR_WALLET_ADDRESS") print(balance) ``` -------------------------------- ### Comprehensive Setup Test Script Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/getting-started.md Use this script to validate your AxiomTradeAPI-py installation and configuration. It checks basic imports, client initialization, and balance queries. ```python # test_setup.py import asyncio import logging from axiomtradeapi import AxiomTradeClient from config import Config async def run_comprehensive_test(): """Run comprehensive test of your setup""" print("🧪 Running AxiomTradeAPI-py Setup Tests") print("=" * 50) tests_passed = 0 tests_failed = 0 # Test 1: Basic import try: from axiomtradeapi import AxiomTradeClient print("✅ Test 1: Import successful") tests_passed += 1 except Exception as e: print(f"❌ Test 1 failed: {e}") tests_failed += 1 # Test 2: Client initialization try: client = AxiomTradeClient(log_level=logging.WARNING) print("✅ Test 2: Client initialization successful") tests_passed += 1 except Exception as e: print(f"❌ Test 2 failed: {e}") tests_failed += 1 return # Test 3: Balance query try: test_wallet = Config.TEST_WALLETS[0] balance = client.GetBalance(test_wallet) print(f"✅ Test 3: Balance query successful - {balance['sol']} SOL") tests_passed += 1 except Exception as e: print(f"❌ Test 3 failed: {e}") tests_failed += 1 # Test 4: Batch balance query try: balances = client.GetBatchedBalance(Config.TEST_WALLETS) print(f"✅ Test 4: Batch query successful - {len(balances)} wallets") tests_passed += 1 except Exception as e: print(f"❌ Test 4 failed: {e}") tests_failed += 1 # Test 5: WebSocket availability (requires auth) if Config.AUTH_TOKEN: try: auth_client = AxiomTradeClient( auth_token=Config.AUTH_TOKEN, refresh_token=Config.REFRESH_TOKEN ) print("✅ Test 5: WebSocket client initialized") tests_passed += 1 except Exception as e: print(f"❌ Test 5 failed: {e}") tests_failed += 1 else: print("⏭️ Test 5: Skipped (no auth token)") # Summary print("=" * 50) print(f"📊 Test Results:") print(f" Passed: {tests_passed}") print(f" Failed: {tests_failed}") print(f" Success Rate: {tests_passed/(tests_passed+tests_failed)*100:.1f}%") if tests_failed == 0: print("\n🎉 All tests passed! Your setup is ready for trading.") else: print("\n⚠️ Some tests failed. Check your configuration and try again.") if __name__ == "__main__": asyncio.run(run_comprehensive_test()) ``` ```bash python test_setup.py ``` -------------------------------- ### Initialize AxiomTradeClient (Deprecated vs. Recommended) Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/AUTHENTICATION_CHANGES.md Shows the old method of initializing the client with username and password, and the new recommended approach without credentials. ```python # Old approach (deprecated) client = AxiomTradeClient(username="user@email.com", password="password") # New approach (recommended) client = AxiomTradeClient() ``` -------------------------------- ### Get Token Balance Example Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/TRADING_GUIDE.md Retrieve the balance of a specific token in your wallet. You need to provide your wallet's public key and the token's mint address. ```python balance = client.get_token_balance( wallet_address="your_wallet_public_key", token_mint="So11111111111111111111111111111111111111112" ) ``` -------------------------------- ### Basic Trading Example: Buy and Sell Tokens Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/PUMPPORTAL_INTEGRATION_COMPLETE.md This example demonstrates how to initialize the AxiomTradeClient and perform buy and sell operations for tokens. Ensure you have your authentication tokens and private key loaded from environment variables. Replace placeholder addresses and amounts with real values for actual trading. ```python from axiomtradeapi.client import AxiomTradeClient import os from dotenv import load_dotenv load_dotenv() # Initialize client client = AxiomTradeClient( auth_token=os.getenv('auth-access-token'), refresh_token=os.getenv('auth-refresh-token') ) private_key = os.getenv('PRIVATE_KEY') # Buy tokens with SOL buy_result = client.buy_token( private_key=private_key, token_mint="VALID_TOKEN_MINT_ADDRESS", # Use a real token address amount_sol=0.01, # Amount of SOL to spend slippage_percent=5.0, # Slippage tolerance priority_fee=0.005, # Priority fee in SOL pool="auto" # Exchange selection ) if buy_result["success"]: print(f"✅ Buy successful! Tx: {buy_result['signature']}") print(f"🔗 Explorer: {buy_result['explorer_url']}") else: print(f"❌ Buy failed: {buy_result['error']}") # Sell tokens for SOL sell_result = client.sell_token( private_key=private_key, token_mint="VALID_TOKEN_MINT_ADDRESS", # Same token address amount_tokens=1000, # Number of tokens to sell slippage_percent=5.0, # Slippage tolerance priority_fee=0.005, # Priority fee in SOL pool="auto" # Exchange selection ) if sell_result["success"]: print(f"✅ Sell successful! Tx: {sell_result['signature']}") print(f"🔗 Explorer: {sell_result['explorer_url']}") else: print(f"❌ Sell failed: {sell_result['error']}") ``` -------------------------------- ### Complete Trading Workflow Example Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/TRADING_GUIDE.md This example demonstrates a full trading workflow: initializing the client, checking balances, buying tokens, and then selling a portion of the acquired tokens. It includes error handling and proper client closure. ```python import asyncio import logging from axiomtradeapi import AxiomTradeClient async def trading_example(): # Initialize client client = AxiomTradeClient( username="your_email@example.com", password="your_password" ) private_key = "your_base58_private_key" token_mint = "token_mint_address" wallet_address = "your_wallet_public_key" try: # Check current balances sol_balance = client.GetBalance(wallet_address) token_balance = client.get_token_balance(wallet_address, token_mint) print(f"SOL Balance: {sol_balance['sol'] if sol_balance else 'N/A'}") print(f"Token Balance: {token_balance if token_balance else 'N/A'}") # Buy tokens buy_result = client.buy_token( private_key=private_key, token_mint=token_mint, amount_sol=0.1, slippage_percent=5.0 ) if buy_result["success"]: print(f"✅ Buy successful: {buy_result['signature']}") else: print(f"❌ Buy failed: {buy_result['error']}") # Wait a moment, then sell await asyncio.sleep(5) # Check new token balance new_token_balance = client.get_token_balance(wallet_address, token_mint) if new_token_balance and new_token_balance > 0: # Sell half of the tokens sell_amount = new_token_balance / 2 sell_result = client.sell_token( private_key=private_key, token_mint=token_mint, amount_tokens=sell_amount, slippage_percent=5.0 ) if sell_result["success"]: print(f"✅ Sell successful: {sell_result['signature']}") else: print(f"❌ Sell failed: {sell_result['error']}") except Exception as e: print(f"Error: {e}") finally: if hasattr(client, 'ws') and client.ws: await client.ws.close() # Run the example asyncio.run(trading_example()) ``` -------------------------------- ### PyCharm IDE Setup for Python Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/installation.md Steps to set up PyCharm for Python development, including creating a new project, selecting an interpreter, installing packages, and configuring code style. ```text 1. Create new Python project 2. Select Python 3.8+ interpreter 3. Install AxiomTradeAPI-py via PyCharm's package manager 4. Configure code style for PEP 8 compliance ``` -------------------------------- ### Generate Dockerfile for Bot Deployment Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/trading-bots.md Creates a Dockerfile for deploying a trading bot. It includes system dependency installation, Python environment setup, user creation for security, and a health check endpoint. ```python import os import sys from pathlib import Path import docker import yaml class ProductionBotManager: """ Production deployment manager for trading bots Enterprise-grade deployment strategies from chipa.tech infrastructure team """ def __init__(self, config_path: str): with open(config_path, 'r') as f: self.config = yaml.safe_load(f) self.docker_client = docker.from_env() self.running_bots = {} def create_bot_dockerfile(self, bot_class: str) -> str: """Generate Dockerfile for bot deployment""" dockerfile_content = f""" FROM python:3.11-slim # Install system dependencies RUN apt-get update && apt-get install -y \ gcc \ g++ \ && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /app # Copy requirements and install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy bot code COPY . . # Create non-root user for security RUN useradd -m botuser && chown -R botuser:botuser /app USER botuser # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD python -c "import requests; requests.get('http://localhost:8080/health')" # Run the bot CMD ["python", "-m", "bots.{bot_class}"] """ return dockerfile_content.strip() def create_docker_compose(self) -> str: """Generate docker-compose.yml for multi-bot deployment""" compose_content = """ version: '3.8' services: token-sniping-bot: build: . environment: - BOT_TYPE=TokenSnipingBot - AUTH_TOKEN=${AUTH_TOKEN} - WALLET_ADDRESS=${WALLET_ADDRESS} - LOG_LEVEL=INFO volumes: - ./logs:/app/logs - ./config:/app/config restart: unless-stopped healthcheck: test: ["CMD", "python", "-c", "import requests; requests.get('http://localhost:8080/health')"] interval: 30s timeout: 10s retries: 3 market-making-bot: build: . environment: - BOT_TYPE=MarketMakingBot - AUTH_TOKEN=${AUTH_TOKEN} - WALLET_ADDRESS=${WALLET_ADDRESS} - LOG_LEVEL=INFO volumes: - ./logs:/app/logs - ./config:/app/config restart: unless-stopped arbitrage-bot: build: . environment: - BOT_TYPE=ArbitrageBot - AUTH_TOKEN=${AUTH_TOKEN} - WALLET_ADDRESS=${WALLET_ADDRESS} - LOG_LEVEL=INFO volumes: - ./logs:/app/logs - ./config:/app/config restart: unless-stopped monitoring: image: prom/prometheus ports: - "9090:9090" volumes: - ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml grafana: image: grafana/grafana ports: - "3000:3000" environment: - GF_SECURITY_ADMIN_PASSWORD=admin volumes: - grafana-storage:/var/lib/grafana volumes: grafana-storage: """ return compose_content.strip() def deploy_bot_fleet(self): """Deploy complete bot fleet with monitoring""" try: # Create necessary directories os.makedirs('logs', exist_ok=True) os.makedirs('config', exist_ok=True) os.makedirs('monitoring', exist_ok=True) # Generate deployment files with open('Dockerfile', 'w') as f: f.write(self.create_bot_dockerfile('BaseTradingBot')) with open('docker-compose.yml', 'w') as f: f.write(self.create_docker_compose()) # Create monitoring configuration self.create_monitoring_config() # Build and deploy os.system('docker-compose up -d --build') print("🚀 Bot fleet deployed successfully!") print("📊 Monitoring available at http://localhost:3000 (Grafana)") print("📈 Metrics available at http://localhost:9090 (Prometheus)") print("📝 Check logs with: docker-compose logs -f") except Exception as e: print(f"❌ Deployment failed: {e}") def create_monitoring_config(self): """Create Prometheus monitoring configuration""" prometheus_config = """ global: scrape_interval: 15s scrape_configs: - job_name: 'trading-bots' static_configs: - targets: ['token-sniping-bot:8080', 'market-making-bot:8080', 'arbitrage-bot:8080'] scrape_interval: 5s metrics_path: /metrics """ with open('monitoring/prometheus.yml', 'w') as f: f.write(prometheus_config.strip()) ``` -------------------------------- ### Initialize PortfolioDashboard Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/get-meme-open-positions-guide.md Initializes the PortfolioDashboard with an AxiomClient instance and a wallet address. Requires the AxiomClient to be set up beforehand. ```python from typing import Dict, List from datetime import datetime class PortfolioDashboard: """Comprehensive portfolio dashboard for meme positions""" def __init__(self, client: AxiomClient, wallet_address: str): self.client = client self.wallet_address = wallet_address self.positions_data = None ``` -------------------------------- ### Verify API Connectivity with a Test Pair Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/get-last-transaction-guide.md To troubleshoot 'Failed to get last transaction' errors, verify the pair address is correct and active. This example tests the API with a known active pair. ```python # Test with a known active pair first test_pair = "Cr8Qy7quTPDdR3sET6fZk7bRFtiDFLeuwntgZGKJrnAY" try: test_tx = client.get_last_transaction(test_pair) print("API working correctly") except Exception as e: print(f"API issue: {e}") ``` -------------------------------- ### Install AxiomTradeAPI-py for user Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/installation.html Install the package for the current user only, which can resolve 'Permission Denied' errors when installing packages globally. This is an alternative to system-wide installations. ```bash pip install --user axiomtradeapi ``` -------------------------------- ### Authentication Setup Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/buy-token-guide.md Initializes the AxiomTradeClient, which is a prerequisite for using the buy_token() method. Ensure you import the client correctly. ```python from axiomtradeapi.client import AxiomTradeClient ``` -------------------------------- ### Set up Performance Tracker Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/get-meme-open-positions-guide.md Initialize a PerformanceTracker with the authenticated client and a specific strategy ID. This tracker will record performance data. ```python tracker = PerformanceTracker(client, "BJBgjyDZx5FSsyJf6bFKVXuJV7DZY9PCSMSi5d9tcEVh") ``` -------------------------------- ### Initialize and Login AxiomClient Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/get-meme-open-positions-guide.md Instantiate the AxiomClient and log in using your email and password. Ensure you have your credentials ready. ```python client = AxiomClient() client.login(email="your@email.com", password="your_password") ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/examples/README.md Installs the necessary Python libraries for the Telegram bot and environment variable management. Ensure Python 3.7+ is installed. ```bash pip install python-telegram-bot python-dotenv ``` -------------------------------- ### Initialize and Use LiquidityTracker Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/get-last-transaction-guide.md This snippet shows how to instantiate the `LiquidityTracker` class, feed it with transaction data over time, and then generate a liquidity report. Ensure you have logged into the `AxiomClient` before creating the tracker. ```python from typing import List, Dict class LiquidityTracker: """Track liquidity changes from transaction data""" def __init__(self, client: AxiomClient, pair_address: str): self.client = client self.pair_address = pair_address self.liquidity_history: List[Dict] = [] self.last_signature = None def update_liquidity_data(self) -> Optional[Dict]: """Update liquidity data if there's a new transaction""" try: last_tx = self.client.get_last_transaction(self.pair_address) # Check if this is new data if last_tx['signature'] == self.last_signature: return None self.last_signature = last_tx['signature'] liquidity_data = { 'timestamp': last_tx['createdAt'], 'sol_liquidity': last_tx['liquiditySol'], 'token_liquidity': last_tx['liquidityToken'], 'tx_type': last_tx['type'], 'tx_size_usd': last_tx['totalUsd'] } self.liquidity_history.append(liquidity_data) return liquidity_data except Exception as e: print(f"Error updating liquidity: {e}") return None def calculate_liquidity_change(self) -> Dict: """Calculate liquidity change metrics""" if len(self.liquidity_history) < 2: return {'has_data': False} first = self.liquidity_history[0] last = self.liquidity_history[-1] sol_change = last['sol_liquidity'] - first['sol_liquidity'] sol_change_pct = (sol_change / first['sol_liquidity']) * 100 token_change = last['token_liquidity'] - first['token_liquidity'] token_change_pct = (token_change / first['token_liquidity']) * 100 return { 'has_data': True, 'sol_change': sol_change, 'sol_change_pct': sol_change_pct, 'token_change': token_change, 'token_change_pct': token_change_pct, 'initial_sol': first['sol_liquidity'], 'current_sol': last['sol_liquidity'], 'initial_token': first['token_liquidity'], 'current_token': last['token_liquidity'] } def analyze_liquidity_trend(self) -> str: """Analyze liquidity trend""" change = self.calculate_liquidity_change() if not change['has_data']: return "INSUFFICIENT_DATA" sol_change = change['sol_change_pct'] if sol_change > 10: return "STRONG_ADDITION" elif sol_change > 5: return "MODERATE_ADDITION" elif sol_change > 0: return "SLIGHT_ADDITION" elif sol_change > -5: return "SLIGHT_REMOVAL" elif sol_change > -10: return "MODERATE_REMOVAL" else: return "STRONG_REMOVAL" def get_report(self) -> str: """Generate liquidity report""" if not self.liquidity_history: return "No liquidity data collected yet" change = self.calculate_liquidity_change() trend = self.analyze_liquidity_trend() report = f"💧 Liquidity Report for {self.pair_address[:8]}...\n" report += f"{ '='*60}\n\n" if change['has_data']: report += f"📊 SOL Liquidity:\n" report += f" Initial: {change['initial_sol']:,.2f} SOL\n" report += f" Current: {change['current_sol']:,.2f} SOL\n" report += f" Change: {change['sol_change']:+,.2f} SOL ({change['sol_change_pct']:+.2f}%)\n\n" report += f"🪙 Token Liquidity:\n" report += f" Initial: {change['initial_token']:,.0f} tokens\n" report += f" Current: {change['current_token']:,.0f} tokens\n" report += f" Change: {change['token_change']:+,.0f} tokens ({change['token_change_pct']:+.2f}%)\n\n" report += f"📈 Trend: {trend.replace('_', ' ')}\n" report += f"📝 Total transactions tracked: {len(self.liquidity_history)}\n" else: last = self.liquidity_history[-1] report += f"Current SOL Liquidity: {last['sol_liquidity']:,.2f} SOL\n" report += f"Current Token Liquidity: {last['token_liquidity']:,.0f} tokens\n" return report # Usage client = AxiomClient() client.login(email="your@email.com", password="your_password") tracker = LiquidityTracker(client, "Cr8Qy7quTPDdR3sET6fZk7bRFtiDFLeuwntgZGKJrnAY") # Collect data over time import time for i in range(10): new_data = tracker.update_liquidity_data() if new_data: print(f"✅ New liquidity data: {new_data['sol_liquidity']:.2f} SOL") time.sleep(30) ``` -------------------------------- ### Install nodriver for Browser Login Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/release-1-1-6.md Install the optional nodriver dependency for browser-based login functionality. This can be installed as part of the axiomtradeapi package or separately. ```bash pip install "axiomtradeapi[browser]" # or pip install nodriver ``` -------------------------------- ### AxiomClient Initialization and Rebalancer Usage Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/get-meme-open-positions-guide.md Demonstrates how to initialize the AxiomClient, log in, create a PositionRebalancer instance, set rebalancing parameters, display the plan, and execute rebalancing actions with a dry run. ```python # Usage client = AxiomClient() client.login(email="your@email.com", password="your_password") rebalancer = PositionRebalancer(client, "BJBgjyDZx5FSsyJf6bFKVXuJV7DZY9PCSMSi5d9tcEVh") rebalancer.target_position_pct = 10 rebalancer.max_position_pct = 15 rebalancer.display_rebalancing_plan() # Execute with dry run first rebalancer.execute_rebalancing(dry_run=True) ``` -------------------------------- ### Install AxiomTradeAPI Python Package Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/PYPI_RELEASE_READY.md Instructions for installing the AxiomTradeAPI package using pip. Supports installing the latest version, a specific version, or with optional dependencies. ```bash pip install axiomtradeapi ``` ```bash pip install axiomtradeapi==1.0.3 ``` ```bash pip install axiomtradeapi[telegram] ``` -------------------------------- ### Install AxiomTradeAPI via pip Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/installation.md Use this command to install the latest stable version of the AxiomTradeAPI Python SDK. Verify the installation by running a simple Python command. ```bash pip install axiomtradeapi python -c "from axiomtradeapi import AxiomTradeClient; print('✅ Installation successful!')" ``` -------------------------------- ### Python - AxiomTradeClient Initialization and Authentication Methods Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/ensure-authenticated-guide.md Demonstrates various ways to initialize the AxiomTradeClient and provide authentication credentials, including direct login, initialization with credentials, and manual token setting. ```python from axiomtradeapi.client import AxiomTradeClient # Initialize client client = AxiomTradeClient() # Provide authentication (one of these): # Option 1: Login with credentials client.login("username", "password") # Option 2: Initialize with credentials (auto-login) client = AxiomTradeClient(username="user", password="pass") # Option 3: Set tokens manually client.set_tokens("access_token", "refresh_token") ``` -------------------------------- ### Initialize AxiomTradeClient and Fetch Data Source: https://github.com/chipadevteam/axiomtradeapi-py/blob/main/docs/PYPI_RELEASE_READY.md Example of initializing the AxiomTradeClient with authentication tokens and fetching trending tokens. Requires environment variables for auth tokens. ```python from axiomtradeapi.client import AxiomTradeClient import os # Initialize client client = AxiomTradeClient( auth_token=os.getenv('auth-access-token'), refresh_token=os.getenv('auth-refresh-token') ) # Get trending tokens trending = client.get_trending_tokens('1h') ```