Documentation ¶
Index ¶
- Variables
- type APIData
- type BacktesterConfig
- type CSVData
- type Config
- type Credentials
- type CurrencySettings
- type DataSettings
- type DatabaseData
- type ExchangeLevelFunding
- type FundingSettings
- type FuturesDetails
- type GRPC
- type Leverage
- type LiveData
- type MinMax
- type PortfolioSettings
- type Report
- type SpotDetails
- type StatisticSettings
- type StrategySettings
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultBTDir is the default backtester config directory DefaultBTDir = filepath.Join(gctcommon.GetDefaultDataDir(runtime.GOOS), "backtester") // DefaultBTConfigDir is the default backtester config file DefaultBTConfigDir = filepath.Join(DefaultBTDir, "config.json") )
Functions ¶
This section is empty.
Types ¶
type APIData ¶
type APIData struct { StartDate time.Time `json:"start-date"` EndDate time.Time `json:"end-date"` InclusiveEndDate bool `json:"inclusive-end-date"` }
APIData defines all fields to configure API based data
type BacktesterConfig ¶
type BacktesterConfig struct { PrintLogo bool `json:"print-logo"` LogSubheaders bool `json:"log-subheaders"` Verbose bool `json:"verbose"` StopAllTasksOnClose bool `json:"stop-all-tasks-on-close"` PluginPath string `json:"plugin-path"` Report Report `json:"report"` GRPC GRPC `json:"grpc"` UseCMDColours bool `json:"use-cmd-colours"` Colours common.Colours `json:"cmd-colours"` }
BacktesterConfig contains the configuration for the backtester
func GenerateDefaultConfig ¶
func GenerateDefaultConfig() (*BacktesterConfig, error)
GenerateDefaultConfig will return the default backtester config
func ReadBacktesterConfigFromPath ¶
func ReadBacktesterConfigFromPath(path string) (*BacktesterConfig, error)
ReadBacktesterConfigFromPath will take a config from a path
type CSVData ¶
type CSVData struct {
FullPath string `json:"full-path"`
}
CSVData defines all fields to configure CSV based data
type Config ¶
type Config struct { Nickname string `json:"nickname"` Goal string `json:"goal"` StrategySettings StrategySettings `json:"strategy-settings"` FundingSettings FundingSettings `json:"funding-settings"` CurrencySettings []CurrencySettings `json:"currency-settings"` DataSettings DataSettings `json:"data-settings"` PortfolioSettings PortfolioSettings `json:"portfolio-settings"` StatisticSettings StatisticSettings `json:"statistic-settings"` }
Config defines what is in an individual strategy config
func ReadStrategyConfigFromFile ¶
ReadStrategyConfigFromFile will take a config from a path
func (*Config) PrintSetting ¶
func (c *Config) PrintSetting()
PrintSetting prints relevant settings to the console for easy reading
type Credentials ¶
type Credentials struct { Exchange string `json:"exchange"` Keys account.Credentials `json:"credentials"` }
Credentials holds each exchanges credentials
type CurrencySettings ¶
type CurrencySettings struct { ExchangeName string `json:"exchange-name"` Asset asset.Item `json:"asset"` Base currency.Code `json:"base"` Quote currency.Code `json:"quote"` // USDTrackingPair is used for price tracking data only USDTrackingPair bool `json:"-"` SpotDetails *SpotDetails `json:"spot-details,omitempty"` FuturesDetails *FuturesDetails `json:"futures-details,omitempty"` BuySide MinMax `json:"buy-side"` SellSide MinMax `json:"sell-side"` MinimumSlippagePercent decimal.Decimal `json:"min-slippage-percent"` MaximumSlippagePercent decimal.Decimal `json:"max-slippage-percent"` UsingExchangeMakerFee bool `json:"-"` MakerFee *decimal.Decimal `json:"maker-fee-override,omitempty"` UsingExchangeTakerFee bool `json:"-"` TakerFee *decimal.Decimal `json:"taker-fee-override,omitempty"` MaximumHoldingsRatio decimal.Decimal `json:"maximum-holdings-ratio"` SkipCandleVolumeFitting bool `json:"skip-candle-volume-fitting"` CanUseExchangeLimits bool `json:"use-exchange-order-limits"` ShowExchangeOrderLimitWarning bool `json:"-"` UseExchangePNLCalculation bool `json:"use-exchange-pnl-calculation"` }
CurrencySettings stores pair based variables It contains rules about the specific currency pair you wish to trade with Backtester will load the data of the currencies specified here
type DataSettings ¶
type DataSettings struct { Interval kline.Interval `json:"interval"` DataType string `json:"data-type"` VerboseExchangeRequests bool `json:"verbose-exchange-requests"` APIData *APIData `json:"api-data,omitempty"` DatabaseData *DatabaseData `json:"database-data,omitempty"` LiveData *LiveData `json:"live-data,omitempty"` CSVData *CSVData `json:"csv-data,omitempty"` }
DataSettings is a container for each type of data retrieval setting. Only ONE can be populated per config
type DatabaseData ¶
type DatabaseData struct { StartDate time.Time `json:"start-date"` EndDate time.Time `json:"end-date"` Config database.Config `json:"config"` Path string `json:"path"` InclusiveEndDate bool `json:"inclusive-end-date"` }
DatabaseData defines all fields to configure database based data
type ExchangeLevelFunding ¶
type ExchangeLevelFunding struct { ExchangeName string `json:"exchange-name"` Asset asset.Item `json:"asset"` Currency currency.Code `json:"currency"` InitialFunds decimal.Decimal `json:"initial-funds"` TransferFee decimal.Decimal `json:"transfer-fee"` }
ExchangeLevelFunding allows the portfolio manager to access a shared pool. For example, The base currencies BTC and LTC can both access the same USDT funding to make purchasing decisions Similarly, when a BTC is sold, LTC can now utilise the increased funding Importantly, exchange level funding is all-inclusive, you cannot have it for only some uses It also is required to use SimultaneousSignalProcessing, otherwise the first currency processed will have dibs
type FundingSettings ¶
type FundingSettings struct { UseExchangeLevelFunding bool `json:"use-exchange-level-funding"` ExchangeLevelFunding []ExchangeLevelFunding `json:"exchange-level-funding,omitempty"` }
FundingSettings contains funding details for individual currencies
type FuturesDetails ¶
type FuturesDetails struct {
Leverage Leverage `json:"leverage"`
}
FuturesDetails contains data relevant to futures currency pairs
type GRPC ¶
type GRPC struct { Username string `json:"username"` Password string `json:"password"` gctconfig.GRPCConfig TLSDir string `json:"tls-dir"` }
GRPC holds the GRPC configuration
type Leverage ¶
type Leverage struct { CanUseLeverage bool `json:"can-use-leverage"` MaximumOrdersWithLeverageRatio decimal.Decimal `json:"maximum-orders-with-leverage-ratio"` // MaximumOrderLeverageRate allows for orders to be placed with higher leverage rate. eg have $100 in collateral, // but place an order for $200 using 2x leverage MaximumOrderLeverageRate decimal.Decimal `json:"maximum-leverage-rate"` // MaximumCollateralLeverageRate allows for orders to be placed at `1x leverage, but utilise collateral as leverage to place more. // eg if this is 2x, and collateral is $100 I can place two long/shorts of $100 MaximumCollateralLeverageRate decimal.Decimal `json:"maximum-collateral-leverage-rate"` }
Leverage rules are used to allow or limit the use of leverage in orders when supported
type LiveData ¶
type LiveData struct { NewEventTimeout time.Duration `json:"new-event-timeout"` DataCheckTimer time.Duration `json:"data-check-timer"` RealOrders bool `json:"real-orders"` ClosePositionsOnStop bool `json:"close-positions-on-stop"` DataRequestRetryTolerance int64 `json:"data-request-retry-tolerance"` DataRequestRetryWaitTime time.Duration `json:"data-request-retry-wait-time"` ExchangeCredentials []Credentials `json:"exchange-credentials"` }
LiveData defines all fields to configure live data
type MinMax ¶
type MinMax struct { MinimumSize decimal.Decimal `json:"minimum-size"` // will not place an order if under this amount MaximumSize decimal.Decimal `json:"maximum-size"` // can only place an order up to this amount MaximumTotal decimal.Decimal `json:"maximum-total"` }
MinMax are the rules which limit the placement of orders.
type PortfolioSettings ¶
type PortfolioSettings struct { Leverage Leverage `json:"leverage"` BuySide MinMax `json:"buy-side"` SellSide MinMax `json:"sell-side"` }
PortfolioSettings act as a global protector for strategies these settings will override ExchangeSettings that go against it and assess the bigger picture
type Report ¶
type Report struct { GenerateReport bool `json:"output-report"` TemplatePath string `json:"template-path"` OutputPath string `json:"output-path"` DarkMode bool `json:"dark-mode"` }
Report contains the report settings
type SpotDetails ¶
type SpotDetails struct { InitialBaseFunds *decimal.Decimal `json:"initial-base-funds,omitempty"` InitialQuoteFunds *decimal.Decimal `json:"initial-quote-funds,omitempty"` }
SpotDetails contains funding information that cannot be shared with another pair during the backtesting run. Use exchange level funding to share funds
type StatisticSettings ¶
StatisticSettings adjusts ratios where proper data is currently lacking
type StrategySettings ¶
type StrategySettings struct { Name string `json:"name"` SimultaneousSignalProcessing bool `json:"use-simultaneous-signal-processing"` // If true, won't track USD values against currency pair // bool language is opposite to encourage use by default DisableUSDTracking bool `json:"disable-usd-tracking"` CustomSettings map[string]interface{} `json:"custom-settings,omitempty"` }
StrategySettings contains what strategy to load, along with custom settings map (variables defined per strategy) along with defining whether the strategy will assess all currencies at once, or individually