Skip to content

Commit d689a20

Browse files
committed
Fixed bug error closing short trades
1 parent 77c9f4f commit d689a20

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/trader/trader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ function checkTradingData(signal: Signal, source: SourceType): TradingData {
943943
// Check to satisfy the compiler, if no price it will fail later anyway
944944
if (signal.price) {
945945
// Calculate whether this trade will make a profit or loss
946-
const percent = PositionType.LONG ? calculatePnL(tradeOpen.priceBuy!, signal.price) : calculatePnL(signal.price, tradeOpen.priceSell!)
946+
const percent = signal.positionType == PositionType.LONG ? calculatePnL(tradeOpen.priceBuy!, signal.price) : calculatePnL(signal.price, tradeOpen.priceSell!)
947947
logger.debug(`Closing ${percent.isLessThan(0) ? "loss" : "profit"} for ${getLogName(tradeOpen)} trade will be ${percent.toFixed(3)}% with fees.`)
948948

949949
// Check if strategy has hit the losing trade limit, and this an automatic trade signal

0 commit comments

Comments
 (0)