1use backproof_sdk::{
2 api::{Candle, Order},
3 BackproofStrategy, Options,
4};
5use std::time::Duration;
6use tokio;
7use tracing::{info, instrument};
8
9#[instrument]
10#[tokio::main]
11async fn main() {
12 tracing_subscriber::fmt::init();
13
14 let address = std::env::args().nth(1).unwrap();
15
16 let mut strategy = BackproofStrategy::builder()
17 .api_key("A323FSDEO3123FSD".to_string())
18 .api_strategy("flex".to_string(), |x: Candle| -> Order {
19 println!("Strategy running with input {x:?}...");
20 std::thread::sleep(Duration::from_secs(1));
21
22 Order {
23 symbol: "BTC".to_string(),
24 quantity: "100".to_string(),
25 side: 1,
26 }
27 })
28 .build(address)
29 .await
30 .expect("strategy build failed");
31
32 let session = strategy.register().await.expect("register");
33
34 info!("Starting strategy");
35
36 let closer = strategy
37 .run(Options::default(), session)
38 .await
39 .expect("strategy run failed");
40
41 std::thread::sleep(Duration::from_secs(5));
42 info!("closing backend.");
43 let _ = closer.send(()).expect("failed to close");
44}