Documentation ¶
Overview ¶
bollmaker is a maker strategy depends on the bollinger band
bollmaker uses two bollinger bands for trading: 1) the first bollinger is a long-term time frame bollinger, it controls your position. (how much you can hold) 2) the second bollinger is a short-term time frame bollinger, it controls whether places the orders or not.
Index ¶
- Constants
- type BollingerSetting
- type DynamicSpreadAmpSettings
- type DynamicSpreadBollWidthRatioSettings
- type DynamicSpreadSettings
- func (ds *DynamicSpreadSettings) GetAskSpread() (askSpread float64, err error)
- func (ds *DynamicSpreadSettings) GetBidSpread() (bidSpread float64, err error)
- func (ds *DynamicSpreadSettings) Initialize(symbol string, session *bbgo.ExchangeSession, ...)
- func (ds *DynamicSpreadSettings) IsEnabled() bool
- func (ds *DynamicSpreadSettings) Update(kline types.KLine)
- type EMACrossSetting
- type PriceTrend
- type Statedeprecated
- type Strategy
- func (s *Strategy) ClosePosition(ctx context.Context, percentage fixedpoint.Value) error
- func (s *Strategy) CurrentPosition() *types.Position
- func (s *Strategy) ID() string
- func (s *Strategy) InstanceID() string
- func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, ...) error
- func (s *Strategy) Subscribe(session *bbgo.ExchangeSession)
- func (s *Strategy) Validate() error
Constants ¶
View Source
const ID = "bollmaker"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BollingerSetting ¶
type BollingerSetting struct { types.IntervalWindow BandWidth float64 `json:"bandWidth"` }
type DynamicSpreadAmpSettings ¶ added in v1.40.0
type DynamicSpreadAmpSettings struct { types.IntervalWindow // AskSpreadScale is used to define the ask spread range with the given percentage. AskSpreadScale *bbgo.PercentageScale `json:"askSpreadScale"` // BidSpreadScale is used to define the bid spread range with the given percentage. BidSpreadScale *bbgo.PercentageScale `json:"bidSpreadScale"` // contains filtered or unexported fields }
type DynamicSpreadBollWidthRatioSettings ¶ added in v1.40.0
type DynamicSpreadBollWidthRatioSettings struct { // AskSpreadScale is used to define the ask spread range with the given percentage. AskSpreadScale *bbgo.PercentageScale `json:"askSpreadScale"` // BidSpreadScale is used to define the bid spread range with the given percentage. BidSpreadScale *bbgo.PercentageScale `json:"bidSpreadScale"` // Sensitivity factor of the weighting function: 1 / (1 + exp(-(x - mid) * sensitivity / width)) // A positive number. The greater factor, the sharper weighting function. Default set to 1.0 . Sensitivity float64 `json:"sensitivity"` // contains filtered or unexported fields }
type DynamicSpreadSettings ¶ added in v1.33.0
type DynamicSpreadSettings struct { AmpSpreadSettings *DynamicSpreadAmpSettings `json:"amplitude"` WeightedBollWidthRatioSpreadSettings *DynamicSpreadBollWidthRatioSettings `json:"weightedBollWidth"` // deprecated Enabled *bool `json:"enabled"` // deprecated types.IntervalWindow // deprecated. AskSpreadScale is used to define the ask spread range with the given percentage. AskSpreadScale *bbgo.PercentageScale `json:"askSpreadScale"` // deprecated. BidSpreadScale is used to define the bid spread range with the given percentage. BidSpreadScale *bbgo.PercentageScale `json:"bidSpreadScale"` }
func (*DynamicSpreadSettings) GetAskSpread ¶ added in v1.33.0
func (ds *DynamicSpreadSettings) GetAskSpread() (askSpread float64, err error)
GetAskSpread returns current ask spread
func (*DynamicSpreadSettings) GetBidSpread ¶ added in v1.33.0
func (ds *DynamicSpreadSettings) GetBidSpread() (bidSpread float64, err error)
GetBidSpread returns current dynamic bid spread
func (*DynamicSpreadSettings) Initialize ¶ added in v1.40.0
func (ds *DynamicSpreadSettings) Initialize(symbol string, session *bbgo.ExchangeSession, neutralBoll, defaultBoll *indicatorv2.BOLLStream)
Initialize dynamic spreads and preload SMAs
func (*DynamicSpreadSettings) IsEnabled ¶ added in v1.40.0
func (ds *DynamicSpreadSettings) IsEnabled() bool
func (*DynamicSpreadSettings) Update ¶ added in v1.33.0
func (ds *DynamicSpreadSettings) Update(kline types.KLine)
Update dynamic spreads
type EMACrossSetting ¶ added in v1.56.0
type PriceTrend ¶ added in v1.28.0
type PriceTrend string
const ( NeutralTrend PriceTrend = "neutral" UpTrend PriceTrend = "upTrend" DownTrend PriceTrend = "downTrend" UnknownTrend PriceTrend = "unknown" )
type State
deprecated
type State struct { // Deprecated: Position is deprecated, please define the Position field in the strategy struct directly. Position *types.Position `json:"position,omitempty"` // Deprecated: ProfitStats is deprecated, please define the ProfitStats field in the strategy struct directly. ProfitStats types.ProfitStats `json:"profitStats,omitempty"` }
Deprecated: State is deprecated, please use the persistence tag
type Strategy ¶
type Strategy struct { Environment *bbgo.Environment StandardIndicatorSet *bbgo.StandardIndicatorSet Market types.Market // Symbol is the market symbol you want to trade Symbol string `json:"symbol"` types.IntervalWindow bbgo.QuantityOrAmount // BidQuantity is used for placing buy order, this will override the default quantity BidQuantity fixedpoint.Value `json:"bidQuantity"` // AskQuantity is used for placing sell order, this will override the default quantity AskQuantity fixedpoint.Value `json:"askQuantity"` // TrendEMA is used for detecting the trend by a given EMA // you can define interval and window TrendEMA *bbgo.TrendEMA `json:"trendEMA"` // 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 fixedpoint.Value `json:"spread"` // BidSpread overrides the spread setting, this spread will be used for the buy order BidSpread fixedpoint.Value `json:"bidSpread,omitempty"` // AskSpread overrides the spread setting, this spread will be used for the sell order AskSpread fixedpoint.Value `json:"askSpread,omitempty"` // DynamicSpread enables the automatic adjustment to bid and ask spread. DynamicSpread DynamicSpreadSettings `json:"dynamicSpread,omitempty"` // 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 fixedpoint.Value `json:"minProfitSpread"` // MinProfitActivationRate activates MinProfitSpread when position RoI higher than the specified percentage MinProfitActivationRate *fixedpoint.Value `json:"minProfitActivationRate"` // 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 bool `json:"useTickerPrice"` // 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 MaxExposurePosition fixedpoint.Value `json:"maxExposurePosition"` // DynamicExposurePositionScale is used to define the exposure position range with the given percentage // when DynamicExposurePositionScale is set, // your MaxExposurePosition will be calculated dynamically according to the bollinger band you set. DynamicExposurePositionScale *bbgo.PercentageScale `json:"dynamicExposurePositionScale"` // Long means your position will be long position // Currently not used yet Long *bool `json:"long,omitempty"` // Short means your position will be long position // Currently not used yet Short *bool `json:"short,omitempty"` // DisableShort means you can don't want short position during the market making // Set to true if you want to hold more spot during market making. DisableShort bool `json:"disableShort"` // BuyBelowNeutralSMA if true, the market maker will only place buy order when the current price is below the neutral band SMA. BuyBelowNeutralSMA bool `json:"buyBelowNeutralSMA"` // EMACrossSetting is used for defining ema cross signal to turn on/off buy EMACrossSetting *EMACrossSetting `json:"emaCross"` // NeutralBollinger is the smaller range of the bollinger band // If price is in this band, it usually means the price is oscillating. // If price goes out of this band, we tend to not place sell orders or buy orders NeutralBollinger *BollingerSetting `json:"neutralBollinger"` // DefaultBollinger is the wide range of the bollinger band // for controlling your exposure position DefaultBollinger *BollingerSetting `json:"defaultBollinger"` // DowntrendSkew is the order quantity skew for normal downtrend band. // The price is still in the default bollinger band. // greater than 1.0 means when placing buy order, place sell order with less quantity // less than 1.0 means when placing sell order, place buy order with less quantity DowntrendSkew fixedpoint.Value `json:"downtrendSkew"` // UptrendSkew is the order quantity skew for normal uptrend band. // The price is still in the default bollinger band. // greater than 1.0 means when placing buy order, place sell order with less quantity // less than 1.0 means when placing sell order, place buy order with less quantity UptrendSkew fixedpoint.Value `json:"uptrendSkew"` // TradeInBand // When this is on, places orders only when the current price is in the bollinger band. TradeInBand bool `json:"tradeInBand"` // ShadowProtection is used to avoid placing bid order when price goes down strongly (without shadow) ShadowProtection bool `json:"shadowProtection"` ShadowProtectionRatio fixedpoint.Value `json:"shadowProtectionRatio"` ExitMethods bbgo.ExitMethodSet `json:"exits"` // persistence fields Position *types.Position `json:"position,omitempty" persistence:"position"` ProfitStats *types.ProfitStats `json:"profitStats,omitempty" persistence:"profit_stats"` // StrategyController bbgo.StrategyController // contains filtered or unexported fields }
func (*Strategy) ClosePosition ¶ added in v1.26.0
func (*Strategy) CurrentPosition ¶ added in v1.26.0
func (*Strategy) InstanceID ¶ added in v1.33.0
func (*Strategy) Run ¶
func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error
func (*Strategy) Subscribe ¶
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession)
Click to show internal directories.
Click to hide internal directories.