Skip to content

Commit

Permalink
feat: improve UI (chrisleekr#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
uhliksk authored Aug 18, 2022
1 parent a370a49 commit 77f00b6
Show file tree
Hide file tree
Showing 19 changed files with 408 additions and 221 deletions.
18 changes: 11 additions & 7 deletions app/cronjob/trailingTrade/step/__tests__/cancel-order.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,14 @@ describe('cancel-order.js', () => {
sell: {
openOrders: [
{
orderId: 'another-sellorder',
orderId: 'another-sell-order',
side: 'sell'
}
]
},
order: {
orderId: 'order-123'
orderId: 'order-123',
side: 'buy'
}
};

Expand Down Expand Up @@ -199,7 +200,7 @@ describe('cancel-order.js', () => {
side: 'buy'
}
],
processMessage: 'The order has been cancelled.',
processMessage: 'The buy order has been cancelled.',
updatedAt: expect.any(Object)
},
sell: {
Expand All @@ -211,7 +212,8 @@ describe('cancel-order.js', () => {
]
},
order: {
orderId: 'order-123'
orderId: 'order-123',
side: 'buy'
}
});
});
Expand Down Expand Up @@ -262,7 +264,8 @@ describe('cancel-order.js', () => {
]
},
order: {
orderId: 'order-123'
orderId: 'order-123',
side: 'buy'
}
};

Expand Down Expand Up @@ -295,14 +298,15 @@ describe('cancel-order.js', () => {
openOrders: [],
buy: {
openOrders: [],
processMessage: 'The order has been cancelled.',
processMessage: 'The buy order has been cancelled.',
updatedAt: expect.any(Object)
},
sell: {
openOrders: []
},
order: {
orderId: 'order-123'
orderId: 'order-123',
side: 'buy'
}
});
});
Expand Down
12 changes: 8 additions & 4 deletions app/cronjob/trailingTrade/step/cancel-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ const execute = async (logger, rawData) => {
{ symbol, apiLimit: getAPILimit(logger) }
);

const { side } = order;
logger.info(
{ function: 'order', orderParams, saveLog: true },
'The order will be cancelled.'
`The ${side.toLowerCase()} order will be cancelled.`
);

const orderResult = await binance.client.cancelOrder(orderParams);

logger.info({ orderResult, saveLog: true }, 'The order has been cancelled.');
logger.info(
{ orderResult, saveLog: true },
`The ${side.toLowerCase()} order has been cancelled.`
);

await deleteManualOrder(logger, symbol, order.orderId);

Expand All @@ -68,7 +72,7 @@ const execute = async (logger, rawData) => {
PubSub.publish('frontend-notification', {
type: 'success',
title:
`The order for ${symbol} has been cancelled successfully.` +
`The ${side.toLowerCase()} order for ${symbol} has been cancelled successfully.` +
` If the order still display, it should be removed soon.`
});

Expand All @@ -82,7 +86,7 @@ const execute = async (logger, rawData) => {
{ symbol, apiLimit: getAPILimit(logger) }
);

data.buy.processMessage = `The order has been cancelled.`;
data.buy.processMessage = `The ${side.toLowerCase()} order has been cancelled.`;
data.buy.updatedAt = moment().utc().toDate();

return data;
Expand Down
8 changes: 6 additions & 2 deletions app/cronjob/trailingTradeHelper/__tests__/common.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3024,15 +3024,19 @@ describe('common.js', () => {
}
},
profit: { $sum: '$sell.currentProfit' },
estimatedBalance: { $sum: '$baseAssetBalance.estimatedValue' }
estimatedBalance: { $sum: '$baseAssetBalance.estimatedValue' },
free: { $first: '$quoteAssetBalance.free' },
locked: { $first: '$quoteAssetBalance.locked' }
}
},
{
$project: {
asset: '$_id',
amount: '$amount',
profit: '$profit',
estimatedBalance: '$estimatedBalance'
estimatedBalance: '$estimatedBalance',
free: '$free',
locked: '$locked'
}
}
]
Expand Down
8 changes: 6 additions & 2 deletions app/cronjob/trailingTradeHelper/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1029,15 +1029,19 @@ const getCacheTrailingTradeTotalProfitAndLoss = logger =>
}
},
profit: { $sum: '$sell.currentProfit' },
estimatedBalance: { $sum: '$baseAssetBalance.estimatedValue' }
estimatedBalance: { $sum: '$baseAssetBalance.estimatedValue' },
free: { $first: '$quoteAssetBalance.free' },
locked: { $first: '$quoteAssetBalance.locked' }
}
},
{
$project: {
asset: '$_id',
amount: '$amount',
profit: '$profit',
estimatedBalance: '$estimatedBalance'
estimatedBalance: '$estimatedBalance',
free: '$free',
locked: '$locked'
}
}
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ describe('get-closed-trades.js', () => {
stopLossQuoteQty: 70,
profit: 80,
profitPercentage: 90,
trades: 100
trades: 100,
lastProfit: 110,
lastSymbol: 'BTCUSDT',
lastArchivedAt: '2022-08-17T21:04:47.017Z'
}
]);

Expand Down Expand Up @@ -149,7 +152,10 @@ describe('get-closed-trades.js', () => {
sellManualQuoteQty: { $sum: '$sellManualQuoteQty' },
stopLossQuoteQty: { $sum: '$stopLossQuoteQty' },
profit: { $sum: '$profit' },
trades: { $sum: 1 }
trades: { $sum: 1 },
lastProfit: { $last: '$profit' },
lastSymbol: { $last: '$symbol' },
lastArchivedAt: { $last: '$archivedAt' }
}
},
{
Expand Down Expand Up @@ -179,7 +185,10 @@ describe('get-closed-trades.js', () => {
else: 0
}
},
trades: 1
trades: 1,
lastProfit: 1,
lastSymbol: 1,
lastArchivedAt: 1
}
}
]
Expand Down Expand Up @@ -217,7 +226,10 @@ describe('get-closed-trades.js', () => {
stopLossQuoteQty: 70,
profit: 80,
profitPercentage: 90,
trades: 100
trades: 100,
lastProfit: 110,
lastSymbol: 'BTCUSDT',
lastArchivedAt: '2022-08-17T21:04:47.017Z'
}
});
});
Expand Down Expand Up @@ -276,7 +288,10 @@ describe('get-closed-trades.js', () => {
sellManualQuoteQty: { $sum: '$sellManualQuoteQty' },
stopLossQuoteQty: { $sum: '$stopLossQuoteQty' },
profit: { $sum: '$profit' },
trades: { $sum: 1 }
trades: { $sum: 1 },
lastProfit: { $last: '$profit' },
lastSymbol: { $last: '$symbol' },
lastArchivedAt: { $last: '$archivedAt' }
}
},
{
Expand Down Expand Up @@ -306,7 +321,10 @@ describe('get-closed-trades.js', () => {
else: 0
}
},
trades: 1
trades: 1,
lastProfit: 1,
lastSymbol: 1,
lastArchivedAt: 1
}
}
]
Expand Down Expand Up @@ -341,7 +359,10 @@ describe('get-closed-trades.js', () => {
stopLossQuoteQty: 0,
profit: 0,
profitPercentage: 0,
trades: 0
trades: 0,
lastProfit: 0,
lastSymbol: '',
lastArchivedAt: ''
}
});
});
Expand Down
15 changes: 12 additions & 3 deletions app/cronjob/trailingTradeIndicator/step/get-closed-trades.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ const execute = async (logger, rawData) => {
sellManualQuoteQty: { $sum: '$sellManualQuoteQty' },
stopLossQuoteQty: { $sum: '$stopLossQuoteQty' },
profit: { $sum: '$profit' },
trades: { $sum: 1 }
trades: { $sum: 1 },
lastProfit: { $last: '$profit' },
lastSymbol: { $last: '$symbol' },
lastArchivedAt: { $last: '$archivedAt' }
}
},
{
Expand Down Expand Up @@ -103,7 +106,10 @@ const execute = async (logger, rawData) => {
else: 0
}
},
trades: 1
trades: 1,
lastProfit: 1,
lastSymbol: 1,
lastArchivedAt: 1
}
}
])
Expand All @@ -118,7 +124,10 @@ const execute = async (logger, rawData) => {
stopLossQuoteQty: 0,
profit: 0,
profitPercentage: 0,
trades: 0
trades: 0,
lastProfit: 0,
lastSymbol: '',
lastArchivedAt: ''
};

