Example #1
0
def get_price_above(df=None,
                    type="close above ma20",
                    period_of_days=1,
                    stock_list=None,
                    period_type='day'):
    if df is None and stock_list is None:
        stock_list_file = 'basic-no3.csv'
        # stock_list_file = 'mystocklist-detail.csv'
        df = myapi.read_csv(stock_list_file)
    else:
        if stock_list is not None:
            df = myapi.read_csv(stock_list)
    df_result = myapi.get_price_above(df, type, period_of_days, period_type)

    return df_result
Example #2
0
def get_maximum_price_sum_in_n(df=None,
                               p_change=(4, 10),
                               period_of_days=10,
                               stock_list=None,
                               period_type='day'):
    if df is None and stock_list is None:
        stock_list_file = 'basic-no3.csv'
        # stock_list_file = 'mystocklist-detail.csv'
        df = myapi.read_csv(stock_list_file)
    else:
        if stock_list is not None:
            df = myapi.read_csv(stock_list)
    df_result = myapi.get_maximum_price_sum_in_n(df, p_change, period_of_days,
                                                 period_type)

    return df_result
Example #3
0
def get_history_high_price(df=None,
                           event_to_now=1,
                           period_of_days=60,
                           stock_list=None,
                           period_type='day'):
    if df is None and stock_list is None:
        stock_list_file = 'basic-no3.csv'
        #stock_list_file = 'mystocklist-detail.csv'
        df = myapi.read_csv(stock_list_file)
    else:
        if stock_list is not None:
            df = myapi.read_csv(stock_list)
    df_result = myapi.get_history_high_price(df, event_to_now, period_of_days,
                                             period_type)

    return df_result
Example #4
0
def get_maximum_period_break_high(df=None,
                                  min_break_num=4,
                                  period_of_days=10,
                                  stock_list=None,
                                  period_type='day'):
    if df is None and stock_list is None:
        stock_list_file = 'basic-no3.csv'
        #stock_list_file = 'mystocklist-detail.csv'
        df = myapi.read_csv(stock_list_file)
    else:
        if stock_list is not None:
            df = myapi.read_csv(stock_list)
    df_result = myapi.get_maximum_period_break_high(df, min_break_num,
                                                    period_of_days,
                                                    period_type)

    return df_result
Example #5
0
def get_a_across_b(df=None,
                   cross_above=True,
                   cross_type="ma5-ma10",
                   period_of_days=10,
                   stock_list=None,
                   period_type='day',
                   rank=False):
    if df is None and stock_list is None:
        stock_list_file = 'basic-no3.csv'
        # stock_list_file = 'mystocklist-detail.csv'
        df = myapi.read_csv(stock_list_file)
    else:
        if stock_list is not None:
            df = myapi.read_csv(stock_list)
    df_result = myapi.get_a_across_b(df, cross_above, cross_type,
                                     period_of_days, period_type, rank)

    return df_result
Example #6
0
def get_minimum_price_sum_in_n(df=None,
                               is_price_up=True,
                               price_up_sum=0,
                               min_day_range=0,
                               period_of_days=10,
                               stock_list=None,
                               period_type='day'):
    if df is None and stock_list is None:
        stock_list_file = 'basic-no3.csv'
        # stock_list_file = 'mystocklist-detail.csv'
        df = myapi.read_csv(stock_list_file)
    else:
        if stock_list is not None:
            df = myapi.read_csv(stock_list)
    df_result = myapi.get_miminum_price_sum_in_n(df, is_price_up, price_up_sum,
                                                 min_day_range, period_of_days,
                                                 period_type)

    return df_result
Example #7
0
def get_first_history_high_volume_in_10_days():
    stock_list_file = 'basic-no3.csv'
    tmpfile = Path().joinpath('result', 'get_first_history_high_volume_in_10_days.csv')
    df = myapi.read_csv(stock_list_file)
    df = myapi.remove_unwanted_fields(df)

    """
    in latest 10 days, find history high
    """
    df_result = myapi.get_first_history_high_volume_in_n(df, 2)
    df_result.to_csv(tmpfile)
