Documentation
¶
Index ¶
- Constants
- Variables
- type State
- type Strategy
- func (s *Strategy) ID() string
- func (s *Strategy) InstanceID() string
- func (s *Strategy) LoadState() error
- func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, ...) error
- func (s *Strategy) SaveState() error
- func (s *Strategy) Subscribe(session *bbgo.ExchangeSession)
- func (s *Strategy) Validate() error
Constants ¶
View Source
const ID = "grid"
Variables ¶
View Source
var NotionalModifier = fixedpoint.NewFromFloat(1.0001)
Functions ¶
This section is empty.
Types ¶
type State ¶ added in v1.14.0
type State struct {
Orders []types.SubmitOrder `json:"orders,omitempty"`
FilledBuyGrids map[fixedpoint.Value]struct{} `json:"filledBuyGrids"`
FilledSellGrids map[fixedpoint.Value]struct{} `json:"filledSellGrids"`
Position *types.Position `json:"position,omitempty"`
AccumulativeArbitrageProfit fixedpoint.Value `json:"accumulativeArbitrageProfit"`
// any created orders for tracking trades
// [source Order ID] -> arbitrage order
ArbitrageOrders map[uint64]types.Order `json:"arbitrageOrders"`
ProfitStats types.ProfitStats `json:"profitStats,omitempty"`
}
State is the grid snapshot
type Strategy ¶
type Strategy struct {
// The notification system will be injected into the strategy automatically.
// This field will be injected automatically since it's a single exchange strategy.
*bbgo.Notifiability `json:"-" yaml:"-"`
*bbgo.Graceful `json:"-" yaml:"-"`
*bbgo.Persistence
// OrderExecutor is an interface for submitting order.
// This field will be injected automatically since it's a single exchange strategy.
bbgo.OrderExecutor `json:"-" yaml:"-"`
// Market stores the configuration of the market, for example, VolumePrecision, PricePrecision, MinLotSize... etc
// This field will be injected automatically since we defined the Symbol field.
types.Market `json:"-" yaml:"-"`
TradeService *service.TradeService `json:"-" yaml:"-"`
// These fields will be filled from the config file (it translates YAML to JSON)
Symbol string `json:"symbol" yaml:"symbol"`
// ProfitSpread is the fixed profit spread you want to submit the sell order
ProfitSpread fixedpoint.Value `json:"profitSpread" yaml:"profitSpread"`
// GridNum is the grid number, how many orders you want to post on the orderbook.
GridNum int64 `json:"gridNumber" yaml:"gridNumber"`
UpperPrice fixedpoint.Value `json:"upperPrice" yaml:"upperPrice"`
LowerPrice fixedpoint.Value `json:"lowerPrice" yaml:"lowerPrice"`
// Quantity is the quantity you want to submit for each order.
Quantity fixedpoint.Value `json:"quantity,omitempty"`
// QuantityScale helps user to define the quantity by price scale or volume scale
QuantityScale *bbgo.PriceVolumeScale `json:"quantityScale,omitempty"`
// FixedAmount is used for fixed amount (dynamic quantity) if you don't want to use fixed quantity.
FixedAmount fixedpoint.Value `json:"amount,omitempty" yaml:"amount"`
// Side is the initial maker orders side. defaults to "both"
Side types.SideType `json:"side" yaml:"side"`
// CatchUp let the maker grid catch up with the price change.
CatchUp bool `json:"catchUp" yaml:"catchUp"`
// Long means you want to hold more base asset than the quote asset.
Long bool `json:"long,omitempty" yaml:"long,omitempty"`
// contains filtered or unexported fields
}
func (*Strategy) InstanceID ¶ added in v1.18.1
InstanceID returns the instance identifier from the current grid configuration parameters
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.