Example: Executing a Trade on Raydium

Start the CLI:bash
./run-omniflux.sh
From the Interactive Menu:
Select "
Trading"
Choose "Create Trading Agent"
Enter agent details (e.g., name: "SOL-USDC Trader", strategy: "momentum")
Select "Execute Trade"
Choose trading pair (e.g., SOL/USDC)
Specify order type (market), side (buy), and quantity (1 SOL)
Confirm and monitor the trade
Alternatively, use the Python wrapper:python
import asyncio
from omniflux import OmniFlux
async def execute_trade():
client = OmniFlux(host="localhost", port=8052)
await client.connect()
agent = await client.agents.create_agent(
name="SOL-USDC Trader",
agent_type="trading",
config={"strategy": "momentum", "risk_level": "medium"}
)
wallet = await client.wallets.create_wallet(
name="Trading Wallet",
wallet_type="phantom",
network="solana"
)
result = await client.trading.execute_trade(
agent_id=agent["id"],
wallet_id=wallet["id"],
network="solana",
pair="SOL/USDC",
order_type="market",
side="buy",
quantity=1.0,
dex="raydium",
slippage=1.0
)
print(f"Trade executed: {result['transaction_id']}")
await client.disconnect()
asyncio.run(execute_trade())
Last updated