funding

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 21 Imported by: 0

README

GoCryptoTrader Backtester: Funding package

Build Status Software License GoDoc Coverage Status Go Report Card

This funding package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progress on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Funding package overview

What does the funding package do?

The funding package is responsible for keeping track of all funds across all events during a backtesting run. It is backwards compatible with all existing backtesting strategies

What is the funding manager?

The funding manager is responsible for holding all funding Items and Pairs over the course of a backtesting run. It prevents funds from being overwritten and maintains relationships of currency pairs.

Consider the following example: Exchange Level Funding is disabled and Simultaneous Processing is disabled, so each currency in the .strat config will execute a strategy individually. If the pairs BTC-USDT, BNB-USDT and LTC-BTC are present, then the funding manager will ensure that none of the funds are shared between each of the currencies, even if they all share base or quote values.

Conversely, Exchange level funding and Simultaneous Processing is enabled, so each currency in the .strat file will be processed in one step per time interval. The pairs BTC-USDT, BNB-USDT and BTC-LTC can all share the same base or quote level funds and can make complex decisions on how that funding is used, such as allowing BTC-LTC to make a purchase if an indicator is strongest for that pair.

What is a funding Item?

A funding item holds the initial funding, current funding, reserved funding and transfer fees associated with an exchange, asset and currency. If it is a Pair, then the Item will be linked to the paired Item.

What is a funding Pair?

A funding Pair consists of two funding Items, the Base and Quote. If Exchange Level Funding is disabled, the Base and Quote are linked to each other and the funds cannot be shared with other Pairs or Items. If Exchange Level Funding is enabled, the pair can access the same funds as every other currency that shares the exchange and asset type.

What is a collateral Pair?

A collateral Pair consists of two funding Items, the Contract and Collateral. These are exclusive to FUTURES asset type and help track how much money there is, along with how many contract holdings there are

What does Exchange Level Funding mean?

Exchange level funding allows funds to be shared during a backtesting run. If the strategy contains the two pairs BTC-USDT and BNB-USDT and the strategy sells 3 BTC for $100,000 USDT, then BNB-USDT can use that $100,000 USDT to make a purchase of $20,000 BNB. It is restricted to an exchange and asset type, so BTC used in spot, cannot be used in a futures contract (futures backtesting is not currently supported). However, the funding manager can transfer funds between exchange and asset types.

Having funding at the exchange level also allows for a finer degree of control while also being more realistic for strategic execution. A user can create a strategy with many pairs, such as BTC-USDT, LTC-BTC, DOGE-XRP and XRP-USDT, but only creating funding for USDT and still see the purchase of LTC or DOGE. Another strategy could start with funding in the Base currency. So an RSI strategy for BTC-USDT that has 3 BTC as funding will then start by selling rather than buying.

Why is Simultaneous Processing a prerequisite of Exchange Level Funding?

Simultaneous Processing allows a strategy to process multiple data signals for a single time period to be processed in one step. The reason Simultaneous Processing is required for Exchange Level Funding is that if it is disabled, all events are handled in a sequence. If any funding was to be shared in such a scenario, the first currency to be processed will always get the choice share of funding. Simultaneous Processing ensures the decision to spend funds for BTC-USDT over BNB-USDT is a measured decision, and not done by the order of currencies in a strategy config.

Can I transfer funds from one place to another?

Yes! Though it does use some things to consider.

  • It is handled at the strategy execution level, so when creating a strategy, you design the conditions in which funding may be transferred from one place to another.
    • For example, if an indicator is very strong on one exchange, but not another, you may wish to transfer funds to the strongest exchange to act upon
  • It comes with the assumption that a transfer is actually possible in the candle timeframe your strategy runs on.
    • For example, a 1 minute candle strategy likely would not be able to process a transfer of funds and have another exchange use it in that timeframe. So any positive results from such a strategy may not be reflected in real-world scenarios
  • You can only transfer to the same currency eg BTC from Binance to Kraken, no conversions
  • You set the transfer fee in your config
Do I need to add funding settings to my config if Exchange Level Funding is disabled?

No. The already existing CurrencySettings will populate the funding manager with initial funds if Exchange Level Funding is disabled.

