moved sl. added trade check before order
This commit is contained in:
parent
37c0fa46cc
commit
605f998815
24
index.js
24
index.js
@ -17,7 +17,7 @@ const client = new pg.Client({
|
||||
|
||||
client.connect()
|
||||
|
||||
const port = 5000
|
||||
const port = 3000
|
||||
const host = "0.0.0.0"
|
||||
|
||||
|
||||
@ -140,14 +140,15 @@ async function order(acct_id, api_key, instrument, quantity) {
|
||||
try {
|
||||
|
||||
|
||||
let dist = "0.001"
|
||||
let pdist = "0.001"
|
||||
let dist = "0.0005"
|
||||
let pdist = "0.0005"
|
||||
|
||||
if (instrument.includes("JPY")) {
|
||||
dist = "0.1"
|
||||
pdist = "0.1"
|
||||
dist = "0.05"
|
||||
pdist = "0.05"
|
||||
}
|
||||
|
||||
|
||||
data = {
|
||||
"order": {
|
||||
"trailingStopLossOnFill": {
|
||||
@ -383,13 +384,17 @@ app.get('/trailingStop/:instrument', async (req, res) => {
|
||||
})
|
||||
app.get('/tradesByInstrument/:instrument', async (req, res) => {
|
||||
res.header('Access-Control-Allow-Origin', '*')
|
||||
res.json(await getTradesByInstrument(ACCT, APIKEY, req.params.instrument))
|
||||
r = {};
|
||||
for (account of Object.keys(accounts)) {
|
||||
r[account] = await getTradesByInstrument(accounts[account]['ACCT'], accounts[account]['APIKEY'], req.params.instrument);
|
||||
}
|
||||
res.json(r);
|
||||
})
|
||||
app.get('/order/:instrument/:quantity', async (req, res) => {
|
||||
|
||||
|
||||
r = {};
|
||||
/*td = await getTradesByInstrument(accounts['1']['ACCT'], accounts['1']['APIKEY'], req.params.instrument);
|
||||
/*td = await getTradesByInstrument(accounts['2']['ACCT'], accounts['1']['APIKEY'], req.params.instrument);
|
||||
if (td) {
|
||||
|
||||
if (td["initialUnits"] != req.params.quantity) {
|
||||
@ -397,10 +402,10 @@ app.get('/order/:instrument/:quantity', async (req, res) => {
|
||||
if (req.params.instrument.includes("JPY")) {
|
||||
let dist = "0.5"
|
||||
}
|
||||
await takeProfit(accounts['1']['ACCT'], accounts['1']['APIKEY'], td["id"], dist)
|
||||
await takeProfit(accounts['2']['ACCT'], accounts['1']['APIKEY'], td["id"], dist)
|
||||
}
|
||||
} else {
|
||||
response = await order(accounts['1']['ACCT'], accounts['1']['APIKEY'], req.params.instrument, req.params.quantity);
|
||||
response = await order(accounts['2']['ACCT'], accounts['1']['APIKEY'], req.params.instrument, req.params.quantity);
|
||||
}*/
|
||||
/*td = await getTradesByInstrument(accounts['2']['ACCT'], accounts['2']['APIKEY'], req.params.instrument);
|
||||
if (td) {
|
||||
@ -418,6 +423,7 @@ app.get('/order/:instrument/:quantity', async (req, res) => {
|
||||
response = await order(accounts['2']['ACCT'], accounts['2']['APIKEY'], req.params.instrument, req.params.quantity);
|
||||
} */
|
||||
for (account of Object.keys(accounts)) {
|
||||
td = await getTradesByInstrument(accounts[account]['ACCT'], accounts[account]['APIKEY'], req.params.instrument);
|
||||
response = await order(accounts[account]['ACCT'], accounts[account]['APIKEY'], req.params.instrument, req.params.quantity);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user