Arthur LangChain Tools 🤖⚡
Trade perpetual futures with any LangChain agent. Built on Arthur DEX - the exchange for AI agents.
Installation
pip install arthur-langchain
Quick Start
from arthur_langchain import ArthurToolkit
from langchain_openai import ChatOpenAI
from langchain.agents import create_react_agent, AgentExecutor
from langchain import hub
# Initialize toolkit with your credentials
toolkit = ArthurToolkit(
account_id="your_account_id",
api_key="ed25519:your_api_key",
secret_key="ed25519:your_secret_key"
)
# Create an agent with trading capabilities
llm = ChatOpenAI(model="gpt-4")
prompt = hub.pull("hwchase17/react")
agent = create_react_agent(llm, toolkit.get_tools(), prompt)
executor = AgentExecutor(agent=agent, tools=toolkit.get_tools(), verbose=True)
# Let your agent trade!
executor.invoke({"input": "Buy 0.01 BTC if the price is under $100k"})
Tools Included
🔄 ArthurTradeTool
Execute market and limit orders.
# Market buy
agent.invoke({"input": "Buy 0.5 ETH at market price"})
# Limit sell
agent.invoke({"input": "Place a limit sell for 1 SOL at $150"})
📊 ArthurPortfolioTool
Check positions, balance, and P&L.
agent.invoke({"input": "What are my current positions and P&L?"})
agent.invoke({"input": "How much margin do I have available?"})
📈 ArthurMarketTool
Get prices, orderbook, and funding rates.
agent.invoke({"input": "What's the current BTC price?"})
agent.invoke({"input": "Show me the ETH orderbook"})
agent.invoke({"input": "What's the funding rate on SOL?"})
📋 ArthurOrdersTool
Manage open orders.
agent.invoke({"input": "List my open orders"})
agent.invoke({"input": "Cancel all my orders"})
Example: Trading Agent
Here's a complete trading agent that follows a simple strategy:
from arthur_langchain import ArthurToolkit
from langchain_openai import ChatOpenAI
from langchain.agents import create_react_agent, AgentExecutor
from langchain_core.prompts import PromptTemplate
# Setup
toolkit = ArthurToolkit(
account_id="your_account_id",
api_key="ed25519:your_api_key",
secret_key="ed25519:your_secret_key"
)
llm = ChatOpenAI(model="gpt-4", temperature=0)
# Custom trading prompt
prompt = PromptTemplate.from_template("""You are a crypto trading agent with access to Arthur DEX.
Your trading rules:
1. Never risk more than 10% of portfolio on a single trade
2. Always check current price before trading
3. Set reasonable position sizes
Available tools:
{tools}
Tool names: {tool_names}
Question: {input}
Think step by step:
{agent_scratchpad}
""")
agent = create_react_agent(llm, toolkit.get_tools(), prompt)
executor = AgentExecutor(agent=agent, tools=toolkit.get_tools(), verbose=True)
# Run the agent
result = executor.invoke({
"input": "Check if BTC is under $95k. If so, buy $100 worth."
})
print(result)
Example: CrewAI Integration
from crewai import Agent, Task, Crew
from arthur_langchain import ArthurToolkit
toolkit = ArthurToolkit(
account_id="your_account_id",
api_key="ed25519:your_api_key",
secret_key="ed25519:your_secret_key"
)
trader = Agent(
role="Crypto Trader",
goal="Execute profitable trades on Arthur DEX",
backstory="Expert perpetual futures trader",
tools=toolkit.get_tools(),
verbose=True
)
task = Task(
description="Analyze BTC market and decide whether to open a position",
agent=trader
)
crew = Crew(agents=[trader], tasks=[task])
result = crew.kickoff()
Supported Markets
80+ perpetual futures including:
- Majors: BTC, ETH, SOL, BNB
- L2s: ARB, OP, MATIC
- DeFi: UNI, AAVE, LINK, MKR
- Memes: DOGE, SHIB, PEPE, WIF
- AI: FET, RNDR, TAO
Getting Credentials
- Go to Arthur DEX
- Connect your wallet
- Generate API keys in Settings
Or use the Arthur SDK directly:
from arthur_sdk import Arthur
client = Arthur.create_account() # Creates new account
print(client.account_id, client.api_key, client.secret_key)
Links
- 🌐 Arthur DEX
- 📦 Arthur SDK
- 🐦 @Arthur_Orderly
- 💬 Discord
License
MIT
Metadata
Release files for arthur-langchain 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| arthur_langchain-0.1.0.tar.gz | 8.2 kB | Without provenance | Details for arthur_langchain-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| arthur_langchain-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for arthur_langchain-0.1.0-py3-none-any.whl |
Total release size: 16.8 kB
Release files / arthur_langchain-0.1.0.tar.gz
| Download URL | arthur_langchain-0.1.0.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83a6742f7515b395019d1cfff620021a2ce1cefeb7fc1048e6d74679a14a8883
|
|
BLAKE2b-256 checksum How to use checksums |
70e3a4c8849133d0855561dfa81a5f3a4ce595f29dfb9efbbdf7da023d744a78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / arthur_langchain-0.1.0-py3-none-any.whl
| Download URL | arthur_langchain-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
81c03471a302b6b840aa8093bd74ec427284f3e0021c3c90323a8a2254af9c9a
|
|
BLAKE2b-256 checksum How to use checksums |
74a05d92a1d39ed5a4151e787ec0d4a58e1b9f23a8bf61f717a0e82135cd24f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for arthur-langchain 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.