Third-party API (jqdatasdk) to obtain real-time market data

Here is an introduction to using jqdatasdk of JQData to obtain real-time market data and store it in the database (mongodb and myslq) in real time.

JQData is a local quantitative financial data service provided by the Jukuan Data team for financial institutions, academic groups and quantitative researchers. Using JQData, you can quickly view and calculate financial data, and meet the needs of local, web, and financial terminals to call data without any problems.

JQData is suitable for Windows, Mac, and Linux operating systems, and supports python2, python3 and any programming language. For details, please refer to the official website of Jukuan.

1. Import the library

import pandas as pd
import numpy as np
import re
import util.dbcom as dbcom
import util.mdbcom as mdbcom
import util.xtool as xtool
import util.tradeDate as TD
import util.xEmail as XEMAIL
from jqdatasdk import *
import time

2. Authorization (free version can be skipped)

auth('用户名', '密码') 
print(get_query_count())
def hasJQAuthSpare():
    ...
    return True

3. Update variety contracts

Contract information for all futures and options is automatically updated every 8:00 am.

def getContrs(startDate=None,isSaveMysql=True,isSaveMongo=True):
    if hasJQAuthSpare():
        xtime = xtool.nowTime()
        contrs = g

Guess you like

Origin blog.csdn.net/weixin_41192839/article/details/122359683