Organize modules
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::types::Source;
|
||||
use crate::types::alpaca::Source;
|
||||
use governor::{DefaultDirectRateLimiter, Quota, RateLimiter};
|
||||
use reqwest::{header::HeaderMap, Client};
|
||||
use std::{env, num::NonZeroU32, sync::Arc};
|
||||
|
@@ -5,12 +5,12 @@ use crate::{
|
||||
},
|
||||
data::authenticate_websocket,
|
||||
database,
|
||||
time::{duration_until, last_minute, next_minute, ONE_MINUTE},
|
||||
types::{
|
||||
api::incoming,
|
||||
alpaca::{api::incoming, websocket},
|
||||
asset::{self, Asset},
|
||||
websocket, Bar, BarValidity, BroadcastMessage, Class,
|
||||
Bar, BarValidity, BroadcastMessage, Class,
|
||||
},
|
||||
utils::{duration_until, last_minute, next_minute, ONE_MINUTE},
|
||||
};
|
||||
use core::panic;
|
||||
use futures_util::{
|
||||
@@ -283,8 +283,9 @@ pub async fn backfill(
|
||||
]);
|
||||
|
||||
app_config.alpaca_rate_limit.until_ready().await;
|
||||
|
||||
let response = request.send().await.unwrap();
|
||||
let mut response = if response.status() == reqwest::StatusCode::OK {
|
||||
let response = if response.status() == reqwest::StatusCode::OK {
|
||||
response.json::<incoming::bar::Message>().await.unwrap()
|
||||
} else {
|
||||
error!(
|
||||
@@ -297,14 +298,11 @@ pub async fn backfill(
|
||||
break;
|
||||
};
|
||||
|
||||
for bar in response
|
||||
.bars
|
||||
.remove(&asset.symbol)
|
||||
.unwrap_or_default()
|
||||
.unwrap_or_default()
|
||||
{
|
||||
bars.push(Bar::from((bar, asset.symbol.clone())));
|
||||
}
|
||||
response.bars.into_iter().for_each(|(symbol, bar_vec)| {
|
||||
bar_vec.unwrap_or_default().into_iter().for_each(|bar| {
|
||||
bars.push(Bar::from((bar, symbol.clone())));
|
||||
});
|
||||
});
|
||||
|
||||
if response.next_page_token.is_none() {
|
||||
break;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
pub mod market;
|
||||
|
||||
use crate::{config::Config, types::websocket};
|
||||
use crate::{config::Config, types::alpaca::websocket};
|
||||
use core::panic;
|
||||
use futures_util::{
|
||||
stream::{SplitSink, SplitStream},
|
||||
|
@@ -5,8 +5,8 @@ mod config;
|
||||
mod data;
|
||||
mod database;
|
||||
mod routes;
|
||||
mod time;
|
||||
mod types;
|
||||
mod utils;
|
||||
|
||||
use config::Config;
|
||||
use dotenv::dotenv;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
use crate::config::{Config, ALPACA_ASSET_API_URL};
|
||||
use crate::database;
|
||||
use crate::types::{
|
||||
api::incoming::{self, asset::Status},
|
||||
alpaca::api::incoming::{self, asset::Status},
|
||||
asset, Asset, BroadcastMessage,
|
||||
};
|
||||
use axum::{extract::Path, Extension, Json};
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#![allow(clippy::struct_excessive_bools)]
|
||||
|
||||
use crate::types::api::impl_from_enum;
|
||||
use crate::types::alpaca::api::impl_from_enum;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
5
src/types/alpaca/mod.rs
Normal file
5
src/types/alpaca/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
pub mod api;
|
||||
pub mod source;
|
||||
pub mod websocket;
|
||||
|
||||
pub use source::Source;
|
@@ -1,12 +1,9 @@
|
||||
pub mod api;
|
||||
pub mod alpaca;
|
||||
pub mod asset;
|
||||
pub mod bar;
|
||||
pub mod source;
|
||||
pub mod websocket;
|
||||
|
||||
pub use asset::{Asset, Class, Exchange};
|
||||
pub use bar::{Bar, BarValidity};
|
||||
pub use source::Source;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum BroadcastMessage {
|
||||
|
3
src/utils/mod.rs
Normal file
3
src/utils/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
pub mod time;
|
||||
|
||||
pub use time::{duration_until, last_minute, next_minute, ONE_MINUTE};
|
Reference in New Issue
Block a user