openclosepb

package
v0.0.0-...-ee17ca8 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultModelOptions = []resource.Option{
	WithInitialPositions(),
}

DefaultModelOptions holds the default options for the model.

Functions

func WithInitialPositions

func WithInitialPositions(positions ...*traits.OpenClosePosition) resource.Option

WithInitialPositions returns an option that configures the positions resource to initialise with the given positions. This option should only be used once per model.

func WithOpenCloseApiClientFactory

func WithOpenCloseApiClientFactory(f func(name string) (traits.OpenCloseApiClient, error)) router.Option

WithOpenCloseApiClientFactory instructs the router to create a new client the first time Get is called for that name.

func WithOpenCloseInfoClientFactory

func WithOpenCloseInfoClientFactory(f func(name string) (traits.OpenCloseInfoClient, error)) router.Option

WithOpenCloseInfoClientFactory instructs the router to create a new client the first time Get is called for that name.

func WithPositionsOption

func WithPositionsOption(opts ...resource.Option) resource.Option

WithPositionsOption configures options for the position resource.

func WithPreset

WithPreset returns an option that configures the model with the given preset. This option does not apply to any resource.

Types

type ApiRouter

ApiRouter is a traits.OpenCloseApiServer that allows routing named requests to specific traits.OpenCloseApiClient

func NewApiRouter

func NewApiRouter(opts ...router.Option) *ApiRouter

func (*ApiRouter) Add

func (r *ApiRouter) Add(name string, client any) any

Add extends Router.Add to panic if client is not of type traits.OpenCloseApiClient.

func (*ApiRouter) AddOpenCloseApiClient

func (r *ApiRouter) AddOpenCloseApiClient(name string, client traits.OpenCloseApiClient) traits.OpenCloseApiClient

func (*ApiRouter) GetOpenCloseApiClient

func (r *ApiRouter) GetOpenCloseApiClient(name string) (traits.OpenCloseApiClient, error)

func (*ApiRouter) GetPositions

func (*ApiRouter) HoldsType

func (r *ApiRouter) HoldsType(client any) bool

func (*ApiRouter) PullPositions

func (*ApiRouter) Register

func (r *ApiRouter) Register(server grpc.ServiceRegistrar)

func (*ApiRouter) RemoveOpenCloseApiClient

func (r *ApiRouter) RemoveOpenCloseApiClient(name string) traits.OpenCloseApiClient

func (*ApiRouter) Stop

func (*ApiRouter) UpdatePositions

type ApiWrapper

type ApiWrapper struct {
	traits.OpenCloseApiClient
	// contains filtered or unexported fields
}

func WrapApi

func WrapApi(server traits.OpenCloseApiServer) *ApiWrapper

WrapApi adapts a traits.OpenCloseApiServer and presents it as a traits.OpenCloseApiClient

func (*ApiWrapper) Unwrap

func (w *ApiWrapper) Unwrap() any

Unwrap implements wrap.Unwrapper and returns the underlying server instance as an unknown type.

func (*ApiWrapper) UnwrapServer

func (w *ApiWrapper) UnwrapServer() traits.OpenCloseApiServer

UnwrapServer returns the underlying server instance.

func (*ApiWrapper) UnwrapService

func (w *ApiWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)

type InfoRouter

InfoRouter is a traits.OpenCloseInfoServer that allows routing named requests to specific traits.OpenCloseInfoClient

func NewInfoRouter

func NewInfoRouter(opts ...router.Option) *InfoRouter

func (*InfoRouter) Add

func (r *InfoRouter) Add(name string, client any) any

Add extends Router.Add to panic if client is not of type traits.OpenCloseInfoClient.

func (*InfoRouter) AddOpenCloseInfoClient

func (r *InfoRouter) AddOpenCloseInfoClient(name string, client traits.OpenCloseInfoClient) traits.OpenCloseInfoClient

func (*InfoRouter) DescribePositions

func (r *InfoRouter) DescribePositions(ctx context.Context, request *traits.DescribePositionsRequest) (*traits.PositionsSupport, error)

func (*InfoRouter) GetOpenCloseInfoClient

func (r *InfoRouter) GetOpenCloseInfoClient(name string) (traits.OpenCloseInfoClient, error)

func (*InfoRouter) HoldsType

func (r *InfoRouter) HoldsType(client any) bool

func (*InfoRouter) Register

func (r *InfoRouter) Register(server grpc.ServiceRegistrar)

func (*InfoRouter) RemoveOpenCloseInfoClient

func (r *InfoRouter) RemoveOpenCloseInfoClient(name string) traits.OpenCloseInfoClient

type InfoWrapper

type InfoWrapper struct {
	traits.OpenCloseInfoClient
	// contains filtered or unexported fields
}

func WrapInfo

func WrapInfo(server traits.OpenCloseInfoServer) *InfoWrapper

WrapInfo adapts a traits.OpenCloseInfoServer and presents it as a traits.OpenCloseInfoClient

func (*InfoWrapper) Unwrap

func (w *InfoWrapper) Unwrap() any

Unwrap implements wrap.Unwrapper and returns the underlying server instance as an unknown type.

func (*InfoWrapper) UnwrapServer

func (w *InfoWrapper) UnwrapServer() traits.OpenCloseInfoServer

UnwrapServer returns the underlying server instance.

func (*InfoWrapper) UnwrapService

func (w *InfoWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)

type Model

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

func NewModel

func NewModel(opts ...resource.Option) *Model

NewModel creates a new *Model with the given options. Options are applied to all resource types in the model unless specified otherwise in the option.

func (*Model) GetPosition

func (*Model) GetPositions

func (m *Model) GetPositions(opts ...resource.ReadOption) (*traits.OpenClosePositions, error)

func (*Model) HasPreset

func (m *Model) HasPreset(name string) bool

func (*Model) ListPresets

func (m *Model) ListPresets() []*traits.OpenClosePositions_Preset

func (*Model) PullPositions

func (m *Model) PullPositions(ctx context.Context, ops ...resource.ReadOption) <-chan PullOpenClosePositionsChange

func (*Model) UpdatePosition

func (m *Model) UpdatePosition(position *traits.OpenClosePosition, opts ...resource.WriteOption) (*traits.OpenClosePosition, error)

func (*Model) UpdatePositions

func (m *Model) UpdatePositions(positions *traits.OpenClosePositions, opts ...resource.WriteOption) (*traits.OpenClosePositions, error)

type ModelServer

type ModelServer struct {
	traits.UnimplementedOpenCloseApiServer
	traits.UnimplementedOpenCloseInfoServer
	// contains filtered or unexported fields
}

func NewModelServer

func NewModelServer(model *Model) *ModelServer

func (*ModelServer) DescribePositions

func (*ModelServer) GetPositions

func (*ModelServer) PullPositions

func (*ModelServer) Register

func (s *ModelServer) Register(server grpc.ServiceRegistrar)

func (*ModelServer) Unwrap

func (s *ModelServer) Unwrap() any

func (*ModelServer) UpdatePositions

type PullOpenClosePositionsChange

type PullOpenClosePositionsChange struct {
	Positions  *traits.OpenClosePositions
	ChangeTime time.Time
}

Jump to

Keyboard shortcuts

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