oanda

package module
v0.0.0-...-d229ac8 Latest Latest
Warning

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

Go to latest
Published: May 11, 2019 License: MIT Imports: 10 Imported by: 0

README

go-oanda

A Go client for the OANDA API

Go Report Card GoDoc

Documentation

Overview

Package oanda provides a client for the OANDA API. For information on the OANDA API, please refer to the OANDA development guide: http://developer.oanda.com/rest-live-v20/development-guide/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountIdentifier

type AccountIdentifier struct {
	ID   string        `json:"id"`
	Tags []interface{} `json:"tags"`
}

AccountIdentifier contains an Account ID and associated tags.

type Client

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

Client holds configuration and state for the OANDA API client.

func NewClient

func NewClient(c *http.Client) *Client

NewClient returns a new OANDA client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication. For example: golang.org/x/oauth2

func (*Client) Accounts

func (c *Client) Accounts(ctx context.Context) ([]AccountIdentifier, error)

Accounts returns a list of all Accounts.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) error

Do sends a request and returns the response. An error is returned if the request cannot be sent or if the API returns an error. If a response is received, the body response body is decoded and stored in the value pointed to by v. Inspiration: https://github.com/google/go-github/blob/master/github/github.go

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, body interface{}) (*http.Request, error)

NewRequest creates an HTTP Request. The client baseURL is checked to confirm that it has a trailing slash. A relative URL should be provided without the leading slash. If a non-nil body is provided it will be JSON encoded and included in the request. Inspiration: https://github.com/google/go-github/blob/master/github/github.go

func (*Client) Pricing

func (c *Client) Pricing(ctx context.Context, actID string, instruments []string) ([]Price, error)

Pricing returns pricing information for a specified list of instruments within an Account.

type Price

type Price struct {
	Type        string           `json:"type"`
	Time        time.Time        `json:"time"`
	Bids        []PriceLiquidity `json:"bids"`
	Asks        []PriceLiquidity `json:"asks"`
	CloseoutBid string           `json:"closeoutBid"`
	CloseoutAsk string           `json:"closeoutAsk"`
	Tradeable   bool             `json:"tradeable"`
	Instrument  string           `json:"instrument"`
}

Price is an Account-specific Price.

type PriceLiquidity

type PriceLiquidity struct {
	Price     string `json:"price"`
	Liquidity int    `json:"liquidity"`
}

PriceLiquidity is a list of prices and liquidity available on an Instrument. It is possible for this list to be empty if there is liquidity currently available for the Instrument in the Account.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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