Version: v0.0.0-...-130b979 Latest Latest

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

Go to latest
Published: Jul 21, 2020 License: Apache-2.0 Imports: 12 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type AccountInstruments

type AccountInstruments struct {
	Instruments []Instrument `json:"instruments"`

type AccountProperties

type AccountProperties struct {
	ID string `json:"id"`

type AccountSummary

type AccountSummary struct {
	NAV                         float64   `json:"NAV,string"`
	Alias                       string    `json:"alias"`
	Balance                     float64   `json:"balance,string"`
	CreatedByUserID             int       `json:"createdByUserID"`
	CreatedTime                 time.Time `json:"createdTime"`
	Currency                    string    `json:"currency"`
	HedgingEnabled              bool      `json:"hedgingEnabled"`
	ID                          string    `json:"id"`
	LastTransactionID           string    `json:"lastTransactionID"`
	MarginAvailable             float64   `json:"marginAvailable,string"`
	MarginCloseoutMarginUsed    float64   `json:"marginCloseoutMarginUsed,string"`
	MarginCloseoutNAV           float64   `json:"marginCloseoutNAV,string"`
	MarginCloseoutPercent       float64   `json:"marginCloseoutPercent,string"`
	MarginCloseoutPositionValue float64   `json:"marginCloseoutPositionValue,string"`
	MarginCloseoutUnrealizedPL  float64   `json:"marginCloseoutUnrealizedPL,string"`
	MarginRate                  float64   `json:"marginRate,string"`
	MarginUsed                  float64   `json:"marginUsed,string"`
	OpenPositionCount           int       `json:"openPositionCount"`
	OpenTradeCount              int       `json:"openTradeCount"`
	PendingOrderCount           int       `json:"pendingOrderCount"`
	Pl                          float64   `json:"pl,string"`
	PositionValue               float64   `json:"positionValue,string"`
	ResettablePL                float64   `json:"resettablePL,string"`
	UnrealizedPL                float64   `json:"unrealizedPL,string"`
	WithdrawalLimit             float64   `json:"withdrawalLimit,string"`

type AccountSummaryResponse

type AccountSummaryResponse struct {
	Account AccountSummary `json:"account"`

type Accounts

type Accounts struct {
	Accounts []AccountProperties `json:"accounts"`

type ClientExtensions

type ClientExtensions struct {
	Comment *string `json:"comment,omitempty"`
	ID      *string `json:"id,omitempty"`
	Tag     *string `json:"tag,omitempty"`

type CloseTradeResponse

type CloseTradeResponse struct {
	OrderCreateTransaction *OrderCreateTransaction `json:"orderCreateTransaction"`
	OrderFillTransaction   *OrderFillTransaction   `json:"orderFillTransaction"`
	OrderCancelTransaction *OrderCancelTransaction `json:"orderCancelTransaction"`

type Headers

type Headers struct {
	// contains filtered or unexported fields

type Instrument

type Instrument struct {
	DisplayName                 string  `json:"displayName"`
	DisplayPrecision            int     `json:"displayPrecision"`
	MarginRate                  float64 `json:"marginRate,string"`
	MaximumOrderUnits           float64 `json:"maximumOrderUnits,string"`
	MaximumPositionSize         float64 `json:"maximumPositionSize,string"`
	MaximumTrailingStopDistance float64 `json:"maximumTrailingStopDistance,string"`
	MinimumTradeSize            float64 `json:"minimumTradeSize,string"`
	MinimumTrailingStopDistance float64 `json:"minimumTrailingStopDistance,string"`
	Name                        string  `json:"name"`
	PipLocation                 int     `json:"pipLocation"`
	TradeUnitsPrecision         int     `json:"tradeUnitsPrecision"`
	Type                        string  `json:"type"`

type MarketOrderTradeClose

type MarketOrderTradeClose struct {
	TradeID string `json:"tradeID"`
	Units   string `json:"units"`

type OandaClient

type OandaClient struct {
	// contains filtered or unexported fields

func NewClient

func NewClient(token string, live bool) *OandaClient

func (*OandaClient) CloseTrade

func (c *OandaClient) CloseTrade(accountID, tradeID string) (CloseTradeResponse, error)

func (*OandaClient) CreateMarketOrder

func (c *OandaClient) CreateMarketOrder(accountID, instrument, side string, units int32) (OrderResponse, error)

func (*OandaClient) GetAccountInstruments

func (c *OandaClient) GetAccountInstruments(accountID string) (AccountInstruments, error)

func (*OandaClient) GetAccountSummary

func (c *OandaClient) GetAccountSummary(accountID string) (AccountSummaryResponse, error)

func (*OandaClient) GetAccounts

func (c *OandaClient) GetAccounts() (Accounts, error)

func (*OandaClient) GetOpenTrades

func (c *OandaClient) GetOpenTrades(accountID string) (Trades, error)

func (*OandaClient) GetPrices

func (c *OandaClient) GetPrices(accountID string, instruments []string) (Pricings, error)

func (*OandaClient) SubscribePrices

func (c *OandaClient) SubscribePrices(accountID string, instruments []string, handler PriceHandler) (*PriceSubscription, error)

func (*OandaClient) SubscribeTransactions

func (c *OandaClient) SubscribeTransactions(accountID string, transType []TransactionType, handler TransactionHandler) error

type Order

type Order struct {
	Units            int32             `json:"units,string"`
	Instrument       string            `json:"instrument"`
	TimeInForce      string            `json:"timeInForce"`
	Type             string            `json:"type"`
	PositionFill     string            `json:"positionFill,omitempty"`
	Price            float64           `json:"price,omitempty"`
	ClientExtensions *ClientExtensions `json:"tradeClientExtensions,omitempty"`

type OrderCancelTransaction

type OrderCancelTransaction struct {
	Type      string    `json:"type"`
	OrderID   string    `json:"orderID"`
	Reason    string    `json:"reason"`
	ID        string    `json:"id"`
	UserID    int       `json:"userID"`
	AccountID string    `json:"accountID"`
	BatchID   string    `json:"batchID"`
	RequestID string    `json:"requestID"`
	Time      time.Time `json:"time"`

type OrderCreateTransaction

type OrderCreateTransaction struct {
	AccountID    string                 `json:"accountID"`
	ID           string                 `json:"id"`
	Instrument   string                 `json:"instrument"`
	PositionFill string                 `json:"positionFill"`
	Reason       string                 `json:"reason"`
	TradeClose   *MarketOrderTradeClose `json:"tradeClose"`
	Time         time.Time              `json:"time"`
	TimeInForce  string                 `json:"timeInForce"`
	Type         string                 `json:"type"`
	Units        string                 `json:"units"`

type OrderFillTransaction

type OrderFillTransaction struct {
	Type           string          `json:"type"`
	Instrument     string          `json:"instrument"`
	Units          string          `json:"units"`
	PL             string          `json:"pl"`
	Financing      string          `json:"financing"`
	Commission     string          `json:"commission"`
	AccountBalance string          `json:"accountBalance"`
	TimeInForce    string          `json:"timeInForce"`
	PositionFill   string          `json:"positionFill"`
	Reason         string          `json:"reason"`
	TradesClosed   []*TradeReduced `json:"tradesClosed"`
	TradeReduced   *TradeReduced   `json:"tradeReduced"`
	TradeOpened    *TradeOpened    `json:"tradeOpened"`
	ID             string          `json:"id"`
	UserID         int             `json:"userID"`
	AccountID      string          `json:"accountID"`
	BatchID        string          `json:"batchID"`
	RequestID      string          `json:"requestID"`
	OrderID        string          `json:"orderId"`
	ClientOrderID  string          `json:"clientOrderId"`
	Time           time.Time       `json:"time"`

type OrderRequest

type OrderRequest struct {
	Order Order `json:"order"`

type OrderResponse

type OrderResponse struct {
	OrderCreateTransaction *OrderCreateTransaction `json:"orderCreateTransaction"`
	OrderFillTransaction   *OrderFillTransaction   `json:"orderFillTransaction"`

type PositionFinancing

type PositionFinancing struct {
	Instrument      string            `json:"instrument"`
	Financing       float64           `json:"financing,string"`
	TradesFinancing []*TradeFinancing `json:"openTradeFinancings"`

type Price

type Price struct {
	Asks        []PriceBucket `json:"asks"`
	Bids        []PriceBucket `json:"bids"`
	CloseoutAsk string        `json:"closeoutAsk"`
	CloseoutBid string        `json:"closeoutBid"`
	Instrument  string        `json:"instrument"`
	Time        time.Time     `json:"time"`

type PriceBucket

type PriceBucket struct {
	Liquidity int     `json:"liquidity"`
	Price     float64 `json:"price,string"`

type PriceHandler

type PriceHandler func(price Price)

type PriceSubscription

type PriceSubscription struct {
	// contains filtered or unexported fields

PriceSubscription represents a subscription, can be used to free resources

func (*PriceSubscription) Stop

func (s *PriceSubscription) Stop()

Stop will stop the subscription

type Pricings

type Pricings struct {
	Prices []*Price `json:"prices"`

type Trade

type Trade struct {
	CurrentUnits int32     `json:"currentUnits,string"`
	Financing    float64   `json:"financing,string"`
	ID           string    `json:"id"`
	InitialUnits int32     `json:"initialUnits,string"`
	Instrument   string    `json:"instrument"`
	OpenTime     time.Time `json:"openTime"`
	Price        float64   `json:"price,string"`
	RealizedPL   float64   `json:"realizedPL,string"`
	State        string    `json:"state"`
	UnrealizedPL float64   `json:"unrealizedPL,string"`

type TradeFinancing

type TradeFinancing struct {
	TradeID   string  `json:"tradeID"`
	Financing float64 `json:"financing,string"`

type TradeOpened

type TradeOpened struct {
	TradeID string  `json:"tradeID"`
	Units   int32   `json:"units,string"`
	Price   float64 `json:"price,string"`

type TradeReduced

type TradeReduced struct {
	TradeID    string  `json:"tradeID"`
	Units      int32   `json:"units,string"`
	Price      float64 `json:"price,string"`
	RealizedPL float64 `json:"realizedPL,string"`
	Financing  float64 `json:"financing,string"`

type Trades

type Trades struct {
	Trades []Trade `json:"trades"`

type Transaction

type Transaction struct {
	AccountBalance     float64              `json:"accountBalance,string"`
	AccountID          string               `json:"accountID"`
	Amount             float64              `json:"amount,string"`
	Financing          float64              `json:"financing,string"`
	ID                 string               `json:"id"`
	Instrument         string               `json:"instrument"`
	OrderID            string               `json:"orderID"`
	Pl                 float64              `json:"pl,string"`
	Price              float64              `json:"price,string"`
	Reason             string               `json:"reason"`
	Time               time.Time            `json:"time"`
	TradeOpened        *TradeOpened         `json:"tradeOpened"`
	TradesClosed       []*TradeReduced      `json:"tradesClosed"`
	PositionFinancings []*PositionFinancing `json:"positionFinancings"`
	Type               string               `json:"type"`
	Units              string               `json:"units"`
	RejectReason       *string              `json:"rejectReason"`

type TransactionHandler

type TransactionHandler func(transaction *Transaction)

type TransactionType

type TransactionType int
const (
	OrderFill TransactionType = iota

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to