mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-06-06 05:51:19 +08:00
Restore config.json.example
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
|
||||
## 配置方式
|
||||
|
||||
~~在 `config.json` 中添加使用自定义 API 的 trader:~~
|
||||
在 `config.json` 中添加使用自定义 API 的 trader(~~已弃用~~):
|
||||
|
||||
*注意:现在通过Web界面配置自定义API,不再使用config.json文件*
|
||||
*注意:现在通过Web界面配置自定义API和交易员,config.json仅保留基础设置*
|
||||
|
||||
```json
|
||||
{
|
||||
|
||||
@@ -49,13 +49,13 @@ docker compose --version # Docker 24+ includes this, no separate installation n
|
||||
### Step 1: Prepare Configuration File
|
||||
|
||||
```bash
|
||||
# ~~Copy configuration template~~
|
||||
# ~~cp config.example.jsonc config.json~~
|
||||
# Copy configuration template
|
||||
cp config.example.jsonc config.json
|
||||
|
||||
# ~~Edit configuration file with your API keys~~
|
||||
# ~~nano config.json # or use any other editor~~
|
||||
# Edit configuration file with your API keys
|
||||
nano config.json # or use any other editor
|
||||
|
||||
⚠️ **Note**: Configuration is now done through the web interface, no longer using JSON files.
|
||||
⚠️ **Note**: Basic config.json is still needed for some settings, but ~~trader configurations~~ are now done through the web interface.
|
||||
```
|
||||
|
||||
**Required fields:**
|
||||
|
||||
15
README.md
15
README.md
@@ -156,7 +156,7 @@ A Binance-compatible decentralized perpetual futures exchange!
|
||||
```
|
||||
nofx/
|
||||
├── main.go # Program entry (multi-trader manager)
|
||||
├── ~~config.json~~ # ~~Configuration file (API keys, multi-trader config)~~ (Deprecated: Use web interface)
|
||||
├── config.json # Configuration file (API keys, ~~multi-trader config~~) (Trader config via web interface)
|
||||
│
|
||||
├── api/ # HTTP API service
|
||||
│ └── server.go # Gin framework, RESTful API
|
||||
@@ -251,15 +251,16 @@ Before using this system, you need a Binance Futures account. **Use our referral
|
||||
|
||||
Docker automatically handles all dependencies (Go, Node.js, TA-Lib, SQLite) and environment setup.
|
||||
|
||||
#### ~~Step 1: Prepare Configuration~~ (Deprecated)
|
||||
#### Step 1: Prepare Configuration
|
||||
```bash
|
||||
# ~~Copy configuration template~~
|
||||
# ~~cp config.example.jsonc config.json~~
|
||||
# Copy configuration template
|
||||
cp config.example.jsonc config.json
|
||||
|
||||
# ~~Edit and fill in your API keys~~
|
||||
# ~~nano config.json # or use any editor~~
|
||||
# Edit and fill in your API keys
|
||||
nano config.json # or use any editor
|
||||
```
|
||||
⚠️ **Note**: Configuration is now done through the web interface, not JSON files.
|
||||
|
||||
⚠️ **Note**: Basic config.json is still needed for some settings, but ~~trader configurations~~ are now done through the web interface.
|
||||
|
||||
#### Step 2: One-Click Start
|
||||
```bash
|
||||
|
||||
@@ -150,7 +150,7 @@ NOFX现已支持**三大交易所**:Binance、Hyperliquid和Aster DEX!
|
||||
```
|
||||
nofx/
|
||||
├── main.go # 程序入口(多trader管理器)
|
||||
├── ~~config.json~~ # ~~配置文件(API密钥、多trader配置)~~ (已弃用:使用Web界面)
|
||||
├── config.json # 配置文件(API密钥、~~多trader配置~~)(交易员配置通过Web界面)
|
||||
│
|
||||
├── api/ # HTTP API服务
|
||||
│ └── server.go # Gin框架,RESTful API
|
||||
@@ -245,15 +245,16 @@ nofx/
|
||||
|
||||
Docker会自动处理所有依赖(Go、Node.js、TA-Lib)和环境配置,完美适合新手!
|
||||
|
||||
#### ~~步骤1:准备配置文件~~ (已弃用)
|
||||
#### 步骤1:准备配置文件
|
||||
```bash
|
||||
# ~~复制配置文件模板~~
|
||||
# ~~cp config.example.jsonc config.json~~
|
||||
# 复制配置文件模板
|
||||
cp config.example.jsonc config.json
|
||||
|
||||
# ~~编辑并填入你的API密钥~~
|
||||
# ~~nano config.json # 或使用其他编辑器~~
|
||||
# 编辑并填入你的API密钥
|
||||
nano config.json # 或使用其他编辑器
|
||||
```
|
||||
⚠️ **注意**: 现在通过Web界面进行配置,不再使用JSON文件。
|
||||
|
||||
⚠️ **注意**: 基础config.json仍需要一些设置,但~~交易员配置~~现在通过Web界面进行。
|
||||
|
||||
#### 步骤2:一键启动
|
||||
```bash
|
||||
|
||||
24
config.json.example
Normal file
24
config.json.example
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"leverage": {
|
||||
"btc_eth_leverage": 5,
|
||||
"altcoin_leverage": 5
|
||||
},
|
||||
"use_default_coins": true,
|
||||
"default_coins": [
|
||||
"BTCUSDT",
|
||||
"ETHUSDT",
|
||||
"SOLUSDT",
|
||||
"BNBUSDT",
|
||||
"XRPUSDT",
|
||||
"DOGEUSDT",
|
||||
"ADAUSDT",
|
||||
"HYPEUSDT"
|
||||
],
|
||||
"coin_pool_api_url": "",
|
||||
"oi_top_api_url": "",
|
||||
"api_server_port": 8080,
|
||||
"max_daily_loss": 10.0,
|
||||
"max_drawdown": 20.0,
|
||||
"stop_trading_minutes": 60,
|
||||
"jwt_secret": "Qk0kAa+d0iIEzXVHXbNbm+UaN3RNabmWtH8rDWZ5OPf+4GX8pBflAHodfpbipVMyrw1fsDanHsNBjhgbDeK9Jg=="
|
||||
}
|
||||
49
start.sh
49
start.sh
@@ -77,6 +77,42 @@ check_env() {
|
||||
print_success "环境变量文件存在"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# Validation: Configuration File (config.json) - DEPRECATED
|
||||
# ------------------------------------------------------------------------
|
||||
check_config() {
|
||||
if [ ! -f "config.json" ]; then
|
||||
print_warning "config.json 不存在,从模板复制..."
|
||||
cp config.example.jsonc config.json
|
||||
print_info "⚠️ 注意:config.json 已弃用,请使用Web界面进行配置"
|
||||
print_info "此文件仅作为参考保留"
|
||||
fi
|
||||
print_success "配置文件存在(已弃用,使用Web界面配置)"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# Utility: Read Environment Variables
|
||||
# ------------------------------------------------------------------------
|
||||
read_env_vars() {
|
||||
if [ -f ".env" ]; then
|
||||
# 读取端口配置,设置默认值
|
||||
NOFX_FRONTEND_PORT=$(grep "^NOFX_FRONTEND_PORT=" .env 2>/dev/null | cut -d'=' -f2 || echo "3000")
|
||||
NOFX_BACKEND_PORT=$(grep "^NOFX_BACKEND_PORT=" .env 2>/dev/null | cut -d'=' -f2 || echo "8080")
|
||||
|
||||
# 去除可能的引号和空格
|
||||
NOFX_FRONTEND_PORT=$(echo "$NOFX_FRONTEND_PORT" | tr -d '"'"'" | tr -d ' ')
|
||||
NOFX_BACKEND_PORT=$(echo "$NOFX_BACKEND_PORT" | tr -d '"'"'" | tr -d ' ')
|
||||
|
||||
# 如果为空则使用默认值
|
||||
NOFX_FRONTEND_PORT=${NOFX_FRONTEND_PORT:-3000}
|
||||
NOFX_BACKEND_PORT=${NOFX_BACKEND_PORT:-8080}
|
||||
else
|
||||
# 如果.env不存在,使用默认端口
|
||||
NOFX_FRONTEND_PORT=3000
|
||||
NOFX_BACKEND_PORT=8080
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# Validation: Database File (trading.db)
|
||||
# ------------------------------------------------------------------------
|
||||
@@ -123,6 +159,9 @@ check_database() {
|
||||
start() {
|
||||
print_info "正在启动 NOFX AI Trading System..."
|
||||
|
||||
# 读取环境变量
|
||||
read_env_vars
|
||||
|
||||
# Auto-build frontend if missing or forced
|
||||
# if [ ! -d "web/dist" ] || [ "$1" == "--build" ]; then
|
||||
# build_frontend
|
||||
@@ -138,8 +177,8 @@ start() {
|
||||
fi
|
||||
|
||||
print_success "服务已启动!"
|
||||
print_info "Web 界面: http://localhost:3000"
|
||||
print_info "API 端点: http://localhost:8080"
|
||||
print_info "Web 界面: http://localhost:${NOFX_FRONTEND_PORT}"
|
||||
print_info "API 端点: http://localhost:${NOFX_BACKEND_PORT}"
|
||||
print_info ""
|
||||
print_info "查看日志: ./start.sh logs"
|
||||
print_info "停止服务: ./start.sh stop"
|
||||
@@ -178,11 +217,14 @@ logs() {
|
||||
# Monitoring: Status
|
||||
# ------------------------------------------------------------------------
|
||||
status() {
|
||||
# 读取环境变量
|
||||
read_env_vars
|
||||
|
||||
print_info "服务状态:"
|
||||
$COMPOSE_CMD ps
|
||||
echo ""
|
||||
print_info "健康检查:"
|
||||
curl -s http://localhost:8080/health | jq '.' || echo "后端未响应"
|
||||
curl -s "http://localhost:${NOFX_BACKEND_PORT}/health" | jq '.' || echo "后端未响应"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
@@ -243,6 +285,7 @@ main() {
|
||||
case "${1:-start}" in
|
||||
start)
|
||||
check_env
|
||||
check_config
|
||||
check_database
|
||||
start "$2"
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user