code: def get_calendar_list_by_ratio(
      source_dir: [str, Path],
      date_field_name: str = "date",
      threshold: float = 0.5,
      minimum_count: int = 10,
      max_workers: int = 16,
  ) -> list:
      """get calendar list by selecting the date when few funds trade in this day
  
      Parameters
      ----------
      source_dir: str or Path
          The directory where the raw data collected from the Internet is saved
      date_field_name: str
              date field name, default is date
      threshold: float
          threshold to exclude some days when few funds trade in this day, default 0.5
      minimum_count: int
          minimum count of funds should trade in one day
      max_workers: int
          Concurrent number, default is 16
  
      Returns
      -------
          history calendar list
      """
      logger.info(
          f"get calendar list from {source_dir} by threshold = {threshold}......"
      )
  
      source_dir = Path(source_dir).expanduser()
      file_list = list(source_dir.glob("*.csv"))
  
      _number_all_funds = len(file_list)
  
      logger.info(f"count how many funds trade in this day......")
      _dict_count_trade = dict()  # dict{date:count}
      _fun = partial(return_date_list, date_field_name)
      all_oldest_list = []
      with tqdm(total=_number_all_funds) as p_bar:
          with ProcessPoolExecutor(max_workers=max_workers) as executor:
              for date_list in executor.map(_fun, file_list):
                  if date_list:
                      all_oldest_list.append(date_list[0])
                  for date in date_list:
                      if date not in _dict_count_trade:
                          _dict_count_trade[date] = 0
  
                      _dict_count_trade[date] += 1
  
                  p_bar.update()
  
      logger.info(
          f"count how many funds have founded in this day......"
      )
      _dict_count_founding = {
          date: _number_all_funds for date in _dict_count_trade
      }  # dict{date:count}
      with tqdm(total=_number_all_funds) as p_bar:
          for oldest_date in all_oldest_list:
              for date in _dict_count_founding.keys():
                  if date < oldest_date:
                      _dict_count_founding[date] -= 1
  
      calendar = [
          date
          for date, count in _dict_count_trade.items()
          if count >= max(int(count * threshold), minimum_count)
      ]
  
      return calendar
  
imports: import re
  import copy
  import importlib
  import time
  import bisect
  import pickle
  import random
  import requests
  import functools
  from pathlib import Path
  from typing import Iterable, Tuple, List
  import numpy
  import pandas
  from lxml import etree
  from loguru import logger
  from yahooquery import Ticker
  from tqdm import tqdm
  from functools import partial
  from concurrent.futures import ProcessPoolExecutor
  from bs4 import BeautifulSoup
label_desc: Use image node_id 3 for calling a global function with example usage: get_calendar_list_by_ratio(source_dir, date_field_name, threshold, minimum_count, max_workers) and returns: calendar