Fix watch list
This commit is contained in:
@@ -16,6 +16,7 @@ pub struct Engine {
|
||||
pub strategy: Arc<StrategyEngine>,
|
||||
pub config: Arc<Mutex<Config>>,
|
||||
pub accounts: Arc<Mutex<AccountList>>,
|
||||
pub watch_list: Arc<Mutex<Vec<MarketItem>>>,
|
||||
}
|
||||
|
||||
impl Engine {
|
||||
@@ -32,6 +33,7 @@ impl Engine {
|
||||
strategy: strategy.initialize(engine.clone()),
|
||||
config,
|
||||
accounts,
|
||||
watch_list: Arc::new(Mutex::new(Vec::new())),
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -53,6 +55,8 @@ impl Engine {
|
||||
|
||||
match crate::fetch::fetch_watch_list(&client, watch_list).await {
|
||||
Ok(watch_list) => {
|
||||
*self.watch_list.lock().await = watch_list.clone();
|
||||
|
||||
if let Err(error) = self
|
||||
.terminal_server
|
||||
.broadcast(
|
||||
|
||||
@@ -74,11 +74,11 @@ impl StrategyEngine {
|
||||
None => {}
|
||||
|
||||
Some(StrategyMessage::GetWatchList) => {
|
||||
let mut v = vec![1];
|
||||
|
||||
v.extend(engine.config.lock().await.watchlist.to_com());
|
||||
|
||||
self.strategy.send_raw(&v).await?;
|
||||
self.strategy
|
||||
.send(&StrategyEngineMessage::WatchList(
|
||||
engine.watch_list.lock().await.clone(),
|
||||
))
|
||||
.await?;
|
||||
}
|
||||
|
||||
Some(StrategyMessage::Log(mut log)) => {
|
||||
|
||||
Reference in New Issue
Block a user