Example #1
0
def main():
    filename = os.path.join(DATA_PATH, 'blacklist.csv')
    # 本地更新
    db_name = 'db_stock'
    DB = DBSelector()
    conn = DB.get_mysql_conn(db_name, 'qq')
    create_tb(conn)
    update_data(filename,conn)

    # 远程更新
    # db_name = 'db_stock'
    remote_conn = DB.get_mysql_conn('qdm225205669_db', 'qq')
    create_tb(remote_conn)
    update_data(filename,remote_conn)
Example #2
0
MAX_PAGE = 114

headers = {
    'Connection': 'keep-alive',
    'Pragma': 'no-cache',
    'Cache-Control': 'no-cache',
    'User-Agent':
    'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36',
    'Accept': '*/*',
    # 'Referer': 'http://stockapp.finance.qq.com/mstats/?id=fund_close',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'zh,en;q=0.9,en-US;q=0.8',
}

DB = DBSelector()
conn = DB.get_mysql_conn('db_fund', 'qq')
cursor = conn.cursor()
base_dir = os.path.dirname(os.path.abspath(__file__))
log_path = os.path.join(base_dir, '..', 'log')
logger = llogger(os.path.join(log_path, 'fund_info.log'))


class FundSpider(object):
    def __init__(self):
        self.create_tb()

    def create_tb(self):
        create_table = 'create table if not EXISTS `{}` (`基金代码` varchar(20) PRIMARY KEY,`基金简称` varchar(100),`最新规模-万` float,' \
                       '`实时价格` float,`涨跌幅` float,`成交额-万` float,`净值日期` VARCHAR(10),`单位净值` float,`累计净值` float,`折溢价率` float ,`申购状态` VARCHAR(20),`申赎状态` varchar(20),`基金经理` VARCHAR(200),' \
                       '`成立日期` VARCHAR(20), `管理人名称` VARCHAR(200),`实时估值` INT,`QDII` INT ,`更新时间` VARCHAR(20));'.format(
            today)
Example #3
0
# @Time : 2020/1/14 0:05
# @File : fd_money.py
# 涨停封单数据

from settings import DBSelector
import datetime
import matplotlib.pyplot as plt
DB = DBSelector()
conn = DB.get_mysql_conn('db_zdt', 'qq')
cursor = conn.cursor()
diff_day = 20
dataset = []
date = []

for d in range(diff_day):
    day = datetime.datetime.now() + datetime.timedelta(days=-1 * d)
    # if ts.is_holiday(day.strftime('%Y-%m-%d')):
    #     continue

    sql = 'select 封单金额 as total_money from `{}zdt`'.format(
        day.strftime('%Y%m%d'))

    # sql = '''select sum(封单金额) as total_money from `20200113zdt`'''
    # print(sql)

    try:
        cursor.execute(sql)
        ret = cursor.fetchone()
        # print(ret[0])
        dataset.append(int(ret[0] / 10000))
        date.append(day.strftime('%Y%m%d'))
Example #4
0
__author__ = 'Rocky'
'''
http://30daydo.com
Contact: [email protected]
'''
# 交割单处理 保存交割单到数据库
import os
import datetime
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from settings import DBSelector
import fire
DB = DBSelector()
engine = DB.get_engine('db_stock', 'qq')
conn = DB.get_mysql_conn('db_stock', 'qq')
pd.set_option('display.max_rows', None)


class DeliveryOrder():
    def __init__(self):
        self.gj_table = 'tb_delivery_gj_django'
        self.hb_table = 'tb_delivery_hb_django'

    def setpath(self, path):
        path = os.path.join(os.getcwd(), path)
        if os.path.exists(path) == False:
            os.mkdir(path)
        os.chdir(path)

    # 单独处理华宝证券的数据
Example #5
0
# 收集可转债的市场全景图
from settings import DBSelector,send_from_aliyun,llogger
import pandas as pd
import datetime
from config import token
import tushare as ts
today = datetime.datetime.now().strftime('%Y-%m-%d')
today_fmt = datetime.datetime.now().strftime('%Y%m%d')
# today='2020-02-06'
# today_fmt='20200206'
cons=ts.get_apis()
logger=llogger('log/bond_daily.log')
# ts.set_token(token)
DB = DBSelector()
# pro = ts.pro_api()
conn=DB.get_mysql_conn('db_bond_daily','qq')

def creat_table(day):
    '''
    建表
    :param day:
    :return:
    '''
    tb_name = 'bond_{}'.format(day)
    create_cmd = 'create table if not exists `{tb_name}` (`date` varchar(20),`code` varchar(10) primary key,`name` varchar(16),`open` float ,' \
                 '`close` float,`high` float,`low` float,`vol` float,`amount` float) '.format(tb_name=tb_name)
    cursor = conn.cursor()
    try:
        cursor.execute(create_cmd)
        conn.commit()
    except Exception as e:
Example #6
0
import time
import tushare as ts
import pandas as pd
import os, datetime, math
import numpy as np
import logging
from settings import DBSelector, MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, REDIS_HOST
import redis
from threading import Thread
from BaseService import BaseService

DB = DBSelector()
engine = DB.get_engine('history', 'qq')
conn = ts.get_apis()
MYSQL_DB = 'history'
cursor = DB.get_mysql_conn(MYSQL_DB, 'qq').cursor()

# pd.set_option('display.max_rows', None)


class Kline(BaseService):
    def __init__(self):
        super(Kline, self).__init__('log/kline.log')

        path = os.path.join(os.getcwd(), 'data')
        self.today_date = datetime.datetime.now().strftime('%Y-%m-%d')

        if not os.path.exists(path):
            os.mkdir(path)
        os.chdir(path)