mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-27 17:25:16 +00:00
221 lines
8.8 KiB
YAML
221 lines
8.8 KiB
YAML
---
|
|
persistence:
|
|
redis:
|
|
host: 127.0.0.1
|
|
port: 6379
|
|
db: 0
|
|
|
|
sessions:
|
|
binance:
|
|
exchange: binance
|
|
envVarPrefix: BINANCE
|
|
|
|
# example command:
|
|
# godotenv -f .env.local -- go run ./cmd/bbgo backtest --sync-from 2020-11-01 --config config/grid.yaml --base-asset-baseline
|
|
backtest:
|
|
# for testing max draw down (MDD) at 03-12
|
|
# see here for more details
|
|
# https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp
|
|
startTime: "2022-05-01"
|
|
endTime: "2022-08-14"
|
|
sessions:
|
|
- binance
|
|
symbols:
|
|
- ETHUSDT
|
|
accounts:
|
|
binance:
|
|
balances:
|
|
ETH: 0.0
|
|
USDT: 10_000.0
|
|
|
|
exchangeStrategies:
|
|
|
|
- on: binance
|
|
bollmaker:
|
|
symbol: ETHUSDT
|
|
|
|
# interval is how long do you want to update your order price and quantity
|
|
interval: 1m
|
|
|
|
# quantity is the base order quantity for your buy/sell order.
|
|
quantity: 0.05
|
|
|
|
# amount is used for fixed-amount order, for example, use fixed 20 USDT order for BTCUSDT market
|
|
# amount: 20
|
|
|
|
# useTickerPrice use the ticker api to get the mid price instead of the closed kline price.
|
|
# The back-test engine is kline-based, so the ticker price api is not supported.
|
|
# Turn this on if you want to do real trading.
|
|
useTickerPrice: true
|
|
|
|
# spread is the price spread from the middle price.
|
|
# For ask orders, the ask price is ((bestAsk + bestBid) / 2 * (1.0 + spread))
|
|
# For bid orders, the bid price is ((bestAsk + bestBid) / 2 * (1.0 - spread))
|
|
# Spread can be set by percentage or floating number. e.g., 0.1% or 0.001
|
|
spread: 0.1%
|
|
|
|
# minProfitSpread is the minimal order price spread from the current average cost.
|
|
# For long position, you will only place sell order above the price (= average cost * (1 + minProfitSpread))
|
|
# For short position, you will only place buy order below the price (= average cost * (1 - minProfitSpread))
|
|
minProfitSpread: 0.1%
|
|
|
|
# trendEMA detects the trend by a given EMA
|
|
# when EMA goes up (the last > the previous), allow buy and sell
|
|
# when EMA goes down (the last < the previous), disable buy, allow sell
|
|
# uncomment this to enable it:
|
|
trendEMA:
|
|
interval: 1d
|
|
window: 7
|
|
maxGradient: 1.5
|
|
minGradient: 1.01
|
|
|
|
# ==================================================================
|
|
# Dynamic spread is an experimental feature. it will override the fixed spread settings above.
|
|
#
|
|
# dynamicSpread enables the automatic adjustment to bid and ask spread.
|
|
# Choose one of the scaling strategy to enable dynamicSpread:
|
|
# - amplitude: scales by K-line amplitude
|
|
# - weightedBollWidth: scales by weighted Bollinger band width (explained below)
|
|
# ==================================================================
|
|
#
|
|
# =========================================
|
|
# dynamicSpread with amplitude
|
|
# =========================================
|
|
# dynamicSpread:
|
|
# amplitude: # delete other scaling strategy if this is defined
|
|
# # window is the window of the SMAs of spreads
|
|
# window: 1
|
|
# askSpreadScale:
|
|
# byPercentage:
|
|
# # exp means we want to use exponential scale, you can replace "exp" with "linear" for linear scale
|
|
# exp:
|
|
# # from down to up
|
|
# domain: [ 0.0001, 0.005 ]
|
|
# # when in down band, holds 1.0 by maximum
|
|
# # when in up band, holds 0.05 by maximum
|
|
# range: [ 0.001, 0.002 ]
|
|
# bidSpreadScale:
|
|
# byPercentage:
|
|
# # exp means we want to use exponential scale, you can replace "exp" with "linear" for linear scale
|
|
# exp:
|
|
# # from down to up
|
|
# domain: [ 0.0001, 0.005 ]
|
|
# # when in down band, holds 1.0 by maximum
|
|
# # when in up band, holds 0.05 by maximum
|
|
# range: [ 0.001, 0.002 ]
|
|
#
|
|
# =========================================
|
|
# dynamicSpread with weightedBollWidth
|
|
# =========================================
|
|
# dynamicSpread:
|
|
# # weightedBollWidth scales spread base on weighted Bollinger bandwidth ratio between default and neutral bands.
|
|
# #
|
|
# # Given the default band: moving average bd_mid, band from bd_lower to bd_upper.
|
|
# # And the neutral band: from bn_lower to bn_upper
|
|
# # Set the sigmoid weighting function:
|
|
# # - to ask spread, the weighting density function d_weight(x) is sigmoid((x - bd_mid) / (bd_upper - bd_lower))
|
|
# # - to bid spread, the weighting density function d_weight(x) is sigmoid((bd_mid - x) / (bd_upper - bd_lower))
|
|
# # Then calculate the weighted band width ratio by taking integral of d_weight(x) from bx_lower to bx_upper:
|
|
# # - weighted_ratio = integral(d_weight from bn_lower to bn_upper) / integral(d_weight from bd_lower to bd_upper)
|
|
# # - The wider neutral band get greater ratio
|
|
# # - To ask spread, the higher neutral band get greater ratio
|
|
# # - To bid spread, the lower neutral band get greater ratio
|
|
# # The weighted ratio always positive, and may be greater than 1 if neutral band is wider than default band.
|
|
#
|
|
# weightedBollWidth: # delete other scaling strategy if this is defined
|
|
# # sensitivity is a factor of the weighting function: 1 / (1 + exp(-(x - bd_mid) * sensitivity / (bd_upper - bd_lower)))
|
|
# # A positive number. The greater factor, the sharper weighting function. Default set to 1.0 .
|
|
# sensitivity: 1.0
|
|
#
|
|
# askSpreadScale:
|
|
# byPercentage:
|
|
# # exp means we want to use exponential scale, you can replace "exp" with "linear" for linear scale
|
|
# linear:
|
|
# # from down to up
|
|
# domain: [ 0.1, 0.5 ]
|
|
# range: [ 0.001, 0.002 ]
|
|
# bidSpreadScale:
|
|
# byPercentage:
|
|
# # exp means we want to use exponential scale, you can replace "exp" with "linear" for linear scale
|
|
# linear:
|
|
# # from down to up
|
|
# domain: [ 0.1, 0.5 ]
|
|
# range: [ 0.001, 0.002 ]
|
|
|
|
# maxExposurePosition is the maximum position you can hold
|
|
# +10 means you can hold 10 ETH long position by maximum
|
|
# -10 means you can hold -10 ETH short position by maximum
|
|
# uncomment this if you want a fixed position exposure.
|
|
# maxExposurePosition: 3.0
|
|
maxExposurePosition: 10
|
|
|
|
# dynamicExposurePositionScale overrides maxExposurePosition
|
|
# for domain,
|
|
# -1 means -100%, the price is on the lower band price.
|
|
# if the price breaks the lower band, a number less than -1 will be given.
|
|
# 1 means 100%, the price is on the upper band price.
|
|
# if the price breaks the upper band, a number greater than 1 will be given, for example, 1.2 for 120%, and 1.3 for 130%.
|
|
dynamicExposurePositionScale:
|
|
byPercentage:
|
|
# exp means we want to use exponential scale, you can replace "exp" with "linear" for linear scale
|
|
exp:
|
|
# from lower band -100% (-1) to upper band 100% (+1)
|
|
domain: [ -1, 1 ]
|
|
# when in down band, holds 1.0 by maximum
|
|
# when in up band, holds 0.05 by maximum
|
|
range: [ 10.0, 1.0 ]
|
|
|
|
# DisableShort means you can don't want short position during the market making
|
|
# THe short here means you might sell some of your existing inventory.
|
|
disableShort: true
|
|
|
|
# uptrendSkew, like the strongUptrendSkew, but the price is still in the default band.
|
|
uptrendSkew: 0.8
|
|
|
|
# downtrendSkew, like the strongDowntrendSkew, but the price is still in the default band.
|
|
downtrendSkew: 1.2
|
|
|
|
# defaultBollinger is a long-term time frame bollinger
|
|
# this bollinger band is used for controlling your position (how much you can hold)
|
|
# when price is near the upper band, it holds less.
|
|
# when price is near the lower band, it holds more.
|
|
defaultBollinger:
|
|
interval: "1h"
|
|
window: 21
|
|
bandWidth: 2.0
|
|
|
|
# neutralBollinger is the smaller range of the bollinger band
|
|
# If price is in this band, it usually means the price is oscillating.
|
|
neutralBollinger:
|
|
interval: "5m"
|
|
window: 21
|
|
bandWidth: 2.0
|
|
|
|
# tradeInBand: when tradeInBand is set, you will only place orders in the bollinger band.
|
|
tradeInBand: true
|
|
|
|
# buyBelowNeutralSMA: when this set, it will only place buy order when the current price is below the SMA line.
|
|
buyBelowNeutralSMA: true
|
|
|
|
exits:
|
|
|
|
# roiTakeProfit is used to force taking profit by percentage of the position ROI (currently the price change)
|
|
# force to take the profit ROI exceeded the percentage.
|
|
- roiTakeProfit:
|
|
percentage: 3%
|
|
|
|
- protectiveStopLoss:
|
|
activationRatio: 1%
|
|
stopLossRatio: 0.2%
|
|
placeStopOrder: false
|
|
|
|
- protectiveStopLoss:
|
|
activationRatio: 2%
|
|
stopLossRatio: 1%
|
|
placeStopOrder: false
|
|
|
|
- protectiveStopLoss:
|
|
activationRatio: 5%
|
|
stopLossRatio: 3%
|
|
placeStopOrder: false
|