normal

package
v0.41.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscreteThreeLevelProbabilities added in v0.37.0

func DiscreteThreeLevelProbabilities(V []float64, muHat float64, sigmaHat float64) ([]float64, error)

DiscreteThreeLevelProbabilities is a method for calculating price levels.

func GeneratePriceUsingDiscreteThreeLevel added in v0.37.0

func GeneratePriceUsingDiscreteThreeLevel(M0, delta, sigma, tgtTimeHorizonYrFrac, N float64) (price float64, err error)

GeneratePriceUsingDiscreteThreeLevel is a method for calculating price levels input is a float price (so divide uint64 price by 10^{num of decimals}) it returns a float price which you want to multiply by 10^{num of decimals} and then round.

Types

type Bot

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

Bot represents one Normal liquidity bot.

func New

func New(config config.BotConfig, pe PricingEngine, ws *wallets.Handler) (b *Bot, err error)

New returns a new instance of Bot.

func (*Bot) GetRealisticOrderDetails added in v0.37.0

func (b *Bot) GetRealisticOrderDetails(externalPrice *num.Uint) (price, size *num.Uint, err error)

GetRealisticOrderDetails uses magic to return a realistic order price and size.

func (*Bot) GetTraderDetails added in v0.36.0

func (b *Bot) GetTraderDetails() string

GetTraderDetails returns information relating to the trader.

func (*Bot) Start

func (b *Bot) Start() error

Start starts the liquidity bot goroutine(s).

func (*Bot) Stop

func (b *Bot) Stop()

Stop stops the liquidity bot goroutine(s).

type CoreService added in v0.41.0

type CoreService interface {
	SubmitTransaction(req *vegaapipb.SubmitTransactionRequest) (response *vegaapipb.SubmitTransactionResponse, err error)
	// rpc PropagateChainEvent(PropagateChainEventRequest) returns (PropagateChainEventResponse);
	// rpc Statistics(StatisticsRequest) returns (StatisticsResponse);
	LastBlockData() (*vegaapipb.LastBlockHeightResponse, error)
	GetVegaTime() (t time.Time, err error)
	ObserveEventBus() (client vegaapipb.CoreService_ObserveEventBusClient, err error)
}

CoreService implements the gRPC service of the same name.

type CoreStateService added in v0.41.0

type CoreStateService interface {
}

CoreStateService implements the gRPC service of the same name.

type DataNode added in v0.41.0

type DataNode interface {
	GetAddress() (url.URL, error)
	CoreService
	TradingDataService
}

DataNode is a Vega Data node

type LODParamsConfig

type LODParamsConfig struct {
	Method              SteeringMethod
	GttLength           uint64
	TgtTimeHorizonHours float64
	NumTicksFromMid     uint64
	NumIdenticalBots    int
}

LODParamsConfig is a little data structure which sets the algo and params for how limits orders are generated.

type PricingEngine

type PricingEngine interface {
	GetPrice(pricecfg ppconfig.PriceConfig) (pi ppservice.PriceResponse, err error)
}

PricingEngine is the source of price information from the price proxy.

type ShapeConfig

type ShapeConfig struct {
	Sells []*vega.LiquidityOrder
	Buys  []*vega.LiquidityOrder
}

ShapeConfig is the top level definition of a liquidity shape.

type SteeringMethod added in v0.37.0

type SteeringMethod int

SteeringMethod is an enum for all the possible price calculations methods for price steering.

const (
	// NotSet for when we cannot parse the input string.
	NotSet SteeringMethod = iota
	// DiscreteThreeLevel uses the discrete three level method.
	DiscreteThreeLevel
	// CoinAndBinomial uses the coin and binomial method.
	CoinAndBinomial
)

type Strategy

