Skip to content

NorbertNiderla/rust-xtb-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust_xtb_api

XTB API in Rust.

Todo

  • At this moment API is connecting only to real accounts, it should have option to connect to demo server.

Example

let mut xtb = XtbConnection::new().await.expect("Failed to connect to Xtb");
let login_response = xtb.issue_command(&XtbCommand::Login(XtbLoginCommand::new(&login, &password))).await.expect("Failed to login to Xtb");

let request_response = xtb.issue_command(&XtbCommand::GetLastChartRequest(XtbGetLastChartRequestCommand::new(
        "B24.PL",
        XtbPeriod::D1,
        NaiveDateTime::parse_from_str("2023-12-10 07:00:00", "%Y-%m-%d %H:%M:%S").unwrap()
))).await.expect("Failed to obtain data from Xtb");

let data = GetLastChartRequestReturnData::new(&request_response).expect("Failed to parse get last char request response");
    
let logout_response = xtb.issue_command(&XtbCommand::Logout(XtbLogoutCommand::new())).await.expect("Failed to logout from Xtb");

Tests

In order to run tests you have to specify login and password to real XTB account as environment variables.

Windows command_line:
set XTB_LOGIN="login"
set XTB_PASSWORD="password"

, or add them to [build] section in Config.toml.

About

XTB API in Rust.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages