public static void printShareKhanBidAskLists(ShareKhanBidAskLists bidAskLists) throws Exception {
    BidAskLists bseLists = bidAskLists.getBseList();
    Iterator<Bet> it = bseLists.getBidsIterator();
    System.out.println("BSE Bids");
    while (it.hasNext()) {
      Bet bet = it.next();
      System.out.println(bet.getOrderCount() + " " + bet.getQuantity() + " " + bet.getPrice());
    }

    it = bseLists.getAsksIterator();
    System.out.println("BSE Asks");
    while (it.hasNext()) {
      Bet bet = it.next();
      System.out.println(bet.getOrderCount() + " " + bet.getQuantity() + " " + bet.getPrice());
    }

    BidAskLists nseLists = bidAskLists.getNseList();
    it = nseLists.getBidsIterator();
    System.out.println("NSE Bids");
    while (it.hasNext()) {
      Bet bet = it.next();
      System.out.println(bet.getOrderCount() + " " + bet.getQuantity() + " " + bet.getPrice());
    }

    it = nseLists.getAsksIterator();
    System.out.println("NSE Asks");
    while (it.hasNext()) {
      Bet bet = it.next();
      System.out.println(bet.getOrderCount() + " " + bet.getQuantity() + " " + bet.getPrice());
    }
  }
  public static synchronized void printBidAskListToConsole(ShareKhanBidAskLists skBaList) {
    BidAskLists bseLists = skBaList.getBseList();
    Iterator<Bet> it = bseLists.getBidsIterator();
    System.out.println("BID-ASK List for scrip - " + skBaList.getScrip());
    System.out.println("BSE TimeStamp - " + skBaList.getBseTimeStamp());
    System.out.println("BSE Bids");
    while (it.hasNext()) {
      Bet bet = it.next();
      System.out.println(bet.getOrderCount() + " " + bet.getQuantity() + " " + bet.getPrice());
    }

    it = bseLists.getAsksIterator();
    System.out.println("BSE Asks");
    while (it.hasNext()) {
      Bet bet = it.next();
      System.out.println(bet.getOrderCount() + " " + bet.getQuantity() + " " + bet.getPrice());
    }

    System.out.println("NSE TimeStamp - " + skBaList.getNseTimeStamp());
    BidAskLists nseLists = skBaList.getNseList();
    it = nseLists.getBidsIterator();
    System.out.println("NSE Bids");
    while (it.hasNext()) {
      Bet bet = it.next();
      System.out.println(bet.getOrderCount() + " " + bet.getQuantity() + " " + bet.getPrice());
    }

    it = nseLists.getAsksIterator();
    System.out.println("NSE Asks");
    while (it.hasNext()) {
      Bet bet = it.next();
      System.out.println(bet.getOrderCount() + " " + bet.getQuantity() + " " + bet.getPrice());
    }
  }
    public void run() {
      logger.debug("Executing BidAskDownloaderPocJob for scrip-" + scrip);

      while (true) {
        String dom = "";
        try {
          dom = worker.getBidAskListDom(scrip);
          ShareKhanBidAskLists skBaList = ShareKhanParserUtil.getBidAskLists(dom);
          skBaList.setScrip(scrip);
          printBidAskListToConsole(skBaList);
          Thread.sleep(10000);
        } catch (Exception e) {
          logger.error(e);
          e.printStackTrace();
          throw new RuntimeException(e);
        }
      }
      // logger.debug("FINISHED Executing BidAskDownloaderPocJob for scrip-"+scrip);
    }
  public static ShareKhanBidAskLists getBidAskLists(String dom) {
    logger.debug("CALL getBidAskLists");
    ShareKhanBidAskLists shareKhanBidAskList = new ShareKhanBidAskLists();
    List<String> t1s = getTagBodiesFromAString(dom, "t1");

    for (int i = 0; i < t1s.size(); i++) {
      // System.out.println(t1s.get(i));
      Map<String, String> tagValueMap = getAllTagValues(t1s.get(i));

      /*
       * for(Map.Entry<String, String> e:tagValueMap.entrySet()) {
       * System.out.println(e.getKey()+" "+e.getValue()); }
       */

      String market = tagValueMap.get("t15").trim();
      String scrip = tagValueMap.get("t2").trim();
      String timeStamp = tagValueMap.get("t14").trim();

      Double ltp = Double.parseDouble(tagValueMap.get("t3").trim());
      Integer ltq = Integer.parseInt(tagValueMap.get("t6").trim());

      BidAskLists bidAskList = new BidAskLists();

      for (int j = 0; j < 5; j++) {
        String orderCountS = tagValueMap.get("t2" + (j + 5));
        String quantityS = tagValueMap.get("t3" + j);
        String priceS = tagValueMap.get("t3" + (j + 5));

        Integer orderCount = Integer.parseInt(orderCountS.trim());
        Integer quantity = Integer.parseInt(quantityS.trim());
        Double price = Double.parseDouble(priceS.trim());

        Bet bid = new Bet(BetType.BID, orderCount, quantity, price);

        orderCountS = tagValueMap.get("t4" + j);
        quantityS = tagValueMap.get("t4" + (j + 5));
        priceS = tagValueMap.get("t5" + j);

        orderCount = Integer.parseInt(orderCountS.trim());
        quantity = Integer.parseInt(quantityS.trim());
        price = Double.parseDouble(priceS.trim());

        Bet ask = new Bet(BetType.ASK, orderCount, quantity, price);

        bidAskList.addBid(bid);
        bidAskList.addAsk(ask);
      }

      if (market.equals("BSE")) {
        shareKhanBidAskList.setBseList(bidAskList);
        shareKhanBidAskList.setBseTimeStamp(timeStamp);
        shareKhanBidAskList.setBseLtp(ltp);
        shareKhanBidAskList.setBseLtq(ltq);

      } else if (market.equals("NSE")) {
        shareKhanBidAskList.setNseList(bidAskList);
        shareKhanBidAskList.setNseTimeStamp(timeStamp);
        shareKhanBidAskList.setNseLtp(ltp);
        shareKhanBidAskList.setNseLtq(ltq);
      }
    }

    logger.debug("RETURN getBidAskLists");
    return shareKhanBidAskList;
  }