Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions backend/config/README_CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,52 @@ ROMA Trading Platform supports **two configuration styles**:
- **`QUICK_START.md`** - Step-by-step setup guide
- **`README_CONFIG.md`** - This file (detailed documentation)

## Global System Settings

```yaml
system:
scan_interval_minutes: 3
max_concurrent_agents: 6
log_level: "INFO"

api:
host: "0.0.0.0"
port: 8000

x402:
enabled: false
price_usdc: 5.0
network: ${X402_NETWORK:-base-sepolia}
pay_to_address: ${X402_PAY_TO_ADDRESS}
facilitator_url: ${X402_FACILITATOR_URL}
payment_description: "roma-01 strategy recommendation"
resource_description: "AI-generated trading strategy advice"
resource_mime_type: "application/json"
max_deadline_seconds: 120
discoverable: true
cdp_api_key_id: ${X402_CDP_API_KEY_ID}
cdp_api_key_secret: ${X402_CDP_API_KEY_SECRET}

remote_strategy:
enabled: false
endpoint: ${REMOTE_X402_ENDPOINT}
network: ${REMOTE_X402_NETWORK}
payment_asset: ${REMOTE_X402_PAYMENT_ASSET:-USDC}
account: ${REMOTE_X402_ACCOUNT}
private_key: ${REMOTE_X402_PRIVATE_KEY}
price_cap: ${REMOTE_X402_PRICE_CAP}
discovery: ${REMOTE_X402_DISCOVERY}
fallback_mode: ${REMOTE_FALLBACK_MODE:-local}
timeout_seconds: ${REMOTE_TIMEOUT_SECONDS:-10}
retry_limit: ${REMOTE_RETRY_LIMIT:-1}
```

- `x402.enabled`: Whether to enable the paid entry. Defaults to `false`. When enabled, you must also configure payout address, price, network, facilitator, and CDP API key.
- `remote_strategy.enabled`: Whether to act as a buyer and call a remote `/x402`. Defaults to `false`. When enabled, provide the remote endpoint and wallet private key (inject via env vars or secrets manager).
- `fallback_mode`: Strategy when the remote call fails: `local` = fall back to local model, `wait` = skip this cycle, `error` = raise immediately.
- `price_cap`: Optional cap on the maximum payment per request (USDC).
- Default settings read values from environment variables to avoid hardcoding; leave unused fields blank.

## Configuration Styles

### 1. Legacy Style (Backward Compatible)
Expand Down
213 changes: 213 additions & 0 deletions backend/config/trading_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# ROMA Trading Platform - Main Configuration
# Account-Centric Configuration Style
#
# This configuration uses the account-centric architecture:
# - accounts: Define all DEX accounts (Aster, Hyperliquid, etc.)
# - models: Define all LLM models (DeepSeek, Qwen, Claude, etc.)
# - agents: Bind accounts with models to create trading agents
#
# You can add more accounts, models, and agents as needed.
# See README_CONFIG.md for detailed documentation.

system:
scan_interval_minutes: 3
max_concurrent_agents: 6
log_level: "INFO"
prompt_language: "en" # zh(中文) or en(English)

auth:
admin:
username: "admin"
password_hash: "pbkdf2_sha256$600000$gxtnJqmRLdRxef4d6bljzA==$ZwvN+9xZAJroC1BFdop9TgJEkL3ok+76+e/RHAdU0fI="
updated_at: "2025-11-10T00:00:00Z"

api:
host: "0.0.0.0"
port: 8080

x402:
enabled: false
price_usdc: 5.0
network: ${X402_NETWORK:-base-sepolia}
pay_to_address: ${X402_PAY_TO_ADDRESS}
facilitator_url: ${X402_FACILITATOR_URL}
payment_description: "roma-01 strategy recommendation"
resource_description: "AI-generated trading strategy advice"
resource_mime_type: "application/json"
max_deadline_seconds: 120
discoverable: true
cdp_api_key_id: ${X402_CDP_API_KEY_ID}
cdp_api_key_secret: ${X402_CDP_API_KEY_SECRET}

