Documentation
¶
Index ¶
- Constants
- type Account
- type AccountCreateEvent
- func (t *AccountCreateEvent) AccountId() int
- func (t *AccountCreateEvent) HomeCurrency() string
- func (t *AccountCreateEvent) Reason() string
- func (t *AccountCreateEvent) String() string
- func (t *AccountCreateEvent) Time() time.Time
- func (t *AccountCreateEvent) TranId() int
- func (t *AccountCreateEvent) Type() string
- func (t *AccountCreateEvent) UnmarshalJSON(data []byte) (err error)
- type AlignmentTimezone
- type ApiError
- type BidAskCandles
- type CalendarEvent
- type CancelOrderResponse
- type CandlesArg
- type Client
- func (c *Client) Account(accountId int) (*Account, error)
- func (c *Client) Accounts() ([]Account, error)
- func (c *Client) Calendar(instrument string, period Period) ([]CalendarEvent, error)
- func (c *Client) CancelOrder(orderId int) (*CancelOrderResponse, error)
- func (c *Client) CancelRequest(req *http.Request)
- func (c *Client) ClosePosition(instrument string) (*PositionCloseResponse, error)
- func (c *Client) CloseTrade(tradeId int) (*CloseTradeResponse, error)
- func (c *Client) FullEventHistory() (*url.URL, error)
- func (c *Client) Instruments(instruments []string, fields []InstrumentField) (map[string]InstrumentInfo, error)
- func (c *Client) ModifyOrder(orderId int, arg ModifyOrderArg, args ...ModifyOrderArg) (*Order, error)
- func (c *Client) ModifyTrade(tradeId int, arg ModifyTradeArg, args ...ModifyTradeArg) (*Trade, error)
- func (c *Client) NewEventServer(accountId ...int) (*EventServer, error)
- func (c *Client) NewOrder(orderType OrderType, side TradeSide, units int, instrument string, ...) (*Order, error)
- func (c *Client) NewPricePoller(since time.Time, instr string, instrs ...string) (*PricePoller, error)
- func (c *Client) NewPriceServer(instr string, instrs ...string) (*PriceServer, error)
- func (c *Client) NewRequest(method, urlStr string, body io.Reader) (*http.Request, error)
- func (c *Client) NewTrade(side TradeSide, units int, instrument string, args ...NewTradeArg) (*Trade, error)
- func (c *Client) Order(orderId int) (*Order, error)
- func (c *Client) Orders(args ...OrdersArg) ([]Order, error)
- func (c *Client) PollBidAskCandles(instrument string, granularity Granularity, args ...CandlesArg) (*BidAskCandles, error)
- func (c *Client) PollEvent(tranId int) (Event, error)
- func (c *Client) PollEvents(args ...EventsArg) ([]Event, error)
- func (c *Client) PollMidpointCandles(instrument string, granularity Granularity, args ...CandlesArg) (*MidpointCandles, error)
- func (c *Client) PollPrices(instrument string, instruments ...string) (Prices, error)
- func (c *Client) PollPricesSince(since time.Time, instr string, instrs ...string) (Prices, error)
- func (c *Client) Position(instrument string) (*Position, error)
- func (c *Client) Positions() (Positions, error)
- func (c *Client) SelectAccount(accountId int)
- func (c *Client) Trade(tradeId int) (*Trade, error)
- func (c *Client) Trades(args ...TradesArg) (Trades, error)
- type CloseTradeResponse
- type ContentType
- type Count
- type DailyAlignment
- type DailyInterestEvent
- func (t *DailyInterestEvent) AccountId() int
- func (t *DailyInterestEvent) Interest() float64
- func (t *DailyInterestEvent) String() string
- func (t *DailyInterestEvent) Time() time.Time
- func (t *DailyInterestEvent) TranId() int
- func (t *DailyInterestEvent) Type() string
- func (t *DailyInterestEvent) UnmarshalJSON(data []byte) (err error)
- type DateFormat
- type EndTime
- type Environment
- type Event
- type EventHandlerFunc
- type EventServer
- type EventsArg
- type Expiry
- type FeeEvent
- func (t *FeeEvent) AccountBalance() float64
- func (t *FeeEvent) AccountId() int
- func (t *FeeEvent) Amount() float64
- func (t *FeeEvent) Reason() string
- func (t *FeeEvent) String() string
- func (t *FeeEvent) Time() time.Time
- func (t *FeeEvent) TranId() int
- func (t *FeeEvent) Type() string
- func (t *FeeEvent) UnmarshalJSON(data []byte) (err error)
- type Granularity
- type HeartbeatHandlerFunc
- type Ids
- type IncludeFirst
- type Instrument
- type InstrumentField
- type InstrumentInfo
- type LowerBound
- type MaxId
- type MidpointCandles
- type MigrateTradeOpenEvent
- func (t *MigrateTradeOpenEvent) AccountId() int
- func (t *MigrateTradeOpenEvent) Instrument() string
- func (t *MigrateTradeOpenEvent) Price() float64
- func (t *MigrateTradeOpenEvent) Side() string
- func (t *MigrateTradeOpenEvent) StopLossPrice() float64
- func (t *MigrateTradeOpenEvent) String() string
- func (t *MigrateTradeOpenEvent) TakeProfitPrice() float64
- func (t *MigrateTradeOpenEvent) Time() time.Time
- func (t *MigrateTradeOpenEvent) TradeOpened() *evtTradeDetail
- func (t *MigrateTradeOpenEvent) TrailingStopLossDistance() float64
- func (t *MigrateTradeOpenEvent) TranId() int
- func (t *MigrateTradeOpenEvent) Type() string
- func (t *MigrateTradeOpenEvent) Units() int
- func (t *MigrateTradeOpenEvent) UnmarshalJSON(data []byte) (err error)
- type MinId
- type ModifyOrderArg
- type ModifyTradeArg
- type NewOrderArg
- type NewTradeArg
- type Order
- type OrderCancelEvent
- func (t *OrderCancelEvent) AccountId() int
- func (t *OrderCancelEvent) OrderId() int
- func (t *OrderCancelEvent) Reason() string
- func (t *OrderCancelEvent) String() string
- func (t *OrderCancelEvent) Time() time.Time
- func (t *OrderCancelEvent) TranId() int
- func (t *OrderCancelEvent) Type() string
- func (t *OrderCancelEvent) UnmarshalJSON(data []byte) (err error)
- type OrderCreateEvent
- func (t *OrderCreateEvent) AccountId() int
- func (t *OrderCreateEvent) Expiry() time.Time
- func (t *OrderCreateEvent) Instrument() string
- func (t *OrderCreateEvent) LowerBound() float64
- func (t *OrderCreateEvent) Price() float64
- func (t *OrderCreateEvent) Reason() string
- func (t *OrderCreateEvent) Side() string
- func (t *OrderCreateEvent) StopLossPrice() float64
- func (t *OrderCreateEvent) String() string
- func (t *OrderCreateEvent) TakeProfitPrice() float64
- func (t *OrderCreateEvent) Time() time.Time
- func (t *OrderCreateEvent) TrailingStopLossDistance() float64
- func (t *OrderCreateEvent) TranId() int
- func (t *OrderCreateEvent) Type() string
- func (t *OrderCreateEvent) Units() int
- func (t *OrderCreateEvent) UnmarshalJSON(data []byte) (err error)
- func (t *OrderCreateEvent) UpperBound() float64
- type OrderFilledEvent
- func (t *OrderFilledEvent) AccountId() int
- func (t *OrderFilledEvent) OrderId() int
- func (t *OrderFilledEvent) String() string
- func (t *OrderFilledEvent) Time() time.Time
- func (t *OrderFilledEvent) TranId() int
- func (t *OrderFilledEvent) Type() string
- func (t *OrderFilledEvent) UnmarshalJSON(data []byte) (err error)
- type OrderType
- type OrderUpdateEvent
- func (t *OrderUpdateEvent) AccountId() int
- func (t *OrderUpdateEvent) Instrument() string
- func (t *OrderUpdateEvent) LowerBound() float64
- func (t *OrderUpdateEvent) Reason() string
- func (t *OrderUpdateEvent) Side() string
- func (t *OrderUpdateEvent) StopLossPrice() float64
- func (t *OrderUpdateEvent) String() string
- func (t *OrderUpdateEvent) TakeProfitPrice() float64
- func (t *OrderUpdateEvent) Time() time.Time
- func (t *OrderUpdateEvent) TrailingStopLossDistance() float64
- func (t *OrderUpdateEvent) TranId() int
- func (t *OrderUpdateEvent) Type() string
- func (t *OrderUpdateEvent) Units() int
- func (t *OrderUpdateEvent) UnmarshalJSON(data []byte) (err error)
- func (t *OrderUpdateEvent) UpperBound() float64
- type OrdersArg
- type Period
- type PollRequest
- type Position
- type PositionCloseResponse
- type Positions
- type Price
- type PricePoller
- type PriceServer
- type PriceTick
- type Prices
- type SetMarginRateEvent
- func (t *SetMarginRateEvent) AccountId() int
- func (t *SetMarginRateEvent) Rate() float64
- func (t *SetMarginRateEvent) String() string
- func (t *SetMarginRateEvent) Time() time.Time
- func (t *SetMarginRateEvent) TranId() int
- func (t *SetMarginRateEvent) Type() string
- func (t *SetMarginRateEvent) UnmarshalJSON(data []byte) (err error)
- type StartTime
- type StopLoss
- type StreamHandler
- type StreamMessage
- type StreamServer
- type TakeProfit
- type TickHandlerFunc
- type TimedReader
- type TokenAuthenticator
- type Trade
- type TradeCloseEvent
- func (t *TradeCloseEvent) AccountBalance() float64
- func (t *TradeCloseEvent) AccountId() int
- func (t *TradeCloseEvent) Instrument() string
- func (t *TradeCloseEvent) Interest() float64
- func (t *TradeCloseEvent) Pl() float64
- func (t *TradeCloseEvent) Price() float64
- func (t *TradeCloseEvent) Side() string
- func (t *TradeCloseEvent) String() string
- func (t *TradeCloseEvent) Time() time.Time
- func (t *TradeCloseEvent) TradeId() int
- func (t *TradeCloseEvent) TranId() int
- func (t *TradeCloseEvent) Type() string
- func (t *TradeCloseEvent) Units() int
- func (t *TradeCloseEvent) UnmarshalJSON(data []byte) (err error)
- type TradeCreateEvent
- func (t *TradeCreateEvent) AccountBalance() float64
- func (t *TradeCreateEvent) AccountId() int
- func (t *TradeCreateEvent) Instrument() string
- func (t *TradeCreateEvent) Interest() float64
- func (t *TradeCreateEvent) LowerBound() float64
- func (t *TradeCreateEvent) Pl() float64
- func (t *TradeCreateEvent) Price() float64
- func (t *TradeCreateEvent) Side() string
- func (t *TradeCreateEvent) StopLossPrice() float64
- func (t *TradeCreateEvent) String() string
- func (t *TradeCreateEvent) TakeProfitPrice() float64
- func (t *TradeCreateEvent) Time() time.Time
- func (t *TradeCreateEvent) TradeOpened() *evtTradeDetail
- func (t *TradeCreateEvent) TradeReduced() *evtTradeDetail
- func (t *TradeCreateEvent) TrailingStopLossDistance() float64
- func (t *TradeCreateEvent) TranId() int
- func (t *TradeCreateEvent) Type() string
- func (t *TradeCreateEvent) Units() int
- func (t *TradeCreateEvent) UnmarshalJSON(data []byte) (err error)
- func (t *TradeCreateEvent) UpperBound() float64
- type TradeSide
- type TradeUpdateEvent
- func (t *TradeUpdateEvent) AccountId() int
- func (t *TradeUpdateEvent) Instrument() string
- func (t *TradeUpdateEvent) Side() string
- func (t *TradeUpdateEvent) StopLossPrice() float64
- func (t *TradeUpdateEvent) String() string
- func (t *TradeUpdateEvent) TailingStopLossDistance() float64
- func (t *TradeUpdateEvent) TakeProfitPrice() float64
- func (t *TradeUpdateEvent) Time() time.Time
- func (t *TradeUpdateEvent) TradeId() int
- func (t *TradeUpdateEvent) TranId() int
- func (t *TradeUpdateEvent) Type() string
- func (t *TradeUpdateEvent) Units() int
- func (t *TradeUpdateEvent) UnmarshalJSON(data []byte) (err error)
- type Trades
- type TradesArg
- type TrailingStop
- type TransferFundsEvent
- func (t *TransferFundsEvent) AccountId() int
- func (t *TransferFundsEvent) Amount() float64
- func (t *TransferFundsEvent) String() string
- func (t *TransferFundsEvent) Time() time.Time
- func (t *TransferFundsEvent) TranId() int
- func (t *TransferFundsEvent) Type() string
- func (t *TransferFundsEvent) UnmarshalJSON(data []byte) (err error)
- type Units
- type UpperBound
- type UsernameAuthenticator
- type WeeklyAlignment
Constants ¶
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { AccountId int `json:"accountId"` Name string `json:"accountName"` Balance float64 `json:"balance"` UnrealizedPl float64 `json:"unrealizedPl"` RealizedPl float64 `json:"realizedPl"` MarginUsed float64 `json:"marginUsed"` MarginAvailable float64 `json:"marginAvailable"` OpenTrades int `json:"openTrades"` OpenOrders int `json:"openOrders"` Currency string `json:"accountCurrency"` MarginRate float64 `json:"marginRate"` PropertyName []string `json:"accountPropertyName"` }
Account represents an Oanda account.
type AccountCreateEvent ¶
type AccountCreateEvent struct {
// contains filtered or unexported fields
}
AccountCreateEvent represents an event of type CREATE.
func (*AccountCreateEvent) HomeCurrency ¶
func (t *AccountCreateEvent) HomeCurrency() string
func (*AccountCreateEvent) Reason ¶
func (t *AccountCreateEvent) Reason() string
func (*AccountCreateEvent) String ¶
func (t *AccountCreateEvent) String() string
String implementes the fmt.Stringer interface.
func (*AccountCreateEvent) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type AlignmentTimezone ¶
Optional argument for PollMidpriceCandles and PollBidAskCandles that indicates the timezone to use when aligning candles with DailyAlignment.
See http://developer.oanda.com/docs/v1/rates/#retrieve-instrument-history for further information.
type ApiError ¶
type ApiError struct { Code int `json:"code"` Message string `json:"message"` MoreInfo string `json:"moreInfo"` }
ApiError holds error details as returned by the Oanda servers.
type BidAskCandles ¶
type BidAskCandles struct { Instrument string `json:"instrument"` Granularity Granularity `json:"granularity"` Candles []struct { Time time.Time `json:"time"` OpenBid float64 `json:"openBid"` OpenAsk float64 `json:"openAsk"` HighBid float64 `json:"highBid"` HighAsk float64 `json:"highAsk"` LowBid float64 `json:"lowBid"` LowAsk float64 `json:"lowAsk"` CloseBid float64 `json:"closeBid"` CloseAsk float64 `json:"closeAsk"` Volume int `json:"volume"` Complete bool `json:"complete"` } `json:"candles"` }
BidAskCandles represents Bid and Ask instrument history with a specific granularity.
type CalendarEvent ¶
type CalendarEvent struct { Title string `json:"title"` Timestamp time.Time `json:"timestamp"` Unit string `json:"unit"` Currency string `json:"currency"` Forecast float64 `json:"forecast,string"` Previous float64 `json:"previous,string"` Actual float64 `json:"actual,string"` Market float64 `json:"market,string"` }
func (*CalendarEvent) UnmarshalJSON ¶
func (ce *CalendarEvent) UnmarshalJSON(data []byte) error
type CancelOrderResponse ¶
type CandlesArg ¶
type CandlesArg interface {
// contains filtered or unexported methods
}
CandlesArg implements optional arguments for MidpointCandles and BidAskCandles.
type Client ¶
func NewFxPracticeClient ¶
NewFxPracticeClient returns a client instance that connects to Oanda's fxpractice environment. String token should be set to the generated personal access token.
See http://developer.oanda.com/docs/v1/auth/ for further information.
func NewFxTradeClient ¶
NewFxTradeClient returns a client instance that connects to Oanda's fxtrade environment. String token should be set to the generated personal access token.
See http://developer.oanda.com/docs/v1/auth/ for further information.
func NewSandboxClient ¶
NewSandboxClient returns a client instance that connects to Oanda's fxsandbox environment. Creating a client will create a user in the sandbox environment with wich all further calls with be authenticated.
See http://developer.oanda.com/docs/v1/auth/ for further information.
func (*Client) Account ¶
Account queries the Oanda servers for account information for the specified accountId and returns a new Account instance.
func (*Client) Calendar ¶
func (c *Client) Calendar(instrument string, period Period) ([]CalendarEvent, error)
func (*Client) CancelOrder ¶
func (c *Client) CancelOrder(orderId int) (*CancelOrderResponse, error)
CancelOrder closes an open order.
func (*Client) CancelRequest ¶
CancelRequest aborts an in-progress http request.
func (*Client) ClosePosition ¶
func (c *Client) ClosePosition(instrument string) (*PositionCloseResponse, error)
ClosePosition closes an existing position.
func (*Client) CloseTrade ¶
func (c *Client) CloseTrade(tradeId int) (*CloseTradeResponse, error)
CloseTrade closes an open trade.
func (*Client) FullEventHistory ¶
FullEventHistory returns a url from which a file containing the full transaction history for the account can be downloaded.
func (*Client) Instruments ¶
func (c *Client) Instruments(instruments []string, fields []InstrumentField) (map[string]InstrumentInfo, error)
Instruments returns instrument information. Only the specified instruments are returned if instruments is not nil. If fields is not nil additional information fields is included.
See http://developer.oanda.com/docs/v1/rates/#get-an-instrument-list for further information.
func (*Client) ModifyOrder ¶
func (c *Client) ModifyOrder(orderId int, arg ModifyOrderArg, args ...ModifyOrderArg) (*Order, error)
ModifyOrder updates an open order. Supported arguments are Units(), Price(), Expiry(), UpperBound(), StopLoss(), TakeProfit() and TrailingStop().
func (*Client) ModifyTrade ¶
func (c *Client) ModifyTrade(tradeId int, arg ModifyTradeArg, args ...ModifyTradeArg) (*Trade, error)
ModifyTrade modifies an open trade. Supported optional arguments are StopLoss(), TakeProfit(), TrailingStop()
func (*Client) NewEventServer ¶
func (c *Client) NewEventServer(accountId ...int) (*EventServer, error)
NewEventServer returns an server instance for receiving events for the specified accountId(s). If no accountId is specified events for all accountIds are received. Note that the sandbox environment requires that at least one accountId is provided.
See http://developer.oanda.com/docs/v1/stream/#events-streaming for further information.
func (*Client) NewOrder ¶
func (c *Client) NewOrder(orderType OrderType, side TradeSide, units int, instrument string, price float64, expiry time.Time, args ...NewOrderArg) (*Order, error)
NewOrder creates and submits a new order.
func (*Client) NewPricePoller ¶
func (c *Client) NewPricePoller(since time.Time, instr string, instrs ...string) (*PricePoller, error)
NewPricePoller returns a poller to repeatedly poll Oanda for updates of the same set of instruments.
func (*Client) NewPriceServer ¶
func (c *Client) NewPriceServer(instr string, instrs ...string) (*PriceServer, error)
NewPriceServer returns a PriceServer instance for receiving and handling Ticks.
func (*Client) NewRequest ¶
NewRequest creates a new http request.
func (*Client) NewTrade ¶
func (c *Client) NewTrade(side TradeSide, units int, instrument string, args ...NewTradeArg) (*Trade, error)
NewTrade submits a MarketOrder request to the Oanda servers. Supported OptionalArgs are UpperBound(), LowerBound(), StopLoss(), TakeProfit() and TrailingStop().
func (*Client) Orders ¶
Orders returns an array with all orders that match the optional arguments (if any). Supported OrdersArg are MaxId, Count and Instrument.
func (*Client) PollBidAskCandles ¶
func (c *Client) PollBidAskCandles(instrument string, granularity Granularity, args ...CandlesArg) (*BidAskCandles, error)
PollBidAskCandles returns historic bid- and ask prices for an instrument.
func (*Client) PollEvents ¶
PollEvents returns an array of events. Supported optional arguments are MaxId, MinId, Count, Instrument and Ids.
See http://developer.oanda.com/docs/v1/transactions/#get-transaction-history for further information.
func (*Client) PollMidpointCandles ¶
func (c *Client) PollMidpointCandles(instrument string, granularity Granularity, args ...CandlesArg) (*MidpointCandles, error)
PollMidpointCandles returns historic midpoint prices for an instrument.
func (*Client) PollPrices ¶
PollPrices returns the latest PriceTick for the specified instruments.
func (*Client) PollPricesSince ¶
PollPricesSince returns the PriceTicks for instruments. If since is not the zero time instruments whose prices were not updated since the requested time.Time are excluded from the result.
func (*Client) SelectAccount ¶
SelectAccount configures the account for which subsequent trades and orders are. Use AccountId 0 to disable account selection.
type CloseTradeResponse ¶
type ContentType ¶
type ContentType string
type Count ¶
type Count int
Count is an optional argument for Client methods Events(), Orders(), /MidpriceCandles(), BidAskCandles() and Trades().
type DailyAlignment ¶
type DailyAlignment int
Optional argument for PollMidpriceCandles and PollBidAskCandles to indicate the hour at which candles hould be aligned. Only relevant for hourly or greater granularities.
See http://developer.oanda.com/docs/v1/rates/#retrieve-instrument-history for further information.
type DailyInterestEvent ¶
type DailyInterestEvent struct {
// contains filtered or unexported fields
}
DailyInterestEvent represents an event of type DAILY_INTEREST.
func (*DailyInterestEvent) Interest ¶
func (t *DailyInterestEvent) Interest() float64
func (*DailyInterestEvent) String ¶
func (t *DailyInterestEvent) String() string
String implementes the fmt.Stringer interface.
func (*DailyInterestEvent) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type DateFormat ¶
type DateFormat string
type EndTime ¶
Optional argument for PollMidpriceCandles and PollBidAskCandles to specify the end time of until which instrument history should be included.
See http://developer.oanda.com/docs/v1/rates/#retrieve-instrument-history for further information.
type Environment ¶
type Environment string
type EventHandlerFunc ¶
type EventServer ¶
type EventServer struct { // If HeartbeatFunc is not nil it is invoked once for every heartbeat message that the // EventServer receives. HeartbeatFunc HeartbeatHandlerFunc // contains filtered or unexported fields }
An EventServer receives events (aka transactions) for one or more accountId(s).
func (*EventServer) ConnectAndHandle ¶
func (es *EventServer) ConnectAndHandle(handleFn EventHandlerFunc) (err error)
ConnectAndDispatch starts the event server and blocks until Stop() is called. Function handleFn is called for each event that is received.
See http://developer.oanda.com/docs/v1/stream/ and http://developer.oanda.com/docs/v1/transactions/ for further information.
func (*EventServer) Stop ¶
func (es *EventServer) Stop()
Stop terminates the events server and causes ConnectAndHandle() to return.
type EventsArg ¶
type EventsArg interface {
// contains filtered or unexported methods
}
EventsArg is an optional argument for method PollEvents.
type FeeEvent ¶
type FeeEvent struct {
// contains filtered or unexported fields
}
FeeEvent represents an event of type FEE
func (*FeeEvent) AccountBalance ¶
func (*FeeEvent) String ¶
func (t *FeeEvent) String() string
String implementes the fmt.Stringer interface.
func (*FeeEvent) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Granularity ¶
type Granularity string
Granularity determines the interval at which historic instrument prices are converted into candles.
const ( S5 Granularity = "S5" S10 Granularity = "S10" S15 Granularity = "S15" S30 Granularity = "S30" M1 Granularity = "M1" M2 Granularity = "M2" M3 Granularity = "M3" M5 Granularity = "M5" M10 Granularity = "M10" M15 Granularity = "M15" M30 Granularity = "M30" H1 Granularity = "H1" H2 Granularity = "H2" H3 Granularity = "H3" H4 Granularity = "H4" H6 Granularity = "H6" H8 Granularity = "H8" H12 Granularity = "H12" D Granularity = "D" W Granularity = "W" M Granularity = "M" )
type HeartbeatHandlerFunc ¶
type IncludeFirst ¶
type IncludeFirst bool
Optional argument for PollMidpriceCandles and PollBidAskCandles to indicate whether the candle that starts at StartTime should be included.
See http://developer.oanda.com/docs/v1/rates/#retrieve-instrument-history for further information.
type Instrument ¶
type Instrument string
Instrument is an optional argument for Client methods Events(), Orders() and Trades().
type InstrumentField ¶
type InstrumentField string
const ( DisplayNameField InstrumentField = "displayName" PipField InstrumentField = "pip" MaxTradeUnitsField InstrumentField = "maxTradeUnits" PrecisionField InstrumentField = "precision" MaxTrailingStopField InstrumentField = "maxTrailingStop" MinTrailingStopField InstrumentField = "minTrailingStop" MarginRateField InstrumentField = "marginRate" HaltedField InstrumentField = "halted" InterestRateField InstrumentField = "interestRate" )
type InstrumentInfo ¶
type InstrumentInfo struct { DisplayName string `json:"displayName"` Pip float64 `json:"pip,string"` MaxTradeUnits int `json:"maxTradeUnits"` Precision float64 `json:"precision"` MaxTrailingStop float64 `json:"maxTrailingStop"` MinTrailingStop float64 `json:"minTrailingStop"` MarginRate float64 `json:"marginRate"` Halted bool `json:"halted"` InterestRate map[string]struct { Bid float64 `json:"bid"` Ask float64 `json:"ask"` } `json:"interestRate"` }
func (*InstrumentInfo) String ¶
func (ii *InstrumentInfo) String() string
type LowerBound ¶
type LowerBound float64
LowerBound is an optional argument for Client methods NewOrder(), ModifyOrder() and NewTrade().
type MaxId ¶
type MaxId int
MaxId is an optional argument for Client methods Events(), Orders() and Trades().
type MidpointCandles ¶
type MidpointCandles struct { Instrument string `json:"instrument"` Granularity Granularity `json:"granularity"` Candles []struct { Time time.Time `json:"time"` OpenMid float64 `json:"openMid"` HighMid float64 `json:"highMid"` LowMid float64 `json:"lowMid"` CloseMid float64 `json:"closeMid"` Volume int `json:"volume"` Complete bool `json:"complete"` } `json:"candles"` }
MidpointCandles represents instrument history with a specific granularity.
type MigrateTradeOpenEvent ¶
type MigrateTradeOpenEvent struct {
// contains filtered or unexported fields
}
MigrateTradeOpenEvent represents an event of type MIGRATE_TRADE_OPEN
func (*MigrateTradeOpenEvent) Instrument ¶
func (t *MigrateTradeOpenEvent) Instrument() string
func (*MigrateTradeOpenEvent) Price ¶
func (t *MigrateTradeOpenEvent) Price() float64
func (*MigrateTradeOpenEvent) Side ¶
func (t *MigrateTradeOpenEvent) Side() string
func (*MigrateTradeOpenEvent) StopLossPrice ¶
func (t *MigrateTradeOpenEvent) StopLossPrice() float64
func (*MigrateTradeOpenEvent) String ¶
func (t *MigrateTradeOpenEvent) String() string
String implementes the fmt.Stringer interface.
func (*MigrateTradeOpenEvent) TakeProfitPrice ¶
func (t *MigrateTradeOpenEvent) TakeProfitPrice() float64
func (*MigrateTradeOpenEvent) TradeOpened ¶
func (t *MigrateTradeOpenEvent) TradeOpened() *evtTradeDetail
func (*MigrateTradeOpenEvent) TrailingStopLossDistance ¶
func (t *MigrateTradeOpenEvent) TrailingStopLossDistance() float64
func (*MigrateTradeOpenEvent) Units ¶
func (t *MigrateTradeOpenEvent) Units() int
func (*MigrateTradeOpenEvent) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type ModifyOrderArg ¶
type ModifyOrderArg interface {
// contains filtered or unexported methods
}
ModifyOrderArg represents an opional argument for method ModifyOrder. Types that implement the interface are Units, Price, Expiry, LowerBound, UpperBound, StopLoss, TakeProfit and TrailingStop.
type ModifyTradeArg ¶
type ModifyTradeArg interface {
// contains filtered or unexported methods
}
type NewOrderArg ¶
type NewOrderArg interface {
// contains filtered or unexported methods
}
NewOrderArg represents an optional argument for method NewOrder. Types that implement the interface are LowerBound, UpperBound, StopLoss, TakeProfit and TrailingStop.
type NewTradeArg ¶
type NewTradeArg interface {
// contains filtered or unexported methods
}
type Order ¶
type Order struct { OrderId int `json:"id"` Units int `json:"units"` Instrument string `json:"instrument"` Side string `json:"side"` Price float64 `json:"price"` Time time.Time `json:"time"` StopLoss float64 `json:"stopLoss"` TakeProfit float64 `json:"takeProfit"` TrailingStop float64 `json:"trailingStop"` TrailingAmount float64 `json:"trailingAmount"` OrderType string `json:"type"` Expiry time.Time `json:"expiry"` UpperBound float64 `json:"upperBound"` LowerBound float64 `json:"lowerBound"` }
type OrderCancelEvent ¶
type OrderCancelEvent struct {
// contains filtered or unexported fields
}
OrderCancelEvent represents and event of type ORDER_CANCEL.
func (*OrderCancelEvent) OrderId ¶
func (t *OrderCancelEvent) OrderId() int
func (*OrderCancelEvent) Reason ¶
func (t *OrderCancelEvent) Reason() string
func (*OrderCancelEvent) String ¶
func (t *OrderCancelEvent) String() string
String implementes the fmt.Stringer interface.
func (*OrderCancelEvent) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type OrderCreateEvent ¶
type OrderCreateEvent struct {
// contains filtered or unexported fields
}
OrderCreateEvent represents an event of type LIMIT_ORDER_CREATE, STOP_ORDER_CREATE or MARKET_IF_TOUCHED_CREATE
func (*OrderCreateEvent) Expiry ¶
func (t *OrderCreateEvent) Expiry() time.Time
func (*OrderCreateEvent) Instrument ¶
func (t *OrderCreateEvent) Instrument() string
func (*OrderCreateEvent) LowerBound ¶
func (t *OrderCreateEvent) LowerBound() float64
func (*OrderCreateEvent) Price ¶
func (t *OrderCreateEvent) Price() float64
func (*OrderCreateEvent) Reason ¶
func (t *OrderCreateEvent) Reason() string
func (*OrderCreateEvent) Side ¶
func (t *OrderCreateEvent) Side() string
func (*OrderCreateEvent) StopLossPrice ¶
func (t *OrderCreateEvent) StopLossPrice() float64
func (*OrderCreateEvent) String ¶
func (t *OrderCreateEvent) String() string
String implementes the fmt.Stringer interface.
func (*OrderCreateEvent) TakeProfitPrice ¶
func (t *OrderCreateEvent) TakeProfitPrice() float64
func (*OrderCreateEvent) TrailingStopLossDistance ¶
func (t *OrderCreateEvent) TrailingStopLossDistance() float64
func (*OrderCreateEvent) Units ¶
func (t *OrderCreateEvent) Units() int
func (*OrderCreateEvent) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
func (*OrderCreateEvent) UpperBound ¶
func (t *OrderCreateEvent) UpperBound() float64
type OrderFilledEvent ¶
type OrderFilledEvent struct {
// contains filtered or unexported fields
}
OrderFilledEvent represents an event of type ORDER_FILLED.
func (*OrderFilledEvent) OrderId ¶
func (t *OrderFilledEvent) OrderId() int
func (*OrderFilledEvent) String ¶
func (t *OrderFilledEvent) String() string
String implementes the fmt.Stringer interface.
func (*OrderFilledEvent) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type OrderUpdateEvent ¶
type OrderUpdateEvent struct {
// contains filtered or unexported fields
}
OrderUpdateEvent represents an event of type ORDER_UPDATE
func (*OrderUpdateEvent) Instrument ¶
func (t *OrderUpdateEvent) Instrument() string
func (*OrderUpdateEvent) LowerBound ¶
func (t *OrderUpdateEvent) LowerBound() float64
func (*OrderUpdateEvent) Reason ¶
func (t *OrderUpdateEvent) Reason() string
func (*OrderUpdateEvent) Side ¶
func (t *OrderUpdateEvent) Side() string
func (*OrderUpdateEvent) StopLossPrice ¶
func (t *OrderUpdateEvent) StopLossPrice() float64
func (*OrderUpdateEvent) String ¶
func (t *OrderUpdateEvent) String() string
String implementes the fmt.Stringer interface.
func (*OrderUpdateEvent) TakeProfitPrice ¶
func (t *OrderUpdateEvent) TakeProfitPrice() float64
func (*OrderUpdateEvent) TrailingStopLossDistance ¶
func (t *OrderUpdateEvent) TrailingStopLossDistance() float64
func (*OrderUpdateEvent) Units ¶
func (t *OrderUpdateEvent) Units() int
func (*OrderUpdateEvent) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
func (*OrderUpdateEvent) UpperBound ¶
func (t *OrderUpdateEvent) UpperBound() float64
type OrdersArg ¶
type OrdersArg interface {
// contains filtered or unexported methods
}
OrderArgs represents an optional argument for method Orders. Types that implement the interface are MaxId, Count and Instrument.
type PollRequest ¶
type PollRequest struct {
// contains filtered or unexported fields
}
PollRequest represents an http request that is executed repeatedly.
type Position ¶
type PositionCloseResponse ¶
type PricePoller ¶
type PricePoller struct {
// contains filtered or unexported fields
}
func (*PricePoller) Poll ¶
func (pp *PricePoller) Poll() (Prices, error)
Poll returns the most recent set of prices for the instruments with which the PricePoller was configured.
type PriceServer ¶
type PriceServer struct { // If HeartbeatFunc is not nil it is invoked once for every heartbeat message that the // PriceServer receives. HeartbeatFunc HeartbeatHandlerFunc // contains filtered or unexported fields }
A PriceServer receives PriceTicks for one or more instrument(s).
func (*PriceServer) ConnectAndHandle ¶
func (ps *PriceServer) ConnectAndHandle(handleFn TickHandlerFunc) error
ConnectAndHandle connects to the Oanda server and invokes handleFn for every Tick received.
type PriceTick ¶
type PriceTick struct { Time time.Time `json:"time"` Bid float64 `json:"bid"` Ask float64 `json:"ask"` Status string `json:"status"` }
PriceTick holds the Bid price, Ask price and status for an instrument at a given point in time
type SetMarginRateEvent ¶
type SetMarginRateEvent struct {
// contains filtered or unexported fields
}
SetMarginRateEvent represent and event of type SET_MARGIN_RATE.
func (*SetMarginRateEvent) Rate ¶
func (t *SetMarginRateEvent) Rate() float64
func (*SetMarginRateEvent) String ¶
func (t *SetMarginRateEvent) String() string
String implementes the fmt.Stringer interface.
func (*SetMarginRateEvent) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type StartTime ¶
Optional argument for PollMidpriceCandles and PollBidAskCandles to specify the start time from which instrument history should be included.
See http://developer.oanda.com/docs/v1/rates/#retrieve-instrument-history for further information.
type StopLoss ¶
type StopLoss float64
StopLoss is an optional argument for Client methods NewOrder(), ModifyOrder(), NewTrade() and ModifyTrade().
type StreamHandler ¶
type StreamHandler interface { HandleHeartbeats(<-chan time.Time) HandleMessages(<-chan StreamMessage) }
type StreamMessage ¶
type StreamMessage struct { Type string RawMessage json.RawMessage }
func (*StreamMessage) String ¶
func (msg *StreamMessage) String() string
func (*StreamMessage) UnmarshalJSON ¶
func (msg *StreamMessage) UnmarshalJSON(data []byte) error
type StreamServer ¶
type StreamServer struct {
// contains filtered or unexported fields
}
func (StreamServer) HandleHeartbeats ¶
func (ss StreamServer) HandleHeartbeats(hbC <-chan time.Time)
func (StreamServer) HandleMessages ¶
func (ss StreamServer) HandleMessages(msgC <-chan StreamMessage)
type TakeProfit ¶
type TakeProfit float64
TakeProfit is an optional argument for Client methods NewOrder(), ModifyOrder(), NewTrade(), and ModifyTrade().
type TickHandlerFunc ¶
type TimedReader ¶
type TimedReader struct { Timeout time.Duration io.ReadCloser // contains filtered or unexported fields }
func NewTimedReader ¶
func NewTimedReader(r io.ReadCloser, timeout time.Duration) *TimedReader
NewTimedReader returns an instance of TimedReader where Read operations time out.
type TokenAuthenticator ¶
type TokenAuthenticator string
type Trade ¶
type Trade struct { TradeId int `json:"id"` Units int `json:"units"` Instrument string `json:"instrument"` Side string `json:"side"` Price float64 `json:"price"` Time time.Time `json:"time"` StopLoss float64 `json:"stopLoss"` TakeProfit float64 `json:"takeProfit"` TrailingStop float64 `json:"trailingStop"` TrailingAmount float64 `json:"trailingAmount"` }
Trade represents an open Oanda trade.
type TradeCloseEvent ¶
type TradeCloseEvent struct {
// contains filtered or unexported fields
}
TradeCloseEvent represents an event of type TRADE_CLOSE, MIGRATE_TRADE_CLOSE, TAKE_PROFIT_FILLED, STOP_LOSS_FILLED, TRAILING_STOP_FILLED or MARGIN_CLOSEOUT.
func (*TradeCloseEvent) AccountBalance ¶
func (t *TradeCloseEvent) AccountBalance() float64
func (*TradeCloseEvent) Instrument ¶
func (t *TradeCloseEvent) Instrument() string
func (*TradeCloseEvent) Interest ¶
func (t *TradeCloseEvent) Interest() float64
func (*TradeCloseEvent) Pl ¶
func (t *TradeCloseEvent) Pl() float64
func (*TradeCloseEvent) Price ¶
func (t *TradeCloseEvent) Price() float64
func (*TradeCloseEvent) Side ¶
func (t *TradeCloseEvent) Side() string
func (*TradeCloseEvent) String ¶
func (t *TradeCloseEvent) String() string
String implementes the fmt.Stringer interface.
func (*TradeCloseEvent) TradeId ¶
func (t *TradeCloseEvent) TradeId() int
func (*TradeCloseEvent) Units ¶
func (t *TradeCloseEvent) Units() int
func (*TradeCloseEvent) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type TradeCreateEvent ¶
type TradeCreateEvent struct {
// contains filtered or unexported fields
}
TradeCreateEvent represents an event of type MARKET_ORDER_CREATE
func (*TradeCreateEvent) AccountBalance ¶
func (t *TradeCreateEvent) AccountBalance() float64
func (*TradeCreateEvent) Instrument ¶
func (t *TradeCreateEvent) Instrument() string
func (*TradeCreateEvent) Interest ¶
func (t *TradeCreateEvent) Interest() float64
func (*TradeCreateEvent) LowerBound ¶
func (t *TradeCreateEvent) LowerBound() float64
func (*TradeCreateEvent) Pl ¶
func (t *TradeCreateEvent) Pl() float64
func (*TradeCreateEvent) Price ¶
func (t *TradeCreateEvent) Price() float64
func (*TradeCreateEvent) Side ¶
func (t *TradeCreateEvent) Side() string
func (*TradeCreateEvent) StopLossPrice ¶
func (t *TradeCreateEvent) StopLossPrice() float64
func (*TradeCreateEvent) String ¶
func (t *TradeCreateEvent) String() string
String implementes the fmt.Stringer interface.
func (*TradeCreateEvent) TakeProfitPrice ¶
func (t *TradeCreateEvent) TakeProfitPrice() float64
func (*TradeCreateEvent) TradeOpened ¶
func (t *TradeCreateEvent) TradeOpened() *evtTradeDetail
func (*TradeCreateEvent) TradeReduced ¶
func (t *TradeCreateEvent) TradeReduced() *evtTradeDetail
func (*TradeCreateEvent) TrailingStopLossDistance ¶
func (t *TradeCreateEvent) TrailingStopLossDistance() float64
func (*TradeCreateEvent) Units ¶
func (t *TradeCreateEvent) Units() int
func (*TradeCreateEvent) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
func (*TradeCreateEvent) UpperBound ¶
func (t *TradeCreateEvent) UpperBound() float64
type TradeUpdateEvent ¶
type TradeUpdateEvent struct {
// contains filtered or unexported fields
}
TradeUpdateEvent represents an event of type TRADE_UPDATE
func (*TradeUpdateEvent) Instrument ¶
func (t *TradeUpdateEvent) Instrument() string
func (*TradeUpdateEvent) Side ¶
func (t *TradeUpdateEvent) Side() string
func (*TradeUpdateEvent) StopLossPrice ¶
func (t *TradeUpdateEvent) StopLossPrice() float64
func (*TradeUpdateEvent) String ¶
func (t *TradeUpdateEvent) String() string
String implementes the fmt.Stringer interface.
func (*TradeUpdateEvent) TailingStopLossDistance ¶
func (t *TradeUpdateEvent) TailingStopLossDistance() float64
func (*TradeUpdateEvent) TakeProfitPrice ¶
func (t *TradeUpdateEvent) TakeProfitPrice() float64
func (*TradeUpdateEvent) TradeId ¶
func (t *TradeUpdateEvent) TradeId() int
func (*TradeUpdateEvent) Units ¶
func (t *TradeUpdateEvent) Units() int
func (*TradeUpdateEvent) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type TrailingStop ¶
type TrailingStop float64
TrailingStop is an optional argument for Client methods NewOrder(), ModifyOrder(), NewTrade() and ModifyTrade().
type TransferFundsEvent ¶
type TransferFundsEvent struct {
// contains filtered or unexported fields
}
TransferFundsEvent represents an event of type TRANSFER_FUNDS.
func (*TransferFundsEvent) Amount ¶
func (t *TransferFundsEvent) Amount() float64
func (*TransferFundsEvent) String ¶
func (t *TransferFundsEvent) String() string
String implementes the fmt.Stringer interface.
func (*TransferFundsEvent) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type UpperBound ¶
type UpperBound float64
UpperBound is an optional argument for Client methods NewOrder(), ModifyOrder() and NewTrade().
type UsernameAuthenticator ¶
type UsernameAuthenticator string
type WeeklyAlignment ¶
Optional argument for PollMidpriceCandles and PollBidAskCandles to indicate the weekday at which candles should be aligned. Only relevant for weekly granularity.
See http://developer.oanda.com/docs/v1/rates/#retrieve-instrument-history for further information.