This commit is contained in:
Elijah McMorris 2023-06-14 09:03:28 +00:00
parent bb47fb8fb0
commit 5d5fb5cd94
Signed by: NexVeridian
SSH key fingerprint: SHA256:bsA1SKZxuEcEVHAy3gY1HUeM5ykRJl0U0kQHQn0hMg8
3 changed files with 8382 additions and 9625 deletions

File diff suppressed because it is too large Load diff

View file

@ -49,14 +49,15 @@ fn main() {
.unwrap(); .unwrap();
println!("{:#?}", api); println!("{:#?}", api);
// let update = df_format(get_csv_ark(Ticker::ARKK).unwrap()).unwrap(); // let ark = Ark::new(Source::Ark, Ticker::ARKK)
// println!("{:#?}", update); // .unwrap()
// .collect()
// .unwrap();
// println!("{:#?}", ark);
// update_parquet(Ticker::ARKK).unwrap(); // let ark = Ark::new(Source::Ark, Ticker::ARKVC)
// let x = df_format(read_parquet(Ticker::ARKK).unwrap()).unwrap(); // .unwrap()
// println!("{:#?}", x); // .collect()
// .unwrap();
// merge_csv_to_parquet(Ticker::ARKVC).unwrap(); // println!("{:#?}", ark);
// let x = df_format(read_parquet(Ticker::ARKVC).unwrap()).unwrap();
// println!("{:#?}", x);
} }

View file

@ -115,8 +115,7 @@ impl Ark {
ark.df = Self::concat_df(vec![ ark.df = Self::concat_df(vec![
Self::df_format(ark.df)?, Self::df_format(ark.df)?,
Self::df_format(update.into())?, Self::df_format(update.into())?,
])? ])?;
.into();
} }
Ok(ark) Ok(ark)
} }
@ -159,7 +158,7 @@ impl Ark {
fn concat_df(dfs: Vec<DF>) -> Result<DF, Box<dyn Error>> { fn concat_df(dfs: Vec<DF>) -> Result<DF, Box<dyn Error>> {
// with dedupe // with dedupe
let df = concat(dfs.lazy(), false, true)?; let df = concat(dfs.lazy(), false, true)?;
Ok(Self::dedupe(df.into())?) Self::dedupe(df.into())
} }
pub fn dedupe(mut df: DF) -> Result<DF, Box<dyn Error>> { pub fn dedupe(mut df: DF) -> Result<DF, Box<dyn Error>> {
@ -171,11 +170,11 @@ impl Ark {
} }
pub fn format(&mut self) -> Result<&Self, Box<dyn Error>> { pub fn format(&mut self) -> Result<&Self, Box<dyn Error>> {
self.df = Self::df_format(self.df.clone())?.into(); self.df = Self::df_format(self.df.clone())?;
Ok(self) Ok(self)
} }
fn df_format(mut df: DF) -> Result<DF, Box<dyn Error>> { fn df_format(df: DF) -> Result<DF, Box<dyn Error>> {
let mut df = df.collect()?; let mut df = df.collect()?;
if df.get_column_names().contains(&"market_value_($)") { if df.get_column_names().contains(&"market_value_($)") {
@ -222,8 +221,7 @@ impl Ark {
expressions.push(col("date").str().strptime( expressions.push(col("date").str().strptime(
DataType::Date, DataType::Date,
StrptimeOptions { StrptimeOptions {
// format: Some("%m/%d/%Y".into()), format: Some("%m/%d/%Y".into()),
format: None,
strict: false, strict: false,
exact: true, exact: true,
cache: true, cache: true,
@ -307,23 +305,18 @@ impl Ark {
} }
pub fn get_api(&self, last_day: Option<NaiveDate>) -> Result<LazyFrame, Box<dyn Error>> { pub fn get_api(&self, last_day: Option<NaiveDate>) -> Result<LazyFrame, Box<dyn Error>> {
let tic: Ticker = self.ticker; let url = match (self.ticker, last_day) {
let url = match (tic, last_day) {
(self::Ticker::ARKVC, Some(last_day)) => format!( (self::Ticker::ARKVC, Some(last_day)) => format!(
"https://api.nexveridian.com/arkvc_holdings?end={}", "https://api.nexveridian.com/arkvc_holdings?end={}",
last_day last_day
), ),
(tic, Some(last_day)) => format!( (tic, Some(last_day)) => format!(
"https://api.nexveridian.com/ark_holdings?ticker={}&end={}", "https://api.nexveridian.com/ark_holdings?ticker={}&end={}",
tic.value(), tic, last_day
last_day
), ),
(self::Ticker::ARKVC, None) => "https://api.nexveridian.com/arkvc_holdings".to_owned(), (self::Ticker::ARKVC, None) => "https://api.nexveridian.com/arkvc_holdings".to_owned(),
(tic, None) => { (tic, None) => {
format!( format!("https://api.nexveridian.com/ark_holdings?ticker={}", tic)
"https://api.nexveridian.com/ark_holdings?ticker={}",
tic.value()
)
} }
}; };
Reader::Json.get_data_url(url) Reader::Json.get_data_url(url)