Strategy Settings
Key Description Example
name The strategy to use rsi
use-simultaneous-signal-processing This denotes whether multiple currencies are processed simultaneously with the strategy function OnSimultaneousSignals. Eg If you have multiple CurrencySettings and only wish to purchase BTC-USDT when XRP-DOGE is 1337, this setting is useful as you can analyse both signal events to output a purchase call for BTC true
disable-usd-tracking If false, will track all currencies used in your strategy against USD equivalent candles. For example, if you are running a strategy for BTC/XRP, then the GoCryptoTrader Backtester will also retrieve candles data for BTC/USD and XRP/USD to then track strategy performance against a single currency. This also tracks against USDT and other USD tracked stablecoins, so one exchange supporting USDT and another BUSD will still allow unified strategy performance analysis. If disabled, will not track against USD, this can be especially helpful when running strategies under live, database and CSV based data false
custom-settings This is a map where you can enter custom settings for a strategy. The RSI strategy allows for customisation of the upper, lower and length variables to allow you to change them from 70, 30 and 14 respectively to 69, 36, 12 "custom-settings": { "rsi-high": 70, "rsi-low": 30, "rsi-period": 14 }
Funding Config Settings
Key Description Example
use-exchange-level-funding Allows shared funding at an exchange asset level. You can set funding for USDT and all pairs that feature USDT will have access to those funds when making orders. See this for more information false
exchange-level-funding An array of exchange level funding settings. See below, or this for more information []
Funding Item Config Settings
Key Description Example
exchange-name The exchange to set funds. See here for a list of supported exchanges Binance
asset The asset type to set funds. Typically, this will be spot, however, see this package for the various asset types GoCryptoTrader supports spot
currency The currency to set funds BTC
initial-funds The initial funding for the currency 1337
transfer-fee If your strategy utilises transferring of funds via the Funding Manager, this is deducted upon doing so 0.005
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotPair is returned when a user requests funding pair details when it is a collateral pair
	ErrNotPair      = errors.New("not a funding pair")
	ErrIsCollateral = errors.New("is collateral pair")
	ErrNilPair      = errors.New("nil pair")
)

collateral related errors

View Source
var (
	// ErrFundsNotFound used when funds are requested but the funding is not found in the manager
	ErrFundsNotFound = errors.New("funding not found")
	// ErrAlreadyExists used when a matching item or pair is already in the funding manager
	ErrAlreadyExists = errors.New("funding already exists")
	// ErrUSDTrackingDisabled used when attempting to track USD values when disabled
	ErrUSDTrackingDisabled = errors.New("USD tracking disabled")
)
View Source
var (
	// ErrNotCollateral is returned when a user requests collateral pair details when it is a funding pair
	ErrNotCollateral = errors.New("not a collateral pair")
)

Functions

func CreateFuturesCurrencyCode

func CreateFuturesCurrencyCode(b, q currency.Code) currency.Code

CreateFuturesCurrencyCode converts a currency pair into a code The main reasoning is that as a contract, it exists as an item even if it is formatted as BTC-1231. To treat it as a pair in the funding system would cause an increase in funds for BTC, when it is an increase in contracts This function is basic, but is important be explicit in why this is occurring

Types

type BasicItem

type BasicItem struct {
	Exchange     string
	Asset        asset.Item
	Currency     currency.Code
	InitialFunds decimal.Decimal
	Available    decimal.Decimal
	Reserved     decimal.Decimal
	USDPrice     decimal.Decimal
}

BasicItem is a representation of Item

type CollateralPair

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

CollateralPair consists of a currency pair for a futures contract and associates it with an addition collateral pair to take funding from

func CreateCollateral

func CreateCollateral(contract, collateral *Item) (*CollateralPair, error)

CreateCollateral adds two funding items and associates them with one another the association allows for the same currency to be used multiple times when usingExchangeLevelFunding is false. eg BTC-USDT and LTC-USDT do not share the same USDT level funding

func (*CollateralPair) AvailableFunds

func (c *CollateralPair) AvailableFunds() decimal.Decimal

AvailableFunds returns available funds of collateral

func (*CollateralPair) CanPlaceOrder

func (c *CollateralPair) CanPlaceOrder(_ gctorder.Side) bool

CanPlaceOrder checks if there is any collateral to spare

func (*CollateralPair) CollateralCurrency

func (c *CollateralPair) CollateralCurrency() currency.Code

CollateralCurrency returns collateral currency

func (*CollateralPair) CollateralReleaser

func (c *CollateralPair) CollateralReleaser() (ICollateralReleaser, error)

CollateralReleaser returns an ICollateralReleaser to interact with collateral

func (*CollateralPair) ContractCurrency

func (c *CollateralPair) ContractCurrency() currency.Code

ContractCurrency returns the contract currency

func (*CollateralPair) CurrentHoldings

func (c *CollateralPair) CurrentHoldings() decimal.Decimal

CurrentHoldings returns available contract holdings

func (*CollateralPair) FundReader

func (c *CollateralPair) FundReader() IFundReader

FundReader returns a fund reader interface of collateral

func (*CollateralPair) FundReleaser

func (c *CollateralPair) FundReleaser() IFundReleaser

FundReleaser returns an IFundReleaser to interact with collateral

func (*CollateralPair) FundReserver

func (c *CollateralPair) FundReserver() IFundReserver

FundReserver returns a fund reserver interface of CollateralPair

func (*CollateralPair) GetCollateralReader

func (c *CollateralPair) GetCollateralReader() (ICollateralReader, error)

GetCollateralReader returns a collateral reader interface of CollateralPair

func (*CollateralPair) GetPairReader

func (c *CollateralPair) GetPairReader() (IPairReader, error)

GetPairReader returns an error because collateral isn't a pair

func (*CollateralPair) InitialFunds

func (c *CollateralPair) InitialFunds() decimal.Decimal

InitialFunds returns initial funds of collateral

func (*CollateralPair) Liquidate

func (c *CollateralPair) Liquidate()

Liquidate kills your funds and future all value storage are reduced to zero when triggered

func (*CollateralPair) PairReleaser

func (c *CollateralPair) PairReleaser() (IPairReleaser, error)

PairReleaser returns an error as there is no such thing for collateral

func (*CollateralPair) ReleaseContracts

func (c *CollateralPair) ReleaseContracts(amount decimal.Decimal) error

ReleaseContracts lowers the amount of available contracts

func (*CollateralPair) Reserve

func (c *CollateralPair) Reserve(amount decimal.Decimal, side gctorder.Side) error

Reserve reserves or releases collateral based on order side

func (*CollateralPair) TakeProfit

func (c *CollateralPair) TakeProfit(contracts, positionReturns decimal.Decimal) error

TakeProfit handles both the reduction of contracts and the change in collateral

func (*CollateralPair) UpdateContracts

func (c *CollateralPair) UpdateContracts(s gctorder.Side, amount decimal.Decimal) error

UpdateContracts adds or subtracts contracts based on order direction

type CurrencyContribution

type CurrencyContribution struct {
	Currency        currency.Code
	USDContribution decimal.Decimal
}

CurrencyContribution helps breakdown how a USD value determines its number

type FundManager

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

FundManager is the benevolent holder of all funding levels across all currencies used in the backtester

func SetupFundingManager

func SetupFundingManager(exchManager *engine.ExchangeManager, usingExchangeLevelFunding, disableUSDTracking, verbose bool) (*FundManager, error)

SetupFundingManager creates the funding holder. It carries knowledge about levels of funding across all execution handlers and enables fund transfers

func (*FundManager) AddItem

func (f *FundManager) AddItem(item *Item) error

AddItem appends a new funding item. Will reject if exists by exchange asset currency

func (*FundManager) AddPair

func (f *FundManager) AddPair(p *SpotPair) error

AddPair adds a pair to the fund manager if it does not exist

func (*FundManager) AddUSDTrackingData

func (f *FundManager) AddUSDTrackingData(k *kline.DataFromKline) error

AddUSDTrackingData adds USD tracking data to a funding item only in the event that it is not USD and there is data

func (*FundManager) CreateSnapshot

func (f *FundManager) CreateSnapshot(t time.Time) error

CreateSnapshot creates a Snapshot for an event's point in time as funding.snapshots is a map, it allows for the last event in the chronological list to establish the canon at X time

func (*FundManager) Exists

func (f *FundManager) Exists(item *Item) bool

Exists verifies whether there is a funding item that exists with the same exchange, asset and currency

func (*FundManager) GenerateReport

func (f *FundManager) GenerateReport() (*Report, error)

GenerateReport builds report data for result HTML report

func (*FundManager) GetAllFunding

func (f *FundManager) GetAllFunding() ([]BasicItem, error)

GetAllFunding returns basic representations of all current holdings from the latest point

func (*FundManager) GetFundingForEvent

func (f *FundManager) GetFundingForEvent(ev common.Event) (IFundingPair, error)

GetFundingForEvent This will construct a funding based on a backtesting event

func (*FundManager) HasExchangeBeenLiquidated

