mirror of
https://github.com/NexVeridian/ark-invest-api-rust-data.git
synced 2025-09-02 01:49:12 +00:00
refactor: move get url
This commit is contained in:
parent
4283264b0e
commit
817f3c9baf
5 changed files with 34 additions and 9 deletions
|
@ -18,8 +18,8 @@ polars = { version = "0.32", features = [
|
||||||
reqwest = { version = "0.11", features = ["blocking", "gzip"] }
|
reqwest = { version = "0.11", features = ["blocking", "gzip"] }
|
||||||
glob = { version = "0.3" }
|
glob = { version = "0.3" }
|
||||||
clokwerk = "0.4"
|
clokwerk = "0.4"
|
||||||
strum_macros = "0.25"
|
strum_macros = "0.26"
|
||||||
strum = "0.25"
|
strum = "0.26"
|
||||||
tokio = { version = "1.34", features = ["full"] }
|
tokio = { version = "1.34", features = ["full"] }
|
||||||
openssl = { version = "0.10", features = ["vendored"] }
|
openssl = { version = "0.10", features = ["vendored"] }
|
||||||
chrono = { version = "0.4", features = ["serde"] }
|
chrono = { version = "0.4", features = ["serde"] }
|
||||||
|
@ -31,3 +31,5 @@ anyhow = "1.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serial_test = "*"
|
serial_test = "*"
|
||||||
|
rstest = "0.21"
|
||||||
|
pretty_assertions = "1.4"
|
||||||
|
|
|
@ -679,12 +679,7 @@ impl Ark {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_csv_ark(&self) -> Result<DataFrame, Error> {
|
pub fn get_csv_ark(&self) -> Result<DataFrame, Error> {
|
||||||
let url = match self.ticker.data_source() {
|
let url = self.ticker.get_url();
|
||||||
DataSource::ArkVenture => format!("https://assets.ark-funds.com/fund-documents/funds-etf-csv/{}", self.ticker.value()),
|
|
||||||
DataSource::Ark => format!("https://assets.ark-funds.com/fund-documents/funds-etf-csv/ARK_{}_ETF_{}_HOLDINGS.csv", self.ticker.value(), self.ticker),
|
|
||||||
DataSource::Shares21 => format!("https://cdn.21shares-funds.com/uploads/fund-documents/us-bank/holdings/product/current/{}-Export.csv", self.ticker.value()),
|
|
||||||
DataSource::ArkEurope | DataSource::Rize => format!("https://europe.ark-funds.com/funds/{}/full-fund-holdings-download/", self.ticker.value()),
|
|
||||||
};
|
|
||||||
Reader::Csv.get_data_url(url)
|
Reader::Csv.get_data_url(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,6 +747,7 @@ impl Reader {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
use anyhow::Error;
|
||||||
use polars::frame::DataFrame;
|
use polars::frame::DataFrame;
|
||||||
use polars::prelude::{IntoLazy, LazyFrame};
|
use polars::prelude::{IntoLazy, LazyFrame};
|
||||||
use anyhow::Error;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum DF {
|
pub enum DF {
|
||||||
|
|
|
@ -114,4 +114,30 @@ impl Ticker {
|
||||||
| Ticker::PMNT => DataSource::Rize,
|
| Ticker::PMNT => DataSource::Rize,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_url(&self) -> String {
|
||||||
|
match self.data_source() {
|
||||||
|
DataSource::ArkVenture => format!("https://assets.ark-funds.com/fund-documents/funds-etf-csv/{}", self.value()),
|
||||||
|
DataSource::Ark => format!("https://assets.ark-funds.com/fund-documents/funds-etf-csv/ARK_{}_ETF_{}_HOLDINGS.csv", self.value(), self),
|
||||||
|
DataSource::Shares21 => format!("https://cdn.21shares-funds.com/uploads/fund-documents/us-bank/holdings/product/current/{}-Export.csv", self.value()),
|
||||||
|
DataSource::ArkEurope | DataSource::Rize => format!("https://europe.ark-funds.com/funds/{}/full-fund-holdings-download/", self.value()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
use rstest::rstest;
|
||||||
|
|
||||||
|
#[rstest]
|
||||||
|
#[case(Ticker::ARKVX, "https://assets.ark-funds.com/fund-documents/funds-etf-csv/ARK_VENTURE_FUND_ARKVX_HOLDINGS.csv")]
|
||||||
|
#[case(Ticker::ARKK, "https://assets.ark-funds.com/fund-documents/funds-etf-csv/ARK_INNOVATION_ETF_ARKK_HOLDINGS.csv")]
|
||||||
|
#[case(Ticker::ARKA, "https://cdn.21shares-funds.com/uploads/fund-documents/us-bank/holdings/product/current/ARKA-Export.csv")]
|
||||||
|
#[case(Ticker::EUROPE_ARKI, "https://europe.ark-funds.com/funds/artificial-intelligence-robotics/full-fund-holdings-download/")]
|
||||||
|
#[case(Ticker::CYBR, "https://europe.ark-funds.com/funds/cybersecurity-and-data-privacy/full-fund-holdings-download/")]
|
||||||
|
fn get_url(#[case] input: Ticker, #[case] expected: String) {
|
||||||
|
assert_eq!(input.get_url(), expected)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use anyhow::{Error, Result};
|
use anyhow::{Error, Result};
|
||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
use polars::datatypes::DataType;
|
use polars::datatypes::DataType;
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
use ark_invest_api_rust_data::util::ticker::Ticker;
|
use ark_invest_api_rust_data::util::ticker::Ticker;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue