In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "how to use Joinquant to do solid market data", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use Joinquant to do solid market data" this article.
As shown in the figure below, if the market data is downloaded on a trading day, such as 02:30 or 8am, and if the endDate is the same day or later, the returned data will be automatically populated to 3pm trading. The data after this time is that the trading volume is 0, and the price is the price at 02:30.
Therefore, when used for firm data analysis, the minute time of endDate must be entered as the current time to ensure that control does not occur. The overall code is updated as follows:
# encoding: UTF-8 from _ _ future__ import print_functionimport sysimport jsonfrom datetime import datetime,date,timedeltafrom time import time, sleep from pymongo import MongoClient, ASCENDINGimport pandas as pd from vnpy.trader.vtObject import VtBarData, VtTickDatafrom vnpy.trader.app.ctaStrategy.ctaBase import (MINUTE_DB_NAME, DAILY_DB_NAME) TICK_DB_NAME) import jqdatasdk as jq # load configuration config = open ('config.json') setting = json.load (config) mc = MongoClient () # Mongo connection dbMinute = MC [mini _ DB_NAME] # Database # dbDaily = MC [tick _ DB_NAME] USERNAME = setting [' Username'] PASSWORD = setting ['Password'] jq.auth (USERNAME PASSWORD) FIELDS = ['open',' high', 'low',' close', 'volume'] #-def generateVtBar (row Symbol): "" generate K-line "" bar = VtBarData () bar.symbol = symbol bar.exchange = "SHFE" bar.vtSymbol = bar.vtSymbol ='. '.join ([bar.symbol Bar.exchange]) bar.open = row ['open'] bar.high = row [' high'] bar.low = row ['low'] bar.close = row [' close'] bar.volume = row ['volume'] bardatetime = row.name bar.date = bardatetime.strftime ("% Y%m%d") bar.time = bardatetime.strftime ("% H%M%S") # change bar's time to One minute earlier hour = bar.time [0:2] minute = bar.time [2:4] sec = bar.time [4:6] if minute = = "00": minute = "59" h = int (hour) if h = 0: h = 24 hour = str (h-1) .rjust (2 '0') else: minute = str (int (minute)-1) .rjust (2,' 0') bar.time = hour + minute + sec bar.datetime = datetime.strptime ('.join ([bar.date, bar.time]) '% Y%m%d% H% M% S') return bar #-def jqdownloadMinuteBarBySymbol (symbol,startDate EndDate): "" download minute line data for a contract "start = time () cl = dbMinute [symbol] cl.ensure_index ([('datetime', ASCENDING)], unique=True) # add index df = jq.get_price, start_date = startDate,end_date = endDate, frequency='1m', fields=FIELDS,skip_paused = True) for ix, row in df.iterrows (): bar = generateVtBar (row) Symbol) d = bar.__dict__ flt = {'datetime': bar.datetime} cl.replace_one (flt, d, True) end = time () cost = (end-start) * 1000 print (u' contract% s minute K line data download completed% s -% s Time-consuming% s milliseconds'% (symbol, df.index [0], df.index [- 1], cost)) print (jq.get_query_count ()) def jqdownloadMappingExcel (exportpath = "C:\ Project\"): getfuture = jq.get_all_securities (types= ['futures'], date=None) # list: type used to filter securities, list element optional:' stock', 'fund',' index', 'futures',' etf', 'lof' Returns all stocks when the 'fja',' fjb'.types is empty, excluding funds, indices and futures getfuture.to_excel (exportpath + "Mapping" + str (date.today ()) + "futures.xls", index=True Header=True) #-def downloadAllMinuteBar (days=10): "" download minute line data of contracts in all configurations "print ('- * 50) print ( U' start downloading contract minute line data') print ('-'* 50) startDt = datetime.today ()-days * timedelta (1) startDate = startDt.strftime ('% Ymuri% mmure% d') # add download task enddt = datetime.today () endDate = enddt.strftime ('% Y-%m-%d% HGV% MRO% S') jqdownloadMinuteBarBySymbol ('rb1910' StartDate,endDate) print ('-'* 50) print u' contract minute line data download completes' print ('-'* 50) if _ _ name__ = ='_ _ main__': # jqdownloadMappingExcel () # download main contract downloadAllMinuteBar (days=10) # download single variety # jqdownloadMinuteBarBySymbol ('510050.XSHGprecept startDateendDate) these are all the contents of the article "how to use Joinquant to make Real offer data" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.