type Strategy struct {
	// ExpectedMarkPrice (optional) specifies the expected mark price for a market that may not yet
	// have a mark price. It is used to calculate margin cost of orders meeting liquidity
	// requirement.
	ExpectedMarkPrice config.Uint

	// AuctionVolume ...
	AuctionVolume config.Uint

	// CommitmentFraction is the fractional amount of stake for the LP
	CommitmentFraction float64

	// Fee is the 0->1 fee for supplying liquidity
	Fee float64

	// MaxLong specifies the maximum long position that the bot will tolerate.
	MaxLong config.Uint

	// MaxShort specifies the maximum short position that the bot will tolerate.
	MaxShort config.Uint

	// PosManagementFraction controls the size of market orders used to manage the bot's position.
	PosManagementFraction float64

	// StakeFraction (along with OrdersFraction) is used in rule-of-thumb heuristics to decide how
	// the bot should deploy collateral.
	StakeFraction float64

	// OrdersFraction (along with StakeFraction) is used in rule-of-thumb heuristics to decide how
	// the bot should deploy collateral.
	OrdersFraction float64

	// ShorteningShape (which includes both sides of the book) specifies the shape used when the bot
	// is trying to shorten its position.
	ShorteningShape *ShapeConfig

	// LongeningShape (which includes both sides of the book) specifies the shape used when the bot
	// is trying to lengthen its position. Note that the initial shape used by the bot is always the
	// longening shape, because being long is a little cheaper in position margin than being short.
	LongeningShape *ShapeConfig

	// PosManagementSleepMilliseconds is the sleep time, in milliseconds, between position management
	PosManagementSleepMilliseconds uint64

	// MarketPriceSteeringRatePerSecond ...
	MarketPriceSteeringRatePerSecond float64

	// MinPriceSteerFraction is the minimum difference between external and current price that will
	// allow a price steering order to be placed.
	MinPriceSteerFraction float64

	// PriceSteerOrderScale is the scaling factor used when placing a steering order
	PriceSteerOrderScale float64

	// LimitOrderDistributionParams ...
	LimitOrderDistributionParams *LODParamsConfig

	// TargetLNVol specifies the target log-normal volatility (e.g. 0.5 for 50%).
	TargetLNVol float64
}

Strategy configures the normal strategy.

func (*Strategy) String

func (s *Strategy) String() string

type TradingDataService added in v0.41.0

