app

package
v0.0.0-...-a47f6b9 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package app provides functionality for the application logic and startup as well as types to manage the application resources.

Package app is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewmockExchangeClient

func NewmockExchangeClient(ctrl *gomock.Controller) *mockExchangeClient

NewmockExchangeClient creates a new mock instance.

func NewmockIDGenerator

func NewmockIDGenerator(ctrl *gomock.Controller) *mockIDGenerator

NewmockIDGenerator creates a new mock instance.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App represents the encapsulation of the application state. This struct is the main application handler of the trading bot.

func New

func New(logger *zap.Logger, exchange ExchangeClient, opts ...Option) *App

New acts as the default constructor for the application. Use this method to create a new instance of the applcation. This method should be called over directly instantiating the App struct as it initializes internal attributes so that the application can run as expected.

func (*App) Start

func (a *App) Start(ctx context.Context)

Start will begin the application with the given context. This method blocks based on the context given. In order to stop the application, one should cancel the passed in context.

type Config

type Config struct {
}

Config acts as an encapsulation of the application configuration.

type ExchangeClient

type ExchangeClient interface {
	GetLastPrice(ctx context.Context, pair trading.Pair) (string, error)
	CreateLimitOrder(ctx context.Context, order order.Limit) (exchange.Order, error)
	CancelOrders(ctx context.Context, orderIDs ...string) error
	ListOpenOrders(ctx context.Context) ([]exchange.Order, error)
	GetBalance(ctx context.Context, asset trading.Asset) (int64, error)
}

ExchangeClient represents a type that is able to communicate with an exchange.

type IDGenerator

type IDGenerator interface {
	GenerateID(prefix string) string
}

type Option

type Option func(a *App)

Option allows for overriding of the internals of the application. These options are typically only meant for internal testing.

func WithIDGenerator

func WithIDGenerator(gen IDGenerator) Option

WithIDGenerator overrides the internal ID generator of the app. Use this method for testing or for use with an exchange that does not support the id format in use by the app.

Jump to

Keyboard shortcuts

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