Closed simsim-14 closed 5 months ago
I'm in the process of stabilizing the API, so it hasn't undergone thorough testing yet. But, I will certainly provide more examples. In the meantime, please refer to the following snippet:
let mut hbt = LiveBuilder::new()
.register("binancefutures", binance_futures)
.add("binancefutures", "BTCUSDT", 0.1, 0.001) // asset_no: 0
.add("binancefutures", "ETHUSDT", 0.01, 0.001) // asset_no: 1
.build()
.unwrap();
in the algo,
while hbt.elapse(1_000_000_000).unwrap() {
{
// BTCUSDT
let depth = hbt.depth(0);
let position = hbt.position(0);
// your algo
}
// Due to Rust's borrowing rules, {} is necessary.
{
// ETHUSDT
let depth = hbt.depth(1);
let position = hbt.position(1);
// your algo
}
}
Oh okay, so that would still have worked if we had
let mut hbt = LiveBuilder::new() .register("binancefutures", binance_futures), .register("dummyexchange", exchange_2), .add("binancefutures", "BTCUSDT", 0.1, 0.001) // asset_no: 0 .add("dummyexchange", "ETHUSDT", 0.01, 0.001) // asset_no: 1 .build() .unwrap();
?
Thanks for the answer.
yes, that's the planned usage of the api.
Ok, now I understand. Thanks.
Hello,
I am having some hard time trying to run a Multi asset, multi exchange live script.
From what I have seen from the code, I understand that asset_no is probably a pointer to asset info as well as the exchange that it refers to.
However, I am a bit confused on how to use this, I would have some intuition to use for example depth(connection/exchange, asset_name) instead of depth(asset_no) (which I am not sure exactly what it is).
So I would be very grateful if you provide some example implementation on how to run a Multi asset, multi exchange live script (even if the second connection is dummy, since we now have only binance futures).