mirror of
https://github.com/NexVeridian/ark-invest-api-rust-data.git
synced 2025-09-02 09:59:12 +00:00
ARKB for ARKF
This commit is contained in:
parent
3ad11c2881
commit
8ed0fb751c
1 changed files with 46 additions and 0 deletions
46
src/util.rs
46
src/util.rs
|
@ -376,6 +376,16 @@ impl Ark {
|
|||
.otherwise(col("company"))
|
||||
.alias("company"),
|
||||
])
|
||||
.with_columns(vec![
|
||||
when(col("company").eq(lit("ARK BITCOIN ETF HOLDCO (ARKF)")))
|
||||
.then(lit("ARKB"))
|
||||
.otherwise(col("ticker"))
|
||||
.alias("ticker"),
|
||||
when(col("company").eq(lit("ARK BITCOIN ETF HOLDCO (ARKF)")))
|
||||
.then(lit("ARKB"))
|
||||
.otherwise(col("company"))
|
||||
.alias("company"),
|
||||
])
|
||||
.collect()
|
||||
{
|
||||
df = x;
|
||||
|
@ -723,4 +733,40 @@ mod tests {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn arkf_format_arkb() -> Result<(), Error> {
|
||||
let test_df = df![
|
||||
"date" => ["2024-01-01", "2024-01-02"],
|
||||
"ticker" => [None::<&str>, Some("TSLA")],
|
||||
"cusip" => ["123abc", "TESLA"],
|
||||
"company" => ["ARK BITCOIN ETF HOLDCO (ARKF)", "TESLA"],
|
||||
"market_value" => [100, 400],
|
||||
"shares" => [10, 20],
|
||||
"share_price" => [10, 20],
|
||||
"weight" => [10.00, 20.00]
|
||||
]?;
|
||||
|
||||
Ark::write_df_parquet("data/test/ARKF.parquet".into(), test_df.clone().into())?;
|
||||
let read = Ark::new(Source::Read, Ticker::ARKF, Some("data/test".to_owned()))?.collect()?;
|
||||
fs::remove_file("data/test/ARKF.parquet")?;
|
||||
|
||||
let df = Ark::df_format(read.into())?.collect()?;
|
||||
assert_eq!(
|
||||
df,
|
||||
df![
|
||||
"date" => ["2024-01-01", "2024-01-02"],
|
||||
"ticker" => ["ARKB", "TSLA"],
|
||||
"cusip" => ["123abc", "TESLA"],
|
||||
"company" => ["ARKB", "TESLA"],
|
||||
"market_value" => [100, 400],
|
||||
"shares" => [10, 20],
|
||||
"share_price" => [10, 20],
|
||||
"weight" => [10.00, 20.00]
|
||||
]?
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue