预测者网,数据预测未来,互联网时代的金融数据服务,专业服务于量化研究,虚拟货币市场。

{{ globalMessage }}

预测者网


加载中

日线交易数据

所有沪深股票每天的交易数据

历史日线数据

查看详情

日线数据每日推送

查看详情

市场全息数据

所有沪深股票每天的交易数据及各类指标

历史全息数据

查看详情

全息数据每日推送

查看详情

基础交易数据

所有沪深股票每天的交易数据

周、月线交易数据

所有沪深股票每周、每月的交易数据

历史月线数据

查看详情

历史周线数据

查看详情

股票更名数据

所有沪深股票名称变更数据

龙虎榜数据每日推送

每天推送沪深股票的龙虎榜数据

即将上线

概述

订购预测者网推送数据服务后,推送数据会在每天盘后发送到您的邮箱。此外,我们也提供了数据接口,让您可以写程序自动更新数据,不用每天从邮箱中下载数据。


具体步骤

  • 登陆预测者网官方网站后,进入个人设置页面: https://yucezhe.com/user/home,获取或设置API KEY。
  • 进入您已经购买的数据的页面,在该页面的url中,复制该产品的英文名。例如,“日线数据每日推送”的地址是:https://yucezhe.com/product?name=trading-data-push,那么该产品的英文名即为 trading-data-push
  • 使用您的登陆邮箱(例如example@qq.com)、已经购买的推送产品的英文名、以及API KEY(例如:yBr93F9GKUoXv4Yy),拼凑成如些链接:
    https://yucezhe.com/api/v1/data/today?email=example@qq.com&name=trading-data-push&key=yBr93F9GKUoXv4Yy
  • 使用程序访问该链接,即可得到数据的下载地址。

链接返回值

该链接返回数据的下载地址。有如下几种情况:

  1. 若当天的数据已经准备好,则会返回当天数据的下载地址,该地址3小时内有效。
  2. 若当天的数据还没有准备好,则会返回:“NO DATA
  3. 若您未购买该数据产品、或者产品已经过期,则会返回:“NO OWNERSHIP FOR PRODUCT
  4. 若您的邮箱或API KEY错误,则会返回:“NO VALID API ACCESS

其他说明

  • 不管您是否使用API下载数据,每天的数据都会发送到您邮箱。
  • 我们会监控每天请求API的次数,正常使用没有任何问题。若某用户请求次数超出正常使用范围,我们会中断对该用户服务。
  • 若在使用过程中遇到任何问题,可以联系预测者网官方QQ:2023046319。

Python2/3示例代码

Python3只需要更改一下urllib的库引用即可。

# encoding: utf-8
"""
# API PYTHON DEMO
基于API V1的自动下载示例代码
使用前需去[https://www.yucezhe.com/user/home](https://www.yucezhe.com/user/home)配置API KEY;
使用时需配置注册邮箱,默认下载地址为程序同目录;
Copyright © 2011-2017 yucezhe.com, All rights reserved.
"""
from urllib import urlretrieve, urlencode
from urllib2 import urlopen
# from urllib.request import urlopen, urlretrieve, urlencode  # used in python3

API_URL = 'https://yucezhe.com/api/v1/data/today'
# ****************************config*************************************** #
EMAIL = 'contact@yucezhe.com'  # 购买数据时候使用的邮箱地址
API_KEY = 'THIS IS YOUR API KEY'  # 于页面配置的API KEY
# **************************config_end************************************* #


def get_today(product_name, local_file_name):
    """
    :param product_name: the product name, get it from the url of the product homepage
    :param local_file_name: the local file name to save as
    :return: the download url after file saved
    """
    params = {
        'name': product_name,
        'email': EMAIL,
        'key': API_KEY
    }
    params_str = urlencode(params)
    response = urlopen('%s?%s' % (API_URL, params_str))
    data_download_url = response.read()
    if 'data.yucezhe.com' in data_download_url:
        print('[URL GET]:', data_download_url)
        urlretrieve(data_download_url, local_file_name)
        return data_download_url
    else:
        print(data_download_url)
        return None


def get_today_auto(product_name, local_file_name):
    """
    this function will auto wait if the data is not ready
    and auto stop when download finished
    :param product_name: equivalent to 'get_today'
    :param local_file_name: equivalent to 'get_today'
    :return: nothing
    """
    _u = get_today(product_name, local_file_name)
    import time
    while _u is None:
        print '[auto run]: data is not ready, retry in 30s'
        time.sleep(30)
        _u = get_today(product_name, local_file_name)

get_today_auto('trading-data-push', 'trading-data-push.zip')