Cryptrality / backtester

3 stars 2 forks source link

Config file bot.config could be standardized #5

Open c0indev3l opened 1 year ago

c0indev3l commented 1 year ago

Hello,

maybe bot.config could be standardized as a TOML or INI file or YML file. So editor such as VSCode can automatically render it correctly.

Here is an example of toml file (see https://toml.io/ )

# TOML-based config
[influx2]
url = "http://localhost:8086"
org = "my-org"
token = "my-token"

Here is an example of ini

; ini-based config
[influx2]
url = http://localhost:8086
org = my-org
token = my-token

So currently bot.config looks like

SLIPPAGE = 0.0008
FEES = 0.0002
CACHED_KLINES_PATH = cached_klines
INITIAL_BALANCE = 1000

and load_config implementation is

https://github.com/Cryptrality/backtester/blob/f0c1fe7f524e04f54422c2e666cc3a0d05677b34/cryptrality/__config__.py#L4-L16

so comments start with #

so it's a mix of both ;-)

I would name bot_config.toml and use sections

# Bot configuration

[backtest]
slippage = 0.0008
fees = 0.0002
cached_klines_path = "cached_klines"
initial_balance = 1000

[livetrade]

[livetrade.binance]
api_key = "your_long_api_key_here"
api_secret = "your_other_long_api_key_here"
c0indev3l commented 1 year ago

An other quite "standardized" configuration option is the use of .env files https://pypi.org/project/python-dotenv/