| | |
| | | case MY_STOCKS: { |
| | | ZonedDateTime nowKualaLumpur = nowUtc.withZoneSameInstant(ZoneId.of("Asia/Kuala_Lumpur")); |
| | | String formattedDate = nowKualaLumpur.format(formatter); |
| | | if (myStockStopSet.contains(formattedDate)) { |
| | | /*if (myStockStopSet.contains(formattedDate)) { |
| | | return false; |
| | | } |
| | | }*/ |
| | | if (nowKualaLumpur.getDayOfWeek().getValue() < 6) { // 保证周一至周五可以交易 |
| | | if ((nowKualaLumpur.getHour() == 9 && nowKualaLumpur.getMinute() >= 30) || // 上午9:30开始 |
| | | (nowKualaLumpur.getHour() > 9 && nowKualaLumpur.getHour() < 12) || // 9点过后至12点前 |
| | |
| | | ZonedDateTime nowShanghai = nowUtc.withZoneSameInstant(ZoneId.of("Asia/Shanghai")); |
| | | String formattedDate = nowShanghai.format(formatter); |
| | | //logger.info("---> MarketOpenChecker.isOpen market:{}, dayOfWeek:{}, hour:{}", market, nowShanghai.getDayOfWeek().getValue(), nowShanghai.getHour()); |
| | | if (aStockStopSet.contains(formattedDate)) { |
| | | /*if (aStockStopSet.contains(formattedDate)) { |
| | | return false; |
| | | } |
| | | }*/ |
| | | if (nowShanghai.getDayOfWeek().getValue() < 6 && |
| | | ((nowShanghai.getHour() == 9 && nowShanghai.getMinute() >= 30) || |
| | | (nowShanghai.getHour() == 10) || |
| | |
| | | |
| | | ZonedDateTime nowHongKong = nowUtc.withZoneSameInstant(ZoneId.of("Asia/Hong_Kong")); |
| | | String formattedDate = nowHongKong.format(formatter); |
| | | if (hkStockStopSet.contains(formattedDate)) { |
| | | /*if (hkStockStopSet.contains(formattedDate)) { |
| | | return false; |
| | | } |
| | | }*/ |
| | | if (nowHongKong.getDayOfWeek().getValue() < 6 && |
| | | ((nowHongKong.getHour() == 9 && nowHongKong.getMinute() >= 30) || |
| | | (nowHongKong.getHour() > 9 && nowHongKong.getHour() < 12) || |
| | |
| | | } |
| | | case US_STOCKS: { |
| | | ZonedDateTime nowNewYork = nowUtc.withZoneSameInstant(ZoneId.of("America/New_York")); |
| | | String formattedDate = nowNewYork.format(formatter); |
| | | /*String formattedDate = nowNewYork.format(formatter); |
| | | if (usStockStopSet.contains(formattedDate)) { |
| | | return false; |
| | | } |
| | | }*/ |
| | | if (!isUsSupportPreAndAfter()) { |
| | | if (nowNewYork.getDayOfWeek().getValue() < 6 && |
| | | ((nowNewYork.getHour() == 9 && nowNewYork.getMinute() >= 30) || |
| | |
| | | return false; |
| | | } |
| | | |
| | | public static boolean isMarketOpenBuyDz(String market) { |
| | | ZonedDateTime nowUtc = ZonedDateTime.now(ZoneId.of("UTC")); |
| | | return isOpenBuyDz(market, nowUtc); |
| | | } |
| | | |
| | | private static boolean isOpenBuyDz(String market, ZonedDateTime nowUtc) { |
| | | switch (market) { |
| | | case US_STOCKS: { |
| | | ZonedDateTime nowNewYork = nowUtc.withZoneSameInstant(ZoneId.of("America/New_York")); |
| | | if (nowNewYork.getDayOfWeek().getValue() < 6) { |
| | | return true; |
| | | } |
| | | break; |
| | | } |
| | | default: |
| | | throw new IllegalArgumentException("无效的市场名称"); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | public static List<OpenCloseTime> listUsOpenCloseDateTime() { |
| | | int year = 2023; |