orderbook

package
v0.0.0-...-3e0d6b8 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHash

func GetHash(option *Option) (string, error)

GetHash - Compute hash on an option

func NodeComparator

func NodeComparator(a, b interface{}) int

NodeComparator - Order function for RB tree

Types

type Book

type Book struct {
	// The underlying asset for this book
	Underlying shared.Underlying
	// Mapping from identifier to order pointer. These orders are across
	// all derivatives, sides, managers, and queues
	Orders map[uuid.UUID]*list.Element
	// Mapping from user address to open order UUIDs. Given a UUID, the pointer
	// can be found in "orders"
	UserOrderIds map[common.Address]map[uuid.UUID]bool
	// Storage of user addresses that enter in positions in the current round
	UsersWithPositions map[common.Address]bool
	// Pointers to the two sides
	Calls *Derivative
	Puts  *Derivative
	// True if the book is paused
	Paused bool
	// True if the book is setteld
	Settled bool
	// Margin contract data
	MarginContract *MarginContractData
	// Oracle contract data
	OracleContract *OracleContractData
	// Volatility data
	VolManager *controller.VolatilityManager
}

Book - Data structure for an order book Notes:

A "Book" contains two "Derivatives", one for calls and one for puts
A "Derivative" contains two "Sides", one to buy and one to sell
A "Side" is made up many "Managers", organized by unique option
A "Manager" is made up of many "Queues", organized by price
A "Queue" is made up of many "Orders", sorted by time
An "Order" contains an "Option"

func CreateBook

func CreateBook(
	underlying shared.Underlying,
	marginContractAddress common.Address,
	oracleContractAddress common.Address,
) (*Book, error)

CreateBook - Creates new book. Returns a pointer

func (*Book) CancelOrder

func (book *Book) CancelOrder(orderID uuid.UUID) (*Order, error)

CancelOrder - Removes order with id from order book The `orderID` must be the identifier of the order to cancel Orders can be cancelled when paused / @dev Since IM on open orders is purely additive (no netting) / we do not need to perform margin checks

func (*Book) CheckInitialMargin

func (book *Book) CheckInitialMargin(user common.Address) (bool, decimal.Decimal, error)

CheckInitialMargin - Check if the user has enough balance in their margin account on the smart contract for their open orders and positions Returns:

satisifed - true (passes check) or false (fails check)
availableBalance - Amount of extra balance minus unrealized losses and margin reqs

func (*Book) CheckInitialMarginNewOrder

func (book *Book) CheckInitialMarginNewOrder(
	creator common.Address,
	isBuy bool,
	quantity decimal.Decimal,
	option *Option,
) (bool, decimal.Decimal, error)

CheckInitialMarginNewOrder - Check if the user has enough margin: available balance must be higher than the margin requirements for this new order Arguments:

creator - Address of the option creator
isBuy - true if buying, else false if selling
quantity - Amount of the option the user is trying to buy/sell
option - Option under consideration

func (*Book) CheckMaintenanceMargin

func (book *Book) CheckMaintenanceMargin(user common.Address) (
	buffer decimal.Decimal,
	check bool,
	err error,
)

CheckMaintenanceMargin - Get the liquidation buffers for a single user Returns

buffer - Liquidation buffers for each user
check - Whether user passes checks
err - Error

func (*Book) CheckMaintenanceMarginAllAccounts

func (book *Book) CheckMaintenanceMarginAllAccounts() (
	users []common.Address,
	buffers []decimal.Decimal,
	checks []bool,
	err error,
)

CheckMaintenanceMarginAllAccounts - Get the liquidation buffers for all active accounts Returns

users - List of active users
buffers - List of liquidation buffers for each user
checks - List of whether user passes checks
err - Error

func (*Book) CreateLimitOrder

func (book *Book) CreateLimitOrder(
	creator common.Address,
	isBuy bool,
	quantity decimal.Decimal,
	price decimal.Decimal,
	option *Option,
	privateKeyHex string,
	chainID int64,
) (
	order *Order,
	quantityLeft decimal.Decimal,
	err error,
)

CreateLimitOrder - A limit order potentially adds a new order to the book. We must check that no match exists first. If so, fulfill before adding Notes:

https://www.schwab.com/learn/story/3-order-types-market-limit-and-stop-orders

Dev:

Calls `ProcessOrder` under the hood

Arguments:

