A CCXT-compatible adapter/wrapper for the Ethereal Python SDK. It maps Ethereal SDK methods onto familiar CCXT interfaces.
- CCXT: https://github.com/ccxt/ccxt
- Ethereal SDK (Python): https://pypi.org/project/ethereal-sdk/
DOES NOT IMPLEMENT ALL METHODS OR SHOW ALL VALUES, USE WITH CAUTION
- CCXT-style API backed by the Ethereal SDK
- Simple environment-based configuration
- Python 3.13+ support
For installation and inclusion in another projects use
pip install {localpath}\ethereal_ccxt_adapter
or
pip install git+https://github.com/marcelkb/ethereal-ccxt-adapter.git
pip install ethereal-sdk
git clone git@github.com:meridianxyz/ethereal-py-sdk.git
Create a .env file in the project root with the following variables:
PRIVATE_KEY= Your Api private key
WALLET_ADDRESS= Your Api puplic wallet address
L1_WALLET_ADDRESS= Your Ethereal main wallet Adddress
from ethereal_ccxt_adapter import Ethereal
from ethereal_ccxt_adapter.const import EOrderSide, EOrderType
load_dotenv(env.ethereal)
PRIVATE_KEY = os.environ.get("PRIVATE_KEY")
WALLET_ADDRESS = os.environ.get("WALLET_ADDRESS")
L1_WALLET_ADDRESS = os.environ.get("L1_WALLET_ADDRESS")
exchange = Ethereal({
'l1_wallet_address': L1_WALLET_ADDRESS,
"private_key": PRIVATE_KEY,
"wallet_address": WALLET_ADDRESS,
})
symbol = 'SOL/USD:USD' # market symbol
AMOUNT = 0.1
ticker = exchange.fetch_ticker(symbol)
print(f"{symbol} price: {ticker['last']}")
position = exchange.fetch_position(symbol)
print(f"{position['info']['unrealisedPnl']} {position['info']['curRealisedPnl']} {position['info']['size']}")
print(f"Creating LIMIT BUY order for {symbol}")
print(exchange.create_order(symbol, EOrderType.LIMIT.value, EOrderSide.BUY.value, AMOUNT, ticker['last'] * 0.5))
print(f"Creating TAKE PROFIT MARKET SELL order for {symbol}")
print(exchange.create_order(
symbol,
EOrderType.MARKET.value,
EOrderSide.SELL.value,
AMOUNT,
ticker['last'] * 1.01,
params={'takeProfitPrice': '250', 'reduceOnly': True}
))
print(f"Creating STOP LOSS MARKET SELL order for {symbol}")
print(exchange.create_order(
symbol,
EOrderType.MARKET.value,
EOrderSide.SELL.value,
AMOUNT,
ticker['last'] * 1.01,
params={'stopLossPrice': '100', 'reduceOnly': True}
))