Crate fxoanda

Source
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§

account
client
instrument
pricing
serdates
serfloats

Structs§

Account
AccountChanges
AccountChangesState
AccountProperties
AccountSummary
CalculatedAccountState
CalculatedPositionState
CalculatedTradeState
Candlestick
CandlestickData
ClientConfigureRejectTransaction
ClientConfigureTransaction
ClientExtensions
ClientPrice
CloseTransaction
CreateTransaction
DailyFinancingTransaction
DelayedTradeClosureTransaction
DynamicOrderState
FixedPriceOrder
FixedPriceOrderTransaction
GuaranteedStopLossOrderEntryData
GuaranteedStopLossOrderLevelRestriction
HomeConversions
Instrument
InstrumentCommission
LimitOrder
LimitOrderRejectTransaction
LimitOrderRequest
LimitOrderTransaction
LiquidityRegenerationSchedule
LiquidityRegenerationScheduleStep
MT4TransactionHeartbeat
MarginCallEnterTransaction
MarginCallExitTransaction
MarginCallExtendTransaction
MarketIfTouchedOrder
MarketIfTouchedOrderRejectTransaction
MarketIfTouchedOrderRequest
MarketIfTouchedOrderTransaction
MarketOrder
MarketOrderDelayedTradeClose
MarketOrderMarginCloseout
MarketOrderPositionCloseout
MarketOrderRejectTransaction
MarketOrderRequest
MarketOrderTradeClose
MarketOrderTransaction
OpenTradeFinancing
Order
OrderBook
OrderBookBucket
OrderCancelRejectTransaction
OrderCancelTransaction
OrderClientExtensionsModifyRejectTransaction
OrderClientExtensionsModifyTransaction
OrderFillTransaction
OrderIdentifier
OrderRequest
Position
PositionBook
PositionBookBucket
PositionFinancing
PositionSide
Price
PriceBucket
PricingHeartbeat
QuoteHomeConversionFactors
ReopenTransaction
ResetResettablePLTransaction
StopLossDetails
StopLossOrder
StopLossOrderRejectTransaction
StopLossOrderRequest
StopLossOrderTransaction
StopOrder
StopOrderRejectTransaction
StopOrderRequest
StopOrderTransaction
TakeProfitDetails
TakeProfitOrder
TakeProfitOrderRejectTransaction
TakeProfitOrderRequest
TakeProfitOrderTransaction
Trade
TradeClientExtensionsModifyRejectTransaction
TradeClientExtensionsModifyTransaction
TradeOpen
TradeReduce
TradeSummary
TrailingStopLossDetails
TrailingStopLossOrder
TrailingStopLossOrderRejectTransaction
TrailingStopLossOrderRequest
TrailingStopLossOrderTransaction
Transaction
TransactionHeartbeat
TransferFundsRejectTransaction
TransferFundsTransaction
UnitsAvailable
UnitsAvailableDetails
UserInfo
UserInfoExternal

Enums§

AcceptDatetimeFormat
DateTime header
AccountFinancingMode
The financing mode of an Account
CancellableOrderType
The type of the Order.
CandlestickGranularity
The granularity of a candlestick
Direction
In the context of an Order or a Trade, defines whether the units are positive or negative.
FixedPriceOrderReason
The reason that the Fixed Price Order was created
FundingReason
The reason that an Account is being funded.
GuaranteedStopLossOrderMode
The overall behaviour of the Account regarding guaranteed Stop Loss Orders.
InstrumentType
The type of an Instrument.
LimitOrderReason
The reason that the Limit Order was initiated
MarketIfTouchedOrderReason
The reason that the Market-if-touched Order was initiated
MarketOrderMarginCloseoutReason
The reason that the Market Order was created to perform a margin closeout
MarketOrderReason
The reason that the Market Order was created
OrderCancelReason
The reason that an Order was cancelled.
OrderFillReason
The reason that an Order was filled
OrderPositionFill
Specification of how Positions in the Account are modified when the Order is filled.
OrderState
The current state of the Order.
OrderStateFilter
The state to filter the requested Orders by.
OrderTriggerCondition
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.
OrderType
The type of the Order.
PositionAggregationMode
The way that position values for an Account are calculated and aggregated.
PriceStatus
The status of the Price.
StopLossOrderReason
The reason that the Stop Loss Order was initiated
StopOrderReason
The reason that the Stop Order was initiated
TakeProfitOrderReason
The reason that the Take Profit Order was initiated
TimeInForce
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.
TradeState
The current state of the Trade.
TradeStateFilter
The state to filter the Trades by
TrailingStopLossOrderReason
The reason that the Trailing Stop Loss Order was initiated
TransactionFilter
A filter that can be used when fetching Transactions
TransactionRejectReason
The reason that a Transaction was rejected.
TransactionType
The possible types of a Transaction
WeeklyAlignment
The day of the week to use for candlestick granularities with weekly alignment.