示例#1
0
def force_index(close_arr, volume_arr, n):
    """Calculate Force Index for given data.

    :param close_arr: close price of the bar, expect series from cudf
    :param volume_arr: volume the bar, expect series from cudf
    :param n: time steps
    :return: Force Index in cudf.Series
    """
    F = multiply(diff(close_arr, n), diff(volume_arr, n))
    return cudf.Series(F)
示例#2
0
def port_force_index(asset_indicator, close_arr, volume_arr, n):
    """Calculate port Force Index for given data.

    :param asset_indicator: the indicator of beginning of the stock
    :param close_arr: close price of the bar, expect series from cudf
    :param volume_arr: volume the bar, expect series from cudf
    :param n: time steps
    :return: Force Index in cudf.Series
    """
    F = multiply(diff(close_arr, n), diff(volume_arr, n))
    port_mask_nan(asset_indicator.data.to_gpu_array(), F, 0, n)
    return cudf.Series(F)
示例#3
0
def money_flow_index(high_arr, low_arr, close_arr, volume_arr, n):
    """Calculate Money Flow Index and Ratio for given data.

    :param high_arr: high price of the bar, expect series from cudf
    :param low_arr: low price of the bar, expect series from cudf
    :param close_arr: close price of the bar, expect series from cudf
    :param volume_arr: volume the bar, expect series from cudf
    :param n: time steps
    :return: Money Flow Index in cudf.Series
    """
    PP = average_price(high_arr.to_gpu_array(), low_arr.to_gpu_array(),
                       close_arr.to_gpu_array())

    PosMF = money_flow(PP, volume_arr.to_gpu_array())
    MFR = division(PosMF, (multiply(PP, volume_arr.to_gpu_array())))  # TotMF
    MFI = Rolling(n, MFR).mean()
    return cudf.Series(MFI, nan_as_null=False)
示例#4
0
def ease_of_movement(high_arr, low_arr, volume_arr, n):
    """Calculate Ease of Movement for given data.

    :param high_arr: high price of the bar, expect series from cudf
    :param low_arr: low price of the bar, expect series from cudf
    :param volume_arr: volume the bar, expect series from cudf
    :param n: time steps
    :return: Ease of Movement in cudf.Series
    """
    high_arr_gpu = high_arr.data.to_gpu_array()
    low_arr_gpu = low_arr.data.to_gpu_array()

    EoM = division(
        multiply(summation(diff(high_arr_gpu, 1), diff(low_arr_gpu, 1)),
                 substract(high_arr_gpu, low_arr_gpu)),
        scale(volume_arr.data.to_gpu_array(), 2.0))
    Eom_ma = Rolling(n, EoM).mean()
    return cudf.Series(Eom_ma)
示例#5
0
def port_ease_of_movement(asset_indicator, high_arr, low_arr, volume_arr, n):
    """Calculate port Ease of Movement for given data.

    :param asset_indicator: the indicator of beginning of the stock
    :param high_arr: high price of the bar, expect series from cudf
    :param low_arr: low price of the bar, expect series from cudf
    :param volume_arr: volume the bar, expect series from cudf
    :param n: time steps
    :return: Ease of Movement in cudf.Series
    """
    high_arr_gpu = high_arr.data.to_gpu_array()
    low_arr_gpu = low_arr.data.to_gpu_array()

    EoM = division(
        multiply(summation(diff(high_arr_gpu, 1), diff(low_arr_gpu, 1)),
                 substract(high_arr_gpu, low_arr_gpu)),
        scale(volume_arr.data.to_gpu_array(), 2.0))
    port_mask_nan(asset_indicator.data.to_gpu_array(), EoM, 0, 1)
    Eom_ma = Rolling(n, EoM).mean()
    port_mask_nan(asset_indicator.data.to_gpu_array(), Eom_ma, 0, n - 1)
    return cudf.Series(Eom_ma)
示例#6
0
def port_money_flow_index(asset_indicator, high_arr, low_arr, close_arr,
                          volume_arr, n):
    """Calculate port Money Flow Index and Ratio for given data.

    :param asset_indicator: the indicator of beginning of the stock
    :param high_arr: high price of the bar, expect series from cudf
    :param low_arr: low price of the bar, expect series from cudf
    :param close_arr: close price of the bar, expect series from cudf
    :param volume_arr: volume the bar, expect series from cudf
    :param n: time steps
    :return: Money Flow Index in cudf.Series
    """
    PP = average_price(high_arr.to_gpu_array(), low_arr.to_gpu_array(),
                       close_arr.to_gpu_array())

    PosMF = port_money_flow(asset_indicator.to_gpu_array(), PP,
                            volume_arr.to_gpu_array())
    MFR = division(PosMF, (multiply(PP, volume_arr.to_gpu_array())))  # TotMF
    MFI = Rolling(n, MFR).mean()
    port_mask_nan(asset_indicator.to_gpu_array(), MFI, 0, n - 1)
    return cudf.Series(MFI, nan_as_null=False)