feat(V2): pydantic settings con secret str + test
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
"""Pydantic Settings: legge .env e variabili d'ambiente."""
|
||||
from __future__ import annotations
|
||||
|
||||
from pydantic import Field, SecretStr
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class _Sub(BaseSettings):
|
||||
"""Base per sub-settings, condivide model_config con env_file."""
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
extra="ignore",
|
||||
)
|
||||
|
||||
|
||||
class DeribitSettings(_Sub):
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
env_prefix="DERIBIT_",
|
||||
extra="ignore",
|
||||
)
|
||||
client_id: str
|
||||
client_secret: SecretStr
|
||||
url_live: str
|
||||
url_testnet: str
|
||||
max_leverage: int = 3
|
||||
|
||||
|
||||
class BybitSettings(_Sub):
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
env_prefix="BYBIT_",
|
||||
extra="ignore",
|
||||
)
|
||||
api_key: str
|
||||
api_secret: SecretStr
|
||||
url_live: str
|
||||
url_testnet: str
|
||||
max_leverage: int = 3
|
||||
|
||||
|
||||
class HyperliquidSettings(_Sub):
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
env_prefix="HYPERLIQUID_",
|
||||
extra="ignore",
|
||||
)
|
||||
wallet_address: str
|
||||
api_wallet_address: str
|
||||
private_key: SecretStr
|
||||
url_live: str
|
||||
url_testnet: str
|
||||
max_leverage: int = 3
|
||||
|
||||
|
||||
class AlpacaSettings(_Sub):
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
env_prefix="ALPACA_",
|
||||
extra="ignore",
|
||||
)
|
||||
api_key_id: str
|
||||
secret_key: SecretStr
|
||||
url_live: str
|
||||
url_testnet: str
|
||||
max_leverage: int = 1
|
||||
|
||||
|
||||
class MacroSettings(_Sub):
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
extra="ignore",
|
||||
)
|
||||
fred_api_key: SecretStr
|
||||
finnhub_api_key: SecretStr
|
||||
|
||||
|
||||
class SentimentSettings(_Sub):
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
extra="ignore",
|
||||
)
|
||||
cryptopanic_key: SecretStr
|
||||
lunarcrush_key: SecretStr
|
||||
|
||||
|
||||
class Settings(_Sub):
|
||||
host: str = "0.0.0.0"
|
||||
port: int = 9000
|
||||
log_level: str = "info"
|
||||
|
||||
testnet_token: SecretStr
|
||||
mainnet_token: SecretStr
|
||||
|
||||
deribit: DeribitSettings = Field(default_factory=DeribitSettings)
|
||||
bybit: BybitSettings = Field(default_factory=BybitSettings)
|
||||
hyperliquid: HyperliquidSettings = Field(default_factory=HyperliquidSettings)
|
||||
alpaca: AlpacaSettings = Field(default_factory=AlpacaSettings)
|
||||
macro: MacroSettings = Field(default_factory=MacroSettings)
|
||||
sentiment: SentimentSettings = Field(default_factory=SentimentSettings)
|
||||
Reference in New Issue
Block a user