20: Fetch open Perps positions JupiterPerpsEntryPriceVariableRefresher
This commit is contained in:
+21
-2
@@ -1,9 +1,12 @@
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
import com.r35157.libs.jupiter.perps.JupiterPerpsPosition;
|
||||
import com.r35157.libs.jupiter.perps.JupiterPerpsService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public final class JupiterPerpsEntryPriceVariableRefresher {
|
||||
|
||||
@@ -16,14 +19,30 @@ public final class JupiterPerpsEntryPriceVariableRefresher {
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
String wallet = variables.get("JUPITER_PERPS_WALLET");
|
||||
ΩSolanaWalletIdΩ wallet = variables.get("JUPITER_PERPS_WALLET");
|
||||
|
||||
if (wallet == null || wallet.isBlank()) {
|
||||
System.err.println("Cannot refresh Jupiter Perps entry price variables: JUPITER_PERPS_WALLET is not configured");
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("Jupiter Perps entry price variable refresh requested for wallet: " + wallet);
|
||||
try {
|
||||
Set<JupiterPerpsPosition> positions = jupiterPerpsService.getOpenPositions(wallet);
|
||||
|
||||
System.out.println(
|
||||
"Fetched " + positions.size()
|
||||
+ " open Jupiter Perps positions for wallet: " + wallet
|
||||
);
|
||||
} catch (IOException | InterruptedException exception) {
|
||||
if (exception instanceof InterruptedException) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
System.err.println(
|
||||
"Could not refresh Jupiter Perps entry price variables: "
|
||||
+ exception.getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<String, String> variables;
|
||||
|
||||
Reference in New Issue
Block a user