Expand description
This is an unofficial Oanda API client. This client is still an experimental work in progress however it is reasonably functional.
The client is generated from the Oanda V20 API definitions. The current state of the client API is low-level but usable however I would like to see a more ergonomic layer developed on top.
§Installation
$ cargo add fxoanda
§Example usage
use std::env;
use fxoanda::*;
#[tokio::main]
async fn main() {
let api_key = env::var("OANDA_KEY").expect("expected OANDA_KEY environment variable to be set");
let api_host = env::var("OANDA_HOST").expect("expected OANDA_HOST environment variable to be set");
let client = fxoanda::Client {
host: String::from(api_host),
reqwest: reqwest::Client::new(),
authentication: String::from(api_key),
};
match fxoanda::GetInstrumentCandlesRequest::new()
.with_instrument("EUR_USD".to_string())
.with_granularity(CandlestickGranularity::H4)
.remote(&client).await
{
Ok(x) => println!("OK: {:#?}", x),
Err(e) => eprintln!("ERR: {:#?}", e),
};
}
§Warning
Forex markets are extremely risky. Automated trading is also extremely risky. This project is extremely risky. Market conditions, news events, or software bugs can wipe out your account in an instant.
§Disclaimer
Use this project at your own risk. The maintainers of this project make no claims as to this product being fit for purpose. In fact, the maintainers of this project are telling you that you shouldn’t use this project.
Re-exports§
pub use self::account::*;
pub use self::client::*;
pub use self::instrument::*;
pub use self::pricing::*;
Modules§
Structs§
- Account
- Account
Changes - Account
Changes State - Account
Properties - Account
Summary - Calculated
Account State - Calculated
Position State - Calculated
Trade State - Candlestick
- Candlestick
Data - Client
Configure Reject Transaction - Client
Configure Transaction - Client
Extensions - Client
Price - Close
Transaction - Create
Transaction - Daily
Financing Transaction - Delayed
Trade Closure Transaction - Dynamic
Order State - Fixed
Price Order - Fixed
Price Order Transaction - Guaranteed
Stop Loss Order Entry Data - Guaranteed
Stop Loss Order Level Restriction - Home
Conversions - Instrument
- Instrument
Commission - Limit
Order - Limit
Order Reject Transaction - Limit
Order Request - Limit
Order Transaction - Liquidity
Regeneration Schedule - Liquidity
Regeneration Schedule Step - MT4Transaction
Heartbeat - Margin
Call Enter Transaction - Margin
Call Exit Transaction - Margin
Call Extend Transaction - Market
IfTouched Order - Market
IfTouched Order Reject Transaction - Market
IfTouched Order Request - Market
IfTouched Order Transaction - Market
Order - Market
Order Delayed Trade Close - Market
Order Margin Closeout - Market
Order Position Closeout - Market
Order Reject Transaction - Market
Order Request - Market
Order Trade Close - Market
Order Transaction - Open
Trade Financing - Order
- Order
Book - Order
Book Bucket - Order
Cancel Reject Transaction - Order
Cancel Transaction - Order
Client Extensions Modify Reject Transaction - Order
Client Extensions Modify Transaction - Order
Fill Transaction - Order
Identifier - Order
Request - Position
- Position
Book - Position
Book Bucket - Position
Financing - Position
Side - Price
- Price
Bucket - Pricing
Heartbeat - Quote
Home Conversion Factors - Reopen
Transaction - Reset
ResettablePL Transaction - Stop
Loss Details - Stop
Loss Order - Stop
Loss Order Reject Transaction - Stop
Loss Order Request - Stop
Loss Order Transaction - Stop
Order - Stop
Order Reject Transaction - Stop
Order Request - Stop
Order Transaction - Take
Profit Details - Take
Profit Order - Take
Profit Order Reject Transaction - Take
Profit Order Request - Take
Profit Order Transaction - Trade
- Trade
Client Extensions Modify Reject Transaction - Trade
Client Extensions Modify Transaction - Trade
Open - Trade
Reduce - Trade
Summary - Trailing
Stop Loss Details - Trailing
Stop Loss Order - Trailing
Stop Loss Order Reject Transaction - Trailing
Stop Loss Order Request - Trailing
Stop Loss Order Transaction - Transaction
- Transaction
Heartbeat - Transfer
Funds Reject Transaction - Transfer
Funds Transaction - Units
Available - Units
Available Details - User
Info - User
Info External
Enums§
- Accept
Datetime Format - DateTime header
- Account
Financing Mode - The financing mode of an Account
- Cancellable
Order Type - The type of the Order.
- Candlestick
Granularity - The granularity of a candlestick
- Direction
- In the context of an Order or a Trade, defines whether the units are positive or negative.
- Fixed
Price Order Reason - The reason that the Fixed Price Order was created
- Funding
Reason - The reason that an Account is being funded.
- Guaranteed
Stop Loss Order Mode - The overall behaviour of the Account regarding guaranteed Stop Loss Orders.
- Instrument
Type - The type of an Instrument.
- Limit
Order Reason - The reason that the Limit Order was initiated
- Market
IfTouched Order Reason - The reason that the Market-if-touched Order was initiated
- Market
Order Margin Closeout Reason - The reason that the Market Order was created to perform a margin closeout
- Market
Order Reason - The reason that the Market Order was created
- Order
Cancel Reason - The reason that an Order was cancelled.
- Order
Fill Reason - The reason that an Order was filled
- Order
Position Fill - Specification of how Positions in the Account are modified when the Order is filled.
- Order
State - The current state of the Order.
- Order
State Filter - The state to filter the requested Orders by.
- Order
Trigger Condition - Specification of which price component should be used when determining if an Order should be triggered and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always filled using their default price component. This feature is only provided through the REST API. Clients who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s proprietary or partner trading platforms, their transaction history or their account statements. OANDA platforms always assume that an Order’s trigger condition is set to the default value when indicating the distance from an Order’s trigger price, and will always provide the default trigger condition when creating or modifying an Order. A special restriction applies when creating a guaranteed Stop Loss Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side “DEFAULT” results in. So for a Stop Loss Order for a long trade valid values are “DEFAULT” and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
- Order
Type - The type of the Order.
- Position
Aggregation Mode - The way that position values for an Account are calculated and aggregated.
- Price
Status - The status of the Price.
- Stop
Loss Order Reason - The reason that the Stop Loss Order was initiated
- Stop
Order Reason - The reason that the Stop Order was initiated
- Take
Profit Order Reason - The reason that the Take Profit Order was initiated
- Time
InForce - The time-in-force of an Order. TimeInForce describes how long an Order should remain pending before being automatically cancelled by the execution system.
- TradePL
- The classification of TradePLs.
- Trade
State - The current state of the Trade.
- Trade
State Filter - The state to filter the Trades by
- Trailing
Stop Loss Order Reason - The reason that the Trailing Stop Loss Order was initiated
- Transaction
Filter - A filter that can be used when fetching Transactions
- Transaction
Reject Reason - The reason that a Transaction was rejected.
- Transaction
Type - The possible types of a Transaction
- Weekly
Alignment - The day of the week to use for candlestick granularities with weekly alignment.