mirror of
https://github.com/NexVeridian/ark-invest-api-rust-data.git
synced 2025-09-02 09:59:12 +00:00
feat: TSM
This commit is contained in:
parent
948903fff0
commit
b0088a98a4
1 changed files with 31 additions and 0 deletions
|
@ -15,6 +15,7 @@ pub enum Ticker {
|
|||
LUNR,
|
||||
XYZ,
|
||||
CASH_USD,
|
||||
TSM,
|
||||
}
|
||||
|
||||
impl Ticker {
|
||||
|
@ -34,6 +35,7 @@ impl Ticker {
|
|||
Self::LUNR => Self::lunr(df),
|
||||
Self::XYZ => Self::xyz(df),
|
||||
Self::CASH_USD => Self::cash_usd(df),
|
||||
Self::TSM => Self::tsm(df),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,6 +212,24 @@ impl Ticker {
|
|||
|
||||
Ok(df.into())
|
||||
}
|
||||
|
||||
fn tsm(df: DF) -> Result<DF, Error> {
|
||||
let mut df = df.collect()?;
|
||||
|
||||
if let Ok(x) = df
|
||||
.clone()
|
||||
.lazy()
|
||||
.with_columns(vec![when(col("company").eq(lit("TAIWANMICONDUCTORSP")))
|
||||
.then(lit("TMSC"))
|
||||
.otherwise(col("company"))
|
||||
.alias("company")])
|
||||
.collect()
|
||||
{
|
||||
df = x;
|
||||
}
|
||||
|
||||
Ok(df.into())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -302,6 +322,17 @@ mod tests {
|
|||
&[Some("CASH_USD"), Some("CASH_USD"), Some("CASH_USD"), Some("CASH_USD")],
|
||||
)?,
|
||||
)]
|
||||
#[case::tsm(
|
||||
Ticker::TSM,
|
||||
defualt_df(
|
||||
&[Some("TSM")],
|
||||
&[Some("TAIWANMICONDUCTORSP")],
|
||||
)?,
|
||||
defualt_df(
|
||||
&[Some("TSM")],
|
||||
&[Some("TMSC")]
|
||||
)?,
|
||||
)]
|
||||
fn matrix(
|
||||
#[case] ticker: Ticker,
|
||||
#[case] input: DataFrame,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue