endpoint

package
v0.0.0-...-6001708 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultUserAgent string = "oanda-go/0.9.0"

Variables

View Source
var (
	ErrChunkTooBig = errors.New("chunk too big")
)
View Source
var (
	ErrInstrumentsRequired = errors.New("instruments required")
)
View Source
var (
	ErrNilRequest = errors.New("nil request")
)

Functions

func AcquireClientPrice

func AcquireClientPrice() *ClientPrice

func ReleaseClientPrice

func ReleaseClientPrice(price *ClientPrice)

Types

type Connection

type Connection struct {
	DatetimeFormat string
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(token string, live bool) *Connection

func (*Connection) Account

func (c *Connection) Account(
	id AccountID,
) (*Account, error)

GET /v3/accounts Get a list of all Accounts authorized for the provided token.

func (*Connection) AccountChanges

func (c *Connection) AccountChanges(
	id AccountID,
	sinceTransactionID TransactionID,
) (*AccountChangesResponse, error)

GET /v3/accounts/{accountID}/changes Endpoint used to poll an Account for its current state and changes since a specified TransactionID.

func (*Connection) AccountConfigure

func (c *Connection) AccountConfigure(
	id AccountID,
	config *AccountConfigurationRequest,
) (*AccountConfigurationResponse, *AccountConfigurationError, error)

PATCH /v3/accounts/{accountID}/configuration Set the client-configurable portions of an Account.

func (*Connection) AccountInstruments

func (c *Connection) AccountInstruments(
	id AccountID,
	filter ...string,
) (*AccountInstrumentsResponse, error)

GET /v3/accounts/{accountID}/instruments Get the list of tradeable instruments for the given Account. The list of tradeable instruments is dependent on the regulatory division that the Account is located in, thus should be the same for all Accounts owned by a single user.

func (*Connection) AccountSummary

func (c *Connection) AccountSummary(
	id AccountID,
) (*AccountSummaryResponse, error)

GET /v3/accounts/{accountID}/summary Get a summary for a single Account that a client has access to.

func (*Connection) Accounts

func (c *Connection) Accounts() (*AccountsResponse, error)

GET /v3/accounts Get a list of all Accounts authorized for the provided token.

func (*Connection) CandlesLatest

func (c *Connection) CandlesLatest(
	accountID AccountID,
	request *CandlesLatestRequest,
) (*CandlesLatestResponse, error)

GET /v3/accounts/{accountID}/candles/latest Get dancing bears and most recently completed candles within an Account for specified combinations of instrument, granularity, and price component.

func (*Connection) InstrumentCandles

func (c *Connection) InstrumentCandles(
	request *InstrumentCandlesRequest,
) (*CandlestickResponse, error)

GET /v3/instruments/{instrument}/candles Fetch candlestick data for an instrument.

func (*Connection) InstrumentOrderBook

func (c *Connection) InstrumentOrderBook(

	instrument InstrumentName,

	t time.Time,
) (*OrderBook, error)

GET /v3/instruments/{instrument}/orderBook Fetch an order book for an instrument.

func (*Connection) InstrumentPositionBook

func (c *Connection) InstrumentPositionBook(

	instrument InstrumentName,

	t time.Time,
) (*PositionBook, error)

GET /v3/instruments/{instrument}/positionBook Fetch a position book for an instrument.

func (*Connection) OrderCancel

func (c *Connection) OrderCancel(
	accountID AccountID,
	specifier OrderSpecifier,
) (*CancelOrderResponse, *CancelOrderError, error)

PUT /v3/accounts/{accountID}/orders/{orderSpecifier} Replace an Order in an Account by simultaneously cancelling it and creating a replacement Order

func (*Connection) OrderClientExtensions

func (c *Connection) OrderClientExtensions(
	accountID AccountID,
	specifier OrderSpecifier,
	request *OrderClientExtensionsRequest,
) (*OrderClientExtensionsResponse, *OrderClientExtensionsError, error)

PUT /v3/accounts/{accountID}/orders/{orderSpecifier}/clientExtensions Update the Client Extensions for an Order in an Account. Do not set, modify, or delete clientExtensions if your account is associated with MT4.

func (*Connection) OrderCreate

func (c *Connection) OrderCreate(
	accountID AccountID,
	request OrderRequest,
) (*CreateOrderResponse, *CreateOrderError, error)

POST /v3/accounts/{accountID}/orders Create an Order for an Account

func (*Connection) OrderReplace

func (c *Connection) OrderReplace(
	accountID AccountID,
	specifier OrderSpecifier,
	order OrderRequest,
) (*CreateOrderResponse, *CreateOrderError, error)

PUT /v3/accounts/{accountID}/orders/{orderSpecifier} Replace an Order in an Account by simultaneously cancelling it and creating a replacement Order

func (*Connection) Orders

func (c *Connection) Orders(
	accountID AccountID,
	request *OrdersRequest,
) (*OrdersResponse, error)

GET /v3/accounts/{accountID}/orders Get a list of Orders for an Account

func (*Connection) OrdersBySpecifier

func (c *Connection) OrdersBySpecifier(
	accountID AccountID,
	specifier OrderSpecifier,
) (*OrdersResponse, error)

GET /v3/accounts/{accountID}/orders/{orderSpecifier} Get details for a single Order in an Account

func (*Connection) OrdersPending

func (c *Connection) OrdersPending(
	accountID AccountID,
) (*OrdersResponse, error)

GET /v3/accounts/{accountID}/pendingOrders List all pending Orders in an Account

func (*Connection) Position

func (c *Connection) Position(
	accountID AccountID,
	instrument InstrumentName,
) (*PositionResponse, error)

GET /v3/accounts/{accountID}/positions/{instrument} Get the details of a single Instrument’s Position in an Account. The Position may by open or not.

func (*Connection) PositionClose

func (c *Connection) PositionClose(
	accountID AccountID,
	instrument InstrumentName,
	request *PositionCloseRequest,
) (*PositionCloseResponse, *PositionCloseError, error)

PUT /v3/accounts/{accountID}/positions/{instrument}/close Closeout the open Position for a specific instrument in an Account.

func (*Connection) Positions

func (c *Connection) Positions(
	accountID AccountID,
) (*PositionsResponse, error)

GET /v3/accounts/{accountID}/positions List all Positions for an Account. The Positions returned are for every instrument that has had a position during the lifetime of an the Account.

func (*Connection) PositionsOpen

func (c *Connection) PositionsOpen(
	accountID AccountID,
) (*PositionsResponse, error)

GET /v3/accounts/{accountID}/openPositions List all open Positions for an Account. An open Position is a Position in an Account that currently has a Trade opened for it.

func (*Connection) Pricing

func (c *Connection) Pricing(
	accountID AccountID,
	request *PricingRequest,
) (*PricingResponse, error)

GET /v3/accounts/{accountID}/pricing Get pricing information for a specified list of Instruments within an Account.

func (*Connection) PricingCandles

func (c *Connection) PricingCandles(
	accountID AccountID,
	instrument InstrumentName,
	request *PricingCandlesRequest,
) (*PricingCandlesResponse, error)

GET /v3/accounts/{accountID}/instruments/{instrument}/candles Fetch candlestick data for an instrument.

func (*Connection) StartPricingStream

func (c *Connection) StartPricingStream(
	accountID AccountID,
	request *PricingStreamRequest,
	handler PricingStreamHandler,
) (*Stream, error)

GET /v3/accounts/{accountID}/pricing/stream Get a stream of Account Prices starting from when the request is made. This pricing stream does not include every single price created for the Account, but instead will provide at most 4 prices per second (every 250 milliseconds) for each instrument being requested. If more than one price is created for an instrument during the 250 millisecond window, only the price in effect at the end of the window is sent. This means that during periods of rapid price movement, subscribers to this stream will not be sent every price. Pricing windows for different connections to the price stream are not all aligned in the same way (i.e. they are not all aligned to the top of the second). This means that during periods of rapid price movement, different subscribers may observe different prices depending on their alignment.

Note: This endpoint is served by the streaming URLs.

func (*Connection) StartTransactionStream

func (c *Connection) StartTransactionStream(
	accountID AccountID,
	handler TxStreamHandler,
) (*Stream, error)

GET /v3/accounts/{accountID}/transactions/stream Get a stream of Transactions for an Account starting from when the request is made.

Note: This endpoint is served by the streaming URLs.

func (*Connection) Trade

func (c *Connection) Trade(
	accountID AccountID,
	specifier TradeSpecifier,
) (*TradeResponse, error)

GET /v3/accounts/{accountID}/trades/{tradeSpecifier} Get the details of a specific Trade in an Account

func (*Connection) TradeClientExtensions

func (c *Connection) TradeClientExtensions(
	accountID AccountID,
	specifier TradeSpecifier,
	request *OrderClientExtensionsRequest,
) (*OrderClientExtensionsResponse, *OrderClientExtensionsError, error)

PUT /v3/accounts/{accountID}/trades/{tradeSpecifier}/clientExtensions Update the Client Extensions for a Trade. Do not add, update, or delete the Client Extensions if your account is associated with MT4.

func (*Connection) TradeClose

func (c *Connection) TradeClose(
	accountID AccountID,
	specifier TradeSpecifier,
	units DecimalNumber,
) (*TradeCloseResponse, *TradeCloseError, error)

PUT /v3/accounts/{accountID}/trades/{tradeSpecifier}/close Close (partially or fully) a specific open Trade in an Account

func (*Connection) TradeModify

func (c *Connection) TradeModify(
	accountID AccountID,
	specifier TradeSpecifier,
	request *TradeModifyRequest,
) (*TradeModifyResponse, *TradeModifyError, error)

PUT /v3/accounts/{accountID}/trades/{tradeSpecifier}/orders Create, replace and cancel a Trade’s dependent Orders

Take Profit,
Stop Loss
Trailing Stop Loss

through the Trade itself

func (*Connection) Trades

func (c *Connection) Trades(
	accountID AccountID,
	request *TradesRequest,
) (*TradesResponse, error)

func (*Connection) TradesOpen

func (c *Connection) TradesOpen(
	accountID AccountID,
) (*TradesResponse, error)

GET /v3/accounts/{accountID}/openTrades Get the list of open Trades for an Account

func (*Connection) Transaction

func (c *Connection) Transaction(
	accountID AccountID,
	id TransactionID,
) (*TransactionResponse, error)

GET /v3/accounts/{accountID}/transactions/{transactionID} Get the details of a single Account Transaction.

func (*Connection) Transactions

func (c *Connection) Transactions(
	accountID AccountID,
	request *TransactionsRequest,
) (*TransactionsPagesResponse, error)

GET /v3/accounts/{accountID}/transactions Get a list of Transactions pages that satisfy a time-based Transaction query.

func (*Connection) TransactionsIDRange

func (c *Connection) TransactionsIDRange(
	accountID AccountID,
	request *TransactionsIDRangeRequest,
) (*TransactionsResponse, error)

GET /v3/accounts/{accountID}/transactions/idrange Get a range of Transactions for an Account based on the Transaction IDs.

func (*Connection) TransactionsSinceID

func (c *Connection) TransactionsSinceID(
	accountID AccountID,
	request *TransactionsSinceIDRequest,
) (*TransactionsResponse, error)

GET /v3/accounts/{accountID}/transactions/sinceid Get a range of Transactions for an Account starting at (but not including) a provided Transaction ID.

type PricingStreamHandler

type PricingStreamHandler interface {
	OnMessage(price *StreamClientPrice) error

	OnHeartbeat(time time.Time)

	OnClose()
}

type StatusCodeError

type StatusCodeError struct {
	Code int
}

func (StatusCodeError) Error

func (s StatusCodeError) Error() string

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

func (*Stream) Close

func (s *Stream) Close() error

func (*Stream) Done

func (s *Stream) Done() <-chan struct{}

func (*Stream) Started

func (s *Stream) Started() time.Time

func (*Stream) Wait

func (s *Stream) Wait()

type TxStreamHandler

type TxStreamHandler interface {
	/*
		switch v := msg.(type) {
		case *TransactionHeartbeat:
		case *CreateTransaction:
		case *CloseTransaction:
		case *ReopenTransaction:
		case *ClientConfigureTransaction:
		case *ClientConfigureRejectTransaction:
		case *TransferFundsTransaction:
		case *TransferFundsRejectTransaction:
		case *MarketOrderTransaction:
		case *MarketOrderRejectTransaction:
		case *FixedPriceOrderTransaction:
		case *LimitOrderTransaction:
		case *LimitOrderRejectTransaction:
		case *StopOrderTransaction:
		case *StopOrderRejectTransaction:
		case *MarketIfTouchedOrderTransaction:
		case *MarketIfTouchedOrderRejectTransaction:
		case *TakeProfitOrderTransaction:
		case *TakeProfitOrderRejectTransaction:
		case *StopLossOrderTransaction:
		case *StopLossOrderRejectTransaction:
		case *GuaranteedStopLossOrderTransaction:
		case *GuaranteedStopLossOrderRejectTransaction:
		case *TrailingStopLossOrderTransaction:
		case *TrailingStopLossOrderRejectTransaction:
		case *OrderFillTransaction:
		case *OrderCancelTransaction:
		case *OrderCancelRejectTransaction:
		case *OrderClientExtensionsModifyTransaction:
		case *OrderClientExtensionsModifyRejectTransaction:
		case *TradeClientExtensionsModifyTransaction:
		case *TradeClientExtensionsModifyRejectTransaction:
		case *MarginCallEnterTransaction:
		case *MarginCallExtendTransaction:
		case *MarginCallExitTransaction:
		case *DelayedTradeClosureTransaction:
		case *DailyFinancingTransaction:
		case *DividendAdjustmentTransaction:
		case *ResetResettablePLTransaction:
		}
	*/
	OnMessage(msg TransactionMessage) error

	OnHeartbeat(time DateTime, last TransactionID) error

	OnClose()
}

Jump to

Keyboard shortcuts

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