creator - Address for the creator
isBuy - true (buy) or false (sell)
quantity - Amount to buy or sell
price - Limit price: either the maximum price to be paid or the
        minimum price to be received. If such a price does not exist,
        then no match will be executed
option - A pointer to an Option object
privateKeyHex - String of the master private key
chainID - Ethereum chain ID

Returns:

quantityLeft - Amount of quantity in order that is not automatically fulfilled.
 This is the amount of quantity actually placed in the limit order
err - Not nil if something went wrong internally

func (*Book) CreateMarketOrder

func (book *Book) CreateMarketOrder(
	creator common.Address,
	isBuy bool,
	quantity decimal.Decimal,
	option *Option,
	privateKeyHex string,
	chainID int64,
) (
	quantityLeft decimal.Decimal,
	err error,
)

CreateMarketOrder - A market order immediately fulfills a limit order on the book Notes:

Finds the best price: buy @ lowest or sell @ highest
Keeps matching until order fully fulfilled

Dev:

Calls `ProcessOrder` under the hood

Arguments:

creator - Address for the creator
isBuy - true (buy) or false (sell)
quantity - Amount to buy or sell
option - A pointer to an Option object
privateKeyHex - String of the master private key
chainID - Ethereum chain ID

Returns:

quantityLeft - Amount of quantity in order that is not fulfilled
err - Not nil if something went wrong internally

func (*Book) GetAccount

GetAccount - Get various statistics on account health Arguments:

user (common.Address) - Address for the account to measure health of

Returns:

balance (decimal.Decimal) - Balance in margin account
upnl (decimal.Decimal) - Unrealized P&L
orderIM (decimal.Decimal) - Initial margin for orders
positionIM (decimal.Decimal) - Initial margin for positions
positionMM (deimal.Decimal) - Maintenance margin for positions
availableBalance (decimal.Decimal) - Available balance for new orderes
liquidationBuffer (decimal.Decimal) - Buffer until liquidation

func (*Book) GetActiveAnnualizedTau

func (book *Book) GetActiveAnnualizedTau() float64

GetActiveAnnualizedTau - Get the (annualized) time to expiry

func (*Book) GetActiveExpiry

func (book *Book) GetActiveExpiry() uint64

GetActiveExpiry - Get the current active expiry

func (*Book) GetActiveUsers

func (book *Book) GetActiveUsers() []common.Address

GetActiveUsers - Get all the active users

func (*Book) GetAskManager

func (book *Book) GetAskManager(option *Option) (*Manager, bool)

GetAskManager - Retrieves the manager for asks from underlying derivative

func (*Book) GetBidManager

func (book *Book) GetBidManager(option *Option) (*Manager, bool)

GetBidManager - Retrieves the manager for bids from underlying derivative

func (*Book) GetDepth

func (book *Book) GetDepth(option *Option) (
	asks, bids []*PriceLevel,
	err error,
)

GetDepth - For a specific option, returns all unique prices and volumes

func (*Book) GetGreeks

func (book *Book) GetGreeks(
	isCall bool,
	strikeLevel shared.StrikeLevel,
) (
	decimal.Decimal,
	decimal.Decimal,
	decimal.Decimal,
	decimal.Decimal,
	decimal.Decimal,
	error,
)

GetGreeks - Get the Black Scholes greeks Arguments:

isCall (bool) - Pricing for call or put?
strikeLevel (StrikeLevel) - Chosen strike level

Returns:

delta (decimal.Decimal)
gamma (decimal.Decimal)
theta (decimal.Decimal)
vega (decimal.Decimal)
rho (decimal.Decimal)

Dev:

Spot price is fetched using the "SpotManager"
Expiry is fetched from the active expiry

func (*Book) GetInitialMarginNewOrder

func (book *Book) GetInitialMarginNewOrder(
	isBuy bool,
	quantity decimal.Decimal,
	option *Option,
) (decimal.Decimal, error)

GetInitialMarginNewOrder - Get the initial margin requirements for new order Arguments:

isBuy - true if buying, else false if selling
quantity - Amount of the option the user is trying to buy/sell
option - Option under consideration

func (*Book) GetInitialMarginOrders

func (book *Book) GetInitialMarginOrders(
	instance *margin.Margin,
	user common.Address,
) (decimal.Decimal, error)

GetInitialMarginOrders - Get initial margin of all unmatched orders in orderbook These are NOT netted on purpose: it is expensive to open many orders. Only positions have netted margining

func (*Book) GetInitialMarginPositions

