Documentation
¶
Overview ¶
Package config owns the on-disk TOML configuration and its defaults.
Index ¶
- Variables
- func BnwatchPath() string
- func CachePath(name string) string
- func DBPath() string
- func Dir() string
- func Path() string
- func PromptDir() string
- func StatePath(name string) string
- type Alerts
- type Auto
- type Bark
- type Config
- func (c *Config) AddWatch(symbol string) bool
- func (c *Config) FilePath() string
- func (c *Config) Get(key string) (string, error)
- func (c *Config) HasPosition() bool
- func (c *Config) ImportBnwatch(path string) ([]string, error)
- func (c *Config) Keys() []string
- func (c *Config) PositionFor(symbol string) (Position, bool)
- func (c *Config) RemoveWatch(symbol string) bool
- func (c *Config) Save() error
- func (c *Config) Set(key, value string) error
- func (c *Config) SetPath(p string)
- type Endpoint
- type General
- type History
- type Hook
- type LLM
- type Level
- type Notify
- type Position
- type Proxy
- type Telegram
- type Watch
Constants ¶
This section is empty.
Variables ¶
var DefaultAliases = map[string][]string{
"\u9f99\u867eUSDT": {"longxia", "lx", "lobster"},
"\u725b\u6765USDT": {"niulai", "nl", "niu", "bull"},
"\u6211\u8e0f\u9a6c\u6765\u4e86USDT": {"wotamalaile", "wtmll", "tama"},
"\u5e01\u5b89\u4eba\u751fUSDT": {"bianrensheng", "brs", "rensheng"},
}
DefaultAliases maps a symbol to short handles that are typeable on a US keyboard. Chinese contract names are otherwise painful to enter in a TUI.
var DefaultWatch = []string{"\u9f99\u867eUSDT", "\u725b\u6765USDT", "\u6211\u8e0f\u9a6c\u6765\u4e86USDT", "\u5e01\u5b89\u4eba\u751fUSDT", "BTCUSDT", "ETHUSDT"}
DefaultWatch is the starting watchlist. The four Chinese-named perps are the reason this tool exists, so they lead.
Functions ¶
func BnwatchPath ¶
func BnwatchPath() string
BnwatchPath is the config file written by the original Python prototype.
func Dir ¶
func Dir() string
Dir is the per-user configuration directory. On Windows adrg/xdg resolves to %AppData%; elsewhere it honours XDG_CONFIG_HOME and falls back to ~/.config.
Types ¶
type Auto ¶
type Auto struct {
Px15 float64 `toml:"px15"`
OI15 float64 `toml:"oi15"`
Taker float64 `toml:"taker"`
Liq float64 `toml:"liq"`
Stop float64 `toml:"stop"`
Funding float64 `toml:"funding"`
}
Auto holds thresholds for the always-on derived alerts. Zero disables a rule.
type Config ¶
type Config struct {
General General `toml:"general"`
Proxy Proxy `toml:"proxy"`
Endpoint Endpoint `toml:"endpoint"`
Watch Watch `toml:"watch"`
Position Position `toml:"position"`
Alerts Alerts `toml:"alerts"`
Notify Notify `toml:"notify"`
History History `toml:"history"`
LLM LLM `toml:"llm"`
// contains filtered or unexported fields
}
func Default ¶
func Default() *Config
Default returns a fully populated config with no file behind it.
func Load ¶
Load reads the config file, filling anything missing from Default. A missing file is not an error: first run should just work.
func (*Config) Get ¶
Get resolves a dotted key such as "proxy.url" or "alerts.auto.px15" and renders it as text. Composite leaves (lists, maps) render as JSON so the output stays machine readable.
func (*Config) HasPosition ¶
HasPosition reports whether a usable manual position is recorded.
func (*Config) ImportBnwatch ¶
ImportBnwatch merges an existing bnwatch.json into the config, returning a short human summary of what moved across.
func (*Config) PositionFor ¶
PositionFor returns the recorded position only when it belongs to symbol. A position on one contract must not be applied to another after switching.
func (*Config) RemoveWatch ¶
RemoveWatch drops a symbol, reporting whether it changed.
func (*Config) Save ¶
Save writes the config atomically with 0600 permissions, since it can hold push notification tokens.
type Endpoint ¶
type Endpoint struct {
// The json tags keep `niu endpoint show --json` in the same snake_case shape
// as every other JSON output.
REST string `toml:"rest" json:"rest"`
WS string `toml:"ws" json:"ws"`
}
Endpoint overrides the Binance origin entirely. Empty means "use the built-in mirror list plus proxy detection". Non-empty means the user runs their own reverse proxy; niu then skips mirror ranking.
type General ¶
type General struct {
Symbol string `toml:"symbol"`
Interval float64 `toml:"interval"`
Lang string `toml:"lang"`
// Market is um, cm or spot. Empty is read as um.
Market string `toml:"market"`
ASCII bool `toml:"ascii"`
NoColor bool `toml:"no_color"`
// NoWS forces REST polling only. Some proxies complete the WebSocket
// handshake and then forward nothing, and polling is the reliable fallback.
NoWS bool `toml:"no_ws"`
// GuideSeen records that the walkthrough has been shown once. The G key and
// "niu guide" reopen it at any time.
GuideSeen bool `toml:"guide_seen"`
}
type LLM ¶ added in v0.2.0
type LLM struct {
// Provider is "openai" for any OpenAI-compatible HTTP endpoint, or "command"
// to pipe the prompt into a local CLI such as codex, ollama or claude.
Provider string `toml:"provider"`
BaseURL string `toml:"base_url"`
Model string `toml:"model"`
// APIKey is stored in clear text in this file, which is created 0600. Prefer
// APIKeyEnv or the NIU_LLM_API_KEY environment variable.
APIKey string `toml:"api_key"`
APIKeyEnv string `toml:"api_key_env"`
// Command is argv for the "command" provider; the prompt arrives on stdin.
Command []string `toml:"command"`
Temperature float64 `toml:"temperature"`
MaxTokens int `toml:"max_tokens"`
TimeoutSec int `toml:"timeout_sec"`
// Proxy overrides the transport proxy for model calls only. Empty follows the
// global proxy, "direct" forces a direct connection.
Proxy string `toml:"proxy"`
}
LLM configures the optional analysis backend. Nothing here is required: with an empty provider every AI command explains how to fill it in.
type Level ¶
type Level struct {
Symbol string `toml:"symbol"`
Side string `toml:"side"`
Price float64 `toml:"price"`
}
Level is a manual price alert.
type Position ¶
type Position struct {
Symbol string `toml:"symbol"`
Side string `toml:"side"`
Entry float64 `toml:"entry"`
Qty float64 `toml:"qty"`
Mode string `toml:"mode"`
Margin float64 `toml:"margin"`
Wallet float64 `toml:"wallet"`
MMR float64 `toml:"mmr"`
Stop float64 `toml:"stop"`
Take float64 `toml:"take"`
}