fixed STATE bug
This commit is contained in:
parent
f8fc305939
commit
c71679b850
10
index.mjs
10
index.mjs
@ -518,18 +518,24 @@ app.get("/order/:instrument/:quantity", async (req, res) => {
|
||||
if (req.params.instrument.includes("JPY")) {
|
||||
delta = 0.12;
|
||||
}
|
||||
if (typeof(STATE[account]) === 'undefined') {
|
||||
STATE[account] = {};
|
||||
}
|
||||
if (typeof(STATE[account][req.params.instrument]) === 'undefined') {
|
||||
STATE[account][req.params.instrument] = {};
|
||||
}
|
||||
STATE[account][req.params.instrument]["base"] =
|
||||
response["data"]["orderFillTransaction"]["price"] + delta;
|
||||
STATE[account][req.params.instrument]["trigger"] =
|
||||
(response["data"]["orderFillTransaction"]["price"] + delta) * 1.05;
|
||||
STATE[account][req.params.instrument]["TP"] = false;
|
||||
STATE[account][req.params.instrument]["qty"] = req.params.quantity;
|
||||
STATE[account][req.params.instrument]["trade_id"] =
|
||||
response["data"]["orderFillTransaction"]["tradeOpened"]["tradeID"];
|
||||
if (req.params.quantity > 0) {
|
||||
STATE[account][req.params.instrument]["watch"] = "ask";
|
||||
STATE[account][req.params.instrument]["trigger"] = (response["data"]["orderFillTransaction"]["price"] + delta) * 1.05;
|
||||
} else {
|
||||
STATE[account][req.params.instrument]["watch"] = "bid";
|
||||
STATE[account][req.params.instrument]["trigger"] = (response["data"]["orderFillTransaction"]["price"] + delta) * 0.95;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user