Documentation
¶
Index ¶
- Constants
- func CheckErr(err error)
- type AccountChanges
- type AccountInfo
- type AccountInstruments
- type AccountProperties
- type AccountSummary
- type BidAskCandles
- type BrokerBook
- type Bucket
- type ByteStream
- type CancelledOrder
- type Candle
- type Candles
- type ClientPrice
- type ClosePositionPayload
- type CloseTradePayload
- type Connection
- type GetCandlesPayload
- type Headers
- type InstrumentHistory
- type InstrumentPricing
- type ModifiedTrade
- type OandaConnection
- func (c *OandaConnection) CancelOrder(orderSpecifier string) (CancelledOrder, error)
- func (c *OandaConnection) ClosePosition(instrument string, body ClosePositionPayload) (ModifiedTrade, error)
- func (c *OandaConnection) CreateOrder(body OrderPayload) (OrderResponse, error)
- func (c *OandaConnection) GetAccount(id string) (AccountInfo, error)
- func (c *OandaConnection) GetAccountChanges(id string, transactionID string) (AccountChanges, error)
- func (c *OandaConnection) GetAccountInstruments(id string) (AccountInstruments, error)
- func (c *OandaConnection) GetAccountSummary() (AccountSummary, error)
- func (c *OandaConnection) GetAccounts() (AccountProperties, error)
- func (c *OandaConnection) GetBidAskCandles(instrument string, candleSpec GetCandlesPayload) (BidAskCandles, error)
- func (c *OandaConnection) GetCandles(instrument string, candleSpec GetCandlesPayload) (InstrumentHistory, error)
- func (c *OandaConnection) GetInstrumentPrice(instruments string) (InstrumentPricing, error)
- func (c *OandaConnection) GetOpenPositions() (OpenPositions, error)
- func (c *OandaConnection) GetOpenTrades() (ReceivedTrades, error)
- func (c *OandaConnection) GetOrder(orderSpecifier string) (RetrievedOrder, error)
- func (c *OandaConnection) GetOrderDetails(instrument string, units string) (OrderDetails, error)
- func (c *OandaConnection) GetOrders(instrument string) (RetrievedOrders, error)
- func (c *OandaConnection) GetPendingOrders() (RetrievedOrders, error)
- func (c *OandaConnection) GetPricingForInstruments(instruments []string) (Pricings, error)
- func (c *OandaConnection) GetTrade(ticket string) (ReceivedTrade, error)
- func (c *OandaConnection) GetTradesForInstrument(instrument string) (ReceivedTrades, error)
- func (c *OandaConnection) GetTransaction(ticket string) (Transaction, error)
- func (c *OandaConnection) GetTransactions(from time.Time, to time.Time) (TransactionPages, error)
- func (c *OandaConnection) GetTransactionsSinceID(id string) (Transactions, error)
- func (c *OandaConnection) OrderBook(instrument string) (BrokerBook, error)
- func (c *OandaConnection) PositionBook(instrument string) (BrokerBook, error)
- func (c *OandaConnection) ReduceTradeSize(ticket string, body CloseTradePayload) (ModifiedTrade, error)
- func (c *OandaConnection) Request(endpoint string) ([]byte, error)
- func (c *OandaConnection) Send(endpoint string, data []byte) ([]byte, error)
- func (c *OandaConnection) Stream(endpoint string) (chan ByteStream, context.CancelFunc, error)
- func (c *OandaConnection) StreamPricing(instruments []string) (chan PricingStream, context.CancelFunc, error)
- func (c *OandaConnection) Update(endpoint string, data []byte) ([]byte, error)
- func (c *OandaConnection) UpdateOrder(orderSpecifier string, body OrderPayload) (RetrievedOrder, error)
- type OnFill
- type OpenPositions
- type OrderBody
- type OrderDetails
- type OrderExtensions
- type OrderInfo
- type OrderPayload
- type OrderResponse
- type PricingStream
- type Pricings
- type ReceivedTrade
- type ReceivedTrades
- type RetrievedOrder
- type RetrievedOrders
- type Transaction
- type TransactionPages
- type Transactions
Constants ¶
const OandaAgent string = "v20-golang/0.0.1"
OandaAgent http agent header
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccountChanges ¶
type AccountChanges struct {
Changes struct {
OrdersCancelled []interface{} `json:"ordersCancelled"`
OrdersCreated []interface{} `json:"ordersCreated"`
OrdersFilled []struct {
CreateTime time.Time `json:"createTime"`
FilledTime time.Time `json:"filledTime"`
FillingTransactionID string `json:"fillingTransactionID"`
ID string `json:"id"`
Instrument string `json:"instrument"`
PositionFill string `json:"positionFill"`
State string `json:"state"`
TimeInForce string `json:"timeInForce"`
TradeOpenedID string `json:"tradeOpenedID"`
Type string `json:"type"`
Units string `json:"units"`
} `json:"ordersFilled"`
OrdersTriggered []interface{} `json:"ordersTriggered"`
Positions []struct {
Instrument string `json:"instrument"`
Long struct {
Pl string `json:"pl"`
ResettablePL string `json:"resettablePL"`
Units string `json:"units"`
} `json:"long"`
Pl string `json:"pl"`
ResettablePL string `json:"resettablePL"`
Short struct {
AveragePrice string `json:"averagePrice"`
Pl string `json:"pl"`
ResettablePL string `json:"resettablePL"`
TradeIDs []string `json:"tradeIDs"`
Units string `json:"units"`
} `json:"short"`
} `json:"positions"`
TradesClosed []interface{} `json:"tradesClosed"`
TradesOpened []struct {
CurrentUnits string `json:"currentUnits"`
Financing string `json:"financing"`
ID string `json:"id"`
InitialUnits string `json:"initialUnits"`
Instrument string `json:"instrument"`
OpenTime time.Time `json:"openTime"`
Price string `json:"price"`
RealizedPL string `json:"realizedPL"`
State string `json:"state"`
} `json:"tradesOpened"`
TradesReduced []interface{} `json:"tradesReduced"`
Transactions []struct {
AccountID string `json:"accountID"`
BatchID string `json:"batchID"`
ID string `json:"id"`
Instrument string `json:"instrument"`
PositionFill string `json:"positionFill,omitempty"`
Reason string `json:"reason"`
Time time.Time `json:"time"`
TimeInForce string `json:"timeInForce,omitempty"`
Type string `json:"type"`
Units string `json:"units"`
UserID int `json:"userID"`
AccountBalance string `json:"accountBalance,omitempty"`
Financing string `json:"financing,omitempty"`
OrderID string `json:"orderID,omitempty"`
Pl string `json:"pl,omitempty"`
Price string `json:"price,omitempty"`
TradeOpened struct {
TradeID string `json:"tradeID"`
Units string `json:"units"`
} `json:"tradeOpened,omitempty"`
} `json:"transactions"`
} `json:"changes"`
LastTransactionID string `json:"lastTransactionID"`
State struct {
NAV string `json:"NAV"`
MarginAvailable string `json:"marginAvailable"`
MarginCloseoutMarginUsed string `json:"marginCloseoutMarginUsed"`
MarginCloseoutNAV string `json:"marginCloseoutNAV"`
MarginCloseoutPercent string `json:"marginCloseoutPercent"`
MarginCloseoutUnrealizedPL string `json:"marginCloseoutUnrealizedPL"`
MarginUsed string `json:"marginUsed"`
Orders []interface{} `json:"orders"`
PositionValue string `json:"positionValue"`
Positions []struct {
Instrument string `json:"instrument"`
LongUnrealizedPL string `json:"longUnrealizedPL"`
NetUnrealizedPL string `json:"netUnrealizedPL"`
ShortUnrealizedPL string `json:"shortUnrealizedPL"`
} `json:"positions"`
Trades []struct {
ID string `json:"id"`
UnrealizedPL string `json:"unrealizedPL"`
} `json:"trades"`
UnrealizedPL string `json:"unrealizedPL"`
WithdrawalLimit string `json:"withdrawalLimit"`
} `json:"state"`
}
AccountChanges https://developer.oanda.com/rest-live-v20/account-df/
type AccountInfo ¶
type AccountInfo struct {
Account struct {
NAV string `json:"NAV"`
Alias string `json:"alias"`
Balance string `json:"balance"`
CreatedByUserID int `json:"createdByUserID"`
CreatedTime time.Time `json:"createdTime"`
Currency string `json:"currency"`
HedgingEnabled bool `json:"hedgingEnabled"`
ID string `json:"id"`
LastTransactionID string `json:"lastTransactionID"`
MarginAvailable string `json:"marginAvailable"`
MarginCloseoutMarginUsed string `json:"marginCloseoutMarginUsed"`
MarginCloseoutNAV string `json:"marginCloseoutNAV"`
MarginCloseoutPercent string `json:"marginCloseoutPercent"`
MarginCloseoutPositionValue string `json:"marginCloseoutPositionValue"`
MarginCloseoutUnrealizedPL string `json:"marginCloseoutUnrealizedPL"`
MarginRate string `json:"marginRate"`
MarginUsed string `json:"marginUsed"`
OpenPositionCount int `json:"openPositionCount"`
OpenTradeCount int `json:"openTradeCount"`
Orders []interface{} `json:"orders"`
PendingOrderCount int `json:"pendingOrderCount"`
Pl string `json:"pl"`
PositionValue string `json:"positionValue"`
Positions []struct {
Instrument string `json:"instrument"`
Long struct {
Pl string `json:"pl"`
ResettablePL string `json:"resettablePL"`
Units string `json:"units"`
UnrealizedPL string `json:"unrealizedPL"`
} `json:"long"`
Pl string `json:"pl"`
ResettablePL string `json:"resettablePL"`
Short struct {
Pl string `json:"pl"`
ResettablePL string `json:"resettablePL"`
Units string `json:"units"`
UnrealizedPL string `json:"unrealizedPL"`
} `json:"short"`
UnrealizedPL string `json:"unrealizedPL"`
} `json:"positions"`
ResettablePL string `json:"resettablePL"`
Trades []interface{} `json:"trades"`
UnrealizedPL string `json:"unrealizedPL"`
WithdrawalLimit string `json:"withdrawalLimit"`
} `json:"account"`
LastTransactionID string `json:"lastTransactionID"`
}
AccountInfo https://developer.oanda.com/rest-live-v20/account-df/
type AccountInstruments ¶
type AccountInstruments struct {
Instruments []struct {
DisplayName string `json:"displayName"`
DisplayPrecision int `json:"displayPrecision"`
MarginRate string `json:"marginRate"`
MaximumOrderUnits string `json:"maximumOrderUnits"`
MaximumPositionSize string `json:"maximumPositionSize"`
MaximumTrailingStopDistance string `json:"maximumTrailingStopDistance"`
MinimumTradeSize string `json:"minimumTradeSize"`
MinimumTrailingStopDistance string `json:"minimumTrailingStopDistance"`
Name string `json:"name"`
PipLocation int `json:"pipLocation"`
TradeUnitsPrecision int `json:"tradeUnitsPrecision"`
Type string `json:"type"`
} `json:"instruments"`
}
AccountInstruments https://developer.oanda.com/rest-live-v20/primitives-df/#Instrument
type AccountProperties ¶
type AccountProperties struct {
Accounts []struct {
ID string `json:"id"`
Mt4AccountID int `json:"mt4AccountID"`
Tags []string
}
}
AccountProperties https://developer.oanda.com/rest-live-v20/account-df/
type AccountSummary ¶
type AccountSummary struct {
Account struct {
NAV string `json:"NAV"`
Alias string `json:"alias"`
Balance string `json:"balance"`
CreatedByUserID int `json:"createdByUserID"`
CreatedTime time.Time `json:"createdTime"`
Currency string `json:"currency"`
HedgingEnabled bool `json:"hedgingEnabled"`
ID string `json:"id"`
LastTransactionID string `json:"lastTransactionID"`
MarginAvailable string `json:"marginAvailable"`
MarginCloseoutMarginUsed string `json:"marginCloseoutMarginUsed"`
MarginCloseoutNAV string `json:"marginCloseoutNAV"`
MarginCloseoutPercent string `json:"marginCloseoutPercent"`
MarginCloseoutPositionValue string `json:"marginCloseoutPositionValue"`
MarginCloseoutUnrealizedPL string `json:"marginCloseoutUnrealizedPL"`
MarginRate string `json:"marginRate"`
MarginUsed string `json:"marginUsed"`
OpenPositionCount int `json:"openPositionCount"`
OpenTradeCount int `json:"openTradeCount"`
PendingOrderCount int `json:"pendingOrderCount"`
Pl string `json:"pl"`
PositionValue string `json:"positionValue"`
ResettablePL string `json:"resettablePL"`
UnrealizedPL string `json:"unrealizedPL"`
WithdrawalLimit string `json:"withdrawalLimit"`
} `json:"account"`
LastTransactionID string `json:"lastTransactionID"`
}
AccountSummary https://developer.oanda.com/rest-live-v20/account-df/
type BidAskCandles ¶
type BidAskCandles struct {
Candles []struct {
Ask struct {
C string `json:"c"`
H string `json:"h"`
L string `json:"l"`
O string `json:"o"`
} `json:"ask"`
Bid struct {
C string `json:"c"`
H string `json:"h"`
L string `json:"l"`
O string `json:"o"`
} `json:"bid"`
Complete bool `json:"complete"`
Time time.Time `json:"time"`
Volume int `json:"volume"`
} `json:"candles"`
}
BidAskCandles https://developer.oanda.com/rest-live-v20/instrument-df/
type BrokerBook ¶
type BrokerBook struct {
Instrument string `json:"instrument"`
Time time.Time `json:"time"`
Price string `json:"price"`
BucketWidth string `json:"bucketWidth"`
Buckets []Bucket `json:"buckets"`
}
BrokerBook https://developer.oanda.com/rest-live-v20/instrument-df/
type Bucket ¶
type Bucket struct {
Price string `json:"price"`
LongCountPercent string `json:"longCountPercent"`
ShortCountPercent string `json:"shortCountPercent"`
}
Bucket https://developer.oanda.com/rest-live-v20/instrument-df/
type ByteStream ¶
ByteStream streams a line of json encoded data or an error
type CancelledOrder ¶
type CancelledOrder struct {
OrderCancelTransaction struct {
ID string `json:"id"`
Time time.Time `json:"time"`
UserID int `json:"userID"`
AccountID string `json:"accountID"`
BatchID string `json:"batchID"`
RequestID string `json:"requestID"`
Type string `json:"type"`
OrderID string `json:"orderID"`
ClientOrderID string `json:"clientOrderID"`
Reason string `json:"reason"`
ReplacedByOrderID string `json:"replacedByOrderID"`
} `json:"orderCancelTransaction"`
RelatedTransactionIDs []string `json:"relatedTransactionIDs"`
LastTransactionID string `json:"lastTransactionID"`
}
CancelledOrder https://developer.oanda.com/rest-live-v20/order-df/
type Candle ¶
type Candle struct {
Open string `json:"o"`
Close string `json:"c"`
Low string `json:"l"`
High string `json:"h"`
}
Candle https://developer.oanda.com/rest-live-v20/instrument-df/
type Candles ¶
type Candles struct {
Complete bool `json:"complete"`
Volume int `json:"volume"`
Time time.Time `json:"time"`
Mid Candle `json:"mid"`
}
Candles https://developer.oanda.com/rest-live-v20/instrument-df/
type ClientPrice ¶
type ClientPrice struct {
Asks []struct {
Liquidity int `json:"liquidity"`
Price string `json:"price"`
} `json:"asks"`
Bids []struct {
Liquidity int `json:"liquidity"`
Price string `json:"price"`
} `json:"bids"`
CloseoutAsk string `json:"closeoutAsk"`
CloseoutBid string `json:"closeoutBid"`
Instrument string `json:"instrument"`
QuoteHomeConversionFactors struct {
NegativeUnits string `json:"negativeUnits"`
PositiveUnits string `json:"positiveUnits"`
} `json:"quoteHomeConversionFactors"`
Status string `json:"status"`
Time time.Time `json:"time"`
UnitsAvailable struct {
Default struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"default"`
OpenOnly struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"openOnly"`
ReduceFirst struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"reduceFirst"`
ReduceOnly struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"reduceOnly"`
} `json:"unitsAvailable"`
}
ClientPrice https://developer.oanda.com/rest-live-v20/pricing-df/
type ClosePositionPayload ¶
type ClosePositionPayload struct {
LongUnits string `json:"longUnits"`
ShortUnits string `json:"shortUnits"`
}
ClosePositionPayload https://developer.oanda.com/rest-live-v20/order-ep/
type CloseTradePayload ¶
type CloseTradePayload struct {
Units string
}
CloseTradePayload http://developer.oanda.com/rest-live-v20/trade-ep/
type Connection ¶
type Connection interface {
Request(endpoint string) []byte
Send(endpoint string, data []byte) []byte
Update(endpoint string, data []byte) []byte
GetOrderDetails(instrument string, units string) OrderDetails
GetAccountSummary() AccountSummary
CreateOrder(body OrderPayload) OrderResponse
}
Connection methods
type GetCandlesPayload ¶
type GetCandlesPayload struct {
Granularity *string `url:"granularity,omitempty"`
Count *int `url:"count,omitempty"`
From *time.Time `url:"from,omitempty"`
To *time.Time `url:"to,omitempty"`
Smooth *bool `url:"smooth,omitempty"`
IncludeFirst *bool `url:"includeFirst,omitempty"`
DailyAlignment *int `url:"dailyAlignment,omitempty"`
AlignmentTimezone *string `url:"alignmentTimezone,omitempty"`
WeeklyAlignment *string `url:"weeklyAlignment,omitempty"`
}
GetCandlesPayload https://developer.oanda.com/rest-live-v20/instrument-ep/
type Headers ¶
type Headers struct {
DatetimeFormat string
// contains filtered or unexported fields
}
Headers data
type InstrumentHistory ¶
type InstrumentHistory struct {
Instrument string `json:"instrument"`
Granularity string `json:"granularity"`
Candles []Candles `json:"candles"`
}
InstrumentHistory https://developer.oanda.com/rest-live-v20/instrument-df/
type InstrumentPricing ¶
type InstrumentPricing struct {
Time time.Time `json:"time"`
Prices []struct {
Type string `json:"type"`
Time time.Time `json:"time"`
Bids []struct {
Price string `json:"price"`
Liquidity int `json:"liquidity"`
} `json:"bids"`
Asks []struct {
Price string `json:"price"`
Liquidity int `json:"liquidity"`
} `json:"asks"`
CloseoutBid string `json:"closeoutBid"`
CloseoutAsk string `json:"closeoutAsk"`
Status string `json:"status"`
Tradeable bool `json:"tradeable"`
UnitsAvailable struct {
Default struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"default"`
OpenOnly struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"openOnly"`
ReduceFirst struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"reduceFirst"`
ReduceOnly struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"reduceOnly"`
} `json:"unitsAvailable"`
QuoteHomeConversionFactors struct {
PositiveUnits string `json:"positiveUnits"`
NegativeUnits string `json:"negativeUnits"`
} `json:"quoteHomeConversionFactors"`
Instrument string `json:"instrument"`
} `json:"prices"`
}
InstrumentPricing https://developer.oanda.com/rest-live-v20/instrument-df/
type ModifiedTrade ¶
type ModifiedTrade struct {
OrderCreateTransaction struct {
Type string `json:"type"`
Instrument string `json:"instrument"`
Units string `json:"units"`
TimeInForce string `json:"timeInForce"`
PositionFill string `json:"positionFill"`
Reason string `json:"reason"`
TradeClose struct {
Units string `json:"units"`
TradeID string `json:"tradeID"`
} `json:"tradeClose"`
ID string `json:"id"`
UserID int `json:"userID"`
AccountID string `json:"accountID"`
BatchID string `json:"batchID"`
RequestID string `json:"requestID"`
Time time.Time `json:"time"`
} `json:"orderCreateTransaction"`
OrderFillTransaction struct {
Type string `json:"type"`
Instrument string `json:"instrument"`
Units string `json:"units"`
Price string `json:"price"`
FullPrice string `json:"fullPrice"`
PL string `json:"pl"`
Financing string `json:"financing"`
Commission string `json:"commission"`
AccountBalance string `json:"accountBalance"`
TradeOpened string `json:"tradeOpened"`
TimeInForce string `json:"timeInForce"`
PositionFill string `json:"positionFill"`
Reason string `json:"reason"`
TradesClosed []struct {
TradeID string `json:"tradeID"`
Units string `json:"units"`
RealizedPL string `json:"realizedPL"`
Financing string `json:"financing"`
} `json:"tradesClosed"`
TradeReduced struct {
TradeID string `json:"tradeID"`
Units string `json:"units"`
RealizedPL string `json:"realizedPL"`
Financing string `json:"financing"`
} `json:"tradeReduced"`
ID string `json:"id"`
UserID int `json:"userID"`
AccountID string `json:"accountID"`
BatchID string `json:"batchID"`
RequestID string `json:"requestID"`
OrderID string `json:"orderId"`
ClientOrderID string `json:"clientOrderId"`
Time time.Time `json:"time"`
} `json:"orderFillTransaction"`
OrderCancelTransaction struct {
Type string `json:"type"`
OrderID string `json:"orderID"`
Reason string `json:"reason"`
ID string `json:"id"`
UserID int `json:"userID"`
AccountID string `json:"accountID"`
BatchID string `json:"batchID"`
RequestID string `json:"requestID"`
Time time.Time `json:"time"`
} `json:"orderCancelTransaction"`
RelatedTransactionIDs []string `json:"relatedTransactionIDs"`
LastTransactionID string `json:"lastTransactionID"`
}
ModifiedTrade http://developer.oanda.com/rest-live-v20/trade-df/
type OandaConnection ¶
type OandaConnection struct {
// contains filtered or unexported fields
}
OandaConnection data
func NewConnection ¶
func NewConnection(accountID string, token string, live bool) *OandaConnection
NewConnection makes a new API client
func (*OandaConnection) CancelOrder ¶
func (c *OandaConnection) CancelOrder(orderSpecifier string) (CancelledOrder, error)
CancelOrder https://developer.oanda.com/rest-live-v20/order-ep/
func (*OandaConnection) ClosePosition ¶
func (c *OandaConnection) ClosePosition(instrument string, body ClosePositionPayload) (ModifiedTrade, error)
ClosePosition https://developer.oanda.com/rest-live-v20/order-ep/
func (*OandaConnection) CreateOrder ¶
func (c *OandaConnection) CreateOrder(body OrderPayload) (OrderResponse, error)
CreateOrder https://developer.oanda.com/rest-live-v20/order-ep/
func (*OandaConnection) GetAccount ¶
func (c *OandaConnection) GetAccount(id string) (AccountInfo, error)
GetAccount https://developer.oanda.com/rest-live-v20/account-ep/
func (*OandaConnection) GetAccountChanges ¶
func (c *OandaConnection) GetAccountChanges(id string, transactionID string) (AccountChanges, error)
GetAccountChanges https://developer.oanda.com/rest-live-v20/account-ep/
func (*OandaConnection) GetAccountInstruments ¶
func (c *OandaConnection) GetAccountInstruments(id string) (AccountInstruments, error)
GetAccountInstruments https://developer.oanda.com/rest-live-v20/account-ep/
func (*OandaConnection) GetAccountSummary ¶
func (c *OandaConnection) GetAccountSummary() (AccountSummary, error)
GetAccountSummary https://developer.oanda.com/rest-live-v20/account-ep/
func (*OandaConnection) GetAccounts ¶
func (c *OandaConnection) GetAccounts() (AccountProperties, error)
GetAccounts https://developer.oanda.com/rest-live-v20/account-ep/
func (*OandaConnection) GetBidAskCandles ¶
func (c *OandaConnection) GetBidAskCandles(instrument string, candleSpec GetCandlesPayload) (BidAskCandles, error)
GetBidAskCandles https://developer.oanda.com/rest-live-v20/instrument-ep/
func (*OandaConnection) GetCandles ¶
func (c *OandaConnection) GetCandles(instrument string, candleSpec GetCandlesPayload) (InstrumentHistory, error)
GetCandles https://developer.oanda.com/rest-live-v20/instrument-ep/
func (*OandaConnection) GetInstrumentPrice ¶
func (c *OandaConnection) GetInstrumentPrice(instruments string) (InstrumentPricing, error)
GetInstrumentPrice https://developer.oanda.com/rest-live-v20/pricing-ep/
func (*OandaConnection) GetOpenPositions ¶
func (c *OandaConnection) GetOpenPositions() (OpenPositions, error)
GetOpenPositions https://developer.oanda.com/rest-live-v20/order-ep/
func (*OandaConnection) GetOpenTrades ¶
func (c *OandaConnection) GetOpenTrades() (ReceivedTrades, error)
GetOpenTrades http://developer.oanda.com/rest-live-v20/trade-ep/
func (*OandaConnection) GetOrder ¶
func (c *OandaConnection) GetOrder(orderSpecifier string) (RetrievedOrder, error)
GetOrder https://developer.oanda.com/rest-live-v20/order-ep/
func (*OandaConnection) GetOrderDetails ¶
func (c *OandaConnection) GetOrderDetails(instrument string, units string) (OrderDetails, error)
GetOrderDetails https://developer.oanda.com/rest-live-v20/order-ep/
func (*OandaConnection) GetOrders ¶
func (c *OandaConnection) GetOrders(instrument string) (RetrievedOrders, error)
GetOrders https://developer.oanda.com/rest-live-v20/order-ep/
func (*OandaConnection) GetPendingOrders ¶
func (c *OandaConnection) GetPendingOrders() (RetrievedOrders, error)
GetPendingOrders https://developer.oanda.com/rest-live-v20/order-ep/
func (*OandaConnection) GetPricingForInstruments ¶
func (c *OandaConnection) GetPricingForInstruments(instruments []string) (Pricings, error)
GetPricingForInstruments https://developer.oanda.com/rest-live-v20/pricing-ep/
func (*OandaConnection) GetTrade ¶
func (c *OandaConnection) GetTrade(ticket string) (ReceivedTrade, error)
func (*OandaConnection) GetTradesForInstrument ¶
func (c *OandaConnection) GetTradesForInstrument(instrument string) (ReceivedTrades, error)
GetTradesForInstrument http://developer.oanda.com/rest-live-v20/trade-ep/
func (*OandaConnection) GetTransaction ¶
func (c *OandaConnection) GetTransaction(ticket string) (Transaction, error)
GetTransaction http://developer.oanda.com/rest-live-v20/transaction-ep/
func (*OandaConnection) GetTransactions ¶
func (c *OandaConnection) GetTransactions(from time.Time, to time.Time) (TransactionPages, error)
GetTransactions http://developer.oanda.com/rest-live-v20/transaction-ep/ https://golang.org/pkg/time/#Time.AddDate https://play.golang.org/p/Dw7D4JJ7EC
func (*OandaConnection) GetTransactionsSinceID ¶
func (c *OandaConnection) GetTransactionsSinceID(id string) (Transactions, error)
GetTransactionsSinceID http://developer.oanda.com/rest-live-v20/transaction-ep/
func (*OandaConnection) OrderBook ¶
func (c *OandaConnection) OrderBook(instrument string) (BrokerBook, error)
OrderBook https://developer.oanda.com/rest-live-v20/instrument-ep/
func (*OandaConnection) PositionBook ¶
func (c *OandaConnection) PositionBook(instrument string) (BrokerBook, error)
PositionBook https://developer.oanda.com/rest-live-v20/instrument-ep/
func (*OandaConnection) ReduceTradeSize ¶
func (c *OandaConnection) ReduceTradeSize(ticket string, body CloseTradePayload) (ModifiedTrade, error)
ReduceTradeSize http://developer.oanda.com/rest-live-v20/trade-ep/ Default is close the whole position using the string "ALL" in body.units
func (*OandaConnection) Request ¶
func (c *OandaConnection) Request(endpoint string) ([]byte, error)
Request make a get request to the Oanda V20 API TODO: include params as a second option
func (*OandaConnection) Send ¶
func (c *OandaConnection) Send(endpoint string, data []byte) ([]byte, error)
Send post data to the API
func (*OandaConnection) Stream ¶
func (c *OandaConnection) Stream(endpoint string) (chan ByteStream, context.CancelFunc, error)
Stream consume a streamng API
func (*OandaConnection) StreamPricing ¶
func (c *OandaConnection) StreamPricing(instruments []string) (chan PricingStream, context.CancelFunc, error)
StreamPricing https://developer.oanda.com/rest-live-v20/pricing-ep/
func (*OandaConnection) Update ¶
func (c *OandaConnection) Update(endpoint string, data []byte) ([]byte, error)
Update put data to the API
func (*OandaConnection) UpdateOrder ¶
func (c *OandaConnection) UpdateOrder(orderSpecifier string, body OrderPayload) (RetrievedOrder, error)
UpdateOrder https://developer.oanda.com/rest-live-v20/order-ep/
type OnFill ¶
type OpenPositions ¶
type OpenPositions struct {
LastTransactionID string `json:"lastTransactionID"`
Positions []struct {
Instrument string `json:"instrument"`
Long struct {
AveragePrice string `json:"averagePrice"`
Pl string `json:"pl"`
ResettablePL string `json:"resettablePL"`
TradeIDs []string `json:"tradeIDs"`
Units string `json:"units"`
UnrealizedPL string `json:"unrealizedPL"`
} `json:"long"`
Pl string `json:"pl"`
ResettablePL string `json:"resettablePL"`
Short struct {
AveragePrice string `json:"averagePrice"`
Pl string `json:"pl"`
ResettablePL string `json:"resettablePL"`
TradeIDs []string `json:"tradeIDs"`
Units string `json:"units"`
UnrealizedPL string `json:"unrealizedPL"`
} `json:"short"`
UnrealizedPL string `json:"unrealizedPL"`
} `json:"positions"`
}
OpenPositions https://developer.oanda.com/rest-live-v20/position-df/
type OrderBody ¶
type OrderBody struct {
Units int `json:"units"`
Instrument string `json:"instrument"`
TimeInForce string `json:"timeInForce"`
Type string `json:"type"`
PositionFill string `json:"positionFill,omitempty"`
Price string `json:"price,omitempty"`
TakeProfitOnFill *OnFill `json:"takeProfitOnFill,omitempty"`
StopLossOnFill *OnFill `json:"stopLossOnFill,omitempty"`
ClientExtensions *OrderExtensions `json:"clientExtensions,omitempty"`
TradeID string `json:"tradeId,omitempty"`
}
OrderBody https://developer.oanda.com/rest-live-v20/order-df/
type OrderDetails ¶
type OrderDetails struct {
GainPerPipPerMillionUnits string `json:"gainPerPipPerMillionUnits"`
LossPerPipPerMillionUnits string `json:"lossPerPipPerMillionUnits"`
UnitsAvailable struct {
Default struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"default"`
OpenOnly struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"openOnly"`
ReduceFirst struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"reduceFirst"`
ReduceOnly struct {
Long string `json:"long"`
Short string `json:"short"`
} `json:"reduceOnly"`
} `json:"unitsAvailable"`
UnitValues struct {
Isolation struct {
Units string `json:"units"`
Commission string `json:"commission"`
PositionValueChange string `json:"positionValueChange"`
PositionValue string `json:"positionValue"`
MarginRequired string `json:"marginRequired"`
MarginUsed string `json:"marginUsed"`
} `json:"isolation"`
PositionDefault struct {
Units string `json:"units"`
Commission string `json:"commission"`
PositionValueChange string `json:"positionValueChange"`
PositionValue string `json:"positionValue"`
MarginRequired string `json:"marginRequired"`
MarginUsed string `json:"marginUsed"`
} `json:"positionDefault"`
PositionOpenOnly struct {
Units string `json:"units"`
Commission string `json:"commission"`
PositionValueChange string `json:"positionValueChange"`
PositionValue string `json:"positionValue"`
MarginRequired string `json:"marginRequired"`
MarginUsed string `json:"marginUsed"`
} `json:"positionOpenOnly"`
PositionReduceFirst struct {
Units string `json:"units"`
Commission string `json:"commission"`
PositionValueChange string `json:"positionValueChange"`
PositionValue string `json:"positionValue"`
MarginRequired string `json:"marginRequired"`
MarginUsed string `json:"marginUsed"`
} `json:"positionReduceFirst"`
PositionReduceOnly struct {
Units string `json:"units"`
Commission string `json:"commission"`
PositionValueChange string `json:"positionValueChange"`
PositionValue string `json:"positionValue"`
MarginRequired string `json:"marginRequired"`
MarginUsed string `json:"marginUsed"`
} `json:"positionReduceOnly"`
} `json:"unitValues"`
ValueTables struct {
CommissionTable []struct {
Units string `json:"units"`
Value string `json:"value"`
} `json:"commissionTable"`
} `json:"valueTables"`
LastTransactionID string `json:"lastTransactionID"`
}
OrderDetails https://developer.oanda.com/rest-live-v20/order-df/
type OrderExtensions ¶
type OrderExtensions struct {
Comment string `json:"comment,omitempty"`
ID string `json:"id,omitempty"`
Tag string `json:"tag,omitempty"`
}
OrderExtensions https://developer.oanda.com/rest-live-v20/order-df/
type OrderInfo ¶
type OrderInfo struct {
ClientExtensions struct {
Comment string `json:"comment,omitempty"`
ID string `json:"id,omitempty"`
Tag string `json:"tag,omitempty"`
} `json:"clientExtensions,omitempty"`
CreateTime time.Time `json:"createTime"`
ID string `json:"id"`
Instrument string `json:"instrument,omitempty"`
PartialFill string `json:"partialFill"`
PositionFill string `json:"positionFill"`
Price string `json:"price"`
ReplacesOrderID string `json:"replacesOrderID,omitempty"`
State string `json:"state"`
TimeInForce string `json:"timeInForce"`
TriggerCondition string `json:"triggerCondition"`
Type string `json:"type"`
Units string `json:"units,omitempty"`
}
OrderInfo https://developer.oanda.com/rest-live-v20/order-df/
type OrderPayload ¶
type OrderPayload struct {
Order OrderBody `json:"order"`
}
OrderPayload https://developer.oanda.com/rest-live-v20/order-df/
type OrderResponse ¶
type OrderResponse struct {
LastTransactionID string `json:"lastTransactionID"`
OrderCreateTransaction struct {
AccountID string `json:"accountID"`
BatchID string `json:"batchID"`
ID string `json:"id"`
Instrument string `json:"instrument"`
PositionFill string `json:"positionFill"`
Reason string `json:"reason"`
Time time.Time `json:"time"`
TimeInForce string `json:"timeInForce"`
Type string `json:"type"`
Units string `json:"units"`
UserID int `json:"userID"`
} `json:"orderCreateTransaction"`
OrderFillTransaction struct {
AccountBalance string `json:"accountBalance"`
AccountID string `json:"accountID"`
BatchID string `json:"batchID"`
Financing string `json:"financing"`
ID string `json:"id"`
Instrument string `json:"instrument"`
OrderID string `json:"orderID"`
Pl string `json:"pl"`
Price string `json:"price"`
Reason string `json:"reason"`
Time time.Time `json:"time"`
TradeOpened struct {
TradeID string `json:"tradeID"`
Units string `json:"units"`
} `json:"tradeOpened"`
Type string `json:"type"`
Units string `json:"units"`
UserID int `json:"userID"`
} `json:"orderFillTransaction"`
RelatedTransactionIDs []string `json:"relatedTransactionIDs"`
}
OrderResponse https://developer.oanda.com/rest-live-v20/order-df/
type PricingStream ¶
type PricingStream struct {
ClientPrice *ClientPrice
Error error
}
PricingStream used to stream prices over a go channel
type Pricings ¶
type Pricings struct {
Prices []ClientPrice `json:"prices"`
}
Pricings https://developer.oanda.com/rest-live-v20/pricing-df/
type ReceivedTrade ¶
type ReceivedTrade struct {
LastTransactionID string `json:"lastTransactionID"`
Trades struct {
CurrentUnits string `json:"currentUnits"`
Financing string `json:"financing"`
ID string `json:"id"`
InitialUnits string `json:"initialUnits"`
Instrument string `json:"instrument"`
OpenTime time.Time `json:"openTime"`
Price string `json:"price"`
RealizedPL string `json:"realizedPL"`
State string `json:"state"`
UnrealizedPL string `json:"unrealizedPL"`
} `json:"trade"`
}
ReceivedTrade http://developer.oanda.com/rest-live-v20/trade-ep/
type ReceivedTrades ¶
type ReceivedTrades struct {
LastTransactionID string `json:"lastTransactionID"`
Trades []struct {
CurrentUnits string `json:"currentUnits"`
Financing string `json:"financing"`
ID string `json:"id"`
InitialUnits string `json:"initialUnits"`
Instrument string `json:"instrument"`
OpenTime time.Time `json:"openTime"`
Price string `json:"price"`
RealizedPL string `json:"realizedPL"`
State string `json:"state"`
UnrealizedPL string `json:"unrealizedPL"`
} `json:"trades"`
}
ReceivedTrades http://developer.oanda.com/rest-live-v20/trade-ep/
type RetrievedOrder ¶
type RetrievedOrder struct {
Order OrderInfo `json:"order"`
}
RetrievedOrder https://developer.oanda.com/rest-live-v20/order-ep/
type RetrievedOrders ¶
type RetrievedOrders struct {
LastTransactionID string `json:"lastTransactionID"`
Orders []OrderInfo `json:"orders,omitempty"`
}
RetrievedOrders https://developer.oanda.com/rest-live-v20/order-ep/
type Transaction ¶
type Transaction struct {
LastTransactionID string `json:"lastTransactionID"`
Transaction struct {
AccountBalance string `json:"accountBalance"`
AccountID string `json:"accountID"`
BatchID string `json:"batchID"`
Financing string `json:"financing"`
ID string `json:"id"`
Instrument string `json:"instrument"`
OrderID string `json:"orderID"`
Pl string `json:"pl"`
Price string `json:"price"`
Reason string `json:"reason"`
Time time.Time `json:"time"`
TradeOpened struct {
TradeID string `json:"tradeID"`
Units string `json:"units"`
} `json:"tradeOpened"`
Type string `json:"type"`
Units string `json:"units"`
UserID int `json:"userID"`
} `json:"transaction"`
}
Transaction http://developer.oanda.com/rest-live-v20/transaction-df/
type TransactionPages ¶
type TransactionPages struct {
Count int `json:"count"`
From time.Time `json:"from"`
LastTransactionID string `json:"lastTransactionID"`
PageSize int `json:"pageSize"`
Pages []string `json:"pages"`
To time.Time `json:"to"`
}
TransactionPages http://developer.oanda.com/rest-live-v20/transaction-df/
type Transactions ¶
type Transactions struct {
LastTransactionID string `json:"lastTransactionID"`
Transactions []struct {
AccountBalance string `json:"accountBalance"`
AccountID string `json:"accountID"`
BatchID string `json:"batchID"`
Financing string `json:"financing"`
ID string `json:"id"`
Instrument string `json:"instrument"`
OrderID string `json:"orderID"`
Pl string `json:"pl"`
Price string `json:"price"`
Reason string `json:"reason"`
Time time.Time `json:"time"`
TradeOpened struct {
TradeID string `json:"tradeID"`
Units string `json:"units"`
} `json:"tradeOpened"`
Type string `json:"type"`
Units string `json:"units"`
UserID int `json:"userID"`
} `json:"transactions"`
}
Transactions http://developer.oanda.com/rest-live-v20/transaction-df/
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
account
command
|
|
|
candles
command
|
|
|
get_orders
command
|
|
|
limit_order
command
|
|
|
market_order
command
|
|
|
positions
command
|
|
|
price_stream
command
|
|
|
pricing
command
|
|
|
trades
command
|
|
|
transactions
command
|
|
|
update_order
command
|