oandaV20

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: MIT Imports: 9 Imported by: 0

README

oandaV20

Golang interface to Oanda's V20 REST API

Oanda is not affiliated and does not endorse or recommend this package. This was written completely independently by a third party.

This packages provides a flexible API to the Oanda v20 API.

The API is being developed as needed, so only a few REST endpoints are actually available yet.

This software builds on ideas from:

Documentation

Index

Constants

View Source
const PracticeEnvironment = "fxpractice"
View Source
const TradeEnvironment = "fxtrade"

Variables

View Source
var ValidCandlestickGranularities []string = []string{
	"S5",
	"S10",
	"S15",
	"S30",
	"M1",
	"M2",
	"M4",
	"M5",
	"M10",
	"M15",
	"M30",
	"H1",
	"H2",
	"H3",
	"H4",
	"H6",
	"H8",
	"H12",
	"D",
	"W",
	"M",
}

From http://developer.oanda.com/rest-live-v20/instrument-df/#CandlestickGranularity

Functions

This section is empty.

Types

type Candle

type Candle struct {
	Open  float64 `json:"o,string"`
	Close float64 `json:"c,string"`
	Low   float64 `json:"l,string"`
	High  float64 `json:"h,string"`
}

type CandleRequest

type CandleRequest struct {
	Price             string
	Granularity       string
	Count             int
	From              time.Time
	To                time.Time
	Smooth            bool
	IncludeFirst      bool
	DailyAlignment    int
	AlignmentTimezone string
	WeeklyAlignment   string
}

func DefaultCandleRequest

func DefaultCandleRequest() *CandleRequest

type Candles

type Candles struct {
	Complete bool      `json:"complete"`
	Volume   int       `json:"volume"`
	Time     time.Time `json:"time"`
	Mid      Candle    `json:"mid"`
	Bid      Candle    `json:"bid"`
	Ask      Candle    `json:"ask"`
}

type Client

type Client struct {
	Token string

	StreamChunkSize      int
	StreamTimeoutSeconds int

	Agent string

	// "RFC3339" or "UNIX"
	DatetimeFormat string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(accessToken string, environment string,
	streaming bool, timeoutSeconds int, keepAliveSeconds int) (*Client, error)

func (*Client) GET

func (s *Client) GET(urlPath string) ([]byte, error)

func (*Client) GetInstrumentCandles

func (s *Client) GetInstrumentCandles(instrument string, cr *CandleRequest) (*InstrumentCandles, error)

func (*Client) GetInstrumentCandlesBytes

func (s *Client) GetInstrumentCandlesBytes(instrument string, cr *CandleRequest) ([]byte, error)

type InstrumentCandles

type InstrumentCandles struct {
	Instrument  string    `json:"instrument"`
	Granularity string    `json:"granularity"`
	Candles     []Candles `json:"candles"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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