Documentation ¶
Index ¶
- func AnyUser() map[string]struct{}
- func Contains(arg ...string) map[string]struct{}
- func Counter(limit int) func(trade *model.TradeSignal, numberOfTrades int) bool
- func NonStop(trade *model.TradeSignal, numberOfTrades int) bool
- func Reply(private Index, user User, message *Message, err error)
- func Until(time time.Time) func(trade *model.TradeSignal, numberOfTrades int) bool
- type Block
- type Client
- type Command
- type Condition
- type ConsumerKey
- type Exchange
- type ExchangeName
- type Index
- type Message
- type Pair
- type Processor
- type Query
- type Signal
- type StrategyProcessor
- type Trigger
- type TriggerFunc
- type User
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Block ¶
type Block struct { // Action block.Signal <- api.Signal{} Action chan Signal // ReAction <-block.ReAction ReAction chan Signal }
Block allows 2 processes to sync
type Client ¶
type Client interface {
Trades(process <-chan Signal) (model.TradeSource, error)
}
Client exposes the low level interface for interacting with a trade source.
type Command ¶
Command is the definitions of metadata for a command.
func CommandFromMessage ¶
CommandFromMessage parses a command from a message details.
func NewCommand ¶
NewCommand parses a command from a message details.
type Condition ¶
type Condition func(trade *model.TradeSignal, numberOfTrades int) bool
Condition defines a boundary condition to stop execution based on the consumed trades.
type ConsumerKey ¶
ConsumerKey is the internal consumer key for indexing and managing consumers.
type Exchange ¶
type Exchange interface { OpenPositions(ctx context.Context) (*model.PositionBatch, error) OpenOrder(order *model.TrackedOrder) (*model.TrackedOrder, []string, error) Balance(ctx context.Context, priceMap map[model.Coin]model.CurrentPrice) (map[model.Coin]model.Balance, error) Pairs(ctx context.Context) map[string]Pair CurrentPrice(ctx context.Context) (map[model.Coin]model.CurrentPrice, error) }
Exchange allows interaction with the exchange for submitting and closing positions and trades.
type Message ¶
Message defines a message that should be sent to the user or group.
func ErrorMessage ¶
ErrorMessage creates a new error message.
func (*Message) ReferenceTime ¶
ReferenceTime adds a reference time to the message. This is especially useful for back-testing adn debugging.
type Processor ¶
type Processor func(in <-chan *model.TradeSignal, out chan<- *model.TradeSignal)
Processor defines the processing model of input and output channels for trades. Each processor will trigger the next one, when pushing the trade to the output channel. TODO : add load and save functionality for processors interface to allow saving and loading state.
type Signal ¶
Signal is a generic struct used to trigger actions on other processes. it can hold metadata information , but for now we leave it empty.
func (*Signal) WithContent ¶
WithContent adds content to the action. This would indicate an actionable event. The content should be de-coded by using the the name of the action.
type StrategyProcessor ¶
StrategyProcessor defines a processing logic for a strategy
type Trigger ¶
type Trigger struct { ID string Key ConsumerKey Default []string Description string Timeout time.Duration }
Trigger wraps a trigger func into a re-usable object.
func (*Trigger) WithDefaults ¶
WithDefaults specifies default argument for the auto-callback.
func (*Trigger) WithDescription ¶
WithDescription allows to specify a custom description for the trigger.
type TriggerFunc ¶
TriggerFunc defines an execution logic based on the command and options arguments.
type User ¶
type User interface { // Run starts the user interface implementation and initialises any external connections. Run(ctx context.Context) error // Listen returns a channel of commands to the caller to interact with the user. // the caller needs to provide a unique subscription key. // additionally the caller can define a prefix to avoid being spammed with messages not relevant to them. Listen(key, prefix string) <-chan Command // Send sends a message to the user adn returns the message ID Send(channel Index, message *Message, trigger *Trigger) int // AddUser adds the given chatID for the specified user name AddUser(channel Index, user string, chatID int64) error }
User defines an external interface for exchanging information and sharing control with the user(s)
type Validator ¶
Validator is a validation function that checks the string for the given type.
func Float ¶
Float is a predefined Validator checking that the argument is a float. it passes the reference to the value to the given interface argument. it allows for emopty value, and interprets it as zero
func Int ¶
Int is a predefined Validator checking that the argument is an int. it passes the reference to the value to the given interface argument.