Beispiel #1
0
def mergeCodeList():
    endDate = datetime.datetime.now().strftime("%Y-%m-%d")  # 以当天为截止日期
    basicFile = os.path.join(config.listsRootPath, 'stockBasic.json')
    basicDate = readFile(basicFile)  # timeToMarket 上市日期
    indusrtyFile = os.path.join(config.listsRootPath,
                                'stockIndustryClassified.json')
    indusrtyDate = readFile(indusrtyFile)
    if basicDate['errcode'] == 0 and indusrtyDate['errcode'] == 0:
        mergeDate = dict()

    else:
        return {
            'errcode': -1,
            'errmsg': "stockBasic.json或stocIndustryClassified.json获取失败",
        }
Beispiel #2
0
def main():
    global _G_STATUS
    watchData = readFile(jsonFile)
    if watchData["errcode"] ==0:
        data = watchData["data"]
        ##如果当天不在任务时间内,提示改扫描时间
        if isTradeDay(today):
            if today < data["start"]:
                print u"还未到预警时间"
                _G_STATUS = False
                win32api.MessageBox(0, u"还未到预警时间", u"消息提醒", win32con.MB_OK)
            elif today > data["end"]:
                print u"预警时间已结束"
                _G_STATUS = False
                win32api.MessageBox(0, u"预警时间已结束", u"消息提醒", win32con.MB_OK)
            else:
                #TODO 扫描
                for k in data["list"]:
                    getRealTimeQuotes(k)
                #print "在预警期内"
        else:
            _G_STATUS = False
            win32api.MessageBox(0, u"今天休息", u"消息提醒", win32con.MB_OK)
    else:
        win32api.MessageBox(0, u"任务Json文件读取错误", u"消息提醒", win32con.MB_OK)
Beispiel #3
0
#!/usr/bin/python
# coding=UTF-8
##获取指定股票在指定日期内的交易详情

import tushare as ts
import datetime as datetime
import os as os
import config as config
from readJsonFile import readFile
from writeJsonFile import writeFile
from getTradeDay import isTradeDay
import sys

dateStr = datetime.datetime.now().strftime("%Y-%m-%d")
scanFile = config.configRootPath+'\\scanErrorRecord.json'
scanConfigDate = readFile(scanFile)

def getDailyData(stock="", date=""):
    if stock[0] == "2" or stock[0] == "9":
        print "Pass Stock"
        return True
    else:
        if  bool(stock) == False:
            return{'errcode':-1,'errmsg':'need stockCode'}
        else:
            jsonDir = os.path.join(config.dataRootDailyTrade, stock)
            if os.path.isdir(jsonDir):
                pass
            else:
                os.mkdir(jsonDir)
Beispiel #4
0
#!/usr/bin/python
# coding=UTF-8
import datetime as datetime
import os as os
import tushare as ts
import config as config
from readJsonFile import readFile
from getDailyInfo import getDailyData
##获取所有股票在指定日期的日内交易详情

today = datetime.datetime.now().strftime("%Y-%m-%d")
##获取格式化的日期字符串
jsonFile = os.path.join(config.listsRootPath, 'stockBasic.json')
# 遍历数据,创建code对应的文件夹
basicDate = readFile(jsonFile)


def getAllStockList(date=today):

    if basicDate['errcode'] == 0:
        lists = basicDate['data']
        for k in lists:
            if bool(k):
                getDailyData(k, date)
            else:
                print 'error code'
    else:
        #读取文件出错
        print basicDate['errmsg']

Beispiel #5
0
import sys
import os
import time
import tushare as ts
import datetime as datetime
import config as config
from readJsonFile import readFile
from writeJsonFile import writeFile

import urllib
import urllib2
import re
from bs4 import BeautifulSoup

basicFile = os.path.join(config.listsRootPath, 'stockBasic.json')
basicDate = readFile(basicFile)
scanFile = os.path.join(config.configRootPath, 'scanData.json')
scanConfigDate = readFile(scanFile)


# 页面爬虫类
# 处理页面标签类
class Tool:
    # 去除img标签,7位长空格
    removeImg = re.compile('<img.*?>| {7}|')
    # 删除超链接标签
    removeAddr = re.compile('<a.*?>|</a>')
    # 把换行的标签换为\n
    replaceLine = re.compile('<tr>|<div>|</div>|</p>')
    # 将表格制表<td>替换为\t
    replaceTD = re.compile('<td>')
Beispiel #6
0
import sys
import os
import time
import tushare as ts
import datetime as datetime
import config as config
from readJsonFile import readFile
from writeJsonFile import writeFile

import urllib
import urllib2
import re
from bs4 import BeautifulSoup

basicFile = os.path.join(config.listsRootPath, 'stockBasic.json')
basicDate = readFile(basicFile)


# 页面爬虫类
# 处理页面标签类
class Tool:
    # 去除img标签,7位长空格
    removeImg = re.compile('<img.*?>| {7}|')
    # 删除超链接标签
    removeAddr = re.compile('<a.*?>|</a>')
    # 把换行的标签换为\n
    replaceLine = re.compile('<tr>|<div>|</div>|</p>')
    # 将表格制表<td>替换为\t
    replaceTD = re.compile('<td>')
    # 把段落开头换为\n加空两格
    replacePara = re.compile('<p.*?>')
Beispiel #7
0
#!/usr/bin/python
# coding=UTF-8
import datetime as datetime
import os as os
import time as time
import tushare as ts
import config as config
from readJsonFile import readFile
from getDailyInfo import getDailyData
from writeJsonFile import writeFile
##获取单一票在发行期内的全部日交易数据

endDate = datetime.datetime.now().strftime("%Y-%m-%d") #以当天为截止日期
basicFile = os.path.join(config.listsRootPath, 'stockBasic.json')
basicDate = readFile(basicFile)  # timeToMarket 上市日期
scanFile = os.path.join(config.configRootPath, 'scanData.json')
scanConfigDate = readFile(scanFile)

def getSingleStockDate(stock=""):
    if bool(stock):
        ##获取基本数据
        if basicDate['errcode']==0:
            lists = basicDate['data']
            if bool(lists):
                for k in lists:
                    if k ==stock:
                        startBasicDate = str(lists[k]['timeToMarket'])
                        return startBasicDate
                        break
                        #找到code就退出循环
            else: