Available Trading Tools in the AutoHedge Tools Registry: A Complete Guide
The AutoHedge tools registry exposes five core trading utilities—search_tokens, get_token_price, execute_trade, get_holdings, and get_order—through a single get_tools() function defined in autohedge/tools/tools_registry.py.
The AutoHedge repository implements a centralized registry pattern to organize its algorithmic trading capabilities. This design allows automated agents and manual scripts to discover and invoke standardized market operations without hard-coding API endpoints. Understanding the available trading tools in the AutoHedge tools registry is essential for anyone building quantitative strategies on this framework.
What is the AutoHedge Tools Registry?
The registry is a lightweight abstraction layer that aggregates callable trading functions into a single importable list. According to the AutoHedge source code, the get_tools() function serves as the authoritative catalog, returning references to each implemented utility as first-class Python objects. This pattern enables dynamic tool selection and simplifies dependency injection across the codebase.
Available Trading Tools in the Registry
The current registry implementation exposes five distinct trading utilities, grouped by their operational domain.
Token Discovery and Pricing
These tools interface with the Jupiter API to provide market data:
search_tokens– Defined in [autohedge/tools/jupiter_search.py](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/tools/jupiter_search.py), this function queries Jupiter’s token list to resolve symbols, addresses, and metadata.get_token_price– Located in [autohedge/tools/jupiter_price.py](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/tools/jupiter_price.py), this utility fetches real-time price quotes for specified token mints.
Trade Execution and Portfolio Management
These utilities handle order lifecycle and account state via the Ultra API:
execute_trade– Submits buy or sell orders to the market. Implemented in [autohedge/tools/ultra_tools.py](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/tools/ultra_tools.py).get_holdings– Retrieves current portfolio balances and positions. Also defined in [autohedge/tools/ultra_tools.py](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/tools/ultra_tools.py).get_order– Polls the status of a specific order by ID. Found alongside the other Ultra tools inultra_tools.py.
How to Access the Trading Tools
To obtain the complete list of registered functions, import get_tools from the registry module. The function returns a Python list containing the callable objects in the following order:
# autohedge/tools/tools_registry.py
def get_tools():
return [
search_tokens,
get_token_price,
execute_trade,
get_holdings,
get_order,
]
When you invoke get_tools(), you receive direct references to these functions, allowing immediate execution or further composition into higher-level workflows.
Practical Usage Examples
Importing All Registered Tools
The following pattern demonstrates how to unpack and utilize every tool provided by the registry:
from autohedge.tools.tools_registry import get_tools
# Obtain the list of tool callables
tools = get_tools()
# Unpack for direct access
search_fn, price_fn, trade_fn, holdings_fn, order_fn = tools
# Example invocations
tokens = search_fn(query="USDC") # Search for token metadata
price = price_fn(symbol="USDC") # Get current market price
portfolio = holdings_fn() # Fetch current holdings
order_status = order_fn(order_id="abc123") # Check order status
Executing a Specific Trade
For scenarios requiring only the execution capability, import the specific tool directly from its implementation file rather than through the registry:
from autohedge.tools.ultra_tools import execute_trade
# Execute a market buy order for 50 USDC
result = execute_trade(
action="buy",
symbol="USDC",
amount=50,
price_limit=None, # Optional price constraint
)
print("Trade execution result:", result)
Building a Dynamic Trading Engine
You can map the registry output to a dictionary for dynamic dispatch within a class:
from autohedge.tools.tools_registry import get_tools
class AutoHedgeEngine:
def __init__(self):
# Create a name-to-function mapping
self.tools = {fn.__name__: fn for fn in get_tools()}
def get_current_price(self, symbol):
return self.tools["get_token_price"](symbol)
def place_order(self, action, symbol, amount):
return self.tools["execute_trade"](
action=action,
symbol=symbol,
amount=amount
)
# Usage
engine = AutoHedgeEngine()
print(engine.get_current_price("USDC"))
engine.place_order(action="sell", symbol="USDC", amount=20)
Source Files and Implementation Details
The trading functionality is distributed across four primary files in the repository:
| File | GitHub Link | Contents |
|---|---|---|
tools_registry.py |
View Source | get_tools() function that aggregates all trading utilities. |
jupiter_search.py |
View Source | Implementation of search_tokens. |
jupiter_price.py |
View Source | Implementation of get_token_price. |
ultra_tools.py |
View Source | Implementation of execute_trade, get_holdings, and get_order. |
Summary
- The AutoHedge tools registry centralizes access to five trading utilities through the
get_tools()function inautohedge/tools/tools_registry.py. - Market data tools (
search_tokens,get_token_price) leverage the Jupiter API for token discovery and pricing. - Execution and portfolio tools (
execute_trade,get_holdings,get_order) interface with the Ultra API for order management. - You can import the entire registry list or reference individual tool functions directly from their source modules.
- Adding new capabilities requires implementing the function logic and appending the reference to the list returned by
get_tools().
Frequently Asked Questions
How do I add a new trading tool to the AutoHedge registry?
Define your new function in the appropriate module (e.g., ultra_tools.py for Ultra API interactions), then import it into autohedge/tools/tools_registry.py and append the function name to the list returned by get_tools(). The registry will automatically include it in subsequent calls.
Where is the get_tools() function defined?
The get_tools() function is defined at the module level in [autohedge/tools/tools_registry.py](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/tools/tools_registry.py). It returns a hardcoded list of function references that constitute the public API surface for trading operations.
Which API does AutoHedge use for token searches?
According to the source code in jupiter_search.py, AutoHedge uses the Jupiter API for token search functionality. This provides access to Solana-based token metadata and routing information.
Can I use individual tools without importing the entire registry?
Yes. While get_tools() provides a convenient collection, each tool is implemented as a standalone function in its respective module. You can import execute_trade directly from ultra_tools or get_token_price from jupiter_price if you only need specific functionality without the registry overhead.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →