mirror of
https://github.com/bisq-network/bisq-api-reference.git
synced 2026-05-22 12:44:21 +00:00
Show closed trades since midnight today
Don't show entire trade history at end of bot run. Tweak some log statements.
This commit is contained in:
parent
aee939a887
commit
0b245b9998
@ -31,6 +31,7 @@ import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static bisq.bots.BotUtils.*;
|
||||
import static bisq.bots.table.builder.TableType.BSQ_BALANCE_TBL;
|
||||
@ -525,6 +526,19 @@ public abstract class AbstractBot {
|
||||
BotUtils.printTradesSummary(category, trades);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print list of today's trade summaries to stdout.
|
||||
*
|
||||
* @param category category OPEN | CLOSED | FAILED
|
||||
*/
|
||||
protected void printTradesSummaryForToday(Category category) {
|
||||
var midnightToday = BotUtils.midnightToday.get();
|
||||
var trades = getTrades(category).stream()
|
||||
.filter(t -> t.getDate() >= midnightToday)
|
||||
.collect(Collectors.toList());
|
||||
BotUtils.printTradesSummary(category, trades);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a "payment started" message to the BTC seller.
|
||||
*
|
||||
|
||||
@ -55,6 +55,17 @@ public class BotUtils {
|
||||
public static final Predicate<String> isXmr = (currencyCode) -> currencyCode.equalsIgnoreCase("XMR");
|
||||
public static final Predicate<String> isAltcoin = (currencyCode) -> isBsq.test(currencyCode) || isXmr.test(currencyCode);
|
||||
|
||||
/**
|
||||
* Return a timestamp for midnight, today.
|
||||
*/
|
||||
public static final Supplier<Long> midnightToday = () -> {
|
||||
Calendar c = new GregorianCalendar();
|
||||
c.set(Calendar.HOUR_OF_DAY, 0);
|
||||
c.set(Calendar.MINUTE, 0);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
return c.getTimeInMillis();
|
||||
};
|
||||
|
||||
/**
|
||||
* Return price precision of 8 for altcoin, 4 for fiat.
|
||||
*/
|
||||
|
||||
@ -114,8 +114,9 @@ public class RegtestTradePaymentSimulator extends AbstractBot {
|
||||
log.warn("##############################################################################");
|
||||
|
||||
sleep(pollingInterval);
|
||||
log.info("Trade is completed, printing all closed trades and exiting {}.", this.getClass().getSimpleName());
|
||||
printTradesSummary(CLOSED);
|
||||
log.info("Trade is completed. Here are today's completed trades:");
|
||||
printTradesSummaryForToday(CLOSED);
|
||||
|
||||
log.info("Closing {}'s gRPC channel.", this.getClass().getSimpleName());
|
||||
super.grpcStubs.close();
|
||||
}
|
||||
@ -166,7 +167,7 @@ public class RegtestTradePaymentSimulator extends AbstractBot {
|
||||
}
|
||||
|
||||
private void sendPaymentReceivedConfirmationMessage() {
|
||||
log.info("You confirm {} payment was received to you wallet before"
|
||||
log.info("You confirm {} payment was received to your wallet before"
|
||||
+ " sending confirmpaymentreceived to the BTC buyer.",
|
||||
currencyCode);
|
||||
sleep(pollingInterval);
|
||||
|
||||
@ -169,9 +169,9 @@ public class TakeBestPricedOfferToBuyBsq extends AbstractBot {
|
||||
|
||||
private void printBotConfiguration() {
|
||||
var configsByLabel = new LinkedHashMap<String, Object>();
|
||||
configsByLabel.put("Bot OS:", getOSName() + " " + getOSVersion());
|
||||
configsByLabel.put("Bot OS:", "\t" + getOSName() + " " + getOSVersion());
|
||||
var network = getNetwork();
|
||||
configsByLabel.put("BTC Network:", network);
|
||||
configsByLabel.put("BTC Network:", "\t" + network);
|
||||
var isMainnet = network.equalsIgnoreCase("mainnet");
|
||||
var mainnet30DayAvgBsqPrice = isMainnet ? get30DayAvgBsqPriceInBtc() : null;
|
||||
configsByLabel.put("My Payment Account:", "");
|
||||
@ -194,7 +194,7 @@ public class TakeBestPricedOfferToBuyBsq extends AbstractBot {
|
||||
} else {
|
||||
configsByLabel.put("\tPreferred Trading Peers:", "N/A");
|
||||
}
|
||||
configsByLabel.put("Bot Polling Interval:", pollingInterval + " ms");
|
||||
configsByLabel.put("Bot Polling Interval:", "\t" + pollingInterval + " ms");
|
||||
log.info(toTable.apply("Bot Configuration", configsByLabel));
|
||||
}
|
||||
|
||||
|
||||
@ -261,7 +261,9 @@ public class TakeBestPricedOfferToBuyBtc extends AbstractBot {
|
||||
isShutdown = true;
|
||||
|
||||
if (canSimulatePaymentSteps) {
|
||||
log.info("Shutting down bot after successful trade completion. API daemon will not be shut down.");
|
||||
log.info("Shutting down bot after {} successful simulated trades."
|
||||
+ " API daemon will not be shut down.",
|
||||
numOffersTaken);
|
||||
sleep(2_000);
|
||||
} else {
|
||||
log.info("Shutting down API daemon and bot after taking {} offers."
|
||||
@ -305,9 +307,9 @@ public class TakeBestPricedOfferToBuyBtc extends AbstractBot {
|
||||
|
||||
private void printBotConfiguration() {
|
||||
var configsByLabel = new LinkedHashMap<String, Object>();
|
||||
configsByLabel.put("Bot OS:", getOSName() + " " + getOSVersion());
|
||||
configsByLabel.put("Bot OS:", "\t" + getOSName() + " " + getOSVersion());
|
||||
var network = getNetwork();
|
||||
configsByLabel.put("BTC Network:", network);
|
||||
configsByLabel.put("BTC Network:", "\t" + network);
|
||||
configsByLabel.put("My Payment Account:", "");
|
||||
configsByLabel.put("\tPayment Account Id:", paymentAccount.getId());
|
||||
configsByLabel.put("\tAccount Name:", paymentAccount.getAccountName());
|
||||
@ -323,7 +325,7 @@ public class TakeBestPricedOfferToBuyBtc extends AbstractBot {
|
||||
} else {
|
||||
configsByLabel.put("\tPreferred Trading Peers:", "N/A");
|
||||
}
|
||||
configsByLabel.put("Bot Polling Interval:", pollingInterval + " ms");
|
||||
configsByLabel.put("Bot Polling Interval:", "\t" + pollingInterval + " ms");
|
||||
log.info(toTable.apply("Bot Configuration", configsByLabel));
|
||||
}
|
||||
|
||||
|
||||
@ -169,9 +169,9 @@ public class TakeBestPricedOfferToSellBsq extends AbstractBot {
|
||||
|
||||
private void printBotConfiguration() {
|
||||
var configsByLabel = new LinkedHashMap<String, Object>();
|
||||
configsByLabel.put("Bot OS:", getOSName() + " " + getOSVersion());
|
||||
configsByLabel.put("Bot OS:", "\t" + getOSName() + " " + getOSVersion());
|
||||
var network = getNetwork();
|
||||
configsByLabel.put("BTC Network:", network);
|
||||
configsByLabel.put("BTC Network:", "\t" + network);
|
||||
var isMainnet = network.equalsIgnoreCase("mainnet");
|
||||
var mainnet30DayAvgBsqPrice = isMainnet ? get30DayAvgBsqPriceInBtc() : null;
|
||||
configsByLabel.put("My Payment Account:", "");
|
||||
@ -194,7 +194,7 @@ public class TakeBestPricedOfferToSellBsq extends AbstractBot {
|
||||
} else {
|
||||
configsByLabel.put("\tPreferred Trading Peers:", "N/A");
|
||||
}
|
||||
configsByLabel.put("Bot Polling Interval:", pollingInterval + " ms");
|
||||
configsByLabel.put("Bot Polling Interval:", "\t" + pollingInterval + " ms");
|
||||
log.info(toTable.apply("Bot Configuration", configsByLabel));
|
||||
}
|
||||
|
||||
|
||||
@ -261,7 +261,9 @@ public class TakeBestPricedOfferToSellBtc extends AbstractBot {
|
||||
isShutdown = true;
|
||||
|
||||
if (canSimulatePaymentSteps) {
|
||||
log.info("Shutting down bot after successful trade completion. API daemon will not be shut down.");
|
||||
log.info("Shutting down bot after {} successful simulated trades."
|
||||
+ " API daemon will not be shut down.",
|
||||
numOffersTaken);
|
||||
sleep(2_000);
|
||||
} else {
|
||||
log.info("Shutting down API daemon and bot after taking {} offers."
|
||||
@ -305,9 +307,9 @@ public class TakeBestPricedOfferToSellBtc extends AbstractBot {
|
||||
|
||||
private void printBotConfiguration() {
|
||||
var configsByLabel = new LinkedHashMap<String, Object>();
|
||||
configsByLabel.put("Bot OS:", getOSName() + " " + getOSVersion());
|
||||
configsByLabel.put("Bot OS:", "\t" + getOSName() + " " + getOSVersion());
|
||||
var network = getNetwork();
|
||||
configsByLabel.put("BTC Network:", network);
|
||||
configsByLabel.put("BTC Network:", "\t" + network);
|
||||
configsByLabel.put("My Payment Account:", "");
|
||||
configsByLabel.put("\tPayment Account Id:", paymentAccount.getId());
|
||||
configsByLabel.put("\tAccount Name:", paymentAccount.getAccountName());
|
||||
@ -323,7 +325,7 @@ public class TakeBestPricedOfferToSellBtc extends AbstractBot {
|
||||
} else {
|
||||
configsByLabel.put("\tPreferred Trading Peers:", "N/A");
|
||||
}
|
||||
configsByLabel.put("Bot Polling Interval:", pollingInterval + " ms");
|
||||
configsByLabel.put("Bot Polling Interval:", "\t" + pollingInterval + " ms");
|
||||
log.info(toTable.apply("Bot Configuration", configsByLabel));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user