| Crates.io | avanza-rs |
| lib.rs | avanza-rs |
| version | 0.1.3 |
| created_at | 2023-07-28 17:32:25.582491+00 |
| updated_at | 2023-07-31 09:38:27.470767+00 |
| description | A Rust API client for Avanza |
| homepage | |
| repository | https://github.com/feelixe/avanza-rs |
| max_upload_size | |
| id | 928685 |
| size | 24,055 |
A Rust API client for Avanza. Inspired by fhqvst/avanza
use avanza_rs::client:{Client, Credentials};
// Your credentials, preferable from .env.
let username = "username";
let password = "password";
let totp_secret = "totp_secret";
// Construct Credentials instance.
let credentials = super::client::Credentials {
username: String::from(username),
password: String::from(password),
totp_secret: String::from(totp_secret)
};
// Run authenticate.
let client = super::client::Client::authenticate(&credentials).await?;
// Get a list of accounts.
let accounts = client.list_accounts().await?;
// Get a specific account by id.
let account = client.get_acccount("1234567").await?;
// Construct StockOrder instance.
let stock_order = StockOrder {
orderbook_id: String::from("5247"),
account_id: account.id.clone(),
price: 215.0,
volume: 10,
side: Side::BUY,
};
// Execute a StockOrder
let result = client.execute_stock_order(&stock_order).await?;
cargo install totp.totp <TOTP_SECERT> and enter the 6 digit code on Avanza.<TOTP_SECERT> to .env