data.closedTrades = closedTrades;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ describe('cancel-order.js', () => {
data: {
symbol: 'BTCUSDT',
order: {
some: 'value'
some: 'value',
side: 'buy'
}
}
});
Expand All @@ -53,11 +54,11 @@ describe('cancel-order.js', () => {
'BTCUSDT',
{
action: 'cancel-order',
order: { some: 'value' },
order: { some: 'value', side: 'buy' },
actionAt: expect.any(String),
triggeredBy: 'user'
},
'Cancelling the order action has been received. Wait for cancelling the order.'
'Cancelling the buy order action has been received. Wait for cancelling the order.'
);
});

Expand All @@ -70,7 +71,7 @@ describe('cancel-order.js', () => {
JSON.stringify({
result: true,
type: 'cancel-order-result',
message: 'Cancelling the order action has been received.'
message: 'Cancelling the buy order action has been received.'
})
);
});
Expand Down
5 changes: 3 additions & 2 deletions app/frontend/websocket/handlers/cancel-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const handleCancelOrder = async (logger, ws, payload) => {
data: { symbol, order }
} = payload;

const { side } = order;
await saveOverrideAction(
logger,
symbol,
Expand All @@ -20,7 +21,7 @@ const handleCancelOrder = async (logger, ws, payload) => {
actionAt: moment().toISOString(),
triggeredBy: 'user'
},
'Cancelling the order action has been received. Wait for cancelling the order.'
`Cancelling the ${side.toLowerCase()} order action has been received. Wait for cancelling the order.`
);

queue.executeFor(logger, symbol);
Expand All @@ -29,7 +30,7 @@ const handleCancelOrder = async (logger, ws, payload) => {
JSON.stringify({
result: true,
type: 'cancel-order-result',
message: 'Cancelling the order action has been received.'
message: `Cancelling the ${side.toLowerCase()} order action has been received.`
})
);
};
Expand Down
16 changes: 9 additions & 7 deletions public/css/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ input[type='number'] {
}

.coin-info-column-title .coin-info-value {
font-style: italic;
font-style: bold;
font-size: 0.8rem;
}

Expand Down Expand Up @@ -735,7 +735,7 @@ input[type='number'] {
width: 50%;
}

@media (max-width: 550px) {
@media (max-width: 825px) {
.profit-loss-container {
flex-direction: column;
}
Expand All @@ -761,7 +761,8 @@ input[type='number'] {
}

.profit-loss-wrapper {
width: 25%;
width: 16.6%;
min-width: 12rem;
}

.profit-loss-wrapper-body {
Expand All @@ -776,22 +777,23 @@ input[type='number'] {
}

.profit-loss-asset {
flex: 1 40%;
flex: 1 auto;
font-weight: bold;
}

.profit-loss-value {
flex: 1 60%;
flex: 1 auto;
text-align: right;
font-weight: bold;
}

@media (max-width: 1500px) {
@media (max-width: 3300px) {
.profit-loss-wrapper {
width: 33.3333%;
}
}

@media (max-width: 800px) {
@media (max-width: 1650px) {
.profit-loss-wrapper {
width: 50%;
}
Expand Down
Loading

0 comments on commit 77f00b6

Please sign in to comment.