Remove stored abbreviation
- Alpaca is fuck Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -10,13 +10,14 @@ use crate::{
|
||||
utils::{duration_until, last_minute, FIFTEEN_MINUTES, ONE_MINUTE},
|
||||
};
|
||||
use backoff::{future::retry, ExponentialBackoff};
|
||||
use futures_util::future::join_all;
|
||||
use log::{error, info, warn};
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
use time::OffsetDateTime;
|
||||
use tokio::{
|
||||
join, spawn,
|
||||
sync::{mpsc, oneshot, Mutex, RwLock},
|
||||
task::{spawn_blocking, JoinHandle},
|
||||
task::JoinHandle,
|
||||
time::sleep,
|
||||
};
|
||||
|
||||
@@ -87,16 +88,18 @@ async fn handle_backfill_message(
|
||||
let mut backfill_jobs = backfill_jobs.lock().await;
|
||||
|
||||
let symbols = match message.assets {
|
||||
Subset::All => guard.symbols.clone().into_iter().collect::<Vec<_>>(),
|
||||
Subset::All => guard
|
||||
.assets
|
||||
.clone()
|
||||
.into_iter()
|
||||
.map(|(_, symbol)| symbol)
|
||||
.collect(),
|
||||
Subset::Some(assets) => assets
|
||||
.into_iter()
|
||||
.map(|asset| match thread_type {
|
||||
ThreadType::Bars(_) => asset.symbol,
|
||||
ThreadType::News => asset.abbreviation,
|
||||
})
|
||||
.map(|asset| asset.symbol)
|
||||
.filter(|symbol| match message.action {
|
||||
Action::Backfill => guard.symbols.contains(symbol),
|
||||
Action::Purge => !guard.symbols.contains(symbol),
|
||||
Action::Backfill => guard.assets.contains_right(symbol),
|
||||
Action::Purge => !guard.assets.contains_right(symbol),
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
};
|
||||
@@ -365,33 +368,30 @@ async fn execute_backfill_news(
|
||||
return;
|
||||
}
|
||||
|
||||
let app_config_clone = app_config.clone();
|
||||
let inputs = news
|
||||
.iter()
|
||||
.map(|news| format!("{}\n\n{}", news.headline, news.content))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let predictions: Vec<Prediction> = spawn_blocking(move || {
|
||||
inputs
|
||||
.chunks(app_config_clone.max_bert_inputs)
|
||||
.flat_map(|inputs| {
|
||||
app_config_clone
|
||||
.sequence_classifier
|
||||
.lock()
|
||||
.unwrap()
|
||||
.predict(inputs.iter().map(String::as_str).collect::<Vec<_>>())
|
||||
.into_iter()
|
||||
.map(|label| Prediction::try_from(label).unwrap())
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
let predictions = join_all(inputs.chunks(app_config.max_bert_inputs).map(|inputs| {
|
||||
let sequence_classifier = app_config.sequence_classifier.clone();
|
||||
async move {
|
||||
sequence_classifier
|
||||
.lock()
|
||||
.await
|
||||
.predict(inputs.iter().map(String::as_str).collect::<Vec<_>>())
|
||||
.into_iter()
|
||||
.map(|label| Prediction::try_from(label).unwrap())
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
}))
|
||||
.await
|
||||
.unwrap();
|
||||
.into_iter()
|
||||
.flatten();
|
||||
|
||||
let news = news
|
||||
.into_iter()
|
||||
.zip(predictions.into_iter())
|
||||
.zip(predictions)
|
||||
.map(|(news, prediction)| News {
|
||||
sentiment: prediction.sentiment,
|
||||
confidence: prediction.confidence,
|
||||
|
Reference in New Issue
Block a user