src/main/java/github/aq/cryptoprofittracker/web/AssetPriceResource.java
// make it more generic by recomposing the assets portfolio and then requesting just the prices needed

make it more generic by recomposing the assets portfolio and then requesting just the prices needed
make it more generic by recomposing the assets portfolio and then requesting just the prices needed
@RequestMapping(path = "/update", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<String> requestCurrentAssetPairPrices() throws Exception{
    	int pricesFetchedCount = 0;
        if (AssetPortfolio.getLastPriceUpdate() == null) {
        	for (ExchangePairs exchange: AssetPortfolio.getBalances().getAssetPortfolios()) {
        		for (Pair assetPair: exchange.getPairs().keySet()) {
        			CryptowatchResponseCurrentPriceDto resp = callCryptowatchAssetPairCurrentPrice(exchange.getExchange(), assetPair);
        			AssetPortfolio.getAssetPrices().addPrice(exchange.getExchange(), assetPair, resp.getResult().getPrice());
        			pricesFetchedCount ++;
        		}
        	}
        }
        return new ResponseEntity<>("Done - prices fetched count: " + pricesFetchedCount, HttpStatus.OK);
    }
@ RequestMapping ( path = "/update" , method = RequestMethod . GET , produces = MediaType . APPLICATION_JSON_VALUE ) public ResponseEntity < String > requestCurrentAssetPairPrices ( ) throws Exception { int pricesFetchedCount = 0 ; if ( AssetPortfolio . getLastPriceUpdate ( ) == null ) { for ( ExchangePairs exchange : AssetPortfolio . getBalances ( ) . getAssetPortfolios ( ) ) { for ( Pair assetPair : exchange . getPairs ( ) . keySet ( ) ) { CryptowatchResponseCurrentPriceDto resp = callCryptowatchAssetPairCurrentPrice ( exchange . getExchange ( ) , assetPair ) ; AssetPortfolio . getAssetPrices ( ) . addPrice ( exchange . getExchange ( ) , assetPair , resp . getResult ( ) . getPrice ( ) ) ; pricesFetchedCount ++ ; } } } return new ResponseEntity < > ( "Done - prices fetched count: " + pricesFetchedCount , HttpStatus . OK ) ; }
make it more generic by recomposing the assets portfolio and then requesting just the prices needed
make it more generic by recomposing the assets portfolio and then requesting just the prices needed