Example #8
0
def get_half_year_high_v2():
    stock_list_file = 'basic-no3.csv'
    tmpfile = Path().joinpath('result', 'get_half_year_high_v2.csv')
    df = myapi.read_csv(stock_list_file)
    df = myapi.remove_unwanted_fields(df)

    """
    in latest 10 days, find history high
    """
    df_result = myapi.get_history_high_v2(df, 3, 120)
    df_result.to_csv(tmpfile)
Example #9
0
def get_one_year_high():
    stock_list_file = 'basic-no3.csv'
    tmpfile = Path().joinpath('result', 'get_one_year_high.csv')

    # stock_list_file = 'mystocklist-detail.csv'
    df = myapi.read_csv(stock_list_file)
    df = myapi.remove_unwanted_fields(df)

    """
    in latest 10 days, find history high
    """
    df_result = myapi.get_history_high(df, 10, 12)
    df_result.to_csv(tmpfile)
Example #10
0
def get_price_continuous_down_in_n(df=None,
                                   price_down_sum=0,
                                   num_of_days_down=4,
                                   period_of_days=15,
                                   period_type='day'):
    if df is None:
        stock_list_file = 'basic-no3.csv'
        # stock_list_file = 'mystocklist-detail.csv'
        df = myapi.read_csv(stock_list_file)
    df_result = myapi.get_price_continuous_down_in_n(df, num_of_days_down,
                                                     price_down_sum,
                                                     period_of_days,
                                                     period_type)

    return df_result
Example #11
0

"""
   first time in recent 5 days that close price stand above upper band
   for binary-cmp, period_of_days specifies the period that the result of comparisons should all be true.
"""
def first_cross_above_upper(df, market='usa'):
    myapi.market = market
    df = dr5.get_a_across_b(df, period_of_days=1, cross_above=("close", "upper"), cross_type="binary-cmp",
                            period_type='day')
    lib2.head_offset = 1
    df1 = dr5.get_a_across_b(df, period_of_days=5, cross_above=("upper", "close"), cross_type="binary-cmp",
                             period_type='day')
    df.to_csv("{}.csv".format(inspect.stack()[0][3]))
    return df

df1 = myapi.read_csv(r"case\case-main-rise\usa-ma20-up-list.csv")
df1 = first_cross_above_upper(df1)
pdb.set_trace()


#create_ma20_up_list()

"""
df = myapi.read_csv("basic-no3.csv")
df1 = myapi.read_csv("ma20-up-list.csv", local=True)
df1 = lib2.filter_stock(df, df1, "outstanding", 5)
pdb.set_trace()
df1.to_csv("ma20-up-list.csv")
"""
Example #12
0
def get_w_shape():
    stock_list_file = 'basic-no3.csv'
    # stock_list_file = 'mystocklist-detail.csv'
    df = myapi.read_csv(stock_list_file)
    df_result = myapi.get_w_shape(df, 40)
    df_result.to_csv(Path().joinpath('result', 'w-shape.csv'))
Example #13
0
def get_current_no_touch_ma5_periods():
    stock_list_file = 'basic-no3.csv'
    # stock_list_file = 'mystocklist-detail.csv'
    df = myapi.read_csv(stock_list_file)
    df_result = myapi.get_current_no_touch_ma5_periods(df)
    df_result.to_csv(Path().joinpath('result', 'current_no_touch_ma5.csv'))
Example #14
0
def get_no_toch_ma5():
    stock_list_file = 'basic-no3.csv'
    # stock_list_file = 'mystocklist-detail.csv'
    df = myapi.read_csv(stock_list_file)
    df_result = myapi.get_no_touch_ma5(df, 7)
    df_result.to_csv(Path().joinpath('result', 'no_touch_ma5.csv'))
Example #15
0
 def test_read_csv(self):
     name = "20190810"
     filepath = r"C:"
     columns = ["日期", "姓名", "ID"]
     file = read_csv(name, filepath, columns)
     self.assertTrue(file.name(), "20190810")