Class OandaApiClient
Provides a client for the Oanda api.
Inheritance
Implements
Namespace: FFT.Oanda
Assembly: FFT.Oanda.dll
Syntax
public sealed class OandaApiClient : DisposeBase, IDisposable
Constructors
| Improve this Doc View SourceOandaApiClient(AccountType, String)
Initializes a new instance of the OandaApiClient class.
Declaration
public OandaApiClient(AccountType accountType, string accessKey)
Parameters
Type | Name | Description |
---|---|---|
AccountType | accountType | Specify the type of account you wish to connect to. |
System.String | accessKey | The secret access key that allows you to access the api. |
Properties
| Improve this Doc View SourceAccountType
The account type that this instance will connect to. Affects the endpoint used for connections.
Declaration
public AccountType AccountType { get; }
Property Value
Type | Description |
---|---|
AccountType |
Key
The authorization used to authenticate by this instance.
Declaration
public string Key { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceCancelOrder(String, String, Nullable<String>, CancellationToken)
Cancel a pending Order in an Account.
Declaration
public Task<CancelOrderResponse> CancelOrder(string accountId, string orderSpecifier, string? clientRequestId = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.String | orderSpecifier | The order to be canceled. The specification of an Order as referred to by clients. Either the Order’s OANDA-assigned OrderID or the Order’s client-provided ClientID prefixed by the “@” symbol. |
System.Nullable<System.String> | clientRequestId | Client specified RequestID to be sent with request. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<CancelOrderResponse> |
CloseLongPosition(String, String, NumUnits, Nullable<ClientExtensions>, CancellationToken)
Closeout the open Position for a specific instrument in an Account.
Declaration
public Task<CloseLongPositionResponse> CloseLongPosition(string accountId, string instrument, NumUnits longUnits, ClientExtensions? longClientExtensions, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.String | instrument | Name of the Instrument. |
NumUnits | longUnits | Indication of how much of the long Position to closeout using a PositionCloseout MarketOrder. The units specified must always be positive. |
System.Nullable<ClientExtensions> | longClientExtensions | The client extensions to add to the MarketOrder used to close the long position. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<CloseLongPositionResponse> |
CloseShortPosition(String, String, NumUnits, Nullable<ClientExtensions>, CancellationToken)
Closeout the open Position for a specific instrument in an Account.
Declaration
public Task<CloseShortPositionResponse> CloseShortPosition(string accountId, string instrument, NumUnits shortUnits, ClientExtensions? shortClientExtensions, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.String | instrument | Name of the Instrument. |
NumUnits | shortUnits | Indication of how much of the short Position to closeout using a PositionCloseout MarketOrder. The units specified must always be positive. |
System.Nullable<ClientExtensions> | shortClientExtensions | The client extensions to add to the MarketOrder used to close the short position. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<CloseShortPositionResponse> |
CloseTrade(String, String, NumUnits, CancellationToken)
Close (partially or fully) a specific open Trade in an Account.
Declaration
public Task<CloseTradeResponse> CloseTrade(string accountId, string tradeSpecifier, NumUnits numUnits, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.String | tradeSpecifier | Either the Trade’s OANDA-assigned TradeID or the Trade’s client-provided ClientID prefixed by the “@” symbol. |
NumUnits | numUnits | Indication of how much of the Trade to close. Either the string “ALL” (indicating that all of the Trade should be closed), or a DecimalNumber representing the number of units of the open Trade to Close using a TradeClose MarketOrder. The units specified must always be positive, and the magnitude of the value cannot exceed the magnitude of the Trade’s open units. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<CloseTradeResponse> |
CreateOrder<TOrderRequest>(String, TOrderRequest, CancellationToken)
Create an Order for an Account.
Declaration
public Task<CreateOrderResponse> CreateOrder<TOrderRequest>(string accountId, TOrderRequest orderRequest, CancellationToken cancellationToken = null)
where TOrderRequest : OrderRequest
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
TOrderRequest | orderRequest | Specification of the Order to create. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<CreateOrderResponse> |
Type Parameters
Name | Description |
---|---|
TOrderRequest | The type of the order to be created. |
CustomDispose()
Declaration
protected override void CustomDispose()
GetAccount(String, CancellationToken)
Get the full details for a single account. Full pending order, open trade and open position representations are provided.
Declaration
public Task<AccountResponse> GetAccount(string accountId, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<AccountResponse> |
GetAccountChanges(String, Nullable<Int32>, CancellationToken)
Poll an Account for its current state and changes since a specified TransactionID.
Declaration
public Task<AccountChangesResponse> GetAccountChanges(string accountId, int? sinceTransactionId, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | The id of the account for which data is requested. |
System.Nullable<System.Int32> | sinceTransactionId | If you supply this as null, the response will not include the "Changes" data but will include the price-dependent state. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<AccountChangesResponse> |
GetAccountInstruments(String, String[], CancellationToken)
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.
Declaration
public Task<AccountInstrumentListResponse> GetAccountInstruments(string accountId, string[] specificInstruments = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | The account specifier. [Required]. |
System.String[] | specificInstruments | Supply this value if you wish to get instrument details for just this specific set of instruments. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<AccountInstrumentListResponse> |
GetAccounts(CancellationToken)
Get a list of all accounts.
Declaration
public Task<AccountListResponse> GetAccounts(CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<AccountListResponse> |
GetAccountSummary(String, CancellationToken)
Get a summary for a single account. Does not provide full specification of pending Orders, open Trades and Positions.
Declaration
public Task<AccountSummaryResponse> GetAccountSummary(string accountId, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | The account that the summary is required of. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<AccountSummaryResponse> |
GetCandlestickData(CandleSpecification, Nullable<DateTime>, Nullable<DateTime>, Int32, Boolean, Nullable<Boolean>, Int32, String, WeeklyAlignment, Int32, CancellationToken)
Fetch candlestick data for an instrument. This method overload uses the "count" parameter (instead of the "from" and "to" parameters) to determine the range of candles to return.
Declaration
public Task<CandlestickResponse> GetCandlestickData(CandleSpecification candleSpecification, DateTime? from = null, DateTime? to = null, int count = 5000, bool smooth = false, bool? includeFirst = null, int dailyAlignment = 17, string alignmentTimezone = "America/New_York", WeeklyAlignment weeklyAlignment = WeeklyAlignment.FRIDAY, int units = 1, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
CandleSpecification | candleSpecification | An instrument name, a granularity, and a price component to get candlestick data for. |
System.Nullable<DateTime> | from | The start of the time range to fetch candlesticks for.
Do not supply a value if you have supplied |
System.Nullable<DateTime> | to | The end of the time range to fetch candlesticks for.
Do not supply a value if you have supplied both |
System.Int32 | count | The number of candlesticks to return in the response. [minimum=500, maximum=5000]. |
System.Boolean | smooth | A flag that controls whether the candlestick is “smoothed” or not. A smoothed candlestick uses the previous candle’s close price as its open price, while an un-smoothed candlestick uses the first price from its time range as its open price. |
System.Nullable<System.Boolean> | includeFirst | A flag that controls whether the candlestick that is covered by the from
time should be included in the results. This flag enables clients to use
the timestamp of the last completed candlestick received to poll for
future candlesticks but avoid receiving the previous candlestick
repeatedly.
Required if you have supplied |
System.Int32 | dailyAlignment | The hour of the day (in the specified timezone) to use for granularities that have daily alignments. [default=17, minimum=0, maximum=23]. |
System.String | alignmentTimezone | The timezone to use for the dailyAlignment parameter. Candlesticks with daily alignment will be aligned to the dailyAlignment hour within the alignmentTimezone. Note that the returned times will still be represented in UTC. [default=America/New_York]. |
WeeklyAlignment | weeklyAlignment | The day of the week used for granularities that have weekly alignment. [default=Friday]. |
System.Int32 | units | The number of units used to calculate the volume-weighted average bid and ask prices in the returned candles. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<CandlestickResponse> |
GetOpenPositions(String, CancellationToken)
List all open Positions for an Account. An open Position is a Position that currently has a Trade opened for it.
Declaration
public Task<GetPositionsResponse> GetOpenPositions(string accountId, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<GetPositionsResponse> |
GetOpenTrades(String, CancellationToken)
Get the list of open Trades for an Account.
Declaration
public Task<GetTradesResponse> GetOpenTrades(string accountId, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<GetTradesResponse> |
GetOrderBook(String, Nullable<DateTime>, CancellationToken)
Fetch an order book for an instrument.
Declaration
public Task<OrderBookResponse> GetOrderBook(string instrumentName, DateTime? time = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | instrumentName | Name of the Instrument. |
System.Nullable<DateTime> | time | The time of the snapshot to fetch. If not specified, then the most recent snapshot is fetched. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<OrderBookResponse> |
GetOrders(String, Nullable<String>, OrderStateFilter, Int32, Nullable<Int32>, Int32[], CancellationToken)
Get a list of Orders for an Account.
Declaration
public Task<GetOrdersResponse> GetOrders(string accountId, string? instrumentName = null, OrderStateFilter state = OrderStateFilter.PENDING, int count = 50, int? beforeId = null, int[] ids = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.Nullable<System.String> | instrumentName | The instrument to filter the requested orders by. |
OrderStateFilter | state | The state to filter the requested Orders by [default=PENDING]. |
System.Int32 | count | The maximum number of Orders to return [default=50, maximum=500]. |
System.Nullable<System.Int32> | beforeId | The maximum Order ID to return. If not provided the most recent Orders in the Account are returned. |
System.Int32[] | ids | List of Order IDs to retrieve. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<GetOrdersResponse> |
GetPendingOrders(String, CancellationToken)
List all pending Orders in an Account.
Declaration
public Task<GetOrdersResponse> GetPendingOrders(string accountId, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<GetOrdersResponse> |
GetPosition(String, String, CancellationToken)
Get the details of a single Instrument’s Position in an Account. The Position may by open or not.
Declaration
public Task<GetPositionResponse> GetPosition(string accountId, string instrument, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.String | instrument | Name of the Instrument. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<GetPositionResponse> |
GetPositionBook(String, Nullable<DateTime>, CancellationToken)
Fetch a position book for an instrument.
Declaration
public Task<PositionBookResponse> GetPositionBook(string instrumentName, DateTime? time = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | instrumentName | Name of the Instrument. |
System.Nullable<DateTime> | time | The time of the snapshot to fetch. If not specified, then the most recent snapshot is fetched. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<PositionBookResponse> |
GetPositions(String, CancellationToken)
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.
Declaration
public Task<GetPositionsResponse> GetPositions(string accountId, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<GetPositionsResponse> |
GetPricingInformation(String, String[], Nullable<DateTime>, Boolean, CancellationToken)
Get pricing information for a specified list of Instruments within an Account.
Declaration
public Task<PricingInformationResponse> GetPricingInformation(string accountId, string[] instruments, DateTime? since = null, bool includeHomeConversions = false, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.String[] | instruments | List of Instruments to get pricing for. |
System.Nullable<DateTime> | since | Date/Time filter to apply to the response. Only prices and home conversions (if requested) with a time later than this filter (i.e. the price has changed after the since time) will be provided, and are filtered independently. |
System.Boolean | includeHomeConversions | Flag that enables the inclusion of the homeConversions field in the returned response. An entry will be returned for each currency in the set of all base and quote currencies present in the requested instruments list. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<PricingInformationResponse> |
GetPricingStream(String, String[], Boolean, Boolean, CancellationToken)
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.
Declaration
public IAsyncEnumerable<object> GetPricingStream(string accountId, string[] instruments, bool snapshot = true, bool includeHomeConversions = false, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.String[] | instruments | List of Instruments to stream Prices for. |
System.Boolean | snapshot | Flag that enables/disables the sending of a pricing snapshot when initially connecting to the stream. |
System.Boolean | includeHomeConversions | Flag that enables the inclusion of the homeConversions field in the returned response. An entry will be returned for each currency in the set of all base and quote currencies present in the requested instruments list. |
CancellationToken | cancellationToken | Close the stream and break the enumeration. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<System.Object> |
GetSingleOrder(String, String, CancellationToken)
Get details for a single Order in an Account.
Declaration
public Task<GetSingleOrderResponse> GetSingleOrder(string accountId, string orderSpecifier, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.String | orderSpecifier | The specification of an Order as referred to by clients. Either the Order’s OANDA-assigned OrderID or the Order’s client-provided ClientID prefixed by the “@” symbol. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<GetSingleOrderResponse> |
GetTrade(String, String, CancellationToken)
Get the details of a specific Trade in an Account.
Declaration
public Task<GetTradeResponse> GetTrade(string accountId, string tradeSpecifier, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.String | tradeSpecifier | Either the Trade’s OANDA-assigned TradeID or the Trade’s client-provided ClientID prefixed by the “@” symbol. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<GetTradeResponse> |
GetTrades(String, TradeStateFilter, Nullable<String>, Int32, Nullable<Int32>, Int32[], CancellationToken)
Get a list of Trades for an Account.
Declaration
public Task<GetTradesResponse> GetTrades(string accountId, TradeStateFilter state = TradeStateFilter.OPEN, string? instrument = null, int count = 50, int? beforeId = null, int[] tradeIds = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
TradeStateFilter | state | The state to filter the requested Trades by. [default=OPEN]. |
System.Nullable<System.String> | instrument | The instrument to filter the requested Trades by. |
System.Int32 | count | The maximum number of Trades to return. [default=50, maximum=500]. |
System.Nullable<System.Int32> | beforeId | The maximum Trade ID to return. If not provided the most recent Trades in the Account are returned. |
System.Int32[] | tradeIds | List of Trade IDs to retrieve. Only supply this if you wish to specify exactly which trades you need the information for. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<GetTradesResponse> |
GetTransaction(String, String, CancellationToken)
Get the details of a single Account Transaction.
Declaration
public Task<GetTransactionResponse> GetTransaction(string accountId, string transactionId, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.String | transactionId | A Transaction ID. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<GetTransactionResponse> |
GetTransactionIdRange(String, Nullable<DateTime>, Nullable<DateTime>, CancellationToken)
Get a list of Transactions pages that satisfy a time-based Transaction query.
Declaration
public Task<GetTransactionIdRangeResponse> GetTransactionIdRange(string accountId, DateTime? from = null, DateTime? to = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.Nullable<DateTime> | from | The starting time (inclusive) of the time range for the Transactions being queried. If null, the account creation time will be used. |
System.Nullable<DateTime> | to | The ending time (inclusive) of the time range for the Transactions being queried. If null, the current time will be used. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<GetTransactionIdRangeResponse> |
GetTransactions(String, Int32, Int32, TransactionFilter[], CancellationToken)
Get a range of Transactions for an Account based on the Transaction IDs.
Declaration
public IAsyncEnumerable<Transaction> GetTransactions(string accountId, int fromTransactionId, int toTransactionId, TransactionFilter[] types = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.Int32 | fromTransactionId | The starting Transaction ID (inclusive) to fetch. |
System.Int32 | toTransactionId | The ending Transaction ID (inclusive) to fetch. |
TransactionFilter[] | types | The filter that restricts the types of Transactions to retrieve. Null for all transaction types. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<Transaction> |
GetTransactionsSince(String, Int32, TransactionFilter[], CancellationToken)
Get a range of Transactions for an Account starting at (but not including) a provided Transaction ID.
Declaration
public IAsyncEnumerable<Transaction> GetTransactionsSince(string accountId, int sinceTransactionId, TransactionFilter[] types = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.Int32 | sinceTransactionId | The ID of the last Transaction fetched. This query will return all Transactions newer than the TransactionID, up to the maximum number allowed by the Oanda api. |
TransactionFilter[] | types | A filter for restricting the types of Transactions to retrieve. Null to retrieve all Transaction types. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<Transaction> |
GetTransactionsStream(String, CancellationToken)
Get a stream of objects inheriting accountId
starting from the moment the request is made.
Declaration
public IAsyncEnumerable<Transaction> GetTransactionsStream(string accountId, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
CancellationToken | cancellationToken | Closes the underlying stream connection and completes the IAsyncEnumerable without error. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<Transaction> |
GetTransactionStreamSince(String, DateTime, CancellationToken)
Get a stream of objects inheriting accountId
starting from the given moment of time in the past.
Declaration
public IAsyncEnumerable<Transaction> GetTransactionStreamSince(string accountId, DateTime from, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
DateTime | from | The time in the past at which to start load transactions from. |
CancellationToken | cancellationToken | Closes the underlying stream connection and completes the IAsyncEnumerable without error. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<Transaction> |
ReplaceOrder(String, String, OrderRequest, Nullable<String>, CancellationToken)
Replace an Order in an Account by simultaneously cancelling it and creating a replacement Order.
Declaration
public Task<ReplaceOrderResponse> ReplaceOrder(string accountId, string orderSpecifier, OrderRequest replacementOrder, string? clientRequestId = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.String | orderSpecifier | The order to be replaced. The specification of an Order as referred to by clients. Either the Order’s OANDA-assigned OrderID or the Order’s client-provided ClientID prefixed by the “@” symbol. |
OrderRequest | replacementOrder | Specification of the replacing Order. |
System.Nullable<System.String> | clientRequestId | Client specified RequestID to be sent with request. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<ReplaceOrderResponse> |
SetAccountConfiguration(String, AccountConfiguration, CancellationToken)
Set the client-configurable portions of an Account.
Declaration
public Task<AccountConfigurationResponse> SetAccountConfiguration(string accountId, AccountConfiguration accountConfiguration, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | The id of the account that will be updated. |
AccountConfiguration | accountConfiguration | New account configuration information. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<AccountConfigurationResponse> |
SetOrderClientExtensions(String, String, Nullable<ClientExtensions>, Nullable<ClientExtensions>, CancellationToken)
Update the Client Extensions for an Order in an Account.Do not set, modify, or delete clientExtensions if your account is associated with MT4.
Declaration
public Task<UpdateOrderClientExtensionsResponse> SetOrderClientExtensions(string accountId, string orderSpecifier, ClientExtensions? clientExtensions, ClientExtensions? tradeClientExtensions, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.String | orderSpecifier | The specification of an Order as referred to by clients. Either the Order’s OANDA-assigned OrderID or the Order’s client-provided ClientID prefixed by the “@” symbol. |
System.Nullable<ClientExtensions> | clientExtensions | The Client Extensions to update for the Order. Do not set, modify, or delete clientExtensions if your account is associated with MT4. |
System.Nullable<ClientExtensions> | tradeClientExtensions | The Client Extensions to update for the Trade created when the Order is filled. Do not set, modify, or delete clientExtensions if your account is associated with MT4. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<UpdateOrderClientExtensionsResponse> |
SetTradeClientExtensions(String, String, ClientExtensions, CancellationToken)
Update the Client Extensions for a Trade. Do not add, update, or delete the Client Extensions if your account is associated with MT4.
Declaration
public Task<TradeClientExtensionsUpdateResponse> SetTradeClientExtensions(string accountId, string tradeSpecifier, ClientExtensions clientExtensions, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.String | tradeSpecifier | Either the Trade’s OANDA-assigned TradeID or the Trade’s client-provided ClientID prefixed by the “@” symbol. |
ClientExtensions | clientExtensions | The value to be attached to the given trade. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<TradeClientExtensionsUpdateResponse> |
SetTradeOrders(String, String, Nullable<TakeProfitDetails>, Nullable<StopLossDetails>, Nullable<TrailingStopLossDetails>, Nullable<GuaranteedStopLossDetails>, CancellationToken)
Create, replace and cancel a Trade’s dependent Orders (Take Profit, Stop Loss and Trailing Stop Loss) through the Trade itself.
Declaration
public Task<SetTradeOrdersResponse> SetTradeOrders(string accountId, string tradeSpecifier, TakeProfitDetails? takeProfit, StopLossDetails? stopLoss, TrailingStopLossDetails? trailingStopLoss, GuaranteedStopLossDetails? guaranteedStopLoss, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | accountId | “-“-delimited string with format “{siteID}-{divisionID}-{userID}-{accountNumber}”. Eg: 001-011-5838423-001. |
System.String | tradeSpecifier | Either the Trade’s OANDA-assigned TradeID or the Trade’s client-provided ClientID prefixed by the “@” symbol. |
System.Nullable<TakeProfitDetails> | takeProfit | /// The specification of the Take Profit to create/modify/cancel. If takeProfit is set to null, the Take Profit Order will be cancelled if it exists. If takeProfit is not provided, the existing Take Profit Order will not be modified. If a sub-field of takeProfit is not specified, that field will be set to a default value on create, and be inherited by the replacing order on modify. |
System.Nullable<StopLossDetails> | stopLoss | The specification of the Stop Loss to create/modify/cancel. If stopLoss is set to null, the Stop Loss Order will be cancelled if it exists. If stopLoss is not provided, the existing Stop Loss Order will not be modified. If a sub-field of stopLoss is not specified, that field will be set to a default value on create, and be inherited by the replacing order on modify. |
System.Nullable<TrailingStopLossDetails> | trailingStopLoss | The specification of the Trailing Stop Loss to create/modify/cancel. If trailingStopLoss is set to null, the Trailing Stop Loss Order will be cancelled if it exists. If trailingStopLoss is not provided, the existing Trailing Stop Loss Order will not be modified. If a sub-field of trailingStopLoss is not specified, that field will be set to a default value on create, and be inherited by the replacing order on modify. |
System.Nullable<GuaranteedStopLossDetails> | guaranteedStopLoss | The specification of the Guaranteed Stop Loss to create/modify/cancel. If guaranteedStopLoss is set to null, the Guaranteed Stop Loss Order will be cancelled if it exists. If guaranteedStopLoss is not provided, the existing Guaranteed Stop Loss Order will not be modified. If a sub-field of guaranteedStopLoss is not specified, that field will be set to a default value on create, and be inherited by the replacing order on modify. |
CancellationToken | cancellationToken | Cancels the operation. |
Returns
Type | Description |
---|---|
Task<SetTradeOrdersResponse> |