Documentation
¶
Index ¶
- Constants
- type CCISTOCH
- type HeikinAshi
- type Strategy
- func (s *Strategy) CancelAll(ctx context.Context)
- func (s *Strategy) ClosePosition(ctx context.Context) (*types.Order, bool)
- func (s *Strategy) GetLastPrice() fixedpoint.Value
- func (s *Strategy) ID() string
- func (s *Strategy) Initialize() error
- func (s *Strategy) InstanceID() string
- func (s *Strategy) PlaceBuyOrder(ctx context.Context, price fixedpoint.Value) (*types.Order, *types.Order)
- func (s *Strategy) PlaceSellOrder(ctx context.Context, price fixedpoint.Value) (*types.Order, *types.Order)
- func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, ...) error
- func (s *Strategy) SetupIndicators(store *types.MarketDataStore)
- func (s *Strategy) Subscribe(session *bbgo.ExchangeSession)
- type VWEMA
Constants ¶
const ID = "ewo_dgtrd"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CCISTOCH ¶ added in v1.33.0
type CCISTOCH struct {
// contains filtered or unexported fields
}
func NewCCISTOCH ¶ added in v1.33.0
func (*CCISTOCH) SellSignal ¶ added in v1.33.0
type HeikinAshi ¶
type HeikinAshi struct {
Close *types.Queue
Open *types.Queue
High *types.Queue
Low *types.Queue
Volume *types.Queue
}
func NewHeikinAshi ¶
func NewHeikinAshi(size int) *HeikinAshi
func (*HeikinAshi) Print ¶
func (s *HeikinAshi) Print() string
func (*HeikinAshi) Update ¶
func (inc *HeikinAshi) Update(kline types.KLine)
type Strategy ¶
type Strategy struct {
// Embedded components
// ===================
*bbgo.Environment
bbgo.StrategyController
// Market of the symbol
Market types.Market
// Session is the trading session of this strategy
Session *bbgo.ExchangeSession
// Persistence fields
// ====================
// Position
Position *types.Position `json:"position,omitempty" persistence:"position"`
// ProfitStats
ProfitStats *types.ProfitStats `json:"profitStats,omitempty" persistence:"profit_stats"`
// Settings fields
// =========================
UseHeikinAshi bool `json:"useHeikinAshi"` // use heikinashi kline
StopLoss fixedpoint.Value `json:"stoploss"`
Symbol string `json:"symbol"`
Interval types.Interval `json:"interval"`
UseEma bool `json:"useEma"` // use exponential ma or not
UseSma bool `json:"useSma"` // if UseEma == false, use simple ma or not
SignalWindow int `json:"sigWin"` // signal window
DisableShortStop bool `json:"disableShortStop"` // disable SL on short
DisableLongStop bool `json:"disableLongStop"` // disable SL on long
FilterHigh float64 `json:"cciStochFilterHigh"` // high filter for CCI Stochastic indicator
FilterLow float64 `json:"cciStochFilterLow"` // low filter for CCI Stochastic indicator
EwoChangeFilterHigh float64 `json:"ewoChangeFilterHigh"` // high filter for ewo histogram
EwoChangeFilterLow float64 `json:"ewoChangeFilterLow"` // low filter for ewo histogram
Record bool `json:"record"` // print record messages on position exit point
KLineStartTime types.Time
KLineEndTime types.Time
// contains filtered or unexported fields
}
func (*Strategy) ClosePosition ¶ added in v1.33.0
ClosePosition(context.Context) -> (closeOrder *types.Order, ok bool) this will decorate the generated order from NewMarketCloseOrder add do necessary checks if available quantity is zero, will return (nil, true) if any of the checks failed, will return (nil, false) otherwise, return the created close order and true
func (*Strategy) GetLastPrice ¶ added in v1.33.0
func (s *Strategy) GetLastPrice() fixedpoint.Value
func (*Strategy) Initialize ¶
func (*Strategy) InstanceID ¶ added in v1.33.0
func (*Strategy) PlaceBuyOrder ¶ added in v1.33.0
func (*Strategy) PlaceSellOrder ¶ added in v1.33.0
func (*Strategy) Run ¶
func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error
Trading Rules: - buy / sell the whole asset - SL by atr (lastprice < buyprice - atr) || (lastprice > sellprice + atr) - TP by detecting if there's a ewo pivotHigh(1,1) -> close long, or pivotLow(1,1) -> close short - TP by ma34 +- atr * 2 - TP by (lastprice < peak price - atr) || (lastprice > bottom price + atr) - SL by s.StopLoss (Abs(price_diff / price) > s.StopLoss) - entry condition on ewo(Elliott wave oscillator) Crosses ewoSignal(ma on ewo, signalWindow)
- buy signal on (crossover on previous K bar and no crossunder on latest K bar)
- sell signal on (crossunder on previous K bar and no crossunder on latest K bar)
- and filtered by the following rules:
- buy: buy signal ON, kline Close > Open, Close > ma5, Close > ma34, CCI Stochastic Buy signal
- sell: sell signal ON, kline Close < Open, Close < ma5, Close < ma34, CCI Stochastic Sell signal
- or entry when ma34 +- atr * 3 gets touched - entry price: latestPrice +- atr / 2 (short,long), close at market price Cancel non-fully filled orders on new signal (either in same direction or not)
ps: kline might refer to heikinashi or normal ohlc
func (*Strategy) SetupIndicators ¶
func (s *Strategy) SetupIndicators(store *types.MarketDataStore)
Setup the Indicators going to be used
func (*Strategy) Subscribe ¶
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession)
type VWEMA ¶
type VWEMA struct {
PV types.UpdatableSeries
V types.UpdatableSeries
}