Documentation ¶
Index ¶
- Constants
- Variables
- func ErrRender(err error) render.Renderer
- func FileServer(r chi.Router, basePath string, path string, root http.FileSystem)
- func Parse(buf []byte, lc *LaunchConfig) error
- type API
- type AppVersion
- type Connector
- type ErrResponse
- type Instance
- type InstanceEx
- type InstanceInputs
- type InstanceKeySet
- type InstanceLogItem
- type InstanceStatus
- type LaunchConfig
- type LaunchConfigSingleAlgoType
- type PlatformStatus
- type RedisStore
- func (rs *RedisStore) Get(key string, val interface{}) error
- func (rs *RedisStore) GetObject(key string, result interface{}) error
- func (rs *RedisStore) HGet(key, field string) (string, error)
- func (rs *RedisStore) Keys(pattern string, result *[]string) error
- func (rs *RedisStore) LLen(key string) (int, error)
- func (rs *RedisStore) ListLen(key string) (int, error)
- func (rs *RedisStore) ListRange(key string, from, to int) ([]string, error)
- func (rs *RedisStore) MGet(keys []string, val *[]string) error
- func (rs *RedisStore) Publish(code string) (bool, error)
- func (rs *RedisStore) Scan(pattern string, result *[]string) error
- func (rs *RedisStore) Set(key string, val string) error
- type Response
- type Service
- func (s *Service) Config() map[string]string
- func (s *Service) FileStream(fname string) (io.ReadCloser, error)
- func (s *Service) GetObject(key string, result interface{}) error
- func (s *Service) Instances(result *[]InstanceEx) error
- func (s *Service) ListLen(key string) (int, error)
- func (s *Service) ListRange(key string, from, to int) ([]string, error)
- func (s *Service) MatrixI() (map[string]map[string]string, error)
- func (s *Service) NewPnLChart()
- func (s *Service) PlatformStatus() (*PlatformStatus, error)
- func (s *Service) Publish(code string) (bool, error)
- func (s *Service) PublishLaunchConfig(action, fname string, content string) (bool, error)
- func (s *Service) RefreshConfig() error
- func (s *Service) SaveFileToDisk(fname string, buf bytes.Buffer) error
- func (s *Service) SetSession(k, v string)
- func (s *Service) Start(ctx context.Context) error
- type Servicer
- type Status
- type Storer
- type Value
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 FileServer ¶
func Parse ¶
func Parse(buf []byte, lc *LaunchConfig) error
Types ¶
type AppVersion ¶
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 InstanceEx ¶
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"` 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 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 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) ListRange ¶
func (rs *RedisStore) ListRange(key string, from, to int) ([]string, error)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service .
func (*Service) FileStream ¶
func (s *Service) FileStream(fname string) (io.ReadCloser, error)
func (*Service) Instances ¶
func (s *Service) Instances(result *[]InstanceEx) error
Instances retrives instances' figures.
func (*Service) NewPnLChart ¶
func (s *Service) NewPnLChart()
func (*Service) PlatformStatus ¶
func (s *Service) PlatformStatus() (*PlatformStatus, error)
func (*Service) PublishLaunchConfig ¶
func (*Service) RefreshConfig ¶
func (*Service) SaveFileToDisk ¶
func (*Service) SetSession ¶
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 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 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()
Source Files ¶
Click to show internal directories.
Click to hide internal directories.