Fix bad request response handling

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-02-17 20:35:50 +00:00
parent ae5044142d
commit 152a0b4682
10 changed files with 46 additions and 25 deletions

View File

@@ -7,7 +7,7 @@ use crate::{
database,
types::{
alpaca::{
api,
self,
shared::{Sort, Source},
},
news::Prediction,
@@ -167,7 +167,7 @@ struct BarHandler {
fetch_from: OffsetDateTime,
fetch_to: OffsetDateTime,
next_page_token: Option<String>,
) -> api::outgoing::bar::Bar,
) -> alpaca::api::outgoing::bar::Bar,
}
fn us_equity_query_constructor(
@@ -175,14 +175,14 @@ fn us_equity_query_constructor(
fetch_from: OffsetDateTime,
fetch_to: OffsetDateTime,
next_page_token: Option<String>,
) -> api::outgoing::bar::Bar {
api::outgoing::bar::Bar::UsEquity {
) -> alpaca::api::outgoing::bar::Bar {
alpaca::api::outgoing::bar::Bar::UsEquity {
symbols: vec![symbol],
timeframe: ONE_MINUTE,
start: Some(fetch_from),
end: Some(fetch_to),
limit: Some(10000),
adjustment: None,
adjustment: Some(alpaca::api::outgoing::bar::Adjustment::All),
asof: None,
feed: Some(*ALPACA_SOURCE),
currency: None,
@@ -196,8 +196,8 @@ fn crypto_query_constructor(
fetch_from: OffsetDateTime,
fetch_to: OffsetDateTime,
next_page_token: Option<String>,
) -> api::outgoing::bar::Bar {
api::outgoing::bar::Bar::Crypto {
) -> alpaca::api::outgoing::bar::Bar {
alpaca::api::outgoing::bar::Bar::Crypto {
symbols: vec![symbol],
timeframe: ONE_MINUTE,
start: Some(fetch_from),
@@ -241,7 +241,7 @@ impl Handler for BarHandler {
let mut next_page_token = None;
loop {
let Ok(message) = api::incoming::bar::get_historical(
let Ok(message) = alpaca::api::incoming::bar::get_historical(
&self.config.alpaca_client,
&self.config.alpaca_rate_limiter,
self.data_url,
@@ -328,10 +328,10 @@ impl Handler for NewsHandler {
let mut next_page_token = None;
loop {
let Ok(message) = api::incoming::news::get_historical(
let Ok(message) = alpaca::api::incoming::news::get_historical(
&self.config.alpaca_client,
&self.config.alpaca_rate_limiter,
&api::outgoing::news::News {
&alpaca::api::outgoing::news::News {
symbols: vec![symbol.clone()],
start: Some(fetch_from),
end: Some(fetch_to),