def __init__(self, account, passwd, sh_id, sz_id): self.secuids = {ct.MARKET_SH: sh_id, ct.MARKET_SZ: sz_id} self.log = getLogger(__name__) self.passwd = passwd self.account = account self.cookie = None self.headers = { 'Cache-Control': r'max-age=0', 'Upgrade-Insecure-Requests': r'1', 'Origin': r'https://trade.cgws.com', 'Cookie': r'_trs_uv=jsvhvv2t_788_fpgf;', 'Accept-Encoding': r'gzip, deflate, br', 'Content-Type': r'application/x-www-form-urlencoded', 'Referer': r'https://trade.cgws.com/cgi-bin/user/Login', 'Accept-Language': r'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7', 'Accept': r'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'User-Agent': r'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36' } self.client = Client() self.session_client = SessionClient(self.headers)
def __init__(self, dbinfo=ct.DB_INFO, redis_host=None): self.table = ct.COMBINATION_INFO_TABLE self.logger = getLogger(__name__) self.redis = create_redis_obj( ) if redis_host is None else create_redis_obj(host=redis_host) self.mysql_client = cmysql.CMySQL(dbinfo, iredis=self.redis) if not self.init(): raise Exception("init combination table failed")
def __init__(self, market=ct.SH_MARKET_SYMBOL, dbinfo=ct.DB_INFO, redis_host=None): self.market = market self.dbinfo = dbinfo self.balcklist = ['2006-07-10' ] if market == ct.SH_MARKET_SYMBOL else list() self.logger = getLogger(__name__) self.dbname = self.get_dbname(market) self.redis = create_redis_obj( ) if redis_host is None else create_redis_obj(host=redis_host) self.header = { "Host": "query.sse.com.cn", "Referer": "http://www.sse.com.cn/market/stockdata/overview/day/", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" } self.mysql_client = CMySQL(self.dbinfo, dbname=self.dbname, iredis=self.redis) if not self.mysql_client.create_db(self.dbname): raise Exception("create %s failed" % self.dbname)
def __init__(self, dbinfo = ct.DB_INFO, redis_host = None): self.redis = create_redis_obj() if redis_host is None else create_redis_obj(host = redis_host) self.dbname = self.get_dbname() self.redis_host = redis_host self.logger = getLogger(__name__) self.mysql_client = CMySQL(dbinfo, self.dbname, iredis = self.redis) if not self.mysql_client.create_db(self.get_dbname()): raise Exception("init rstock database failed")
def __init__(self, dbinfo=ct.DB_INFO, redis_host=None): self.dbinfo = dbinfo self.logger = getLogger(__name__) self.index_objs = dict() self.stock_objs = dict() self.updating_date = None self.combination_objs = dict() self.cal_client = CCalendar(dbinfo, redis_host) self.index_info_client = IndexInfo() self.cvaluation_client = CValuation() self.reviewer = CReivew(dbinfo, redis_host) self.comb_info_client = CombinationInfo(dbinfo, redis_host) self.stock_info_client = CStockInfo(dbinfo, redis_host) self.rindex_stock_data_client = RIndexStock(dbinfo, redis_host) self.industry_info_client = IndustryInfo(dbinfo, redis_host) self.rindustry_info_client = RIndexIndustryInfo(dbinfo, redis_host) self.animation_client = CAnimation(dbinfo, redis_host) self.subscriber = Subscriber() self.quote_handler = StockQuoteHandler() self.ticker_handler = TickerHandler() self.connect_client = StockConnect(market_from=ct.SH_MARKET_SYMBOL, market_to=ct.HK_MARKET_SYMBOL, dbinfo=dbinfo, redis_host=redis_host) self.margin_client = Margin(dbinfo=dbinfo, redis_host=redis_host) self.emotion_client = Emotion(dbinfo=dbinfo, redis_host=redis_host) self.sh_exchange_client = StockExchange(ct.SH_MARKET_SYMBOL) self.sz_exchange_client = StockExchange(ct.SZ_MARKET_SYMBOL)
def __init__(self, dbinfo=ct.DB_INFO, redis_host=None): self.dbinfo = dbinfo self.emotion_table = ct.EMOTION_TABLE self.redis = create_redis_obj( ) if redis_host is None else create_redis_obj(redis_host) self.mysql_client = CMySQL(self.dbinfo, iredis=self.redis) self.rstock_client = RIndexStock(dbinfo, redis_host) self.logger = getLogger(__name__) if not self.create(): raise Exception("create emotion table failed")
def __init__(self, dbinfo = ct.DB_INFO, redis_host = None): self.table = self.get_table_name() self.logger = getLogger(__name__) self.redis = create_redis_obj() if redis_host is None else create_redis_obj(redis_host) self.mysql_client = CMySQL(dbinfo, iredis = self.redis) self.header = {"Host": "home.flashdata2.jrj.com.cn", "Referer": "http://stock.jrj.com.cn/tzzs/zdtwdj/zdforce.shtml", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"} if not self.create(): raise Exception("create stock %s failed" % self.table)
def __init__(self): self.cookie_value = "" self.log = getLogger(__name__) self.context = ssl._create_unverified_context() self.cookie = cookiejar.MozillaCookieJar() self.ssl_handler = request.HTTPSHandler(context = self.context) self.cookie_handler = request.HTTPCookieProcessor(self.cookie) self.handlers = [self.ssl_handler, self.cookie_handler] self.opener = request.build_opener(*self.handlers)
def __init__(self, index_code, dbinfo = ct.DB_INFO, redis_host = None): self.dbinfo = dbinfo self.index_code = index_code self.index_obj = CIndex(index_code, dbinfo = self.dbinfo, redis_host = redis_host) self.db_name = self.index_obj.get_dbname(index_code) self.logger = getLogger(__name__) self.ris = RIndexStock(dbinfo, redis_host) self.bull_stock_ratio_table = self.get_table_name() self.redis = create_redis_obj() if redis_host is None else create_redis_obj(redis_host) self.mysql_client = CMySQL(self.dbinfo, dbname = self.db_name, iredis = self.redis) if not self.create(): raise Exception("create emotion table failed")
def __init__(self, dbinfo, fpath=ct.USER_FILE): self.logger = getLogger(__name__) self.mysql_client = CMySQL(dbinfo) self.cal_client = ccalendar.CCalendar(without_init=True) self.traders = list() with open(fpath) as f: infos = json.load(f) for info in infos: self.traders.append( Trader(info["account"], info["passwd_encrypted"], info["secuids_sh"], info["secuids_sz"])) self.buy_succeed_date = ""
def __init__(self, dbinfo = ct.DB_INFO, redis_host = None): self.dbinfo = dbinfo self.logger = getLogger(__name__) self.tu_client = get_tushare_client() self.doc = CDoc() self.redis = create_redis_obj() if redis_host is None else create_redis_obj(redis_host) self.mysql_client = CMySQL(dbinfo, iredis = self.redis) self.margin_client = Margin(dbinfo = dbinfo, redis_host = redis_host) self.rstock_client = RIndexStock(dbinfo = dbinfo, redis_host = redis_host) self.sh_market_client = StockExchange(ct.SH_MARKET_SYMBOL) self.sz_market_client = StockExchange(ct.SZ_MARKET_SYMBOL) self.emotion_client = Emotion() self.bullration_client = CBullRation(dbinfo, redis_host)
def __init__(self, market_from=ct.SH_MARKET_SYMBOL, market_to=ct.HK_MARKET_SYMBOL, dbinfo=ct.DB_INFO, redis_host=None): self.market_from = market_from self.market_to = market_to self.balcklist = None self.crawler = None self.mysql_client = None self.dbinfo = dbinfo self.logger = getLogger(__name__) self.redis = create_redis_obj( ) if redis_host is None else create_redis_obj(host=redis_host)
def __init__(self, dbinfo = ct.DB_INFO, redis_host = None): self.dbinfo = dbinfo self.hgt_client = HGT() self.rzrq_client = RZRQ(dbinfo) self.logger = getLogger(__name__)
#coding=utf-8 import os import time import json import cmysql import _pickle import datetime import pandas as pd import const as ct import tushare as ts from cstock import CStock from datetime import datetime from base.clog import getLogger from industry_info import IndustryInfo from common import create_redis_obj, concurrent_run, smart_get logger = getLogger(__name__) class CStockInfo(object): def __init__(self, dbinfo=ct.DB_INFO, redis_host=None, stocks_dir='/data/tdx/history/days', stock_path='/data/tdx/base/stocks.csv'): self.table = ct.STOCK_INFO_TABLE self.redis = create_redis_obj( ) if redis_host is None else create_redis_obj(host=redis_host) self.mysql_client = cmysql.CMySQL(dbinfo, iredis=self.redis) self.mysql_dbs = self.mysql_client.get_all_databases() self.stocks_dir = stocks_dir self.stock_path = stock_path
def __init__(self, report_path = "/data/tdx/report", publish_date_path = "/data/crawler/stock/financial/report_announcement_date"): self.publish_data = dict() self.report_path = report_path self.logger = getLogger(__name__) self.publish_date_path = publish_date_path
def __init__(self, type_): self.link = self.LINK_PATH % type_ self.type = type_ self.logger = getLogger(__name__) self.crawer = MSelenium(self.link, self.logger)
def __init__(self, headers): self.headers = headers self.cookies = None self.connect_timeout = 10 self.log = getLogger(__name__) self.session = requests.Session()
def __init__(self): self.ris = RIndexStock() self.logger = getLogger(__name__)
def __init__(self): self.logger = getLogger(__name__) self.cal_client = CCalendar( dbinfo=ct.OUT_DB_INFO, redis_host='127.0.0.1', filepath='/Volumes/data/quant/stock/conf/calAll.csv')
def __init__(self): self.logger = getLogger(__name__) self.cval_client = CValuation() self.stock_info_client = CStockInfo()