Example #1
0
def test_bar_success(stock_id, start_date, end_date):
    user_id = os.environ.get("FINMIND_USER", "")
    password = os.environ.get("FINMIND_PASSWORD", "")
    data_loader = DataLoader()
    data_loader.login(user_id, password)
    df = data_loader.taiwan_stock_month_revenue(stock_id=stock_id,
                                                start_date=start_date,
                                                end_date=end_date)
    df["labels"] = (df[["revenue_year", "revenue_month"]].astype(str).apply(
        lambda date: f"{date[0]}-{date[1]}M", axis=1))
    df["series"] = df["revenue"].map(lambda value: round(value * 1e-8, 2))
    assert plotting.bar(labels=df["labels"], series=df["series"])
Example #2
0
def df():
    user_id = os.environ.get("FINMIND_USER", "")
    password = os.environ.get("FINMIND_PASSWORD", "")
    data_loader = DataLoader()
    data_loader.login(user_id, password)
    df = data_loader.taiwan_stock_month_revenue(stock_id="2890",
                                                start_date="2018-1M",
                                                end_date="2021-7M")
    df["labels"] = (df[["revenue_year", "revenue_month"]].astype(str).apply(
        lambda date: f"{date[0]}-{date[1]}M", axis=1))
    df["series"] = df["revenue"].map(lambda value: round(value * 1e-8, 2))
    return df
Example #3
0
def test_pie_failed():
    user_id = os.environ.get("FINMIND_USER", "")
    password = os.environ.get("FINMIND_PASSWORD", "")
    data_loader = DataLoader()
    data_loader.login(user_id, password)
    df = data_loader.taiwan_stock_month_revenue(stock_id="2330",
                                                start_date="2018-01-01",
                                                end_date="2021-03-03")
    df["series"] = (df[["revenue_year", "revenue_month"]].astype(str).apply(
        lambda date: f"{date[0]}-{date[1]}M", axis=1))
    df["labels"] = df["revenue"].map(lambda value: round(value * 1e-8, 2))
    with (pytest.raises(Exception)):
        plotting.pie(labels=df["labels"], series=df["series"])