How to use the akshare.cons function in akshare

To help you get started, we’ve selected a few akshare examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jindaxiang / akshare / example / daily_run.py View on Github external
def down_load(date):
    date = akshare.cons.convert_date(date) if date is not None else datetime.date.today()
    if date not in calendar:
        warnings.warn("%s非交易日" % date.strftime("%Y%m%d"))
        return
    # ----------------------------------------------------------------------
    print("\n" + "-" * 80 + "\n展期")
    df = akshare.get_roll_yield_bar(type_method="var", date=date)
    df.to_csv(s["root"] + "展期%s.csv" % date)

    # ----------------------------------------------------------------------
    print("\n" + "-" * 80 + "\n基差")
    df = akshare.futures_spot_price(date)
    df.to_csv(s["root"] + "基差%s.csv" % date)

    # ----------------------------------------------------------------------
    print("\n" + "-" * 80 + "\n会员持仓排名之和")
    df = akshare.get_rank_sum_daily(start_day=date, end_day=date)
github jindaxiang / akshare / example / daily_run.py View on Github external
# -*- coding:utf-8 -*-
# /usr/bin/env python
"""
Date: 2020/5/4 9:07
Desc: test
"""

import datetime
import json
import warnings
from time import sleep

import akshare

calendar = akshare.cons.get_calendar()

setting_file_name = "setting.json"
setting_file_path = akshare.cons.get_json_path(setting_file_name, __file__)
s = json.load(open(setting_file_path, "r"))


def down_load(date):
    date = akshare.cons.convert_date(date) if date is not None else datetime.date.today()
    if date not in calendar:
        warnings.warn("%s非交易日" % date.strftime("%Y%m%d"))
        return
    # ----------------------------------------------------------------------
    print("\n" + "-" * 80 + "\n展期")
    df = akshare.get_roll_yield_bar(type_method="var", date=date)
    df.to_csv(s["root"] + "展期%s.csv" % date)