コード例 #1
0
def download_daily_aggTrades(trading_type, symbols, num_symbols, dates, start_date, end_date, folder, checksum):
  current = 0
  date_range = None

  if start_date and end_date:
    date_range = start_date + " " + end_date

  if not start_date:
    start_date = START_DATE
  else:
    start_date = convert_to_date_object(start_date)

  if not end_date:
    end_date = END_DATE
  else:
    end_date = convert_to_date_object(end_date)

  print("Found {} symbols".format(num_symbols))

  for symbol in symbols:
    print("[{}/{}] - start download daily {} aggTrades ".format(current+1, num_symbols, symbol))
    for date in dates:
      current_date = convert_to_date_object(date)
      if current_date >= start_date and current_date <= end_date:
        path = get_path(trading_type, "aggTrades", "daily", symbol)
        file_name = "{}-aggTrades-{}.zip".format(symbol.upper(), date)
        download_file(path, file_name, date_range, folder)

        if checksum == 1:
          checksum_path = get_path(trading_type, "aggTrades", "daily", symbol)
          checksum_file_name = "{}-aggTrades-{}.zip.CHECKSUM".format(symbol.upper(), date)
          download_file(checksum_path, checksum_file_name, date_range, folder)

    current += 1
コード例 #2
0
def download_monthly_klines(symbols, num_symbols, intervals, years, months,
                            start_date, end_date, folder, checksum):
    current = 0
    date_range = None

    if start_date and end_date:
        date_range = start_date + " " + end_date

    if not start_date:
        start_date = START_DATE
    else:
        start_date = convert_to_date_object(start_date)

    if not end_date:
        end_date = END_DATE
    else:
        end_date = convert_to_date_object(end_date)

    print("Found {} symbols".format(num_symbols))

    for symbol in symbols:
        print("[{}/{}] - start download monthly {} klines ".format(
            current + 1, num_symbols, symbol))
        for interval in intervals:
            for year in years:
                for month in months:
                    current_date = convert_to_date_object('{}-{}-01'.format(
                        year, month))
                    if current_date >= start_date and current_date <= end_date:
                        path = "data/spot/monthly/klines/{}/{}/".format(
                            symbol.upper(), interval)
                        file_name = "{}-{}-{}-{}.zip".format(
                            symbol.upper(), interval, year,
                            '{:02d}'.format(month))
                        download_file(path, file_name, date_range, folder)

                        if checksum == 1:
                            checksum_path = "data/spot/monthly/klines/{}/{}/".format(
                                symbol.upper(), interval)
                            checksum_file_name = "{}-{}-{}-{}.zip.CHECKSUM".format(
                                symbol.upper(), interval, year,
                                '{:02d}'.format(month))
                            download_file(checksum_path, checksum_file_name,
                                          date_range, folder)

        current += 1
コード例 #3
0
def download_daily_klines(symbols, num_symbols, intervals, dates, start_date,
                          end_date, folder, checksum):
    current = 0
    date_range = None

    if start_date and end_date:
        date_range = start_date + " " + end_date

    if not start_date:
        start_date = START_DATE
    else:
        start_date = convert_to_date_object(start_date)

    if not end_date:
        end_date = END_DATE
    else:
        end_date = convert_to_date_object(end_date)

    #Get valid intervals for daily
    intervals = list(set(intervals) & set(DAILY_INTERVALS))
    print("Found {} symbols".format(num_symbols))

    for symbol in symbols:
        print("[{}/{}] - start download daily {} klines ".format(
            current + 1, num_symbols, symbol))
        for interval in intervals:
            for date in dates:
                current_date = convert_to_date_object(date)
                if current_date >= start_date and current_date <= end_date:
                    path = "data/spot/daily/klines/{}/{}/".format(
                        symbol.upper(), interval)
                    file_name = "{}-{}-{}.zip".format(symbol.upper(), interval,
                                                      date)
                    download_file(path, file_name, date_range, folder)

                    if checksum == 1:
                        checksum_path = "data/spot/daily/klines/{}/{}/".format(
                            symbol.upper(), interval)
                        checksum_file_name = "{}-{}-{}.zip.CHECKSUM".format(
                            symbol.upper(), interval, date)
                        download_file(checksum_path, checksum_file_name,
                                      date_range, folder)

        current += 1