func (book *Book) GetInitialMarginPositions(
	instance *margin.Margin,
	user common.Address,
	decimals uint8,
) (decimal.Decimal, error)

GetInitialMarginPositions - Get initial margin of all matched orders (positions) @dev Requires a smart contract call

func (*Book) GetInterestRate

func (book *Book) GetInterestRate() (decimal.Decimal, error)

GetInterestRate - Get the interest rate for USDC in the book Calls the oracle smart contract through a read request

Returns:

rate (decimal.Decimal) - Median rate over data sources

func (*Book) GetMaintenanceMarginPositions

func (book *Book) GetMaintenanceMarginPositions(
	instance *margin.Margin,
	user common.Address,
	decimals uint8,
) (decimal.Decimal, error)

GetMaintenanceMarginPositions - Get maintenance margin of all matched orders (positions) @dev Requires a smart contract call

func (*Book) GetMarginAccountBalance

func (book *Book) GetMarginAccountBalance(
	instance *margin.Margin,
	user common.Address,
	decimals uint8,
) (decimal.Decimal, error)

GetMarginAccountBalance - Get the amount of USDC in user's margin account @dev Requires a smart contract call Arguments:

instance - Margin account instance
user - Account user

func (*Book) GetMarginContract

func (book *Book) GetMarginContract() (*margin.Margin, *ethclient.Client, error)

GetMarginContract - Return an instance of the margin contract

func (*Book) GetMark

func (book *Book) GetMark(
	isCall bool,
	strikeLevel shared.StrikeLevel,
	spot decimal.Decimal,
	interestRate decimal.Decimal,
) decimal.Decimal

GetMark - Get the Black Scholes mark price Arguments:

isCall (bool) - Pricing for call or put?
strikeLevel (StrikeLevel) - Chosen strike level
spot (decimal.Decimal) - Spot price
interestRate (decimal.Decimal) - Interest rate

Returns:

mark (decimal.Decimal) - Mark price

Dev:

Spot price is fetched using the "SpotManager"
Expiry is fetched from the active expiry

func (*Book) GetMinQuantity

func (book *Book) GetMinQuantity() decimal.Decimal

GetMinQuantity - Get the minimum order quantity

func (*Book) GetOracleContract

func (book *Book) GetOracleContract() (*oracle.Oracle, error)

GetOracleContract - Return an instance of the oracle contract

func (*Book) GetOrderByID

func (book *Book) GetOrderByID(orderID uuid.UUID) (*Order, error)

GetOrderByID - Returns an order by identifier

func (*Book) GetOrders

func (book *Book) GetOrders(user common.Address) (orders []*Order, err error)

GetOrders - Return unmatched order by user Arguments:

user - Address of user to look up

func (*Book) GetPositions

func (book *Book) GetPositions(user common.Address) (positions []margin.DerivativeOrder, err error)

GetPositions - Return positions (matched orders) by user Arguments:

user - Hex string of address to look up

func (*Book) GetPrice

func (book *Book) GetPrice(
	isBuy bool,
	quantity decimal.Decimal,
	option *Option,
) (
	price decimal.Decimal,
	err error,
)

GetPrice - Gets market price for requested quantity of asset Dev:

  • Simulate prices you would get over orders
  • This is critically different than the Black Scholes mark price

func (*Book) GetSigma

func (book *Book) GetSigma(strikeLevel shared.StrikeLevel) float64

GetSigma - Get the implied volatility for underlying in book Arguments:

strikeLevel (StrikeLevel) - Chosen strike level

Returns:

sigma (float64) - Implied volatility from nearest point in surface

Dev:

Spot price is fetched using the "SpotManager"
Expiry is fetched from the active expiry

func (*Book) GetSpot

func (book *Book) GetSpot() (decimal.Decimal, error)

GetSpot - Get the spot price for underlying in the book Calls the oracle smart contract through a read request Returns:

price (decimal.Decimal) - Median price over spot oracles

func (*Book) GetStrikes

func (book *Book) GetStrikes() [11]decimal.Decimal

GetStrikes - Get strike prices Returns:

strikes ([11]decimal.Decimal) - 11 strike prices for current expiry

func (*Book) GetUnderlying

func (book *Book) GetUnderlying() shared.Underlying

GetUnderlying - Returns the underlying asset address

func (*Book) GetUnrealizedPnL

func (book *Book) GetUnrealizedPnL(
	instance *margin.Margin,
	user common.Address,
	decimals uint8,
) (decimal.Decimal, error)

