update
This commit is contained in:
@@ -213,6 +213,7 @@ public class MoneyApiController {
|
||||
return ServerResponse.createByErrorMsg("Stock is not exist!");
|
||||
}
|
||||
StockQuoteData data = moneyApiService.getSingleStockQuote(symbol);
|
||||
data.setName(stock.getStockName());
|
||||
return ServerResponse.createBySuccess(data);
|
||||
}
|
||||
|
||||
@@ -592,7 +593,7 @@ public class MoneyApiController {
|
||||
@ResponseBody
|
||||
@EncryptFilter(decryptRequest = false)
|
||||
|
||||
public List<MoneyStockSuggestDTO> getTopLoser(@RequestParam String stockType) {
|
||||
public List<MoneyStockSuggestDTO> getTopLoser(@RequestParam(required = false) String stockType) {
|
||||
List<MoneyStockSuggestDTO> moneyStockSuggestDTOS = null;
|
||||
List<StockQuoteData> stockQuoteDataList = moneyApiService.getTopLosersFromTradingView();
|
||||
moneyStockSuggestDTOS = convertStockQuoteDataToMoneyStockSuggestDTO(stockQuoteDataList);
|
||||
|
||||
@@ -175,6 +175,9 @@ public class MoneyApiService {
|
||||
public List<StockQuoteData> getTopStocksFromTradingView(String sortOrder) {
|
||||
String url = "https://scanner.tradingview.com/germany/scan";
|
||||
|
||||
// Determine preset based on sort order
|
||||
String preset = "desc".equals(sortOrder) ? "gainers" : "losers";
|
||||
|
||||
// Prepare request body
|
||||
String requestBody = "{\n" +
|
||||
" \"columns\": [\n" +
|
||||
@@ -198,6 +201,7 @@ public class MoneyApiService {
|
||||
" \"options\": {\n" +
|
||||
" \"lang\": \"en\"\n" +
|
||||
" },\n" +
|
||||
" \"preset\": \"" + preset + "\",\n" +
|
||||
" \"range\": [\n" +
|
||||
" 0,\n" +
|
||||
" 30\n" +
|
||||
@@ -241,14 +245,7 @@ public class MoneyApiService {
|
||||
|
||||
if (!stocks.isEmpty()) {
|
||||
// Get real-time quotes for these stocks
|
||||
List<StockQuoteData> stockQuoteDatas = getStocksQuote(stocks);
|
||||
for (StockQuoteData stockQuoteData : stockQuoteDatas) {
|
||||
Stock name = stocks.stream().filter(e->e.getStockCode().equals(stockQuoteData.getSymbol())).findFirst().orElse(null);
|
||||
if (name != null) {
|
||||
stockQuoteData.setName(name.getStockName());
|
||||
}
|
||||
}
|
||||
return stockQuoteDatas;
|
||||
return getStocksQuote(stocks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user