signal

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2024 License: MIT Imports: 6 Imported by: 0

README

GoCryptoTrader Backtester: Signal package

Build Status Software License GoDoc Coverage Status Go Report Card

This signal package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progress on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Signal package overview

The signal event is created as a result of a data event being analysed via a strategy. Typically, there are three types of signal that should be expected buy, sell and donothing. An example of this is demonstrated in the RSI strategy. However, other signals can be raised such as MissingData. The signal event will contain data such as price, the direction as well as the reasoning for the signal decision with the GetWhy() function

Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event interface {
	common.Event
	common.Directioner
	ToKline() kline.Event
	GetClosePrice() decimal.Decimal
	GetHighPrice() decimal.Decimal
	GetOpenPrice() decimal.Decimal
	GetLowPrice() decimal.Decimal
	GetVolume() decimal.Decimal
	IsSignal() bool
	GetSellLimit() decimal.Decimal
	GetBuyLimit() decimal.Decimal
	GetAmount() decimal.Decimal
	GetFillDependentEvent() Event
	GetCollateralCurrency() currency.Code
	SetAmount(decimal.Decimal)
	MatchOrderAmount() bool
	IsNil() bool
}

Event handler is used for getting trade signal details Example Amount and Price of current candle tick

type Signal

type Signal struct {
	*event.Base
	OpenPrice  decimal.Decimal
	HighPrice  decimal.Decimal
	LowPrice   decimal.Decimal
	ClosePrice decimal.Decimal
	Volume     decimal.Decimal
	// BuyLimit sets a maximum buy from the strategy
	// it differs from amount as it is more a suggestion
	// use Amount if you wish to have a fillOrKill style amount
	BuyLimit decimal.Decimal
	// SellLimit sets a maximum sell from the strategy
	// it differs from amount as it is more a suggestion
	// use Amount if you wish to have a fillOrKill style amount
	SellLimit decimal.Decimal
	// Amount set the amount when you wish to allow
	// a strategy to dictate order quantities
	// if the amount is not allowed by the portfolio manager
	// the order will not be placed
	Amount    decimal.Decimal
	Direction order.Side
	// FillDependentEvent ensures that an order can only be placed
	// if there is corresponding collateral in the selected currency
	// this enabled cash and carry strategies for example
	FillDependentEvent Event
	// CollateralCurrency is an optional parameter
	// when using futures to limit the collateral available
	// to a singular currency
	// eg with $5000 usd and 1 BTC, specifying BTC ensures
	// the USD value won't be utilised when sizing an order
	CollateralCurrency currency.Code
	// MatchOrderAmount flags to other event handlers
	// that the order amount must match the set Amount property
	MatchesOrderAmount bool
}

Signal contains everything needed for a strategy to raise a signal event

func (*Signal) GetAmount

func (s *Signal) GetAmount() decimal.Decimal

GetAmount retrieves the order amount

func (*Signal) GetBuyLimit

func (s *Signal) GetBuyLimit() decimal.Decimal

GetBuyLimit returns the buy limit

func (*Signal) GetClosePrice

func (s *Signal) GetClosePrice() decimal.Decimal

GetClosePrice returns the price

func (*Signal) GetCollateralCurrency

func (s *Signal) GetCollateralCurrency() currency.Code

GetCollateralCurrency returns the collateral currency

func (*Signal) GetDirection

func (s *Signal) GetDirection() order.Side

GetDirection returns the direction

func (*Signal) GetFillDependentEvent

func (s *Signal) GetFillDependentEvent() Event

GetFillDependentEvent returns the fill dependent event so it can be added to the event queue

func (*Signal) GetHighPrice

func (s *Signal) GetHighPrice() decimal.Decimal

GetHighPrice returns the high price of a signal

func (*Signal) GetLowPrice

func (s *Signal) GetLowPrice() decimal.Decimal

GetLowPrice returns the low price of a signal

func (*Signal) GetOpenPrice

func (s *Signal) GetOpenPrice() decimal.Decimal

GetOpenPrice returns the open price of a signal

func (*Signal) GetSellLimit

func (s *Signal) GetSellLimit() decimal.Decimal

GetSellLimit returns the sell limit

func (*Signal) GetUnderlyingPair

func (s *Signal) GetUnderlyingPair() currency.Pair

GetUnderlyingPair returns the underlying currency pair

func (*Signal) GetVolume

func (s *Signal) GetVolume() decimal.Decimal

GetVolume returns the volume of a signal

func (*Signal) IsNil

func (s *Signal) IsNil() bool

IsNil says if the event is nil

func (*Signal) IsSignal

func (s *Signal) IsSignal() bool

IsSignal returns whether the event is a signal type

func (*Signal) MatchOrderAmount

func (s *Signal) MatchOrderAmount() bool

MatchOrderAmount ensures an order must match its set amount or fail

func (*Signal) Pair

func (s *Signal) Pair() currency.Pair

Pair returns the currency pair

func (*Signal) SetAmount

func (s *Signal) SetAmount(d decimal.Decimal)

SetAmount sets the order amount

func (*Signal) SetBuyLimit

func (s *Signal) SetBuyLimit(f decimal.Decimal)

SetBuyLimit sets the buy limit

func (*Signal) SetDirection

func (s *Signal) SetDirection(st order.Side)

SetDirection sets the direction

func (*Signal) SetPrice

func (s *Signal) SetPrice(f decimal.Decimal)

SetPrice sets the price

func (*Signal) SetSellLimit

func (s *Signal) SetSellLimit(f decimal.Decimal)

SetSellLimit sets the sell limit

func (*Signal) ToKline

func (s *Signal) ToKline() kline.Event

ToKline is used to convert a signal event to a data event for the purpose of closing all positions function CloseAllPositions is builds signal data, but data event data must still be populated

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL