diff --git a/README.md b/README.md index b79d582..3c64088 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ Create data folder next to docker-compose.yml `docker compose up --pull always` +If build the parquet file from the first time use: `ARK_SOURCE=ApiFull` or `ARK_SOURCE=ArkFundsIoFull` + +Afterwards use `ARK_SOURCE=ApiIncremental` + # Changing the data source In docker-compose.yml, change the data source by changing the environment variable ``` diff --git a/src/util.rs b/src/util.rs index fe849f3..2e6895e 100644 --- a/src/util.rs +++ b/src/util.rs @@ -602,37 +602,34 @@ impl Ark { last_day: Option, source: Option<&Source>, ) -> Result { - let url = match (&self.ticker, last_day) { - (self::Ticker::ARKVX, Some(last_day)) => format!( + let default_start_day = "2000-01-01"; + let url = match (&self.ticker, last_day, source) { + (self::Ticker::ARKVX, Some(last_day), _) => format!( "https://api.nexveridian.com/ark_holdings?ticker=ARKVX&start={}", last_day ), - (tic, Some(last_day)) => match source { - Some(Source::ArkFundsIoIncremental) => format!( - "https://arkfunds.io/api/v2/etf/holdings?symbol={}&date_from={}", - tic, last_day - ), - _ => format!( - "https://api.nexveridian.com/ark_holdings?ticker={}&start={}", - tic, last_day - ), - }, - (self::Ticker::ARKVX, None) => { - "https://api.nexveridian.com/ark_holdings?ticker=ARKVX&start=2000-01-01".to_owned() - } - (tic, None) => { - match source { - Some(Source::ArkFundsIoFull) => { - format!("https://arkfunds.io/api/v2/etf/holdings?symbol={}&date_from=2000-01-01", tic) - } - _ => { - format!( - "https://api.nexveridian.com/ark_holdings?ticker={}&start=2000-01-01", - tic - ) - } - } - } + (self::Ticker::ARKVX, None, _) => format!( + "https://api.nexveridian.com/ark_holdings?ticker=ARKVX&start={}", + default_start_day + ), + + (tic, Some(last_day), Some(Source::ArkFundsIoIncremental)) => format!( + "https://arkfunds.io/api/v2/etf/holdings?symbol={}&date_from={}", + tic, last_day + ), + (tic, None, Some(Source::ArkFundsIoFull)) => format!( + "https://arkfunds.io/api/v2/etf/holdings?symbol={}&date_from={}", + tic, default_start_day + ), + + (tic, Some(last_day), _) => format!( + "https://api.nexveridian.com/ark_holdings?ticker={}&start={}", + tic, last_day + ), + (tic, None, _) => format!( + "https://api.nexveridian.com/ark_holdings?ticker={}&start={}", + tic, default_start_day + ), }; let mut df = Reader::Json.get_data_url(url)?; @@ -655,8 +652,8 @@ impl Ark { pub fn get_csv_ark(&self) -> Result { let url = match self.ticker { self::Ticker::ARKVX => format!("https://assets.ark-funds.com/fund-documents/funds-etf-csv/{}", self.ticker.value()), - self::Ticker::ARKA | self::Ticker::ARKZ | - self::Ticker::ARKC | self::Ticker::ARKD | self::Ticker::ARKY => format!("https://cdn.21shares-funds.com/uploads/fund-documents/us-bank/holdings/product/current/{}-Export.csv", self.ticker.value()), + self::Ticker::ARKA | self::Ticker::ARKZ | self::Ticker::ARKC | self::Ticker::ARKD | + self::Ticker::ARKY => format!("https://cdn.21shares-funds.com/uploads/fund-documents/us-bank/holdings/product/current/{}-Export.csv", self.ticker.value()), _ => format!("https://assets.ark-funds.com/fund-documents/funds-etf-csv/ARK_{}_ETF_{}_HOLDINGS.csv", self.ticker.value(), self.ticker), }; Reader::Csv.get_data_url(url)