__author__ = 'Rocky' ''' http://30daydo.com Contact: [email protected] ''' import datetime import os import xlrd import time from xlutils.copy import copy import tushare as ts from setting import get_mysql_conn import codecs from setting import LLogger logger = LLogger('recordMyChoice.log') class Prediction_rate(): def __init__(self): self.today_stock = ts.get_today_all() now = datetime.datetime.now() self.today = now.strftime("%Y-%m-%d") # weekday=now+datetime.timedelta(days=-2) # weekday=weekday.strftime("%Y-%m-%d") # print weekday # today=now.strftime('%Y-%m-%d') self.path = os.path.join(os.getcwd(), 'data') self.filename = os.path.join(self.path, 'recordMyChoice.xls') def stock_pool(self, stock_list):
__author__ = 'Rocky' ''' http://30daydo.com Contact: [email protected] ''' # 每天的涨跌停 import urllib2, re, time, xlrd, xlwt, sys, os import setting import pandas as pd import tushare as ts from setting import LLogger reload(sys) sys.setdefaultencoding('gbk') logger = LLogger('zdt.log') class GetZDT: def __init__(self, current): self.user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/64.0.3282.167 Chrome/64.0.3282.167 Safari/537.36" # self.today = time.strftime("%Y%m%d") self.today = current self.path = os.path.join(os.path.dirname(__file__), 'data') self.zdt_url = 'http://home.flashdata2.jrj.com.cn/limitStatistic/ztForce/' + self.today + ".js" self.zrzt_url = 'http://hqdata.jrj.com.cn/zrztjrbx/limitup.js' self.host = "home.flashdata2.jrj.com.cn" self.reference = "http://stock.jrj.com.cn/tzzs/zdtwdj/zdforce.shtml" self.header_zdt = {
Contact: [email protected] ''' # working v1.0 from bs4 import BeautifulSoup import urllib2 import datetime import time import codecs import random import os, sys # import itchat # import MySQLdb # import setting from setting import sendmail,LLogger from setting import get_mysql_conn logger = LLogger('news.log') def create_tb(conn): cur=conn.cursor() cmd = '''CREATE TABLE IF NOT EXISTS tb_cnstock(Date DATETIME ,Title VARCHAR (80),URL VARCHAR (80),PRIMARY KEY (URL)) charset=utf8;''' try: cur.execute(cmd) conn.commit() # conn.close() return True except Exception as e: logger.log(e) conn.rollback() return False def getinfo(max_index_user=3, days=-2):
# -*-coding=utf-8-*- # 估价达到自己的设定值,发邮件通知, 每天2.45发邮件 import tushare as ts from setting import sendmail, get_engine, trading_time, LLogger import datetime import time import pandas as pd import tushare as ts logger = LLogger('alert.log') # 5秒循环检测一次 LOOP__TIME = 60 EXECEPTION_TIME = 2* LOOP__TIME class ReachTarget(): def __init__(self): self.cb_code, self.name, self.yjl= self.bond() self.stocks = dict(zip(self.cb_code,self.name)) self.stocks_yjl = dict(zip(self.cb_code,self.yjl)) self.api = ts.get_apis() self.code_list = self.stocks.keys() def bond(self): engine = get_engine('db_bond') bond_table = 'tb_bond_jisilu' try: jsl_df = pd.read_sql(bond_table, engine, index_col='index') return list(jsl_df[u'正股代码'].values),list(jsl_df[u'正股名称'].values),list(jsl_df[u'溢价率'].values) except Exception,e: logger.log(e) return None
# -*-coding=utf-8-*- # 估价达到自己的设定值,发邮件通知, 每天2.45发邮件 import tushare as ts from setting import sendmail, get_engine, trading_time, LLogger import datetime import time import pandas as pd import tushare as ts import config logger = LLogger('alert.log') # 5秒循环检测一次 LOOP__TIME = 60 EXECEPTION_TIME = 2 * LOOP__TIME class ReachTarget(): def __init__(self): self.cb_code, self.name, self.yjl = self.bond() self.stocks = dict(zip(self.cb_code, self.name)) self.stocks_yjl = dict(zip(self.cb_code, self.yjl)) self.api = ts.get_apis() self.code_list = self.stocks.keys() def bond(self): engine = get_engine('db_bond') bond_table = 'tb_bond_jisilu' try: jsl_df = pd.read_sql(bond_table, engine, index_col='index')
#-*-coding=utf-8-*- # 每天收盘收运行 import datetime __author__ = 'Rocky' import tushare as ts import os from setting import get_engine,LLogger import pandas as pd logger=LLogger('collect_data.log') class SaveData(): today = datetime.datetime.now().strftime("%Y-%m-%d") daily_engine = get_engine('daily') def __init__(self): current=os.getcwd() work_space=os.path.join(current,'data') if os.path.exists(work_space) ==False: os.mkdir(work_space) os.chdir(work_space) @staticmethod def daily_market(): df = ts.get_today_all() try: df.to_sql(SaveData.today,SaveData.daily_engine,if_exists='replace') except Exception,e: print e print "Save {} data to MySQL".format(SaveData.today)
Contact: [email protected] ''' # working v1.0 from bs4 import BeautifulSoup import urllib2 import datetime import time import codecs import random import os, sys # import itchat # import MySQLdb # import setting from setting import sendmail, LLogger from setting import get_mysql_conn logger = LLogger('news.log') def create_tb(conn): cur = conn.cursor() cmd = '''CREATE TABLE IF NOT EXISTS tb_cnstock(Date DATETIME ,Title VARCHAR (80),URL VARCHAR (80),PRIMARY KEY (URL)) charset=utf8;''' try: cur.execute(cmd) conn.commit() # conn.close() return True except Exception, e: logger.log(e) conn.rollback() return False