#currency #conversion #api #oanda #api-client #fxoanda #conduct

fxoanda_serdes

Library to conduct currency conversion with the Oanda API

2 releases

0.1.1 Apr 2, 2024
0.1.0 Feb 22, 2019

#152 in Finance

Download history 3/week @ 2024-02-16 19/week @ 2024-02-23 6/week @ 2024-03-01 4/week @ 2024-03-08 2/week @ 2024-03-15 3/week @ 2024-03-22 236/week @ 2024-03-29 39/week @ 2024-04-05 2/week @ 2024-04-12

280 downloads per month
Used in 2 crates

MIT/Apache

4KB
61 lines

fxoanda

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

# in your Cargo.toml
reqwest = {version = "0.12.2", features = ["json"]}
tokio = { version = "1.37.0", features = ["macros", "time", "rt-multi-thread"] }
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.

Dependencies

~2.5MB
~39K SLoC