type TradingDataService interface {
	// rpc MarketAccounts(MarketAccountsRequest) returns (MarketAccountsResponse);
	// rpc PartyAccounts(PartyAccountsRequest) returns (PartyAccountsResponse);
	PartyAccounts(req *dataapipb.PartyAccountsRequest) (response *dataapipb.PartyAccountsResponse, err error)
	// rpc FeeInfrastructureAccounts(FeeInfrastructureAccountsRequest) returns (FeeInfrastructureAccountsResponse);
	// rpc GlobalRewardPoolAccounts(GlobalRewardPoolAccountsRequest) returns (GlobalRewardPoolAccountsResponse);
	// rpc Candles(CandlesRequest) returns (CandlesResponse);
	MarketDataByID(req *dataapipb.MarketDataByIDRequest) (response *dataapipb.MarketDataByIDResponse, err error)
	// rpc MarketsData(MarketsDataRequest) returns (MarketsDataResponse);
	// rpc MarketByID(MarketByIDRequest) returns (MarketByIDResponse);
	// rpc MarketDepth(MarketDepthRequest) returns (MarketDepthResponse);
	Markets(req *dataapipb.MarketsRequest) (response *dataapipb.MarketsResponse, err error)
	// rpc OrderByMarketAndID(OrderByMarketAndIDRequest) returns (OrderByMarketAndIDResponse);
	// rpc OrderByReference(OrderByReferenceRequest) returns (OrderByReferenceResponse);
	// rpc OrdersByMarket(OrdersByMarketRequest) returns (OrdersByMarketResponse);
	// rpc OrdersByParty(OrdersByPartyRequest) returns (OrdersByPartyResponse);
	// rpc OrderByID(OrderByIDRequest) returns (OrderByIDResponse);
	// rpc OrderVersionsByID(OrderVersionsByIDRequest) returns (OrderVersionsByIDResponse);
	// rpc MarginLevels(MarginLevelsRequest) returns (MarginLevelsResponse);
	// rpc Parties(PartiesRequest) returns (PartiesResponse);
	// rpc PartyByID(PartyByIDRequest) returns (PartyByIDResponse);
	PositionsByParty(req *dataapipb.PositionsByPartyRequest) (response *dataapipb.PositionsByPartyResponse, err error)
	// rpc LastTrade(LastTradeRequest) returns (LastTradeResponse);
	// rpc TradesByMarket(TradesByMarketRequest) returns (TradesByMarketResponse);
	// rpc TradesByOrder(TradesByOrderRequest) returns (TradesByOrderResponse);
	// rpc TradesByParty(TradesByPartyRequest) returns (TradesByPartyResponse);
	// rpc GetProposals(GetProposalsRequest) returns (GetProposalsResponse);
	// rpc GetProposalsByParty(GetProposalsByPartyRequest) returns (GetProposalsByPartyResponse);
	// rpc GetVotesByParty(GetVotesByPartyRequest) returns (GetVotesByPartyResponse);
	// rpc GetNewMarketProposals(GetNewMarketProposalsRequest) returns (GetNewMarketProposalsResponse);
	// rpc GetUpdateMarketProposals(GetUpdateMarketProposalsRequest) returns (GetUpdateMarketProposalsResponse);
	// rpc GetNetworkParametersProposals(GetNetworkParametersProposalsRequest) returns (GetNetworkParametersProposalsResponse);
	// rpc GetNewAssetProposals(GetNewAssetProposalsRequest) returns (GetNewAssetProposalsResponse);
	// rpc GetProposalByID(GetProposalByIDRequest) returns (GetProposalByIDResponse);
	// rpc GetProposalByReference(GetProposalByReferenceRequest) returns (GetProposalByReferenceResponse);
	// rpc ObserveGovernance(ObserveGovernanceRequest) returns (stream ObserveGovernanceResponse);
	// rpc ObservePartyProposals(ObservePartyProposalsRequest) returns (stream ObservePartyProposalsResponse);
	// rpc ObservePartyVotes(ObservePartyVotesRequest) returns (stream ObservePartyVotesResponse);
	// rpc ObserveProposalVotes(ObserveProposalVotesRequest) returns (stream ObserveProposalVotesResponse);
	// rpc ObserveEventBus(stream ObserveEventBusRequest) returns (stream ObserveEventBusResponse);
	// rpc GetNodeData(GetNodeDataRequest) returns (GetNodeDataResponse);
	// rpc GetNodes(GetNodesRequest) returns (GetNodesResponse);
	// rpc GetNodeByID(GetNodeByIDRequest) returns (GetNodeByIDResponse);
	// rpc GetEpoch(GetEpochRequest) returns (GetEpochResponse);
	// rpc GetVegaTime(GetVegaTimeRequest) returns (GetVegaTimeResponse);
	// rpc AccountsSubscribe(AccountsSubscribeRequest) returns (stream AccountsSubscribeResponse);
	// rpc CandlesSubscribe(CandlesSubscribeRequest) returns (stream CandlesSubscribeResponse);
	// rpc MarginLevelsSubscribe(MarginLevelsSubscribeRequest) returns (stream MarginLevelsSubscribeResponse);
	// rpc MarketDepthSubscribe(MarketDepthSubscribeRequest) returns (stream MarketDepthSubscribeResponse);
	// rpc MarketDepthUpdatesSubscribe(MarketDepthUpdatesSubscribeRequest) returns (stream MarketDepthUpdatesSubscribeResponse);
	// rpc MarketsDataSubscribe(MarketsDataSubscribeRequest) returns (stream MarketsDataSubscribeResponse);
	// rpc OrdersSubscribe(OrdersSubscribeRequest) returns (stream OrdersSubscribeResponse);
	PositionsSubscribe(req *dataapipb.PositionsSubscribeRequest) (client dataapipb.TradingDataService_PositionsSubscribeClient, err error)
	// rpc TradesSubscribe(TradesSubscribeRequest) returns (stream TradesSubscribeResponse);
	// rpc TransferResponsesSubscribe(TransferResponsesSubscribeRequest) returns (stream TransferResponsesSubscribeResponse);
	// rpc GetNodeSignaturesAggregate(GetNodeSignaturesAggregateRequest) returns (GetNodeSignaturesAggregateResponse);
	AssetByID(req *dataapipb.AssetByIDRequest) (response *dataapipb.AssetByIDResponse, err error)
}

TradingDataService implements the gRPC service of the same name.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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