Example #1
0
def fetch_tech_indicators():
    with open("./store/indicators.json", 'w') as indicators_json:
        try:
            price_data = dataset("price_data")
            indicators = transformer("calculate_indicators")(price_data)
            get_signal = {
                "MOM (1)": lambda v: "BUY" if v >= 0 else "SELL",
                "ADX (14)": lambda v: "BUY"
                if v >= 25 else "SELL",  # Not sure about this
                "WILLR": lambda v: "SELL" if v <= -50 else "BUY",
                "RSI (6)": lambda v: "SELL" if v >= 50 else "BUY",
                "ATR (14)": lambda v: "N/A",
                "OBV": lambda v: "N/A",
                "TRIX (20)": lambda v: "N/A",
                "EMA (6)": lambda v: "N/A"
            }

            data = []
            for indicator, signal in get_signal.items():
                val = round(indicators[indicator][0], 2)
                data.append([indicator, str(val), signal(val)])

            indicators_json.write(
                json.dumps(
                    {
                        "error": False,
                        "data": list(sorted(data, key=lambda i: len(i[0])))
                    },
                    indent=2))
        except:
            indicators_json.write(
                json.dumps({
                    "error": True,
                    "data": []
                }, indent=2))
Example #2
0
def fetch_tech_indicators():
    # TODO: Create a mapping between indicator values and signals

    with open("./cache/data/indicators.json", 'w') as indicators_json:
        try:
            indicators = transformer("calculate_indicators")(
                dataset("price_data"))

            # "MACD": {}, # MACD, MACD (Signal), MACD (Historical)
            # "MOM (1)": {"value": indicators["MOM (1)"][0], "signal": ""},
            # "ADX (20)": {"value": indicators["ADX (20)"][0], "signal": ""},
            # "RSI (12)": {"value": indicators["RSI (12)"][0], "signal": ""},
            # "ATR (14)": {"value": indicators["ATR (14)"][0], "signal": ""},
            # "OBV": {"value": indicators["OBV"][0], "signal": ""},
            # "TRIX (20)": {"value": indicators["TRIX (20)"][0], "signal": ""},
            # "EMA (6)": {"value": indicators["EMA (6)"][0], "signal": "NONE"},

            data = [[
                "MOM (3-period)",
                str(round(indicators["MOM (1)"][0], 2)), "SELL"
            ],
                    [
                        "ADX (14-period)",
                        str(round(indicators["ADX (14)"][0], 2)), "SELL"
                    ],
                    ["WILLR",
                     str(round(indicators["WILLR"][0], 2)), "SELL"],
                    [
                        "RSI (6-period)",
                        str(round(indicators["RSI (6)"][0], 2)), "SELL"
                    ],
                    [
                        "ATR (14-period)",
                        str(round(indicators["ATR (14)"][0], 2)), "SELL"
                    ], ["OBV",
                        str(round(indicators["OBV"][0], 2)), "BUY"],
                    [
                        "TRIX (20-period)",
                        str(round(indicators["TRIX (20)"][0], 2)), "BUY"
                    ],
                    [
                        "EMA (6-period)",
                        str(round(indicators["EMA (6)"][0], 2)), "BUY"
                    ]]

            indicators_json.write(
                json.dumps(
                    {
                        "error": False,
                        "data": list(sorted(data, key=lambda i: len(i[0])))
                    },
                    indent=2))
        except:
            indicators_json.write(
                json.dumps({
                    "error": True,
                    "data": []
                }, indent=2))
Example #3
0
def make_prediction():
    price_data = dataset("price_data")
    blockchain_data = dataset("blockchain_data")

    processed_data = (price_data.pipe(
        transformer("calculate_indicators")).pipe(
            transformer("merge_datasets"), other_sets=[blockchain_data]).pipe(
                transformer("fix_null_vals")).pipe(
                    transformer("add_lag_vars")).pipe(
                        transformer("power_transform")).pipe(
                            transformer("binarize_labels")).drop("Date",
                                                                 axis=1))

    feature_vector = processed_data.drop("Trend", axis=1).iloc[0]
    model = Model(processed_data.drop(processed_data.index[0]), hyperopt=False)

    return model.predict(feature_vector.values)[0]