2021-01-14 12:42:23 +00:00
|
|
|
use std::collections::{HashMap, VecDeque};
|
|
|
|
|
2021-01-13 09:24:59 +00:00
|
|
|
use crate::connectors::{Client, Connector};
|
2021-01-13 09:26:29 +00:00
|
|
|
use crate::events::Event;
|
2021-01-13 09:24:59 +00:00
|
|
|
use crate::models::{Order, Position};
|
2021-01-14 12:42:23 +00:00
|
|
|
use crate::strategy::PositionStrategy;
|
2021-01-13 09:24:59 +00:00
|
|
|
use crate::ticker::Ticker;
|
|
|
|
|
2021-01-14 12:42:23 +00:00
|
|
|
pub struct EventManager {
|
2021-01-13 09:26:29 +00:00
|
|
|
events: Vec<Event>,
|
|
|
|
}
|
2021-01-13 09:03:24 +00:00
|
|
|
|
2021-01-14 12:42:23 +00:00
|
|
|
pub struct PositionManager {
|
2021-01-13 09:24:59 +00:00
|
|
|
queue: VecDeque<Position>,
|
|
|
|
open_positions: Vec<Position>,
|
|
|
|
client: Client,
|
2021-01-14 12:42:23 +00:00
|
|
|
strategy: Option<Box<dyn PositionStrategy>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PositionManager {
|
|
|
|
pub fn new(client: Client) -> Self {
|
|
|
|
PositionManager {
|
|
|
|
queue: VecDeque::new(),
|
|
|
|
open_positions: Vec::new(),
|
|
|
|
client,
|
|
|
|
strategy: None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn with_strategy(mut self, strategy: Box<dyn PositionStrategy>) -> Self {
|
|
|
|
self.strategy = Some(strategy);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn update(&self) -> Option<Vec<Event>> {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
2021-01-13 09:24:59 +00:00
|
|
|
}
|
2021-01-13 09:03:24 +00:00
|
|
|
|
2021-01-14 12:42:23 +00:00
|
|
|
pub struct OrderManager {
|
2021-01-13 09:24:59 +00:00
|
|
|
queue: VecDeque<Order>,
|
|
|
|
open_orders: Vec<Order>,
|
|
|
|
client: Client,
|
|
|
|
}
|
2021-01-14 12:42:23 +00:00
|
|
|
|
|
|
|
impl OrderManager {
|
|
|
|
pub fn new(client: Client) -> Self {
|
|
|
|
OrderManager {
|
|
|
|
queue: VecDeque::new(),
|
|
|
|
open_orders: Vec::new(),
|
|
|
|
client,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn update(&self) -> Option<Vec<Event>> {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
}
|