pub struct BackProofStrategyBuilder { /* private fields */ }
Expand description
The strategy backproof strategy builder.
Implementations§
Source§impl BackProofStrategyBuilder
Lets you build your strategy step by step.
impl BackProofStrategyBuilder
Lets you build your strategy step by step.
pub fn new() -> Self
Sourcepub fn api_key(self, api_key: String) -> Self
pub fn api_key(self, api_key: String) -> Self
Examples found in repository?
examples/client.rs (line 17)
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}
Sourcepub fn api_strategy(
self,
name: String,
logic: impl Fn(Candle) -> Order + 'static + Send,
) -> Self
pub fn api_strategy( self, name: String, logic: impl Fn(Candle) -> Order + 'static + Send, ) -> Self
Examples found in repository?
examples/client.rs (lines 18-27)
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}
Sourcepub async fn build<D>(
self,
endpoint: D,
) -> Result<BackproofStrategy, BackproofSdkError>
pub async fn build<D>( self, endpoint: D, ) -> Result<BackproofStrategy, BackproofSdkError>
Examples found in repository?
examples/client.rs (line 28)
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}
Trait Implementations§
Source§impl Debug for BackProofStrategyBuilder
impl Debug for BackProofStrategyBuilder
Source§impl Default for BackProofStrategyBuilder
impl Default for BackProofStrategyBuilder
Source§fn default() -> BackProofStrategyBuilder
fn default() -> BackProofStrategyBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for BackProofStrategyBuilder
impl !RefUnwindSafe for BackProofStrategyBuilder
impl Send for BackProofStrategyBuilder
impl !Sync for BackProofStrategyBuilder
impl Unpin for BackProofStrategyBuilder
impl !UnwindSafe for BackProofStrategyBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request