Documentation ¶
Overview ¶
Package v1 do calls to machina api v1
Index ¶
- Variables
- type Candle
- type Client
- func (c *Client) Authenticate() error
- func (c *Client) ClosePosition(id string) (p *Position, err error)
- func (c *Client) CreateOrder(no NewOrder) (o *Order, err error)
- func (c *Client) CreatePosition(np NewPosition, quantity float64) (p *Position, err error)
- func (c *Client) ListPositions() (p []Position, err error)
- func (c *Client) RetrieveCandle(par string, interval string, pageNumber int, rowsPerPage int) (candle []Candle, err error)
- func (c *Client) RetrievePosition() (p *Position, err error)
- type NewOrder
- type NewPosition
- type Order
- type Position
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUnexpectedCode occurs when a strategy tries opens or close a position, but the strategy's budget is out of fund. ErrUnexpectedCode = errors.New("unexpected code in response") )
Functions ¶
This section is empty.
Types ¶
type Candle ¶
type Candle struct { ID string `json:"id"` SymbolID string `json:"symbol_id"` Symbol string `json:"symbol"` Interval string `json:"interval"` OpenTime time.Time `json:"open_time"` OpenPrice float64 `json:"open_price"` ClosePrice float64 `json:"close_price"` CloseTime time.Time `json:"close_time"` Low float64 `json:"low"` High float64 `json:"high"` Volume float64 `json:"volume"` }
Candle Candlestick charts are used by traders to determine possible price movement based on past patterns.
type Client ¶
type Client struct { *retryablehttp.Client Username string Password string TraderAPI string PullInterval time.Duration // contains filtered or unexported fields }
func (*Client) Authenticate ¶
Authenticate requests a token from the trader api
func (*Client) ClosePosition ¶
ClosePosition closes a position using the trader api
func (*Client) CreatePosition ¶
func (c *Client) CreatePosition(np NewPosition, quantity float64) (p *Position, err error)
CreatePosition do a POST to the trader api and Creates a position
func (*Client) ListPositions ¶
ListPositions return all positions belonging to this username
func (*Client) RetrieveCandle ¶
func (*Client) RetrievePosition ¶
RetrievePosition return the last position belonging to this username
type NewOrder ¶
type NewOrder struct { PositionID string `json:"position_id"` Quantity float64 `json:"quantity"` Side string `json:"side"` }
NewOrder contains information needed to create a new Order.
type NewPosition ¶
NewPosition contains information needed to create a new position
type Order ¶
type Order struct { ID string `json:"order_id"` SymbolID string `json:"symbol_id"` PositionID string `json:"position_id"` CreationTime time.Time `json:"creation_time"` Price float64 `json:"price"` Quantity float64 `json:"quantity"` Status string `json:"status"` Type string `json:"type"` Side string `json:"side"` }
Order represent an order in a position
type Position ¶
type Position struct { ID string `json:"position_id"` // Position ID SymbolID string `json:"-"` // SymbolID this position is trading on, used to preload Symbol UserID string `json:"-"` // UserID who created this position, used to preload User Side string `json:"side"` // Position side: SELL / BUY Status string `json:"status"` // Status open / closed CreationTime time.Time `json:"creation_time"` // CreationTime of the position User string `json:"user"` // Name of the owner Symbol string `json:"symbol"` // Symbol this position is trading on Orders []Order `json:"orders"` // Orders belonging to this position }
Position represents a single position
Click to show internal directories.
Click to hide internal directories.