GetUnrealizedPnL - Get realized profit and losses (losses only) @dev Requires a smart contract call

func (*Book) IsEmpty

func (book *Book) IsEmpty() bool

IsEmpty - Check if the book is empty

func (*Book) IsValidOption

func (book *Book) IsValidOption(option *Option) error

IsValidOption - Check the option object has expected underlying

func (*Book) LevelToStrike

func (book *Book) LevelToStrike(level shared.StrikeLevel) decimal.Decimal

LevelToStrike - Convert strike level to decimal price

func (*Book) PauseOrders

func (book *Book) PauseOrders() error

PauseOrders - Pause the order book

func (*Book) PostMatchedOrderOnchain

func (book *Book) PostMatchedOrderOnchain(
	requestor common.Address,
	isBuy bool,
	isTaker bool,
	matchedQuantity decimal.Decimal,
	matchedOrder *Order,
	privateKeyHex string,
	chainID int64,
) error

PostMatchedOrderOnchain - Call smart contract function to post on-chain Arguments:

requestor - Address of the requestor
isBuy - Is the request to buy or to sell
isTaker - Did the request make a market order (true) or limit order (false)
matchedQuantity - Amount of the order that was matched
matchedOrder - The `order` object that was matched with request
order - Matched order to be posted on chain
privateKeyHex - String of the master private key to post on-chain
chainID - Which chain to post to (int64)

func (*Book) ProcessOrder

func (book *Book) ProcessOrder(
	requestor common.Address,
	isBuy bool,
	isTaker bool,
	queue *Queue,
	quantityRequested decimal.Decimal,
	option *Option,
	privateKeyHex string,
	chainID int64,
) (
	partial *Order,
	quantityLeft decimal.Decimal,
	err error,
)

ProcessOrder - Helper function to process an order Notes:

	Called by `CreateMarketOrder` and `CreateLimitOrder`
	Performs a single match between request and book. If the top order does
	not fully satisfy the request, it does NOT automatically match next order.
	One should loop and call this function repeatedly if they wish to fulfill fully.
 A matched order in the book must also match the requested option

Arguments:

requestor - Owner of either a market or limit order that was matched with an existing order
isBuy - Whether the requestor is buying or selling
isTaker - Whether the requestor is making a limit or market order
queue - Queue or orders at a single price
quantityRequested - Amount requested to be fulfilled
option - A pointer to an Option object
privateKeyHex - String of the master private key
chainID - Ethereum chain ID

Returns:

partial - If `quantityLeft > 0`, returns pointer to a new order that replaces the matched order.
 Set to nil if matched order is fulfilled fully
quantityLeft - Amount in the matched order not used up by request
 Set to zero if matched order is fulfilled fully
err - not nil if something went wrong

Dev:

Updates the volatility surface

func (*Book) PruneOrders

func (book *Book) PruneOrders() error

PruneOrders - Loop through and remove expired orders

func (*Book) ResetVolManager

func (book *Book) ResetVolManager(
	initSigma float64,
	minMoneyness float64,
	maxMoneyness float64,
) error

ResetVolManager - Hard reset for volatility manager (and the surface) By default, volatility surfaces are propagated to the next expiry

func (*Book) RolloverOnchain

func (book *Book) RolloverOnchain(
	users []common.Address,
	privateKeyHex string,
	chainID int64,
) error

RolloverOnchain - Call `rollover` function on-chain

func (*Book) SetAskManager

func (book *Book) SetAskManager(option *Option, manager *Manager)

SetAskManager - Sets the manager for a certain ask

func (*Book) SetBidManager

func (book *Book) SetBidManager(option *Option, manager *Manager)

SetBidManager - Sets the manager for a certain bid

func (*Book) SettleOnchain

func (book *Book) SettleOnchain(privateKeyHex string, chainID int64) error

SettleOnchain - Call `settle` function on-chain

func (*Book) UnpauseOrders

func (book *Book) UnpauseOrders() error

UnpauseOrders - Unpause the order book

func (*Book) UpdateMarginContractData

func (book *Book) UpdateMarginContractData() error

UpdateMarginContractData - Call margin contract to update active expiry & strike selection The book has no internal storage of either

func (*Book) UpdateVolatility

func (book *Book) UpdateVolatility(
	spot decimal.Decimal,
	interestRate decimal.Decimal,
	order *Order,
) error

UpdateVolatility - Update the volatility surface

