"use strict";

const config = require("../util/config");
const alphaEngine = require("../strategy/alpha-engine");

module.exports = ontick;

function ontick(tick) {
    const instrument = tick.instrument;

    if (instrument !== "EUR_USD") {
        return;
    }

    const ask = parseFloat(tick.ask);
    const bid = parseFloat(tick.bid);
    const time = tick.time;

    const pip = config.pips[instrument];
    const countDecimals = pip.toString().split(".")[1].length;
    const mid = parseFloat(((bid + ask) / 2).toFixed(countDecimals));
    const spread = parseFloat(((ask - bid) / pip).toFixed(1));

    const price = {
        ask,
        bid,
        time,
        mid,
        spread
    };

    alphaEngine.run(price);
}

@@ -621,16 +621,36 @@
 ice = %7B%0A
+        instrument,%0A
         
@@ -708,16 +708,39 @@
   spread
+,%0A        countDecimals
 %0A    %7D;%0A

add a few details to price