Skip to content

arthur-orderly/arthur-langchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

arthur-langchain

LangChain tools for trading perpetuals on Arthur DEX — plug into any LangChain/LangGraph agent.

Install

pip install arthur-langchain

Quick Start

from arthur_langchain import ArthurDEXToolkit
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

tools = ArthurDEXToolkit().get_tools()
agent = create_react_agent(ChatOpenAI(model="gpt-4o"), tools)
agent.invoke({"messages": [{"role": "user", "content": "Buy 0.01 BTC perps"}]})

5 lines. Your agent can now trade perps.

Configuration

Set these environment variables:

Variable Description
ORDERLY_ACCOUNT_ID Your Orderly account ID (hex)
ORDERLY_KEY ed25519 public key (ed25519:...)
ORDERLY_SECRET ed25519 secret key (base58)
ORDERLY_BROKER_ID Broker ID (default: arthur)

Get your keys at arthurdex.com → connect wallet → generate API keys.

Available Tools

Tool Description
arthur_place_order Place market/limit perp orders (symbol, side, quantity, price)
arthur_get_positions View open positions with PnL, entry/mark price, liq price
arthur_get_balance Check USDC and token balances
arthur_get_markets List markets with prices, volume, funding rates
arthur_close_position Close a position via opposing market order

Use Individual Tools

from arthur_langchain import ArthurPlaceOrderTool, ArthurGetMarketsTool

# Add specific tools to your agent
tools = [ArthurGetMarketsTool(), ArthurPlaceOrderTool()]

Use with LangGraph

from langgraph.prebuilt import create_react_agent
from arthur_langchain import ArthurDEXToolkit

tools = ArthurDEXToolkit().get_tools()
agent = create_react_agent(llm, tools)

# The agent decides which tools to call based on the user's message
result = agent.invoke({"messages": [{"role": "user", "content": "What's my PnL?"}]})

Links

License

MIT

About

LangChain tools for Arthur DEX - Trade perpetuals with any AI agent

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages