models

package
v0.0.0-...-f9f614f Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyTime = genEmptyTime()

EmptyTime 0001-01-01 00:00:00

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	Key    string `csv:"api_key" json:"api_key"`
	Secret string `csv:"api_secret" json:"api_secret"`
}

APIKey key & secret for api

func (*APIKey) Validate

func (key *APIKey) Validate() bool

Validate completion of api key info

type AuthCache

type AuthCache struct {
	CmdAuthFile string
	DefaultID   string
	DefaultPass Password
	// contains filtered or unexported fields
}

AuthCache api auth cache

func NewAuthCache

func NewAuthCache(ctx context.Context, clientHub *ClientHub) *AuthCache

NewAuthCache create new api auth cache

func (*AuthCache) GetUserDefaultKey

func (cache *AuthCache) GetUserDefaultKey(loginAuth context.Context) *APIKey

GetUserDefaultKey get user's default sys api key

func (*AuthCache) HasDefaultAuth

func (cache *AuthCache) HasDefaultAuth() bool

HasDefaultAuth to judge if auth info is exist from cmd args

func (*AuthCache) HasSavedAuth

func (cache *AuthCache) HasSavedAuth(baseHost string) bool

HasSavedAuth to judge if auth info is already saved in auth.yaml

func (*AuthCache) Login

func (cache *AuthCache) Login(
	identity string, password *Password) context.Context

Login login with identity & password to get auth Context

func (*AuthCache) NextAuth

func (cache *AuthCache) NextAuth(parent context.Context) context.Context

NextAuth get next auth context

func (*AuthCache) SetConfigFile

func (cache *AuthCache) SetConfigFile(path string)

SetConfigFile set auth config file path

func (*AuthCache) SetLoginInfo

func (cache *AuthCache) SetLoginInfo(
	host, identity string, password *Password)

SetLoginInfo save host's login info in viper config

func (*AuthCache) WriteConfig

func (cache *AuthCache) WriteConfig() error

WriteConfig write login info to auth config file

type Authentication

type Authentication struct {
	Identity string   `csv:"identity" json:"identity"`
	Password Password `csv:"password" json:"password"`
	APIKey
}

Authentication auth info including: 1. identity 2. Password instance 3. embedded APIKey struct

func (*Authentication) Validate

func (auth *Authentication) Validate() bool

Validate completion of auth info

type ClientHub

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

ClientHub is a hub of clients from hosts

func (*ClientHub) GetClient

func (hub *ClientHub) GetClient(host string) (*ngerest.APIClient, error)

GetClient to get client instance by host string

type FlagTime

type FlagTime time.Time

FlagTime time format used in flag parse.

func (*FlagTime) GetTime

func (t *FlagTime) GetTime() time.Time

GetTime get Time format

func (*FlagTime) Set

func (t *FlagTime) Set(value string) error

Set set by time string.

func (*FlagTime) String

func (t *FlagTime) String() string

String get time string.

func (*FlagTime) Type

func (t *FlagTime) Type() string

Type get format type string.

type IdentityMap

type IdentityMap map[string]*regexp.Regexp

IdentityMap identity pattern map

func NewIdentityMap

func NewIdentityMap() IdentityMap

NewIdentityMap generate identity pattern map

func (*IdentityMap) AddPattern

func (idMap *IdentityMap) AddPattern(
	name string, pattern *regexp.Regexp) error

AddPattern add new pattern to IdentityMap

func (*IdentityMap) CheckIdentity

func (idMap *IdentityMap) CheckIdentity(
	id string, login map[string]string) error

CheckIdentity check & modify login map

type JavaTime

type JavaTime int64

JavaTime java timestamp format

func (JavaTime) MarshalCSV

func (t JavaTime) MarshalCSV() string

MarshalCSV marshal java time to csv string.

func (JavaTime) UnmarshalCSV

func (t JavaTime) UnmarshalCSV(value string) error

UnmarshalCSV unmarshal csv string to java time

type Order

type Order struct {
	OrderID               string    `csv:"orderID" json:"orderID"`
	ClOrdID               string    `csv:"clOrdID,omitempty" json:"clOrdID,omitempty"`
	ClOrdLinkID           string    `csv:"clOrdLinkID,omitempty" json:"clOrdLinkID,omitempty"`
	Account               float32   `csv:"account,omitempty" json:"account,omitempty"`
	Symbol                string    `csv:"symbol,omitempty" json:"symbol,omitempty"`
	Side                  OrderSide `csv:"side,omitempty" json:"side,omitempty"`
	SimpleOrderQty        float64   `csv:"simpleOrderQty,omitempty" json:"simpleOrderQty,omitempty"`
	OrderQty              float32   `csv:"orderQty,omitempty" json:"orderQty,omitempty"`
	Price                 float64   `csv:"price,omitempty" json:"price,omitempty"`
	DisplayQty            float32   `csv:"displayQty,omitempty" json:"displayQty,omitempty"`
	StopPx                float64   `csv:"stopPx,omitempty" json:"stopPx,omitempty"`
	PegOffsetValue        float64   `csv:"pegOffsetValue,omitempty" json:"pegOffsetValue,omitempty"`
	PegPriceType          string    `csv:"pegPriceType,omitempty" json:"pegPriceType,omitempty"`
	Currency              string    `csv:"currency,omitempty" json:"currency,omitempty"`
	SettlCurrency         string    `csv:"settlCurrency,omitempty" json:"settlCurrency,omitempty"`
	OrdType               string    `csv:"ordType,omitempty" json:"ordType,omitempty"`
	TimeInForce           string    `csv:"timeInForce,omitempty" json:"timeInForce,omitempty"`
	ExecInst              string    `csv:"execInst,omitempty" json:"execInst,omitempty"`
	ContingencyType       string    `csv:"contingencyType,omitempty" json:"contingencyType,omitempty"`
	ExDestination         string    `csv:"exDestination,omitempty" json:"exDestination,omitempty"`
	OrdStatus             string    `csv:"ordStatus,omitempty" json:"ordStatus,omitempty"`
	Triggered             string    `csv:"triggered,omitempty" json:"triggered,omitempty"`
	WorkingIndicator      bool      `csv:"workingIndicator,omitempty" json:"workingIndicator,omitempty"`
	OrdRejReason          string    `csv:"ordRejReason,omitempty" json:"ordRejReason,omitempty"`
	SimpleLeavesQty       float64   `csv:"simpleLeavesQty,omitempty" json:"simpleLeavesQty,omitempty"`
	LeavesQty             float32   `csv:"leavesQty,omitempty" json:"leavesQty,omitempty"`
	SimpleCumQty          float64   `csv:"simpleCumQty,omitempty" json:"simpleCumQty,omitempty"`
	CumQty                float32   `csv:"cumQty,omitempty" json:"cumQty,omitempty"`
	AvgPx                 float64   `csv:"avgPx,omitempty" json:"avgPx,omitempty"`
	MultiLegReportingType string    `csv:"multiLegReportingType,omitempty" json:"multiLegReportingType,omitempty"`
	Text                  string    `csv:"text,omitempty" json:"text,omitempty"`
	TransactTime          JavaTime  `csv:"transactTime,omitempty" json:"transactTime,omitempty"`
	Timestamp             JavaTime  `csv:"timestamp,omitempty" json:"timestamp,omitempty"`
}

Order order table

func ConvertOrder

func ConvertOrder(ori *ngerest.Order) *Order

ConvertOrder convert ngerest.Order structure to local Order structure

func (*Order) IsClosed

func (ord *Order) IsClosed() bool

IsClosed check if order is closed

type OrderCache

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

OrderCache is a order input & output channel

func NewOrderCache

func NewOrderCache() *OrderCache

NewOrderCache to make new order cache

func (*OrderCache) CloseInputs

func (cache *OrderCache) CloseInputs()

CloseInputs to close order cache's input channel

func (*OrderCache) CloseResults

func (cache *OrderCache) CloseResults()

CloseResults to close order results channel

func (*OrderCache) GetInputs

func (cache *OrderCache) GetInputs() <-chan *Order

GetInputs to get order cache's input channel

func (*OrderCache) GetResults

func (cache *OrderCache) GetResults() <-chan *Order

GetResults to get order results channl

func (*OrderCache) PutOrder

func (cache *OrderCache) PutOrder(
	id string, ord *Order, timeout time.Duration) error

PutOrder order into order cache, it's go routing safe

func (*OrderCache) PutResult

func (cache *OrderCache) PutResult(ord *ngerest.Order)

PutResult puts order result into cache

type OrderSide

type OrderSide string

OrderSide order side

const (
	// Buy buy side
	Buy OrderSide = "Buy"
	// Sell sell side
	Sell OrderSide = "Sell"
)

func (*OrderSide) MarshalCSV

func (s *OrderSide) MarshalCSV() string

MarshalCSV marshal to csv column

func (*OrderSide) MarshalJSON

func (s *OrderSide) MarshalJSON() ([]byte, error)

MarshalJSON marshal to json string

func (*OrderSide) MatchSide

func (s *OrderSide) MatchSide(qty int64) error

MatchSide match side with quantity

func (*OrderSide) Opposite

func (s *OrderSide) Opposite() OrderSide

Opposite get opposite order side

func (*OrderSide) Set

func (s *OrderSide) Set(value string) error

Set set OrderSide by string, if value is empty, default: Buy

func (*OrderSide) String

func (s *OrderSide) String() string

String order side string

func (*OrderSide) Type

func (s *OrderSide) Type() string

Type get order side type

func (*OrderSide) UnmarshalCSV

func (s *OrderSide) UnmarshalCSV(value string) error

UnmarshalCSV unmarshal csv column to OrderSide

func (*OrderSide) UnmarshalJSON

func (s *OrderSide) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal from json string

func (*OrderSide) Value

func (s *OrderSide) Value() int64

Value order side value

type Password

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

Password shadowed password store

func NewPassword

func NewPassword() *Password

NewPassword get new password struct

func NewPasswordByPEM

func NewPasswordByPEM(pemPath string) *Password

NewPasswordByPEM create password with user specified pem key, if pemPath not specified or is invalid, will return Password with default key

func (*Password) IsSet

func (p *Password) IsSet() bool

IsSet verify if password set

func (*Password) MarshalCSV

func (p *Password) MarshalCSV() string

MarshalCSV marshal password to csv

func (*Password) MarshalJSON

func (p *Password) MarshalJSON() ([]byte, error)

MarshalJSON marshal to json string

func (*Password) Set

func (p *Password) Set(value string) error

Set set password

func (*Password) Shadow

func (p *Password) Shadow(value string) string

Shadow shadow & store a password

func (*Password) ShadowSet

func (p *Password) ShadowSet(value string) (err error)

ShadowSet set shadowed password

func (*Password) Show

func (p *Password) Show() string

Show show unshadowed password

func (*Password) String

func (p *Password) String() string

func (*Password) Type

func (p *Password) Type() string

Type get password type

func (*Password) UnmarshalCSV

func (p *Password) UnmarshalCSV(value string) error

UnmarshalCSV unmarshal password from csv

func (*Password) UnmarshalJSON

func (p *Password) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal from json string

Jump to

Keyboard shortcuts

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