Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/etd 1401 connectors coinmate.api dont co #470

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b2115cd
feature/ETD-1340-container-update-simplecoin-csv
martinkyov Jul 29, 2024
87c7c1f
Merge branch 'master' into feature/ETD-1340-container-update-simpleco…
Slithercze Aug 30, 2024
e499c45
feature/ETD-1340-container-update-simplecoin-csv
Slithercze Aug 30, 2024
558f138
Merge pull request #1 from Slithercze/feature/ETD-1340-container-upda…
Slithercze Aug 30, 2024
7430621
Merge branch 'everytrade-io:master' into master
Slithercze Sep 6, 2024
7f62f27
bugfix/ETD-1401-connectors-coinmate.api-dont-co-
Slithercze Sep 6, 2024
541cf86
bugfix/ETD-1401-connectors-coinmate.api-dont-co-
Slithercze Sep 16, 2024
64ce2f4
new version
martinkyov Sep 9, 2024
2a31234
Feature/etd 1418 rates add exchange rate for spe (#454)
martinkyov Sep 12, 2024
40d8224
Feature/etd 1418 rates add exchange rate for spe (#455)
martinkyov Sep 13, 2024
6aa8fc7
new version
martinkyov Sep 13, 2024
9563f01
Merge branch 'master' into bugfix/ETD-1401-connectors-coinmate.api-do…
Slithercze Sep 16, 2024
30f36a9
Merge branch 'master' into bugfix/ETD-1401-connectors-coinmate.api-do…
Slithercze Sep 23, 2024
07c3a0f
bugfix/ETD-1401-connectors-coinmate.api-dont-co-
Slithercze Sep 23, 2024
9818e56
bugfix/ETD-1401-connectors-coinmate.api-dont-co-
Slithercze Sep 23, 2024
062bec5
bugfix/ETD-1401-connectors-coinmate.api-dont-co-
Slithercze Sep 23, 2024
b1c2ab7
Merge branch 'master' into bugfix/ETD-1401-connectors-coinmate.api-do…
Slithercze Dec 3, 2024
6ad3513
bugfix/ETD-1401-connectors-coinmate.api-dont-co-
Slithercze Dec 3, 2024
c3172f7
bugfix/ETD-1401-connectors-coinmate.api-dont-co-
Slithercze Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class CoinmateConnector implements IConnector {
private static final long DELAY = 24 * 60 * 60 * 1000L;
// MAX 100 request per minute per user, https://coinmate.docs.apiary.io/#reference/request-limits
// https://coinmate.docs.apiary.io/#reference/transaction-history/get-transaction-history
private static final int TX_PER_REQUEST = 799;
private static final int TX_PER_REQUEST = 1000;
private static final Logger LOG = LoggerFactory.getLogger(CoinmateConnector.class);
private static final int MAX_ITERATIONS = 80;

Expand Down Expand Up @@ -118,42 +118,46 @@ private List<CoinmateTransactionHistoryEntry> downloadTransactions(DownloadState
setTxFromTimestamp(state);
List<CoinmateTransactionHistoryEntry> allData = new ArrayList<>();

long now = Instant.now().toEpochMilli();
long txFrom = state.getTxFrom();
long txTo = state.getTxTo() == 0L ? now : state.getTxTo();
int offset = state.getOffset();
long txTo = state.getTxTo() == 0L ? Instant.now().toEpochMilli() : state.getTxTo();

int iterationCount = 0;

while (true) {
if (iterationCount++ >= MAX_ITERATIONS) {
throw new IllegalStateException("Maximum iterations reached. Possible infinite loop detected.");
}
final List<CoinmateTransactionHistoryEntry> userTransactionBlock;

List<CoinmateTransactionHistoryEntry> userTransactionBlock;
try {
userTransactionBlock = rawServices.getCoinmateTransactionHistory(
offset, TX_PER_REQUEST, SORT_DESC, txFrom, txTo, null).getData();
0, TX_PER_REQUEST, SORT_DESC, txFrom, txTo, null).getData();
} catch (IOException e) {
throw new IllegalStateException("Download user trade history failed.", e);
}

if (userTransactionBlock.isEmpty()) {
state.offset = 0;
state.txFrom = txTo;
state.txTo = 0L;
break;
}
if(userTransactionBlock.size() < TX_PER_REQUEST) {
state.offset = 0;

allData.addAll(userTransactionBlock);

if (userTransactionBlock.size() < TX_PER_REQUEST) {
state.txFrom = txTo;
state.txTo = 0L;
allData.addAll(userTransactionBlock);
break;
} else {
txTo = now;
offset += TX_PER_REQUEST;
state.txTo = now;
state.offset = offset;
allData.addAll(userTransactionBlock);
}

txTo = userTransactionBlock.get(userTransactionBlock.size() - 1).getTimestamp() - 1;
state.txTo = txTo;

try {
Thread.sleep(600);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException("Thread was interrupted during sleep.", e);
}
}
return allData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ public Map<?, List<KrakenBeanV2>> removeGroupsWithUnsupportedRows(Map<?, List<Kr
Map<Object, List<KrakenBeanV2>> result = new HashMap<>();
for (Map.Entry<?, List<KrakenBeanV2>> entry : rowGroups.entrySet()) {
var rowsInGroup = entry.getValue();
var isOneOrMoreUnsupportedRows =
!rowsInGroup.stream().filter(r -> r.isUnsupportedRow() == true).collect(Collectors.toList()).isEmpty();
var isOneOrMoreUnsupportedRows = rowsInGroup.stream().anyMatch(KrakenBeanV2::isUnsupportedRow);
if (!isOneOrMoreUnsupportedRows) {
result.put(entry.getKey(), entry.getValue());
} else {
var ids = rowsInGroup.stream().map(r -> r.getRowId()).collect(Collectors.toList());
var ids = rowsInGroup.stream().map(KrakenBeanV2::getRowId).toList();
var s = BinanceSortedGroupV4.parseIds(ids);
setRowsAsUnsupported(rowsInGroup, "One or more rows in group " + "( rows: " + s + ") is unsupported");
}
Expand Down