slippage

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: 4 Imported by: 0

README

GoCryptoTrader Backtester: Slippage package

Build Status Software License GoDoc Coverage Status Go Report Card

This slippage 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

Slippage package overview

Slippage refers to the difference between the expected price of a trade and the price at which the trade is executed. Slippage is used here to simulate what would occur if trading was live as no perfect conditions exist for placing orders. Slippage is calculated in two ways in the GoCryptoTrader Backtester

If RealOrders is true
  • The orderbook is frequently requested during live cycle candle retrieval
  • When the order is being calculated in the ExecuteOrder eventhandler, it will use the orderbook to simulate placing the order and adjust the order price
If RealOrders is false
  • The min-slippage-percent and max-slippage-percent values for the specific exchange, asset and currency pair will be used as bounds to simulate an orderbook using a random number
    • If it is a buy order, it will raise the price by a random percentage between the two values
    • If the order is a sell order, it will reduce the price by a random percentage between the two values
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 (
	DefaultMaximumSlippagePercent = decimal.NewFromInt(100)
	DefaultMinimumSlippagePercent = decimal.NewFromInt(100)
)

Default slippage rates. It works on a percentage basis 100 means unaffected, 95 would mean 95%

Functions

func CalculateSlippageByOrderbook

func CalculateSlippageByOrderbook(ob *orderbook.Base, side gctorder.Side, allocatedFunds, feeRate decimal.Decimal) (price, amount decimal.Decimal, err error)

CalculateSlippageByOrderbook will analyse a provided orderbook and return the result of attempting to place the order on there

func EstimateSlippagePercentage

func EstimateSlippagePercentage(maximumSlippageRate, minimumSlippageRate decimal.Decimal) decimal.Decimal

EstimateSlippagePercentage takes in an int range of numbers turns it into a percentage

Types

This section is empty.

Jump to

Keyboard shortcuts

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