adash

package
v0.0.0-...-a8632a4 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2020 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// READY to start running (waiting market open).
	READY int8 = 0
	// RUNNING normally.
	RUNNING int8 = 1

	// CLOSED manually by user or by algorithm.
	CLOSED int8 = 2

	// FAILED execution.
	FAILED int8 = 3

	// LOST says no status updates last 2 minutes.
	LOST int8 = 4
)
View Source
const CMND = "CMND"
View Source
const CommandStartInstance = "START:"
View Source
const CommandStopInstance = "STOP:"
View Source
const ConnectorPrefix = "CS:"
View Source
const KeyPortfolioPnL = "PNL:"
View Source
const KeyPrefixInput = "I:"
View Source
const KeyPrefixLaunchConfig = "FILE:"
View Source
const KeyPrefixLog = "L:"
View Source
const KeyPrefixModel = "M:"
View Source
const KeyPrefixStatus = "S:"
View Source
const ScanInputKeys = KeyPrefixInput + "*"

Variables

View Source
var (
	// ErrImcomingMessageEmpty defines error.
	ErrImcomingMessageEmpty = errors.New("imcoming message is empty")
)
View Source
var ErrNotFound = &ErrResponse{HTTPStatusCode: 404, StatusText: "Resource not found."}
View Source
var MarkAsLostAfter = time.Minute * 2
View Source
var TokenAuth *jwtauth.JWTAuth

Functions

func ErrRender

func ErrRender(err error) render.Renderer

func FileServer

func FileServer(r chi.Router, basePath string, path string, root http.FileSystem)

func Parse

func Parse(buf []byte, lc *LaunchConfig) error

Types

type API

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

func NewAPI

func NewAPI(service Servicer, a *aaa.Service, looger zerolog.Logger,
	wwwfolder string, rab hms.HHMM, rsc string, av AppVersion,
	h *holidayer.Holidayer) *API

func (*API) Start

func (a *API) Start(ctx context.Context, listen string, lp *redishashtracker.TrackingEngine, pnlch *charter.Charter) error

type AppVersion

type AppVersion struct {
	Version      string `json:"version"`
	BuildAt      string `json:"buildAt"`
	BuildFor     string `json:"buildFor"`
	ReleaseNotes string `json:"releaseNotes"`
}

type Connector

type Connector struct {
	Name     string `json:"name"`
	Status   int    `json:"status"`
	StatusAt uint64 `json:"status_at,omitempty"`
}

type ErrResponse

type ErrResponse struct {
	Err            error  `json:"-"`               // low-level runtime error
	HTTPStatusCode int    `json:"-"`               // http response status code
	StatusText     string `json:"status"`          // user-level status message
	AppCode        int64  `json:"code,omitempty"`  // application-specific error code
	ErrorText      string `json:"error,omitempty"` // application-level error message, for debugging
}

ErrResponse renderer type for handling all sorts of errors.

In the best case scenario, the excellent github.com/pkg/errors package helps reveal information on the error, setting it on Err, and in the Render() method, using it to set the application-specific error code in AppCode.

func (*ErrResponse) Render

func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error

type Instance

type Instance struct {
	ID       string `json:"id"`
	AlgoType string `json:"atype"`
	Value
	Status
	CurrencyCode  string `json:"cur" redis:"currencyCode"`
	Country       string `json:"cntr" redis:"countryCode"`
	LogItemsCount int    `json:"lic"`
	Group         string `json:"g" redis:"g"`
}

type InstanceEx

type InstanceEx struct {
	Instance
	Color string `json:"color"`
}

type InstanceInputs