type Derivative

type Derivative struct {
	Asks *Side
	Bids *Side
}

Derivative - Data structure representing calls and puts A single derivative holds asks and bids ("Sides")

func CreateDerivative

func CreateDerivative() *Derivative

CreateDerivative - Creates a new derivative. Returns a pointer A "Derivative" object stores two sides: asks and bids

func (*Derivative) Append

func (derivative *Derivative) Append(order *Order) (*list.Element, error)

Append - Add new order to derivative, and to the correct side underneat

func (*Derivative) GetManager

func (derivative *Derivative) GetManager(isBuy bool, option *Option) (*Manager, bool)

GetManager - Retrieve a manager from the right side

func (*Derivative) Remove

func (derivative *Derivative) Remove(ptr *list.Element) (*Order, error)

Remove - Remove an existing order

func (*Derivative) SetManager

func (derivative *Derivative) SetManager(isBuy bool, option *Option, manager *Manager)

SetManager - Set the manager

type Manager

type Manager struct {

	// Map from price (as a string) to queue
	Prices map[string]*Queue `json:"prices"`
	// Total volume in all queues
	Volume decimal.Decimal `json:"volume"`
	// Total number of orders in all queues
	NumOrders int `json:"numOrders"`
	// Amount of unique prices (size of prices map)
	Depth int `json:"depth"`
	// contains filtered or unexported fields
}

Manager - A manager is responsible for an entire side of the market Controls the queues at all prices for a side

func CreateManager

func CreateManager() *Manager

CreateManager - Creates new manager. Returns a pointer

func (*Manager) Append

func (manager *Manager) Append(order *Order) (*list.Element, error)

Append - Add new order at a certain price level

func (*Manager) LeftNeighborQueue

func (manager *Manager) LeftNeighborQueue(
	price decimal.Decimal,
) *Queue

LeftNeighborQueue - Returns nearest queue with price less than threshold

func (*Manager) Len

func (manager *Manager) Len() int

Len - Returns number of orders owned by manager

func (*Manager) MarshalJSON

func (manager *Manager) MarshalJSON() ([]byte, error)

MarshalJSON - Function to serialize queue into JSON

func (*Manager) MaxPriceQueue

func (manager *Manager) MaxPriceQueue() *Queue

MaxPriceQueue - Returns queue of orders at the max price Returns nil when nothing is found

func (*Manager) MinPriceQueue

func (manager *Manager) MinPriceQueue() *Queue

MinPriceQueue - Returns queue of orders at the min price Returns nil when nothing is found

func (*Manager) Remove

func (manager *Manager) Remove(ptr *list.Element) (*Order, error)

Remove - Remove an existing order at a certain price level

func (*Manager) RightNeighborQueue

func (manager *Manager) RightNeighborQueue(
	price decimal.Decimal,
) *Queue

RightNeighborQueue - Returns nearest queue with price greater than threshold

func (*Manager) UnmarshalJSON

func (manager *Manager) UnmarshalJSON(data []byte) error

UnmarshalJSON - Function to de-serialize manager from JSON

type MarginContractData

type MarginContractData struct {
	// Address of contract
	DeployedAddress common.Address
	// The active expiry for new options
	ActiveExpiry int64
	// The strikes for the current round
	RoundStrikes [11]decimal.Decimal
	// Minimum order size
	MinQuantity decimal.Decimal
	// Collateral decimals
	CollateralDecimals uint8
}

MarginContractData - Stores data from smart contracts

type Option

type Option struct {
	// Enum of underlying
	Underlying shared.Underlying `json:"underlying"`
	// Level chosen by user
	Strike shared.StrikeLevel `json:"strike"`
	// Expiry timestamp in epoch time
	Expiry uint64 `json:"expiry"`
	// Store if this is a put or call option
	IsCall bool `json:"isCall"`
}

Option - Stores option information

func CreateOption

func CreateOption(
	underlying shared.Underlying,
	strike shared.StrikeLevel,
	expiry uint64,
	isCall bool,
) *Option

CreateOption - Create a new `Option` object, returns pointer

func (*Option) Hash

func (option *Option) Hash() (string, error)

Hash - String representation for an option object

func (*Option) IsExpired

func (option *Option) IsExpired() bool

IsExpired - Check if an option is expired

func (*Option) IsValid

func (option *Option) IsValid() bool

IsValid - Check parameters of option are valid

func (*Option) Matches

func (option *Option) Matches(op *Option) bool

