In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to clean up the market data of different futures varieties for vnpy. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
Vnpy comes with a relatively simple market clean-up function, but in the removal of non-trading hours, not taking into account Saturdays and Sundays; and just generally gives a maximum time trading range, such as stock index futures without night plate, rebar ends at 11:00 in the evening, but the default is only to end at 02:30 this maximum trading time. So I wrote a method to clean it up in more detail according to different varieties.
You can insert this method directly into\ DataRecording\ runDataCleaning.py and replace the original method. You can also call it yourself.
#-def cleanDataAdv (dbName, collectionName, start): "" Clean data "" # New static data # here take commodity futures as an example MORNING_START = time (9 0) MORNING_REST = time (10,15) MORNING_RESTART = time (10,30) MORNING_END = time (11,30) AFTERNOON_START = time (13,30) AFTERNOON_END = time (15,0) NIGHT_START = time (21,0) NIGHT_END = time (2,30) # Stock index futures STOCK_FUTURE = ["IC", "IF", "IH"] MORNING_START_STOCK = time (9 30) AFTERNOON_START_STOCK = time (136.0) AFTERNOON_END_STOCK = time (15,0) # end trading at 11:00 in the evening, incomplete Please maintain by yourself PM11CLOSE_FUTURE = ['rb','ru','bu','hc','sp'] NIGHT_END_11 = time (23,00) # end trading at 11:30 in the evening, incomplete, please maintain by yourself, there is only one sign in Dalian So with 1 PM1130CLOSE_FUTURE = ['FG','MA','SR','TA','RM','OI','CF','CY','ZC','i1','j1','m1','p1','y1'] NIGHT_END_1130 = time (23,30) # close trading at 01:30, incomplete Please maintain AM1CLOSE_FUTURE = ['cu','pd','al','zn'] NIGHT_END_AM1 = time (1,00) print (u'\ nClean database:% s, collection:% s, start date:% s'% (dbName, collectionName, start)) mc = MongoClient ('localhost') 27017) # create MongoClient cl = mc [dbName] [collectionName] # get data collection d = {'datetime': {' $gte': start}} # filter only data starting from start cx = cl.find (d) # get data pointer for data in cx: # get timestamp object dt = data ['datetime'] .time () # default To clean cleanRequired = True # if it is stock index futures There is no morning rest or night plate, 09:30 to 11:30, 1pm to 3pm, no market on Saturday and Sunday if collectionName [: 2] in STOCK_FUTURE: if data ['datetime'] .weekday () is not (5 or 6): if ((MORNING_START_STOCK)
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.