예제 #1
0
def run(pair_name: str, opt: dict, signal_func) -> pd.DataFrame:
    print(pair_name)

    mid_freq = opt['mid_freq']
    window_size = opt['window_size']
    threshold = opt['threshold']
    intercept = opt['intercept']
    wavelet = opt['wavelet']
    ln = opt['ln']

    pair_bid, pair_ask, pair_mid = aux.create_bid_ask_mid(pair_name, data)

    pair_mid = pair_mid.groupby(
        pd.Grouper(freq='D')).resample(mid_freq).mean().droplevel(0)
    pair_mid = pair_mid.resample('D').apply(aux.fill_nan).droplevel(0)

    if ln:
        pair_mid = np.log(pair_mid)

    pair_ask = pair_ask.resample('D').apply(aux.fill_nan).droplevel(0)

    pair_bid = pair_bid.resample('D').apply(aux.fill_nan).droplevel(0)

    pair_mid.dropna(inplace=True)
    pair_ask.dropna(inplace=True)
    pair_bid.dropna(inplace=True)

    trade_table = trading_table(pair_mid, pair_ask, pair_bid, window_size,
                                threshold, intercept, wavelet, signal_func)
    return trade_table
예제 #2
0
def run(pair_name):
    print("Hesaplanan çift: ", pair_name)
    pair_bid, pair_ask, pair_mid = aux.create_bid_ask_mid(pair_name, data)
    pair_bid, pair_ask, pair_mid = aux.convert_bid_ask_mid(
        pair_bid, pair_ask, pair_mid, mid_freq, ln)
    date_ranges = get_date_ranges(pair_mid.index, step)
    arx_values = ar_x(pair_mid, date_ranges, intercept, wavelet)
    return arx_values
예제 #3
0
def run(pair_name: str, opt: dict, signal_func) -> pd.DataFrame:
    print(pair_name)
    mid_freq = opt['mid_freq']
    window_size = opt['window_size']
    coeff_negative = opt['coeff_negative']
    coeff_positive = opt['coeff_positive']
    intercept = opt['intercept']
    wavelet = opt['wavelet']
    ln = opt['ln']

    pair_bid, pair_ask, pair_mid = aux.create_bid_ask_mid(pair_name, data)

    pair_bid, pair_ask, pair_mid = aux.convert_bid_ask_mid(
        pair_bid, pair_ask, pair_mid, mid_freq, ln)

    trade_table = trading_table(pair_mid, pair_ask, pair_bid, window_size,
                                coeff_negative, coeff_positive, intercept,
                                wavelet, signal_func, mid_freq)
    return trade_table
예제 #4
0
data = pd.read_csv(folder_path, parse_dates=['time'])
data = data[data.time.dt.hour < 15]
data['mid_price'] = (data['bid_price'] + data['ask_price']) / 2

pair_name = ('DOHOL', 'PETKM')

mid_freq = '10Min'
window_size = 300
threshold = 1
intercept = True
wavelet = False
ln = True
signal_func = signals.get_signal2
name = '_'.join(pair_name) + '_' + signal_func.__name__.split('_')[1]

pair_bid, pair_ask, pair_mid = aux.create_bid_ask_mid(pair_name, data)
pair_mid = pair_mid.groupby(
    pd.Grouper(freq='D')).resample(mid_freq).mean().droplevel(0)
pair_mid = pair_mid.resample('D').apply(aux.fill_nan).droplevel(0)

if ln:
    pair_mid = np.log(pair_mid)

pair_ask = pair_ask.resample('D').apply(aux.fill_nan).droplevel(0)

pair_bid = pair_bid.resample('D').apply(aux.fill_nan).droplevel(0)

pair_mid.dropna(inplace=True)
pair_ask.dropna(inplace=True)
pair_bid.dropna(inplace=True)