type InstanceInputs struct {
	AlgoProductCode        string `json:"algoProductCode"`
	DerivativeBrokerCode   string `json:"derivativeBrokerCode"`
	EquityBrokerCode       string `json:"equityBrokerCode"`
	EquityAccount          string `json:"equityAccount"`
	DerivativeAccount      string `json:"derivativeAccount"`
	ProductID              string `json:"productId"`
	AllowedShots           string `json:"allowedShots"`
	PositionTwap           string `json:"positionTwap"`
	PositionCostTwap       string `json:"positionCostTwap"`
	StartTime              string `json:"startTime"`
	EndTime                string `json:"endTime"`
	TwapTimeRange          string `json:"twapTimeRange"`
	RandomInterval         string `json:"randomInterval"`
	Threshold              string `json:"threshold"`
	PositionOption         string `json:"positionOption"`
	OptionPositionCost     string `json:"optionPositionCost"`
	PositionHedge          string `json:"positionHedge"`
	StopLossLimit          string `json:"stopLossLimit"`
	StopProfitLimit        string `json:"stopProfitLimit"`
	PositionCostHedge      string `json:"positionCostHedge"`
	InterestRate           string `json:"interestRate"`
	Strike                 string `json:"strike"`
	ShortCodeShare         string `json:"shortCodeShare"`
	CountryCode            string `json:"countryCode"`
	ExpiryDate             string `json:"expiryDate"`
	OverriddenOpeningPrice string `json:"overriddenOpeningPrice"`
	SectorIndex            string `json:"sectorIndex"`
	CurrencyCode           string `json:"currencyCode"`
	OpenTime               string `json:"openTime"`
	OptionCode4Threshold   string `json:"optionCode4Threshold"`
}

type InstanceKeySet

type InstanceKeySet struct {
	ID           string
	I            string
	M            string
	S            string
	L            string
	AlgoType     string
	CurrencyCode string
	Group        string
}

type InstanceLogItem

type InstanceLogItem struct {
	At       int64  `json:"at"`
	Severity int    `json:"severity"`
	Message  string `json:"msg"`
}

InstanceLogItem describes single log entry to show in the Intance Console.

type InstanceStatus

type InstanceStatus int

InstanceStatus defines allowed list of instance statuses.

type LaunchConfig

type LaunchConfig struct {
}

type LaunchConfigSingleAlgoType

type LaunchConfigSingleAlgoType struct {
	AlgoType  string // BUOYANCY
	Marker    string // EUROPE:300
	CSVHeader string //
	CSVRow    []string
}

type PlatformStatus

type PlatformStatus struct {
	Connectors    []Connector `json:"connectors"`
	LogItemsCount int         `json:"log_items_count"`

	// Status holds general platform status
	Status             int8    `json:"status"`
	StatusAt           int64   `json:"status_at,omitempty"`
	PnL                float64 `json:"pnl"`
	PositionDelta      float64 `json:"pd"`
	PositionDeltaLimit float64 `json:"pl"`
	ServerTime         string  `json:"server_time"`
}

type RedisStore

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

RedisStore хранилище данных полученных от трейдинговых алгоритмов.

func NewRedisStore

func NewRedisStore(pool *radix.Pool, db int) *RedisStore

func (*RedisStore) Get

func (rs *RedisStore) Get(key string, val interface{}) error

func (*RedisStore) GetObject

func (rs *RedisStore) GetObject(key string, result interface{}) error

func (*RedisStore) HGet

func (rs *RedisStore) HGet(key, field string) (string, error)

func (*RedisStore) Keys

func (rs *RedisStore) Keys(pattern string, result *[]string) error

func (*RedisStore) LLen

func (rs *RedisStore) LLen(key string) (int, error)

func (*RedisStore) ListLen

func (rs *RedisStore) ListLen(key string) (int, error)

func (*RedisStore) ListRange

func (rs *RedisStore) ListRange(key string, from, to int) ([]string, error)

func (*RedisStore) MGet

func (rs *RedisStore) MGet(keys []string, val *[]string) error

func (*RedisStore) Publish

func (rs *RedisStore) Publish(code string) (bool, error)

func (*RedisStore) Scan

func (rs *RedisStore) Scan(pattern string, result *[]string) error

Scan returns all instance names startings with "pattern".

func (*RedisStore) Set

func (rs *RedisStore) Set(key string, val string) error

type Response

type Response struct {
	Received bool `json:"received"`
}

type Service

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

Service .

func NewService

func NewService(store Storer, logger *zerolog.Logger, lcfolder string) *Service

func (*Service) Config

func (s *Service) Config() map[string]string

func (*Service) FileStream

func (s *Service) FileStream(fname string) (io.ReadCloser, error)

func (*Service) GetObject

func (s *Service) GetObject(key string, result interface{}) error

func (*Service) Instances

func (s *Service) Instances(result *[]InstanceEx) error

Instances retrives instances' figures.

func (*Service) ListLen

func (s *Service) ListLen(key string) (int, error)

func (*Service) ListRange

func (s *Service) ListRange(key string, from, to int) ([]string, error)

func (*Service) MatrixI

func (s *Service) MatrixI() (map[string]map[string]string, error)

func (*Service) NewPnLChart

func (s *Service) NewPnLChart()

func (*Service) PlatformStatus

func (s *Service) PlatformStatus() (*PlatformStatus, error)

func (*Service) Publish

func (s *Service) Publish(code string) (bool, error)

func (*Service) PublishLaunchConfig

func (s *Service) PublishLaunchConfig(action, fname string, content string) (bool, error)

func (*Service) RefreshConfig

func (s *Service) RefreshConfig() error

func (*Service) SaveFileToDisk

func (s *Service) SaveFileToDisk(fname string, buf bytes.Buffer) error

func (*Service) SetSession

func (s *Service) SetSession(k, v string)

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

type Servicer

type Servicer interface {
	MatrixI() (map[string]map[string]string, error)
	Instances(result *[]InstanceEx) error
	PublishLaunchConfig(action, fname string, content string) (bool, error)
	Publish(code string) (bool, error)
	ListLen(key string) (int, error)
	ListRange(key string, from, to int) ([]string, error)
	GetObject(key string, result interface{}) error
	Config() map[string]string
	RefreshConfig() error
	PlatformStatus() (*PlatformStatus, error)
	FileStream(fname string) (io.ReadCloser, error)
	SaveFileToDisk(fname string, buf bytes.Buffer) error
}

type Status

type Status struct {
	At     int64 `json:"at" redis:"at"`
	Status int8  `json:"status" redis:"st"`
}

type Storer

type Storer interface {
	Scan(pattern string, result *[]string) error
	Keys(pattern string, result *[]string) error
	Get(key string, val interface{}) error
	MGet(keys []string, result *[]string) error
	Set(key string, val string) error
	Publish(code string) (bool, error)
	ListLen(key string) (int, error)
	ListRange(key string, from, to int) ([]string, error)
	GetObject(key string, result interface{}) error
	HGet(key, field string) (string, error)
}

Storer is and interface devinition to data persistent storage.

type Value

type Value struct {
	Pnl                     string  `json:"-" redis:"pnl"`     //float64
	PositionTwap            string  `json:"pt" redis:"pt"`     //int
	PositionHedge           string  `json:"ph" redis:"ph"`     //int
	PositionOption          string  `json:"po" redis:"po"`     //int
	Bid                     string  `json:"b" redis:"b"`       //float64
	Ask                     string  `json:"a" redis:"a"`       //float64
	Last                    string  `json:"l" redis:"l"`       //float64
	OptionBid               string  `json:"ob" redis:"ob"`     //float64
	OptionAsk               string  `json:"oa" redis:"oa"`     //float64
	ShareAverageHedgePrice  string  `json:"sahp" redis:"sahp"` //float64
	TargetQuantityPerPeriod string  `json:"tqpp" redis:"tqpp"` //int
	TargetPositionFlowTwap  string  `json:"tpft" redis:"tpft"` //int
	RemainingShots          string  `json:"rs" redis:"rs"`     //int
	PnlFloat                float64 `json:"pnl" redis:"-"`
	PositionDelta           string  `json:"pd" redis:"pd"` // pd - global
	NumOfSecurities         string  `json:"ns" redis:"ns"` // ns -
	PositionDeltaLimit      string  `json:"pl" redis:"pl"` // pl - global
	PositionDeltaCash       string  `json:"pdc" redis:"pdc"`
	PositionDeltaLimitCash  string  `json:"plc" redis:"plc"` //plc
}

Value holds instance's last metrics.

func (*Value) ReduceLength

func (v *Value) ReduceLength()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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