-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
64 lines (50 loc) · 1.83 KB
/
Copy pathconfig.py
File metadata and controls
64 lines (50 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from typing import Literal
from pydantic import Field, computed_field
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
# Anthropic
anthropic_api_key: str
# Binance
binance_api_key: str = ""
binance_secret_key: str = ""
binance_env: Literal["testnet", "mainnet"] = "testnet"
# PostgreSQL
postgres_host: str = "localhost"
postgres_port: int = 5432
postgres_db: str = "botf"
postgres_user: str = "botf"
postgres_password: str = "botf_dev"
# Redis
redis_host: str = "localhost"
redis_port: int = 6379
redis_db: int = 0
# Bot
symbols: list[str] = Field(default=["BTC/USDT", "ETH/USDT"])
risk_per_trade: float = Field(default=0.01, ge=0.001, le=0.02)
log_level: Literal["DEBUG", "INFO", "WARNING", "ERROR"] = "INFO"
trading_mode: Literal["dry_run", "live"] = "dry_run"
@computed_field
@property
def postgres_dsn(self) -> str:
return (
f"postgresql://{self.postgres_user}:{self.postgres_password}"
f"@{self.postgres_host}:{self.postgres_port}/{self.postgres_db}"
)
@computed_field
@property
def redis_url(self) -> str:
return f"redis://{self.redis_host}:{self.redis_port}/{self.redis_db}"
@classmethod
def _parse_symbols(cls, v: str | list[str]) -> list[str]:
if isinstance(v, str):
return [s.strip() for s in v.split(",") if s.strip()]
return v
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
extra="ignore",
# Allow "BTC/USDT,ETH/USDT" string from .env
json_schema_extra={"symbols": {"type": "string"}},
)
settings = Settings() # type: ignore[call-arg]