Matches - Check if the two options match (and are valid)

func (*Option) Tau

func (option *Option) Tau() uint64

Tau - Return the time to expiry If < 0, returns 0

func (*Option) TauAnnualized

func (option *Option) TauAnnualized() float64

TauAnnualized - Return time to expiry in years If < 0, returns 0

type OracleContractData

type OracleContractData struct {
	// Address of contract
	DeployedAddress common.Address
}

OracleContractData - Stores data from smart contracts

type Order

type Order struct {
	// Address of the creator
	Creator common.Address `json:"creator"`
	// Denotes buy or sell
	IsBuy bool `json:"isBuy"`
	// Unique identifier for the order
	ID uuid.UUID `json:"id"`
	// Time the order was placed in epoch time
	Timestamp uint64 `json:"timestamp"`
	// Amount in order
	Quantity decimal.Decimal `json:"quantity"`
	// Price within the order
	Price decimal.Decimal `json:"price"`
	// Contains option information
	Option *Option `json:"option"`
	// contains filtered or unexported fields
}

Order - Stores order information. Wraps around an Option

func CreateOrder

func CreateOrder(
	id uuid.UUID,
	creator common.Address,
	isBuy bool,
	quantity decimal.Decimal,
	price decimal.Decimal,
	timestamp uint64,
	option *Option,
) *Order

CreateOrder - Create a new order containing an option

func (*Order) IsExpired

func (order *Order) IsExpired() bool

IsExpired - Check if the option in this order is expired

func (*Order) IsValid

func (order *Order) IsValid() bool

IsValid - Check parameters of order are valid

type PriceLevel

type PriceLevel struct {
	Price    decimal.Decimal `json:"price"`
	Quantity decimal.Decimal `json:"quantity"`
}

PriceLevel - Data structure used in reporting depth

type Queue

type Queue struct {
	// List of orders sorted by timestamp
	Orders *list.List `json:"orders"`
	// Total quantity in list
	Volume decimal.Decimal `json:"volume"`
	// Price of orders in the queue
	Price decimal.Decimal `json:"price"`
}

Queue - A queue will store orders at a single price & on one side of the market

func CreateQueue

func CreateQueue(price decimal.Decimal) *Queue

CreateQueue - Create a new `Queue` object, returns pointer

func (*Queue) Append

func (queue *Queue) Append(order *Order) (*list.Element, error)

Append - Append new order to queue. Returns pointer to new element Returns a second argument that is nil if no errors

func (*Queue) Head

func (queue *Queue) Head() *list.Element

Head - Returns pointer to top order in queue (earliest)

func (*Queue) Len

func (queue *Queue) Len() int

Len - Returns number of orders in queue

func (*Queue) MarshalJSON

func (queue *Queue) MarshalJSON() ([]byte, error)

MarshalJSON - Function to serialize queue into JSON

func (*Queue) Remove

func (queue *Queue) Remove(ptr *list.Element) (*Order, error)

Remove - Removes order from queue using pointer Returns a second argument that is nil if no errors

func (*Queue) Tail

func (queue *Queue) Tail() *list.Element

Tail - Returns pointer to bottom order in queue (latest)

func (*Queue) UnmarshalJSON

func (queue *Queue) UnmarshalJSON(data []byte) error

UnmarshalJSON - Function to de-serialize queue from JSON

func (*Queue) Update

func (queue *Queue) Update(
	ptr *list.Element,
	order *Order,
) (*list.Element, error)

Update - Update list pointer with new order Returns a second argument that is nil if no errors

type Side

type Side struct {
	Managers map[string]*Manager `json:"managers"`
}

Side - Data structure to hold managers of different expiries/strikes

func CreateSide

func CreateSide() *Side

CreateSide - Creates new side. Returns a pointer

func (*Side) Append

func (side *Side) Append(order *Order) (*list.Element, error)

Append - Add new order to side, and the correct manager underneath

func (*Side) GetManager

func (side *Side) GetManager(option *Option) (*Manager, bool)

GetManager - Given an option, look up the manager for it

func (*Side) Len

func (side *Side) Len() int

Len - Return number of unique managers

func (*Side) Remove

func (side *Side) Remove(ptr *list.Element) (*Order, error)

Remove - Remove an existing order owned by a single manager

func (*Side) SetManager

func (side *Side) SetManager(option *Option, manager *Manager)

SetManager - Set the manager for a side

Jump to

Keyboard shortcuts

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