normalize arkvx

This commit is contained in:
Elijah McMorris 2023-11-21 15:51:43 -08:00
parent 9426313f73
commit 6343159387
Signed by: NexVeridian
SSH key fingerprint: SHA256:bsA1SKZxuEcEVHAy3gY1HUeM5ykRJl0U0kQHQn0hMg8
5 changed files with 17 additions and 29 deletions

View file

@ -16,7 +16,7 @@ env:
jobs: jobs:
run-tests: run-tests:
name: Run tests name: run tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -31,7 +31,7 @@ jobs:
run: cargo nextest run -E "all() - test(get_api) - kind(bin)" run: cargo nextest run -E "all() - test(get_api) - kind(bin)"
clippy: clippy:
name: Clippy name: clippy
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3

View file

@ -1,7 +1,7 @@
version: "3" version: "3"
services: services:
ark-invest-api-rust: ark-invest-api-rust:
image: ghcr.io/NexVeridian/ark-invest-api-rust:latest image: ghcr.io/nexveridian/ark-invest-api-rust:latest
container_name: ark-invest-api-rust container_name: ark-invest-api-rust
restart: unless-stopped restart: unless-stopped
volumes: volumes:

View file

@ -86,28 +86,20 @@ async fn main() {
.layer(CompressionLayer::new().zstd(true)) .layer(CompressionLayer::new().zstd(true))
.route("/api.json", get(serve_api)) .route("/api.json", get(serve_api))
.layer(CompressionLayer::new().zstd(true)) .layer(CompressionLayer::new().zstd(true))
.api_route(
"/arkvc_holdings",
get_with(routes::arkvc_holdings, |mut o| {
o = o.id("ARKVC Holdings");
description_date(o)
}),
)
.layer(
rate_limit_global(500)
.layer(rate_limit_ip())
.layer(cors())
.layer(CompressionLayer::new().zstd(true)),
)
.api_route( .api_route(
"/ark_holdings", "/ark_holdings",
get_with(routes::ark_holdings, |mut o| { get_with(routes::ark_holdings, |mut o| {
o = o.id("ARK* ETF Holdings"); // test description
o = o.id("ARK* ETF Holdings").description(r"
| date ticker cusip company market_value shares share_price weight
--- --- --- --- --- --- --- ---
date str str str i64 f64 f64 f64
");
description_date(o) description_date(o)
}), }),
) )
.layer( .layer(
rate_limit_global(200) rate_limit_global(1000)
.layer(rate_limit_ip()) .layer(rate_limit_ip())
.layer(cors()) .layer(cors())
.layer(CompressionLayer::new().zstd(true)), .layer(CompressionLayer::new().zstd(true)),

View file

@ -3,16 +3,6 @@ use axum::extract::Query;
mod polars_utils; mod polars_utils;
pub async fn arkvc_holdings(date_range: Query<polars_utils::DateRange>) -> impl IntoApiResponse {
let df = polars_utils::get_parquet("ARKVC".to_owned()).await.unwrap();
let filter_df = polars_utils::filter_date_range(df, date_range)
.await
.unwrap();
axum::Json(polars_utils::to_json(filter_df).await.unwrap())
}
pub async fn ark_holdings( pub async fn ark_holdings(
ticker: Query<polars_utils::Ticker>, ticker: Query<polars_utils::Ticker>,
date_range: Query<polars_utils::DateRange>, date_range: Query<polars_utils::DateRange>,

View file

@ -56,13 +56,19 @@ pub async fn filter_date_range(
} }
#[derive(Serialize, Deserialize, JsonSchema, strum_macros::Display)] #[derive(Serialize, Deserialize, JsonSchema, strum_macros::Display)]
pub enum TypeTicker { pub enum Ticker {
ARKVX,
ARKF, ARKF,
ARKG, ARKG,
ARKK, ARKK,
ARKQ, ARKQ,
ARKW, ARKW,
ARKX, ARKX,
// ARKA,
// ARKZ,
ARKC,
ARKD,
ARKY,
} }
#[derive(Serialize, Deserialize, JsonSchema)] #[derive(Serialize, Deserialize, JsonSchema)]