Пример #1
0
def fetch_revenue_test(stock, period, addition, column, expect):
    """ test module """
    res = fetch.fetch_revenue(stock, period, addition)
    if res[0] == expect[0] and list(res[1][column]) == expect[1]:
        print('pass')
    else:
        print('fail')
Пример #2
0
def new_revenue_in_n_months(stock, period, params):
    """
    filter out revenue if it's new high/low in specified months
    """
    months = int(params[0])
    if months <= 0:
        messagebox.showerror('error', 'months can\'t be <= 0')
        return -1
    high = is_high(params[1])

    res = fetch.fetch_revenue(stock, period, months - 1)
    if res[0] == False:
        return False
    else:
        df = res[1]

    if high:
        res = pandas.stats.moments.rolling_max(df['營業收入'], months)
    else:
        res = pandas.stats.moments.rolling_min(df['營業收入'], months)
    res = (res == df['營業收入'])

    if True in list(res):
        return True
    else:
        return False