environment

package
v0.0.2-alpha.0...-0fc358b Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2019 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package environment contains all the trade environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BotConfig

type BotConfig struct {
	SimulationModeOn bool             `yaml:"simulation_mode"`  // if true, do not create real orders and do not get real balance
	ExchangeConfigs  []ExchangeConfig `yaml:"exchange_configs"` // Represents the current exchange configuration.
	Strategies       []StrategyConfig `yaml:"strategies"`       // Represents the current strategies adopted by the bot.
}

BotConfig contains all config data of the bot, which can be also loaded from config file.

type CandleStick

type CandleStick struct {
	High   decimal.Decimal //Represents the highest value obtained during candle period.
	Open   decimal.Decimal //Represents the first value of the candle period.
	Close  decimal.Decimal //Represents the last value of the candle period.
	Low    decimal.Decimal //Represents the lowest value obtained during candle period.
	Volume decimal.Decimal //Represents the volume of trades during the candle period.
}

CandleStick represents a single candlestick in a chart.

func (CandleStick) String

func (cs CandleStick) String() string

String returns the string representation of the object.

type CandleStickChart

type CandleStickChart struct {
	CandlePeriod time.Duration //Represents the candle period (expressed in time.Duration).
	CandleSticks []CandleStick //Represents the last Candle Sticks used for evaluation of current state.
	OrderBook    []Order       //Represents the Book of current trades.
}

CandleStickChart represents a chart of a market expresed using Candle Sticks.

type ExchangeBindingsConfig

type ExchangeBindingsConfig struct {
	Name       string `yaml:"exchange"`    // Represents the name of the exchange.
	MarketName string `yaml:"market_name"` // Represents the name of the market as seen from the exchange.
}

ExchangeBindingsConfig represents the binding of market names between bot notation and exchange ticker.

type ExchangeConfig

type ExchangeConfig struct {
	ExchangeName     string                     `yaml:"exchange"`          // Represents the exchange name.
	PublicKey        string                     `yaml:"public_key"`        // Represents the public key used to connect to Exchange API.
	SecretKey        string                     `yaml:"secret_key"`        // Represents the secret key used to connect to Exchange API.
	DepositAddresses map[string]string          `yaml:"deposit_addresses"` // Represents the bindings between coins and deposit address on the exchange.
	FakeBalances     map[string]decimal.Decimal `yaml:"fake_balances"`     // Used only in simulation mode, fake starting balance [coin:balance].
}

ExchangeConfig Represents a configuration for an API Connection to an exchange.

Can be used to generate an ExchangeWrapper.

type Market

type Market struct {
	Name           string            `json:"name,required"`            //Represents the name of the market as defined in general (e.g. ETH-BTC).
	BaseCurrency   string            `json:"baseCurrency,omitempty"`   //Represents the base currency of the market.
	MarketCurrency string            `json:"marketCurrency,omitempty"` //Represents the currency to exchange by using base currency.
	ExchangeNames  map[string]string `json:"-"`                        // Represents the various names of the market on various exchanges.
}

Market represents the environment the bot is trading in.

func (Market) String

func (m Market) String() string

type MarketConfig

type MarketConfig struct {
	Name      string                   `yaml:"market"`   // Represents the market where the strategy is applied.
	Exchanges []ExchangeBindingsConfig `yaml:"bindings"` // Represents the list of markets where the strategy is applied, along with extra-data regarding binded exchanges.
}

MarketConfig contains all market configuration data.

type MarketSummary

type MarketSummary struct {
	High   decimal.Decimal `json:"high,required"`   //Represents the 24 hours maximum peak of this market.
	Low    decimal.Decimal `json:"low,required"`    //Represents the 24 hours minimum peak of this market.
	Volume decimal.Decimal `json:"volume,required"` //Represents the 24 volume peak of this market.
	Ask    decimal.Decimal `json:"ask,required"`    //Represents the current ASK value.
	Bid    decimal.Decimal `json:"bid,required"`    //Represents the current BID value.
	Last   decimal.Decimal `json:"last,required"`   //Represents the value of the last trade.
}

MarketSummary represents the summary data of a market.

func (MarketSummary) String

func (ms MarketSummary) String() string

func (*MarketSummary) UpdateFromTicker

func (ms *MarketSummary) UpdateFromTicker(ticker Ticker)

UpdateFromTicker updates the values of the market summary from a Ticker Data.

type Order

type Order struct {
	Value       decimal.Decimal //Value of the trade : e.g. in a BTC ETH is the value of a single ETH in BTC.
	Quantity    decimal.Decimal //Quantity of Coins of this order.
	OrderNumber string          //[optional] Order number as seen in echange archives.
	Timestamp   time.Time       //[optional] The timestamp of the order (as got from the exchange).
}

Order represents a single order in the Order Book for a market.

func (Order) Total

func (order Order) Total() decimal.Decimal

Total returns order total in base currency.

type OrderBook

type OrderBook struct {
	Asks []Order `json:"asks,required"`
	Bids []Order `json:"bids,required"`
}

OrderBook represents a standard orderbook implementation.

func (OrderBook) String

func (book OrderBook) String() string

String returns the string representation of the object.

type OrderType

type OrderType int16

OrderType is an enum {ASK, BID}

const (
	//Ask Represents an ASK Order.
	Ask OrderType = iota
	//Bid Represents a BID Order.
	Bid OrderType = iota
)

type StrategyConfig

type StrategyConfig struct {
	Strategy string         `yaml:"strategy"` // Represents the applied strategy name: must be unique in the system.
	Markets  []MarketConfig `yaml:"markets"`  // Represents the exchanges where the strategy is applied.
}

StrategyConfig contains where a strategy will be applied in the specified exchange.

type Ticker

type Ticker struct {
	Ask  decimal.Decimal `json:"Ask"`  //Represents ASK value from the ticker.
	Bid  decimal.Decimal `json:"Bid"`  //Represents BID value from the ticker.
	Last decimal.Decimal `json:"Last"` //Represents LAST trade value from the ticker.
}

Ticker provides data incoming from API Tickers, which have little amount of information regarding very last updates from a market.

Jump to

Keyboard shortcuts

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