model

package
v0.0.0-...-16fd4a1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	BrlBalance    float64
	CryptoBalance float64
}

type Client

type Client struct {
	Id                        string
	Active                    bool
	LockedUntil               time.Time
	Locked                    bool
	CashAvailable             float64
	CashAmount                float64
	CashReserved              float64
	CryptoAvailable           float64
	CryptoAmount              float64
	CryptoReserved            float64
	OperationStopLoss         float64
	DayStopLoss               float64
	MonthStopLoss             float64
	OperationAmountPercentage float64
	BuyOn                     int
	SellOn                    int
	Symbols                   []string
	Summary                   []*Summary
}

func (*Client) CreateOperation

func (c *Client) CreateOperation(request *OperationRequest, coin *Coin) (*Operation, custom_error.BaseErrorAdapter)

CreateOperation validates if client current values can operate, then creates a model.Operation and also updates reserved balance as necessary for the operation. Will return error in case of validation failure.

func (*Client) Lock

func (c *Client) Lock()

Lock client

func (*Client) SetBalance

func (c *Client) SetBalance(balance *Balance)

SetBalance will update client current balance, will take account of reserved values.

func (*Client) Unlock

func (c *Client) Unlock()

Unlock client

type Coin

type Coin struct {
	Symbol    symbol.Symbol
	Quote     symbol.Symbol
	BuyValue  float64
	SellValue float64
}

func (Coin) GetMinOperationValue

func (c Coin) GetMinOperationValue(operationType operation_type.OperationType) float64

type Operation

type Operation struct {
	Id        string
	Status    status.Status
	CreatedAt time.Time
	Locked    bool
	Type      operation_type.OperationType
	Amount    float64
	Base      symbol.Symbol
	Quote     symbol.Symbol
	StopLoss  float64
}

func NewOperation

func NewOperation(stopLoss float64) *Operation

type OperationRequest

type OperationRequest struct {
	ClientId  string
	Operation operation_type.OperationType
	Symbol    symbol.Symbol
	StartTime time.Time
}

type Summary

type Summary struct {
	Type         summary_type.SummaryType
	Day          int
	Month        int
	Year         int
	AmountSold   float64
	AmountBought float64
	Profit       float64
}

Jump to

Keyboard shortcuts

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