broker

package
v0.0.0-...-cc8f6e5 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BrokerService

type BrokerService interface {
	Start()
	Stop()
	GetClient(login string) (Client, error)
	GetProfile(login string) (Profile, error)
	Create(deal Deal) (Deal, error)
	Cancel(dealID int64) (bool, error)
	History(ticker string) ([]OHLCV, error)
}

BrokerService broker service.

type Client

type Client struct {
	ID      int64
	Login   string
	Balance float64
}

Client broker client.

type ClientRepo

type ClientRepo interface {
	Add(client *Client) error
	Get(login string) (Client, bool, error)
	SumBalance(clientID int64, amount float64) error
	SubBalance(clientID int64, amount float64) error
}

ClientRepo client repository.

type Deal

type Deal struct {
	ID       int64
	ClientID int64
	Ticker   string
	Type     DealType
	Amount   int32
	Partial  bool
	Price    float64
	Status   DealStatus
	Time     time.Time
}

Deal user deal.

type DealRepo

type DealRepo interface {
	Add(deal Deal) error
	GetOpened(clientID int64) ([]Deal, error)
	Update(deal Deal) error
	UpdateStatus(dealID int64, status DealStatus) error
}

DealRepo deal repository.

type DealStatus

type DealStatus string

DealStatus deal status.

const (
	// DealStatusNew new deal status.
	DealStatusNew DealStatus = "NEW"
	// DealStatusCompleted completed deal status.
	DealStatusCompleted DealStatus = "COMPLETED"
	// DealStatusCanceled canceled deal status.
	DealStatusCanceled DealStatus = "CANCELED"
)

type DealType

type DealType string

DealType deal type.

const (
	// Buy deal of buying.
	Buy DealType = "BUY"
	// Sell deal of selling.
	Sell DealType = "SELL"
)

type ExchangeService

type ExchangeService interface {
	Statistic(ctx context.Context, out chan OHLCV) error
	Create(deal Deal) (int64, error)
	Cancel(dealID int64) (bool, error)
	Results(ctx context.Context, out chan Deal) error
}

ExchangeService stock exchange service.

type OHLCV

type OHLCV struct {
	ID       int64
	Ticker   string
	Time     time.Time
	Interval time.Duration
	Open     float64
	High     float64
	Low      float64
	Close    float64
	Volume   int32
}

OHLCV statistic.

type Position

type Position struct {
	ClientID int64
	Ticker   string
	Amount   int32
}

Position user tickers.

type PositionRepo

type PositionRepo interface {
	Add(position Position) error
	Get(clientID int64) ([]Position, error)
	Remove(position Position) error
}

PositionRepo position repository.

type Profile

type Profile struct {
	ClientID  int64
	Balance   float64
	Positions []Position
	OpenDeals []Deal
}

Profile user profile.

type StatisticRepo

type StatisticRepo interface {
	Add(ohlcv OHLCV) error
	Get(ticker string) ([]OHLCV, error)
}

StatisticRepo statistic repository.

Directories

Path Synopsis
delivery
rpc

Jump to

Keyboard shortcuts

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