Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intake orderflow with alternatives to http #191

Open
bertmiller opened this issue Sep 25, 2024 · 2 comments
Open

Intake orderflow with alternatives to http #191

bertmiller opened this issue Sep 25, 2024 · 2 comments

Comments

@bertmiller
Copy link
Member

There are more efficient ways to receive orderflow than just http, e.g. a websocket. Not strongly held on what, but I imagine we'd want to have some alternatives.

@ferranbt
Copy link
Contributor

An idea that comes to mind.

trait Orderflow {
  fn start(&self) -> Receiver<Order>
}

struct MultiOrderflow {
   orderflow_providers: Vec<Box<dyn Orderflow>>
}

impl Orderflow for MultiOrderflow {
    fn start(&self) -> Receiver<Order> {
        let (tx, rx) = channel();

        for provider in &self.orderflow_providers {
            let provider_rx = provider.start();
            let tx_clone = tx.clone();

            thread::spawn(move || {
                for order in provider_rx {
                    tx_clone.send(order).expect("Failed to send order");
                }
            });
        }
        rx
    }
}

struct LiveBuilder {
   pub orderflow: Orderflow
}

@bertmiller
Copy link
Member Author

That's cool, I like that @ferranbt! Then we can get many implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants