diff --git a/index.mjs b/index.mjs index 98b5f4c..be64ac9 100644 --- a/index.mjs +++ b/index.mjs @@ -205,7 +205,7 @@ async function order(acct_id, api_key, instrument, quantity) { } - data = { + let data = { "order": { /*"trailingStopLossOnFill": { "timeInForce": "GTC", @@ -342,7 +342,7 @@ async function takeProfit(acct_id, api_key, tradeID, dist) { app.get('/closeAll', async (req, res) => { - for (account of Object.keys(accounts)) { + for (const account of Object.keys(accounts)) { let trades = await getTrades(accounts[account]['ACCT'], accounts[account]['APIKEY']) for (const t of trades.data['trades']) { await closeOrder(accounts[account]['ACCT'], accounts[account]['APIKEY'], t['id']) @@ -356,7 +356,7 @@ app.get('/closeAll', async (req, res) => { app.get('/tradesData', async (req, res) => { let r = []; - for (account of Object.keys(accounts)) { + for (const account of Object.keys(accounts)) { let response = await getTrades(accounts[account]['ACCT'], accounts[account]['APIKEY']) try { //Object.(response.data['trades']).forEach(([a, t]) =>{ @@ -393,7 +393,7 @@ app.get('/transactionsAll/:account', async (req, res) => { app.get('/transactions', async (req, res) => { let r = {} - for (account of Object.keys(accounts)) { + for (const account of Object.keys(accounts)) { let response = await getTransactions(account, accounts[account]['ACCT'], accounts[account]['APIKEY']) try { r = {}; @@ -408,7 +408,7 @@ app.get('/transactions', async (req, res) => { app.get('/trades', async (req, res) => { let r = {} - for (account of Object.keys(accounts)) { + for (const account of Object.keys(accounts)) { let response = await getTrades(accounts[account]['ACCT'], accounts[account]['APIKEY']) try { r[account] = response.data; @@ -485,12 +485,12 @@ app.get('/state', async (req, res) => { }) app.get('/order/:instrument/:quantity', async (req, res) => { - r = {}; - for (account of Object.keys(accounts)) { - td = await getTradesByInstrument(accounts[account]['ACCT'], accounts[account]['APIKEY'], req.params.instrument); + let r = {}; + for (const account of Object.keys(accounts)) { + let td = await getTradesByInstrument(accounts[account]['ACCT'], accounts[account]['APIKEY'], req.params.instrument); if (td == null || (td['state'] != "OPEN" && td['state'] != "PENDING")) { - response = await order(accounts[account]['ACCT'], accounts[account]['APIKEY'], req.params.instrument, req.params.quantity); + let response = await order(accounts[account]['ACCT'], accounts[account]['APIKEY'], req.params.instrument, req.params.quantity); console.log(response["data"]); if (typeof(response["data"]["orderFillTransaction"]) !== "undefined") { let delta = 0.0012; @@ -552,4 +552,4 @@ try { -setTimeout(myFunc, 1500, 'funky'); +setTimeout(processTP, 1500 );