Documentation ¶
Overview ¶
Package goanda implements a stateless client for the oanda REST-v20 API.
Index ¶
- Constants
- type Account
- type AccountProperties
- type Client
- func (c *Client) GetAccount(accountID string) (acc Account, err error)
- func (c *Client) GetAccountInstruments(accountID string) (instruments []Instrument, err error)
- func (c *Client) GetAccounts() (ids []string, err error)
- func (c *Client) GetHTTPClient() *http.Client
- func (c *Client) GetOpenTrades(accountID string) (trades []Trade, err error)
- func (c *Client) GetPositions(accountID string) (positions []Position, err error)
- func (c *Client) GetPricing(accountID string, instruments []string) (prices []Pricing, err error)
- func (c *Client) GetPricingStream(accountID string, instruments []string) (ch chan Pricing, err error)
- func (c *Client) PlaceOrder(accountID string, order interface{}) (orderID int, err error)
- type DayOfWeek
- type Instrument
- type InstrumentCommission
- type InstrumentFinancing
- type InstrumentType
- type LimitOrderRequest
- type MarketIfTouchedOrderRequest
- type MarketOrderRequest
- type OrderPositionFill
- type OrderRequest
- type OrderType
- type Position
- type PositionSide
- type PriceBucket
- type Pricing
- type StopLossOrderRequest
- type StopOrderRequest
- type TakeProfitOrderRequest
- type TimeInForce
- type Trade
- type TradeState
- type TrailingStopLossOrderRequest
Constants ¶
const ( // HostURL is the host url of most routes of the REST-v20 API. HostURL = "https://api-fxpractice.oanda.com/v3" // HostURLStream is the host url of the specialised streaming routes of the REST-v20 API. HostURLStream = "https://stream-fxpractice.oanda.com/v3" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { ID string Alias string Currency string OpenTradeCount int OpenPositionCount int PendingOrderCount int HedgingEnabled bool MarginRate decimal.Decimal UnrealizedPL decimal.Decimal NAV decimal.Decimal MarginUsed decimal.Decimal MarginAvailable decimal.Decimal PositionValue decimal.Decimal MarginCloseoutUnrealizedPL decimal.Decimal MarginCloseoutNAV decimal.Decimal MarginCloseoutMarginUsed decimal.Decimal MarginCloseoutPercent decimal.Decimal WithdrawalLimit decimal.Decimal Balance decimal.Decimal PL decimal.Decimal ResettablePL decimal.Decimal Trades []Trade Positions []Position }
Account holds complete account information.
type AccountProperties ¶
AccountProperties holds properties related to an account.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a stateless client for the oanda REST-v20 API.
func NewClient ¶ added in v0.1.0
New returns a new client configured with the necessary auth and address etc.
func (*Client) GetAccount ¶
GetAccount returns the IDs of all accounts registered with the broker.
func (*Client) GetAccountInstruments ¶ added in v0.4.0
func (c *Client) GetAccountInstruments(accountID string) (instruments []Instrument, err error)
GetAccountInstruments returns the instruments that an account can trade.
func (*Client) GetAccounts ¶
GetAccounts returns the IDs of all accounts registered with the broker.
func (*Client) GetHTTPClient ¶
GetHTTPClient returns the underlying http client used by the resty client.
func (*Client) GetOpenTrades ¶
GetOpenTrades returns all open trades of an account.
func (*Client) GetPositions ¶
GetPositions returns positions for all instruments that have had a position during the account's lifetime.
func (*Client) GetPricing ¶
GetPricing returns pricing for the given instruments.
type Instrument ¶ added in v0.4.0
type Instrument struct { Name string DisplayName string Type InstrumentType PipLocation int DisplayPrecision int TradeUnitsPrecision int MinimumTradeSize decimal.Decimal MaximumTrailingStopDistance decimal.Decimal MinimumTrailingStopDistance decimal.Decimal MaximumPositionSize decimal.Decimal MaximumOrderUnits decimal.Decimal MarginRate decimal.Decimal Commission InstrumentCommission Financing InstrumentFinancing }
Instrument represents an instrument that can be traded by an account.
type InstrumentCommission ¶ added in v0.4.0
type InstrumentCommission struct { Commission decimal.Decimal UnitsTraded decimal.Decimal MinimumCommission decimal.Decimal }
InstrumentCommission represents instrument-specific commission information.
type InstrumentFinancing ¶ added in v0.4.0
type InstrumentFinancing struct { LongRate decimal.Decimal ShortRate decimal.Decimal FinancingDaysOfWeek []struct { DayOfWeek DayOfWeek DaysCharged int } }
InstrumentFinancing represents instrument-specific commission information.
type InstrumentType ¶ added in v0.4.0
type InstrumentType string
InstrumentType represents what type of instrument it is.
const ( CurrencyType InstrumentType = "CURRENCY" CFDType InstrumentType = "CFD" MetalType InstrumentType = "METAL" )
type LimitOrderRequest ¶
type LimitOrderRequest struct {
OrderRequest
}
TODO: Fill this with its fields.
type MarketIfTouchedOrderRequest ¶
type MarketIfTouchedOrderRequest struct {
OrderRequest
}
TODO: Fill this with its fields.
type MarketOrderRequest ¶
type MarketOrderRequest struct {
OrderRequest
}
TODO: Fill this with its fields.
type OrderPositionFill ¶
type OrderPositionFill string
OrderPositionFill specifies how positions in the account are to be modified when an order is filled.
const ( OpenOnly OrderPositionFill = "OPEN_ONLY" ReduceFirst OrderPositionFill = "REDUCE_FIRST" ReduceOnly OrderPositionFill = "REDUCE_ONLY" Default OrderPositionFill = "DEFAULT" )
type OrderRequest ¶ added in v0.4.1
type OrderRequest struct { Type OrderType `json:"type"` Instrument string `json:"instrument"` Units decimal.Decimal `json:"units,string"` TimeInForce TimeInForce `json:"timeInForce"` PositionFill OrderPositionFill `json:"positionFill"` }
type Position ¶
type Position struct { Instrument string PL decimal.Decimal UnrealizedPL decimal.Decimal MarginUsed decimal.Decimal ResettablePL decimal.Decimal Long PositionSide Short PositionSide }
Position holds information about a market position.
type PositionSide ¶
type PositionSide struct { TradeIDs []string Units decimal.Decimal AveragePrice decimal.Decimal PL decimal.Decimal UnrealizedPL decimal.Decimal ResettablePL decimal.Decimal }
PositionSide holds information either a long or short side of a position.
type PriceBucket ¶
PriceBucket represents a price available for an amount of liquidity.
type Pricing ¶ added in v0.3.0
type Pricing struct { Instrument string Tradeable bool Bids []PriceBucket Asks []PriceBucket Time time.Time }
Pricing represents an account-specific price of an instrument.
func (*Pricing) UnmarshalJSON ¶ added in v0.3.0
type StopLossOrderRequest ¶
type StopLossOrderRequest struct {
OrderRequest
}
TODO: Fill this with its fields.
type StopOrderRequest ¶
type StopOrderRequest struct {
OrderRequest
}
TODO: Fill this with its fields.
type TakeProfitOrderRequest ¶
type TakeProfitOrderRequest struct {
OrderRequest
}
TODO: Fill this with its fields.
type TimeInForce ¶
type TimeInForce string
TimeInForce represents how long an order should remain pending before being automatically cancelled.
const ( GTC TimeInForce = "GTC" GTD TimeInForce = "GTD" GFD TimeInForce = "GFD" FOK TimeInForce = "FOK" IOC TimeInForce = "IOC" )
type Trade ¶
type Trade struct { ID string Instrument string State TradeState Price decimal.Decimal InitialUnits decimal.Decimal InitialMarginRequired decimal.Decimal CurrentUnits decimal.Decimal RealizedPL decimal.Decimal UnrealizedPL decimal.Decimal MarginUsed decimal.Decimal AverageClosePrice decimal.Decimal OpenTime time.Time CloseTime time.Time ClosingTransactionIDs []string }
Trade represents a trade of an account.
func (*Trade) UnmarshalJSON ¶ added in v0.2.0
type TradeState ¶
type TradeState string
TradeState represents the current state of a trade.
const ( Open TradeState = "OPEN" Closed TradeState = "CLOSED" CloseWhenTradeable TradeState = "CLOSE_WHEN_TRADEABLE" )
type TrailingStopLossOrderRequest ¶
type TrailingStopLossOrderRequest struct {
OrderRequest
}
TODO: Fill this with its fields.