Documentation ¶
Index ¶
- Variables
- func CalculateOverlap(obA, obB OrderBook) (float64, error)
- func GetMinInterval(candles []Candle) int
- func SaveCandlesToFile(candles *[]Candle, filepath string) error
- type ActionType
- type Asset
- type AssetsSnapshot
- type Balance
- type BalanceSnapshot
- type Candle
- type Order
- type OrderBook
- type OrderBookRow
- type OrderBookUpdate
- type OrderRequest
- type OrderStatus
- type OrderType
- type Pair
- type Position
- type PositionCloseOrder
- type PositionType
- type Ticker
- type Trade
Constants ¶
This section is empty.
Variables ¶
var PairMappings = map[string]Pair{}/* 1951 elements not displayed */
Functions ¶
func CalculateOverlap ¶ added in v0.12.8
func GetMinInterval ¶ added in v0.1.4
GetMinInterval - Returns the minimun period interval in minutes from an array of candles
func SaveCandlesToFile ¶ added in v0.7.9
Types ¶
type ActionType ¶
type ActionType string
ActionType determines if the action is to buy or to sell
const ( // BuyAction is a purchase action BuyAction ActionType = "buy" // SellAction is a selling action SellAction ActionType = "sell" )
type Asset ¶
type Asset struct { Name string `json:"name"` Symbol string `json:"symbol"` AltSymbol string `json:"alt_symbol"` }
Asset - A resource with economic value
func NewCryptoAsset ¶ added in v0.1.6
func NewForexAsset ¶ added in v0.1.6
func NewStockAsset ¶ added in v0.1.6
type AssetsSnapshot ¶ added in v0.11.0
AssetsSnapshot - An snapshot of the total amount of assets
func (*AssetsSnapshot) String ¶ added in v0.11.0
func (a *AssetsSnapshot) String() string
type BalanceSnapshot ¶ added in v0.1.5
type BalanceSnapshot struct { Balance float64 `json:"balance"` Equity float64 `json:"equity"` Margin float64 `json:"margin"` FreeMargin float64 `json:"free_margin"` }
BalanceSnapshot - An snapshot of the current balance of a user
func (*BalanceSnapshot) String ¶ added in v0.11.0
func (b *BalanceSnapshot) String() string
type Candle ¶
type Candle struct { Time int64 `json:"time"` Open float64 `json:"open"` High float64 `json:"high"` Low float64 `json:"low"` Close float64 `json:"close"` Volume float64 `json:"volume"` }
Candle represents the high, low, open, and closing prices of an asset or security for a specific period
func LoadCandlesFromFile ¶ added in v0.7.9
func ModifyInterval ¶
ModifyInterval - takes an array of candles and the desired interval in minutes and returns an array of candles with the market data resampled to fit the new interval
type Order ¶
type Order struct { ID string `json:"id"` Action ActionType `json:"action"` Type OrderType `json:"type"` Pair *Pair `json:"pair"` Price float64 `json:"price"` Volume float64 `json:"volume"` ExecutedVolume float64 `json:"executed_volume"` Fee float64 `json:"fee"` Cost float64 `json:"cost"` Status OrderStatus `json:"status"` OpenTime time.Time `json:"open_time"` CloseTime time.Time `json:"close_time"` Trades []string `json:"trades"` TakeProfit float64 `json:"take_profit"` StopLoss float64 `json:"stop_loss"` PositionID string `json:"position_id"` ExecutionID string `json:"execution_id"` }
Order - Set of instructions to purchase or sell an asset
func (*Order) GetSchema ¶ added in v0.3.3
func (o *Order) GetSchema() *interfaces.Schema
GetSchema returns the database schema for the Order model
type OrderBook ¶
type OrderBook struct { Time int64 `json:"time"` Asks []OrderBookRow `json:"asks"` // ordered from highest to lowest Bids []OrderBookRow `json:"bids"` // ordered from lowest to highest MaxDepth int `json:"max_depth"` }
OrderBook - A record of active buy and sell orders in a single market
func NewOrderBook ¶ added in v0.12.1
func NewOrderBook(asks, bids []OrderBookRow, maxDepth int) OrderBook
func (*OrderBook) ApplyUpdate ¶ added in v0.12.1
func (ob *OrderBook) ApplyUpdate(update OrderBookUpdate) error
type OrderBookRow ¶
type OrderBookRow struct { Price float64 `json:"price"` Volume float64 `json:"volume"` AccumVolume float64 `json:"accum_volume"` }
OrderBookRow - A single order from the order book
func (*OrderBookRow) String ¶ added in v0.11.0
func (obr *OrderBookRow) String() string
type OrderBookUpdate ¶ added in v0.12.1
type OrderRequest ¶ added in v0.1.9
type OrderRequest struct { Action ActionType Type OrderType Pair Pair Price float64 TakeProfit float64 StopLoss float64 Quantity float64 Total float64 }
OrderRequest - Request to create an order
func NewOrderRequest ¶ added in v0.1.15
func NewOrderRequest(pair Pair, action ActionType, orderType OrderType, quantity, price, total float64) (*OrderRequest, error)
NewOrderRequest - creates a valid new OrderRequest
func (*OrderRequest) CalculateFields ¶ added in v0.1.15
func (o *OrderRequest) CalculateFields(currentPrice float64) (*OrderRequest, error)
func (*OrderRequest) String ¶ added in v0.1.10
func (o *OrderRequest) String() string
type OrderStatus ¶ added in v0.1.9
type OrderStatus string
OrderStatus - determines the status of the order
const ( // FulfilledOrder - The entirety of the order was filled FulfilledOrder OrderStatus = "fulfilled" // PartialyFilledOrder - A the order has been filled partialy PartialyFilledOrder OrderStatus = "partial_fill" // UnfilledOrder - The order has not been filled UnfilledOrder OrderStatus = "unfilled" // CanceledOrder - The order has been cancelled CanceledOrder OrderStatus = "canceled" )
type OrderType ¶
type OrderType string
OrderType determines the type of market order
const ( // MarketOrder will buy or sell at whatever the current price is MarketOrder OrderType = "market" // ClosePosition will buy or sell at whatever the current price to close a position ClosePosition OrderType = "close_position" // LimitOrder will buy or sell at a specific price LimitOrder OrderType = "limit" // TakeProfit will buy or sell at a specific price TakeProfit OrderType = "take_profit" // StopLoss will buy or sell at a specific price StopLoss OrderType = "stop_loss" )
type Pair ¶
Pair - Quotation of two different assets or currencies, with the value of one being quoted against the other.
type Position ¶
type Position struct { ID string `json:"id"` Type PositionType `json:"type"` Pair Pair `json:"pair"` Open bool `json:"open"` TakeProfit PositionCloseOrder `json:"take_profit"` StopLoss PositionCloseOrder `json:"stop_loss"` OpenPrice float64 `json:"open_price"` ClosePrice float64 `json:"close_price"` Quantity float64 `json:"quantity"` Profit float64 `json:"profit"` OpenTime time.Time `json:"open_time"` CloseTime time.Time `json:"close_time"` Trades []string `json:"trades"` ExecutionID string `json:"execution_id"` Data string `json:"data"` }
Position represents a market position
func (*Position) GetSchema ¶ added in v0.3.3
func (p *Position) GetSchema() *interfaces.Schema
GetSchema returns the database schema for the Position model
func (*Position) UnrealizedProfit ¶ added in v0.7.5
UnrealizedProfit - Returns the current unrealized profit of the position
type PositionCloseOrder ¶ added in v0.6.8
PositionCloseOrder - A TakeProfit or StopLoss order to close the position
func (*PositionCloseOrder) String ¶ added in v0.11.0
func (p *PositionCloseOrder) String() string
type PositionType ¶
type PositionType string
PositionType determines if its a long or short position
const ( // LongPosition buy the asset LongPosition PositionType = "long" // ShortPosition sell the asset ShortPosition PositionType = "short" )
type Ticker ¶
type Ticker struct { Time int64 `json:"time"` Ask float64 `json:"ask"` Bid float64 `json:"bid"` Last float64 `json:"last"` Volume float64 `json:"volume"` VWAP float64 `json:"vwap"` }
Ticker - The Latest price data for an asset
type Trade ¶
type Trade struct { ID string `json:"id"` ExecutionTime time.Time `json:"execution_time"` Action ActionType `json:"action"` OrderType OrderType `json:"order_type"` Pair Pair `json:"pair"` Price float64 `json:"price"` Quantity float64 `json:"quantity"` Fee float64 `json:"fee"` Cost float64 `json:"cost"` ExecutionID string `json:"execution_id"` }
Trade represents a market trade
func NewTrade ¶
func NewTrade(id string, executionTime time.Time, actionType ActionType, orderType OrderType, pair Pair, price, quantity, cost float64) *Trade
NewTrade creates a new trade
func (*Trade) GetSchema ¶ added in v0.3.3
func (t *Trade) GetSchema() *interfaces.Schema
GetSchema returns the database schema for the Trade model