Esempio n. 1
0
def get_price_change(row, pip_factor):
    """ If closeBid - openAsk > 0. Can buy. Return value positive.
        If closeAsk - openBid < 0. Can sell. Return value negative.
        Otherwise do nothing. Return 0.

        Args:
            row: list of Strings. A row from data file in /data/store/
            pip_factor: int. The multiplier for calculating pip from price.

        Returns:
            price_change: string. Profitable price change for the day in pips,
                formatted to 1 decimal place.
    """
    row = common.list_to_float(row[1:-1])

    if row[3] - row[4] > 0:
        diff = row[3] - row[4]
    elif row[7] - row[0] < 0:
        diff = row[7] - row[0]
    else:
        diff = 0

    price_change = common.price_to_pip(diff, pip_factor)

    return price_change
Esempio n. 2
0
def list_to_features(row, pip_factor):
    """ Return the row without the date, openBid and volume.
        Then take away the openBid price.

        Args:
            row: list of Strings. A row from data file in ./store/
            pip_factor: int. The multiplier for calculating pip from price.

        Returns:
            features: list of floats. The quantities are: highBid, lowBid,
                closeBid, openAsk, highAsk, lowAsk and closeAsk.
                All relative to openBid, and in pips.
    """
    row = common.list_to_float(row[1:-1])
    row = [x - row[0] for x in row[1:]]
    features = [common.price_to_pip(x, pip_factor) for x in row]

    return features