Files
eth_hedge_sim/backend/app/config.py
T
dekun cce26e87b5 Add dual exit modes: fixed USDT or premium multiple.
Net PnL (after estimated close fees) drives auto close; Plan/Settings expose the choice.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-25 09:17:50 +08:00

68 lines
2.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from __future__ import annotations
from functools import lru_cache
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
model_config = SettingsConfigDict(
env_file=(".env", "../.env"),
env_file_encoding="utf-8",
extra="ignore",
)
mode: str = "SIM"
tz: str = "Asia/Shanghai"
env_name: str = "test" # test / prod
exchange: str = "okx" # okx | binance(币安占位)
api_host: str = "0.0.0.0"
api_port: int = 5155
# Web 登录(仅本机 .env,勿提交真密码)
auth_username: str = "admin"
auth_password: str = "admin123"
auth_secret: str = "change-me-eth-hedge-sim-secret"
auth_token_ttl_sec: int = 60 * 60 * 24 * 7
okx_api_key: str = ""
okx_api_secret: str = ""
okx_api_passphrase: str = ""
okx_rest_base: str = "https://www.okx.com"
okx_ws_public: str = "wss://ws.okx.com:8443/ws/v5/public"
okx_http_proxy: str = ""
perp_inst_id: str = "ETH-USDT-SWAP"
option_inst_family: str = "ETH-USD_UM"
index_inst_id: str = "ETH-USD"
fee_rate: float = 0.0005
initial_equity: float = 100_000.0
max_rounds: int = 3 # 已不再强管控,仅兼容旧字段
open_hhmm: str = "16:00" # 已废弃开仓窗
stop_open_hhmm: str = "08:00" # 已废弃开仓窗
exit_move_points: float = 30.0 # 旧字段,已废弃
exit_move_pct: float = 2.0 # 旧字段,已废弃(改用净盈利出场)
exit_mode: str = "fixed_usdt" # fixed_usdt | premium_multiple
net_profit_target: float = 15.0 # fixed_usdt:净盈利 ≥ 该值(USDT
premium_exit_multiple: float = 1.0 # premium_multiple:净盈利 ≥ 权利金×倍数
rest_seconds: int = 300
leverage: float = 3.0 # 永续杠杆
min_option_hours: float = 12.0 # 期权最小剩余小时
min_option_leverage: float = 100.0 # 现价/卖一权利金 下限
close_bid_mark_max_pct: float = 30.0 # 平仓:买一相对标记最大偏差%
perp_qty_eth: float = 1.0
option_qty_eth: float = 2.0
option_ct_mult_default: float = 0.01
db_path: str = "" # empty -> backend/data/hedge.db
@property
def is_sim(self) -> bool:
return self.mode.strip().upper() != "LIVE"
@lru_cache
def get_settings() -> Settings:
return Settings()