Skip to content

Commit

Permalink
fix(rust): fix the live examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaz001 committed Oct 6, 2024
1 parent fb09190 commit 0bf33c7
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 15 deletions.
2 changes: 1 addition & 1 deletion hftbacktest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ hmac = { version = "0.13.0-pre.3", optional = true }
rand = { version = "0.8.5", optional = true }
uuid = { version = "1.8.0", features = ["v4"], optional = true }
nom = { version = "7.1.3", optional = true }
iceoryx2 = { version = "0.4.1", optional = true }
iceoryx2 = { version = "0.4.1", optional = true, features = ["logger_tracing"] }
hftbacktest-derive = { path = "../hftbacktest-derive", optional = true, version = "0.2.0" }

[dev-dependencies]
Expand Down
22 changes: 17 additions & 5 deletions hftbacktest/examples/gridtrading_live.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
use algo::gridtrading;
use hftbacktest::{
live::{LiveBot, LoggingRecorder},
live::{
ipc::iceoryx::IceoryxUnifiedChannel,
Instrument,
LiveBot,
LiveBotBuilder,
LoggingRecorder,
},
prelude::{Bot, HashMapMarketDepth},
};

mod algo;

const ORDER_PREFIX: &str = "prefix";

fn prepare_live() -> LiveBot<HashMapMarketDepth> {
let mut hbt = LiveBot::builder()
.register("binancefutures", "1000SHIBUSDT", 0.000001, 1.0)
.depth(|asset| HashMapMarketDepth::new(asset.tick_size, asset.lot_size))
fn prepare_live() -> LiveBot<IceoryxUnifiedChannel, HashMapMarketDepth> {
let mut hbt = LiveBotBuilder::new()
.register(Instrument::new(
"binancefutures",
"1000SHIBUSDT",
0.000001,
1.0,
HashMapMarketDepth::new(0.000001, 1.0),
0,
))
.build()
.unwrap();

Expand Down
22 changes: 17 additions & 5 deletions hftbacktest/examples/gridtrading_live_bybit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
use algo::gridtrading;
use hftbacktest::{
live::{LiveBot, LoggingRecorder},
live::{
ipc::iceoryx::IceoryxUnifiedChannel,
Instrument,
LiveBot,
LiveBotBuilder,
LoggingRecorder,
},
prelude::{Bot, ErrorKind, HashMapMarketDepth},
};
use tracing::error;
Expand All @@ -9,10 +15,16 @@ mod algo;

const ORDER_PREFIX: &str = "prefix";

fn prepare_live() -> LiveBot<HashMapMarketDepth> {
let mut hbt = LiveBot::builder()
.register("bybit-futures", "BTCUSDT", 0.1, 0.001)
.depth(|asset| HashMapMarketDepth::new(asset.tick_size, asset.lot_size))
fn prepare_live() -> LiveBot<IceoryxUnifiedChannel, HashMapMarketDepth> {
let mut hbt = LiveBotBuilder::new()
.register(Instrument::new(
"bybit-futures",
"BTCUSDT",
0.1,
0.001,
HashMapMarketDepth::new(0.000001, 1.0),
0,
))
.error_handler(|error| {
match error.kind {
ErrorKind::ConnectionInterrupted => {
Expand Down
22 changes: 18 additions & 4 deletions hftbacktest/examples/live_order_error_handling.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
use algo::gridtrading;
use hftbacktest::{
live::{BotError, LiveBot, LoggingRecorder},
live::{
ipc::iceoryx::IceoryxUnifiedChannel,
BotError,
Instrument,
LiveBot,
LiveBotBuilder,
LoggingRecorder,
},
prelude::{Bot, ErrorKind, HashMapMarketDepth, Value},
};
use tracing::error;
Expand All @@ -9,9 +16,16 @@ mod algo;

const ORDER_PREFIX: &str = "prefix";

fn prepare_live() -> LiveBot<HashMapMarketDepth> {
let mut hbt = LiveBot::builder()
.register("binancefutures", "SOLUSDT", 0.001, 1.0)
fn prepare_live() -> LiveBot<IceoryxUnifiedChannel, HashMapMarketDepth> {
let mut hbt = LiveBotBuilder::new()
.register(Instrument::new(
"binancefutures",
"SOLUSDT",
0.001,
1.0,
HashMapMarketDepth::new(0.001, 1.0),
0,
))
.error_handler(|error| {
match error.kind {
ErrorKind::ConnectionInterrupted => {
Expand Down

0 comments on commit 0bf33c7

Please sign in to comment.