remote_strategy:
enabled: false
endpoint: ${REMOTE_X402_ENDPOINT}
network: ${REMOTE_X402_NETWORK}
payment_asset: ${REMOTE_X402_PAYMENT_ASSET:-USDC}
account: ${REMOTE_X402_ACCOUNT}
private_key: ${REMOTE_X402_PRIVATE_KEY}
price_cap: ${REMOTE_X402_PRICE_CAP}
discovery: ${REMOTE_X402_DISCOVERY}
fallback_mode: ${REMOTE_FALLBACK_MODE:-local}
timeout_seconds: ${REMOTE_TIMEOUT_SECONDS:-10}
retry_limit: ${REMOTE_RETRY_LIMIT:-1}

# ============================================
# Accounts: Define your DEX trading accounts
# ============================================
accounts:
# Default Aster DEX account
- id: "aster-acc-01"
name: "Aster Account 01"
dex_type: "aster"
user: ${ASTER_USER_01}
signer: ${ASTER_SIGNER_01}
private_key: ${ASTER_PRIVATE_KEY_01}
testnet: false
hedge_mode: false

# Add more accounts as needed:
# - id: "aster-acc-02"
# name: "Aster Account 02"
# dex_type: "aster"
# user: ${ASTER_USER_02}
# signer: ${ASTER_SIGNER_02}
# private_key: ${ASTER_PRIVATE_KEY_02}
# testnet: false
# hedge_mode: false
#
# - id: "hl-acc-01"
# name: "Hyperliquid Account 01"
# dex_type: "hyperliquid"
# api_secret: ${HL_SECRET_KEY_01}
# account_id: ${HL_ACCOUNT_ADDRESS_01} # Main wallet address
# testnet: false
# hedge_mode: false

# ============================================
# Models: Define your LLM models
# ============================================
models:
# DeepSeek Chat V3.1
- id: "deepseek-v3.1"
provider: "deepseek"
api_key: ${DEEPSEEK_API_KEY}
model: "deepseek-chat"
temperature: 0.15
max_tokens: 4000

# # Qwen3 Max
# - id: "qwen3-max"
# provider: "qwen"
# api_key: ${QWEN_API_KEY}
# model: "qwen-max"
# location: "china" # "china" for China region, "international" or other values for international region
# temperature: 0.15
# max_tokens: 4000

# # Claude Sonnet 4.5
# - id: "claude-sonnet-4.5"
# provider: "anthropic"
# api_key: ${ANTHROPIC_API_KEY}
# model: "claude-sonnet-4.5"
# temperature: 0.15
# max_tokens: 4000

# # GPT-5
# - id: "gpt-5"
# provider: "openai"
# api_key: ${OPENAI_API_KEY}
# model: "gpt-5"
# temperature: 0.15
# max_tokens: 4000

# # Grok 4
# - id: "grok-4"
# provider: "xai"
# api_key: ${XAI_API_KEY}
# model: "grok-4"
# temperature: 0.15
# max_tokens: 4000

# # Gemini 2.5 Pro
# - id: "gemini-2.5-pro"
# provider: "google"
# api_key: ${GOOGLE_API_KEY}
# model: "gemini-2.5-pro"
# temperature: 0.15
# max_tokens: 4000

# ============================================
# Agents: Bind accounts with models
# ============================================
agents:
# Default agent: DeepSeek on Aster Account
- id: "deepseek-aster-01"
name: "DeepSeek on Aster-01"
enabled: true
account_id: "aster-acc-01" # Reference to account above
model_id: "deepseek-v3.1" # Reference to model above
strategy:
initial_balance: 10000.0
scan_interval_minutes: 3
max_account_usage_pct: 100
default_coins:
- BTCUSDT
- ETHUSDT
- SOLUSDT
- BNBUSDT
- DOGEUSDT
- XRPUSDT
risk_management:
max_positions: 3
max_leverage: 10
max_position_size_pct: 30
max_total_position_pct: 80
max_single_trade_pct: 50
max_single_trade_with_positions_pct: 30
max_daily_loss_pct: 15
stop_loss_pct: 3
take_profit_pct: 10
advanced_orders:
enable_take_profit: false
take_profit_pct: 5.0
enable_stop_loss: false
stop_loss_pct: 2.0
trading_style: "balanced"
custom_prompts:
enabled: false
trading_philosophy: ""
entry_preferences: ""
position_management: ""
market_preferences: ""
additional_rules: ""

# Add more agents as needed:
# Example: Same model on different account
# - id: "deepseek-aster-02"
# name: "DeepSeek on Aster-02"
# enabled: false
# account_id: "aster-acc-02"
# model_id: "deepseek-v3.1" # Same model
# strategy:
# initial_balance: 10000.0
# scan_interval_minutes: 3
# default_coins: [BTCUSDT, ETHUSDT]
# risk_management:
# max_positions: 3
# max_leverage: 10
#
# Example: Different model on same account
# - id: "qwen-aster-01"
# name: "Qwen on Aster-01"
# enabled: false
# account_id: "aster-acc-01" # Same account
# model_id: "qwen3-max" # Different model
# strategy:
# initial_balance: 10000.0
# scan_interval_minutes: 3
# default_coins: [BTCUSDT, ETHUSDT]
# risk_management:
# max_positions: 3
# max_leverage: 10

33 changes: 33 additions & 0 deletions backend/config/trading_config.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,39 @@ api:
host: "0.0.0.0"
port: 8080

# ============================================
# x402 Server Configuration (Seller mode)
# ============================================
x402:
enabled: false # Set to true to enable /x402 paid endpoint
price_usdc: 5.0 # Fee per request (USDC)
network: ${X402_NETWORK:-base-sepolia}
pay_to_address: ${X402_PAY_TO_ADDRESS}
facilitator_url: ${X402_FACILITATOR_URL} # Optional custom facilitator URL
payment_description: "roma-01 strategy recommendation"
resource_description: "AI-generated trading strategy advice"
resource_mime_type: "application/json"
max_deadline_seconds: 120
discoverable: true
cdp_api_key_id: ${X402_CDP_API_KEY_ID} # Required when using Coinbase facilitator
cdp_api_key_secret: ${X402_CDP_API_KEY_SECRET}

# ============================================
# Remote Strategy Configuration (Buyer mode)
# ============================================
remote_strategy:
enabled: false # Set to true to call remote /x402 services
endpoint: ${REMOTE_X402_ENDPOINT} # e.g. https://partner.example.com/x402
network: ${REMOTE_X402_NETWORK} # Optional network filter
payment_asset: ${REMOTE_X402_PAYMENT_ASSET:-USDC}
account: ${REMOTE_X402_ACCOUNT} # Buyer wallet address
private_key: ${REMOTE_X402_PRIVATE_KEY} # Buyer wallet private key (use secure storage)
price_cap: ${REMOTE_X402_PRICE_CAP} # Optional max fee per request
discovery: ${REMOTE_X402_DISCOVERY} # Optional facilitator discovery endpoint
fallback_mode: ${REMOTE_FALLBACK_MODE:-local} # local|wait|error
timeout_seconds: ${REMOTE_TIMEOUT_SECONDS:-10}
retry_limit: ${REMOTE_RETRY_LIMIT:-1}

# ============================================
# Accounts: Define your DEX trading accounts
# ============================================
Expand Down
1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies = [
"eth-abi>=5.1.0",
"web3>=7.0.0",
"hyperliquid-python-sdk>=0.20.0",
"x402>=0.2.1",
"ruamel.yaml>=0.18.6",
]

Expand Down
Loading