Skip to content

Commit

Permalink
create JSON files of actively traded crypto and fiat assets
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacxx committed Nov 22, 2020
1 parent 457257b commit 53a90f9
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableSet;

import java.time.Instant;

import java.io.File;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -135,6 +138,24 @@ private void maybeDumpStatistics() {
.collect(Collectors.toCollection(ArrayList::new));
cryptoCurrencyList.add(0, new CurrencyTuple(Res.getBaseCurrencyCode(), Res.getBaseCurrencyName(), 8));
jsonFileManager.writeToDiscThreaded(Utilities.objectToJson(cryptoCurrencyList), "crypto_currency_list");

Instant yearAgo = Instant.ofEpochSecond(Instant.now().getEpochSecond() - TimeUnit.DAYS.toSeconds(365));
Set<String> activeCurrencies = observableTradeStatisticsSet.stream()
.filter(e -> e.getDate().toInstant().isAfter(yearAgo))
.map(p -> p.getCurrency())
.collect(Collectors.toSet());

ArrayList<CurrencyTuple> activeFiatCurrencyList = fiatCurrencyList.stream()
.filter(e -> activeCurrencies.contains(e.code))
.map(e -> new CurrencyTuple(e.code, e.name, 8))
.collect(Collectors.toCollection(ArrayList::new));
jsonFileManager.writeToDiscThreaded(Utilities.objectToJson(activeFiatCurrencyList), "active_fiat_currency_list");

ArrayList<CurrencyTuple> activeCryptoCurrencyList = cryptoCurrencyList.stream()
.filter(e -> activeCurrencies.contains(e.code))
.map(e -> new CurrencyTuple(e.code, e.name, 8))
.collect(Collectors.toCollection(ArrayList::new));
jsonFileManager.writeToDiscThreaded(Utilities.objectToJson(activeCryptoCurrencyList), "active_crypto_currency_list");
}

List<TradeStatisticsForJson> list = observableTradeStatisticsSet.stream()
Expand Down

0 comments on commit 53a90f9

Please sign in to comment.