func (f *FundManager) HasExchangeBeenLiquidated(ev common.Event) bool

HasExchangeBeenLiquidated checks for any items with a matching exchange and returns whether it has been liquidated

func (*FundManager) HasFutures

func (f *FundManager) HasFutures() bool

HasFutures returns whether the funding manager contains any futures assets

func (*FundManager) IsUsingExchangeLevelFunding

func (f *FundManager) IsUsingExchangeLevelFunding() bool

IsUsingExchangeLevelFunding returns if using usingExchangeLevelFunding

func (*FundManager) LinkCollateralCurrency

func (f *FundManager) LinkCollateralCurrency(item *Item, code currency.Code) error

LinkCollateralCurrency links an item to an existing currency code for collateral purposes

func (*FundManager) Liquidate

func (f *FundManager) Liquidate(ev common.Event) error

Liquidate will remove all funding for all items belonging to an exchange

func (*FundManager) RealisePNL

func (f *FundManager) RealisePNL(receivingExchange string, receivingAsset asset.Item, receivingCurrency currency.Code, realisedPNL decimal.Decimal) error

RealisePNL adds the realised PNL to a receiving exchange asset pair

func (*FundManager) Reset

func (f *FundManager) Reset() error

Reset clears all settings

func (*FundManager) SetFunding

func (f *FundManager) SetFunding(exchName string, item asset.Item, balance *account.Balance, initialFundsSet bool) error

SetFunding overwrites a funding setting. This is for live trading where external wallet amounts need to be synced As external sources may have additional currencies and balances versus the strategy currencies, they must be appended to help calculate collateral

func (*FundManager) Transfer

func (f *FundManager) Transfer(amount decimal.Decimal, sender, receiver *Item, inclusiveFee bool) error

Transfer allows transferring funds from one pretend exchange to another

func (*FundManager) USDTrackingDisabled

func (f *FundManager) USDTrackingDisabled() bool

USDTrackingDisabled clears all settings

func (*FundManager) UpdateAllCollateral

func (f *FundManager) UpdateAllCollateral(isLive, initialFundsSet bool) error

UpdateAllCollateral will update the collateral values of all stored exchanges

func (*FundManager) UpdateCollateralForEvent

func (f *FundManager) UpdateCollateralForEvent(ev common.Event, isLive bool) error

UpdateCollateralForEvent will recalculate collateral for an exchange based on the event passed in

func (*FundManager) UpdateFundingFromLiveData

func (f *FundManager) UpdateFundingFromLiveData(initialFundsSet bool) error

UpdateFundingFromLiveData forcefully updates funding from a live source

type ICollateralReader

type ICollateralReader interface {
	ContractCurrency() currency.Code
	CollateralCurrency() currency.Code
	InitialFunds() decimal.Decimal
	AvailableFunds() decimal.Decimal
	CurrentHoldings() decimal.Decimal
}

ICollateralReader is used to read data from collateral pairs

type ICollateralReleaser

type ICollateralReleaser interface {
	ICollateralReader
	UpdateContracts(order.Side, decimal.Decimal) error
	TakeProfit(contracts, positionReturns decimal.Decimal) error
	ReleaseContracts(decimal.Decimal) error
	Liquidate()
}

ICollateralReleaser limits funding usage for exchange event handling

type IFundReader

type IFundReader interface {
	GetPairReader() (IPairReader, error)
	GetCollateralReader() (ICollateralReader, error)
}

IFundReader can read either collateral or pair details

type IFundReleaser

type IFundReleaser interface {
	IFundReader
	PairReleaser() (IPairReleaser, error)
	CollateralReleaser() (ICollateralReleaser, error)
}

IFundReleaser can read or release pair or collateral funds

type IFundReserver

type IFundReserver interface {
	IFundReader
	CanPlaceOrder(order.Side) bool
	Reserve(decimal.Decimal, order.Side) error
}

IFundReserver limits funding usage for portfolio event handling

type IFundingManager

type IFundingManager interface {
	Reset() error
	IsUsingExchangeLevelFunding() bool
	GetFundingForEvent(common.Event) (IFundingPair, error)
	Transfer(decimal.Decimal, *Item, *Item, bool) error
	GenerateReport() (*Report, error)
	AddUSDTrackingData(*kline.DataFromKline) error
	CreateSnapshot(time.Time) error
	USDTrackingDisabled() bool
	Liquidate(common.Event) error
	GetAllFunding() ([]BasicItem, error)
	UpdateCollateralForEvent(common.Event, bool) error
	UpdateAllCollateral(isLive, hasUpdateFunding bool) error
	UpdateFundingFromLiveData(hasUpdatedFunding bool) error
	HasFutures() bool
	HasExchangeBeenLiquidated(handler common.Event) bool
	RealisePNL(receivingExchange string, receivingAsset asset.Item, receivingCurrency currency.Code, realisedPNL decimal.Decimal) error
	SetFunding(string, asset.Item, *account.Balance, bool) error
}

IFundingManager limits funding usage for portfolio event handling

type IFundingPair

type IFundingPair interface {
	FundReader() IFundReader
	FundReserver() IFundReserver
	FundReleaser() IFundReleaser
}

IFundingPair allows conversion into various funding interfaces

type IFundingReader

type IFundingReader interface {
	GetFundingForEvent(common.Event) (IFundingPair, error)
	GetAllFunding() []BasicItem
}

IFundingReader is a simple interface of IFundingManager for readonly access at portfolio manager

type IFundingTransferer

type IFundingTransferer interface {
	IsUsingExchangeLevelFunding() bool
	Transfer(decimal.Decimal, *Item, *Item, bool) error
	GetFundingForEvent(common.Event) (IFundingPair, error)
	HasExchangeBeenLiquidated(handler common.Event) bool
}

IFundingTransferer allows for funding amounts to be transferred implementation can be swapped for live transferring

type IPairReader

type IPairReader interface {
	BaseInitialFunds() decimal.Decimal
	QuoteInitialFunds() decimal.Decimal
	BaseAvailable() decimal.Decimal
	QuoteAvailable() decimal.Decimal
}

IPairReader is used to limit pair funding functions to readonly

type IPairReleaser

type IPairReleaser interface {
	IPairReader
	IncreaseAvailable(decimal.Decimal, order.Side) error
	Release(decimal.Decimal, decimal.Decimal, order.Side) error
	Liquidate()
}

IPairReleaser limits funding usage for exchange event handling

type Item

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

Item holds funding data per currency item

func CreateItem

func CreateItem(exch string, a asset.Item, ci currency.Code, initialFunds, transferFee decimal.Decimal) (*Item, error)

CreateItem creates a new funding item

func (*Item) AddContracts

func (i *Item) AddContracts(amount decimal.Decimal) error

AddContracts allocates an amount of funds to be used at a later time it prevents multiple events from claiming the same resource

func (*Item) BasicEqual

func (i *Item) BasicEqual(exch string, a asset.Item, currency, pairedCurrency currency.Code) bool

BasicEqual checks for equality via passed in values

func (*Item) CanPlaceOrder

func (i *Item) CanPlaceOrder() bool

CanPlaceOrder checks if the item has any funds available

func (*Item) Equal

func (i *Item) Equal(item *Item) bool

Equal checks for equality via an Item to compare to

func (*Item) IncreaseAvailable

func (i *Item) IncreaseAvailable(amount decimal.Decimal) error

IncreaseAvailable adds funding to the available amount

func (*Item) MatchesCurrency

func (i *Item) MatchesCurrency(c currency.Code) bool

MatchesCurrency checks that an item's currency is equal

func (*Item) MatchesExchange

func (i *Item) MatchesExchange(item *Item) bool

MatchesExchange checks that an item's exchange is equal

func (*Item) MatchesItemCurrency

func (i *Item) MatchesItemCurrency(item *Item) bool

MatchesItemCurrency checks that an item's currency is equal

func (*Item) ReduceContracts

func (i *Item) ReduceContracts(amount decimal.Decimal) error

ReduceContracts allocates an amount of funds to be used at a later time it prevents multiple events from claiming the same resource

func (*Item) Release

func (i *Item) Release(amount, diff decimal.Decimal) error

Release reduces the amount of funding reserved and adds any difference back to the available amount

func (*Item) Reserve

func (i *Item) Reserve(amount decimal.Decimal) error

Reserve allocates an amount of funds to be used at a later time it prevents multiple events from claiming the same resource

func (*Item) TakeProfit

func (i *Item) TakeProfit(amount decimal.Decimal) error

TakeProfit increases/decreases available funds for a futures collateral item

type ItemSnapshot

type ItemSnapshot struct {
	Time          time.Time
	Available     decimal.Decimal
	USDClosePrice decimal.Decimal
	USDValue      decimal.Decimal
	Breakdown     []CurrencyContribution
}

ItemSnapshot holds USD values to allow for tracking across backtesting results

type Report

type Report struct {
	DisableUSDTracking        bool
	UsingExchangeLevelFunding bool
	Items                     []ReportItem
	USDTotalsOverTime         []ItemSnapshot
	InitialFunds              decimal.Decimal
	FinalFunds                decimal.Decimal
}

Report holds all funding data for result reporting

type ReportItem

type ReportItem struct {
	Exchange             string
	Asset                asset.Item
	Currency             currency.Code
	TransferFee          decimal.Decimal
	InitialFunds         decimal.Decimal
	FinalFunds           decimal.Decimal
	USDInitialFunds      decimal.Decimal
	USDInitialCostForOne decimal.Decimal
	USDFinalFunds        decimal.Decimal
	USDFinalCostForOne   decimal.Decimal
	Snapshots            []ItemSnapshot
	USDPairCandle        *kline.DataFromKline
	Difference           decimal.Decimal
	ShowInfinite         bool
	IsCollateral         bool
	AppendedViaAPI       bool
	PairedWith           currency.Code
}

ReportItem holds reporting fields

type SpotPair

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

SpotPair holds two currencies that are associated with each other

func CreatePair

func CreatePair(base, quote *Item) (*SpotPair, error)

CreatePair adds two funding items and associates them with one another the association allows for the same currency to be used multiple times when usingExchangeLevelFunding is false. eg BTC-USDT and LTC-USDT do not share the same USDT level funding

func (*SpotPair) BaseAvailable

func (p *SpotPair) BaseAvailable() decimal.Decimal

BaseAvailable returns the available funds from the base in a currency pair

func (*SpotPair) BaseInitialFunds

func (p *SpotPair) BaseInitialFunds() decimal.Decimal

BaseInitialFunds returns the initial funds from the base in a currency pair

func (*SpotPair) CanPlaceOrder

func (p *SpotPair) CanPlaceOrder(side order.Side) bool

CanPlaceOrder does a > 0 check to see if there are any funds to place an order with changes which currency to affect based on the order side

func (*SpotPair) CollateralReleaser

func (p *SpotPair) CollateralReleaser() (ICollateralReleaser, error)

CollateralReleaser returns an error because a pair is not collateral

func (*SpotPair) FundReader

func (p *SpotPair) FundReader() IFundReader

FundReader returns a fund reader interface of the pair

func (*SpotPair) FundReleaser

func (p *SpotPair) FundReleaser() IFundReleaser

FundReleaser returns a pair releaser interface of the pair

func (*SpotPair) FundReserver

func (p *SpotPair) FundReserver() IFundReserver

FundReserver returns a fund reserver interface of the pair

func (*SpotPair) GetCollateralReader

func (p *SpotPair) GetCollateralReader() (ICollateralReader, error)

GetCollateralReader returns an error because its not collateral

func (*SpotPair) GetPairReader

func (p *SpotPair) GetPairReader() (IPairReader, error)

GetPairReader returns an interface of a SpotPair

func (*SpotPair) IncreaseAvailable

func (p *SpotPair) IncreaseAvailable(amount decimal.Decimal, side order.Side) error

IncreaseAvailable adds funding to the available amount changes which currency to affect based on the order side

func (*SpotPair) Liquidate

func (p *SpotPair) Liquidate()

Liquidate basic liquidation response to remove all asset value

func (*SpotPair) PairReleaser

func (p *SpotPair) PairReleaser() (IPairReleaser, error)

PairReleaser returns a pair releaser interface of the pair

func (*SpotPair) QuoteAvailable

func (p *SpotPair) QuoteAvailable() decimal.Decimal

QuoteAvailable returns the available funds from the quote in a currency pair

func (*SpotPair) QuoteInitialFunds

func (p *SpotPair) QuoteInitialFunds() decimal.Decimal

QuoteInitialFunds returns the initial funds from the quote in a currency pair

func (*SpotPair) Release

func (p *SpotPair) Release(amount, diff decimal.Decimal, side order.Side) error

Release reduces the amount of funding reserved and adds any difference back to the available amount changes which currency to affect based on the order side

func (*SpotPair) Reserve

func (p *SpotPair) Reserve(amount decimal.Decimal, side order.Side) error

Reserve allocates an amount of funds to be used at a later time it prevents multiple events from claiming the same resource changes which currency to affect based on the order side

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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