Beispiel #1
0
 def __init__(self, header):
     self.Today = datetime.date.today().strftime(TIME_FMT)
     self.today = datetime.date.today().strftime('%Y%m%d')
     if not header:
         raise Exception
     self.mysql = mysqlBase(header)
     self.stock_list = []
     self.coder = StockCodeFormat()
Beispiel #2
0
 def holiday_from_stock(self, date_series):
     from polaris.mysql8 import mysqlBase
     from dev_global.env import GLOBAL_HEADER
     mysql = mysqlBase(GLOBAL_HEADER)
     result = mysql.select_values('SH000001', 'trade_date')
     trade_date = list(result[0])
     for dt in trade_date:
         date_series.remove(dt)
     return date_series
def db_init():
    from dev_global.env import GLOBAL_HEADER
    from mars.utils import ERROR
    from polaris.mysql8 import create_table, mysqlBase, mysqlHeader
    from venus.form import formTemplate, formFinanceTemplate, formInfomation
    try:
        root_header = mysqlHeader('root', '6414939', 'stock')
        mysql = mysqlBase(root_header)
        create_table(formFinanceTemplate, mysql.engine)
    except Exception as e:
        print(e)
 def __init__(self,
              header: mysqlHeader,
              name='127.0.0.1',
              port=0,
              forbid_port_table_file=None) -> None:
     self.socket = socket.socket()
     if name is None:
         name = socket.gethostname()
     forbid_port = [0, 21, 22, 23, 80, 8080]
     if port in forbid_port:
         port = 12001
     self.socket.bind((name, port))
     self.task_list = ['test', 'event_mysql_backup', 'system_update']
     self.mysql = mysqlBase(header)
def unit_test_task_module_reload():
    from dev_global.env import TASK_FILE, GLOBAL_HEADER
    from polaris.mysql8 import mysqlBase
    from apscheduler.executors.pool import ThreadPoolExecutor
    from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
    from sqlalchemy.ext.declarative import declarative_base

    Base = declarative_base()
    mysql = mysqlBase(GLOBAL_HEADER)
    jobstores = {
        'default': SQLAlchemyJobStore(engine=mysql.engine,
                                      metadata=Base.metadata)
    }
    executor = {'default': ThreadPoolExecutor(20)}
    default_job = {'max_instance': 5}
    tf = '/home/friederich/Documents/dev/applications/neutrino/config/task.json'
    Neptune = taskManager(taskfile=tf,
                          jobstores=jobstores,
                          executors=executor,
                          job_defaults=default_job)
    Neptune.start()
    Neptune.reload_event()
 def _set_param(self):
     self.path = 'root'
     self.index = mysqlBase(GLOBAL_HEADER)
     self.url = 'http://www.cninfo.com.cn/new/hisAnnouncement/query'
     self.http_header = {
         "Accept": 'application/json, text/javascript, */*; q=0.01',
         "Accept-Encoding": 'gzip, deflate',
         "Accept-Language": 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7',
         "Connection": 'keep-alive',
         "Content-Length": '157',
         "Content-Type": 'application/x-www-form-urlencoded; charset=UTF-8',
         "Cookie":
         'JSESSIONID=BFBF1E4A2BB770FDC299840EBF23A51D; _sp_ses.2141=*; cninfo_user_browse=000603,gssz0000603,%E7%9B%9B%E8%BE%BE%E8%B5%84%E6%BA%90|603019,9900023134,%E4%B8%AD%E7%A7%91%E6%9B%99%E5%85%89|000521,gssz0000521,%E9%95%BF%E8%99%B9%E7%BE%8E%E8%8F%B1; UC-JSESSIONID=800AC4F4588B800E4B0C0469250DF5C8; _sp_id.2141=12284594-c734-478d-82ca-0a1ccbb7de3f.1585407313.7.1585576172.1585500168.83476562-29c9-4d02-9a3a-ee515406e161',
         "Host": 'www.cninfo.com.cn',
         "Origin": 'http://www.cninfo.com.cn',
         "Referer":
         'http://www.cninfo.com.cn/new/disclosure/stock?plate=szse&stockCode=000603&orgId=gssz0000603',
         "User-Agent":
         'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36',
         "X-Requested-With": 'XMLHttpRequest',
     }
     self.form_data = 'stock=603019%2C9900023134&tabName=fulltext&pageSize=30&pageNum=1&column=sse&category=&plate=sh&seDate=&searchkey=&secid=&sortName=&sortType=&isHLtitle=true'
Beispiel #7
0
def task_pipeline(taskfile=None, task_pipeline_name='Default'):
    # init task manager and main
    if not taskfile:
        raise FileNotFoundError(taskfile)
    mysql = mysqlBase(GLOBAL_HEADER)
    jobstores = {
        'default':
        SQLAlchemyJobStore(tablename=f"{task_pipeline_name}_task_sched",
                           engine=mysql.engine)
    }
    task_manager = taskManager2(taskfile=taskfile,
                                task_manager=task_pipeline_name,
                                jobstores=jobstores,
                                executors={'default': ThreadPoolExecutor(20)},
                                job_defaults={'max_instance': 5})
    task_manager.start()
    info_log(f"{PROG_NAME} started with pid {os.getpid()}.")
    while True:
        task_manager.task_report()
        task_manager.task_solver.load_event()
        task_list = task_manager.check_task_list()
        task_manager.task_manage(task_list)
        time.sleep(300)
Beispiel #8
0
 def __init__(self, header):
     self.mysql = mysqlBase(header)
Beispiel #9
0
            query_column = 'trade_date,open_price,close_price,highest_price,lowest_price'
            def_column = ['trade_date','open','close','high','low']
        result = self.mysql.select_values(stock_code, query_column)
        result.columns = def_column
        result['trade_date'] = pandas.to_datetime(result['trade_date'])
        result.set_index('trade_date', inplace=True)
        return result

    def get_benchmark(self, stock_code:str):
        return self.get_data(stock_code, query_type='close')

class RiskBase(object):
    def __init__(self):
        pass

    def set_threshold(self, threshold):
        raise NotImplementedError

if __name__ == "__main__":
    
    from polaris.mysql8 import mysqlBase
    from dev_global.env import GLOBAL_HEADER

    mysql = mysqlBase(GLOBAL_HEADER)
    event = StockDataSet()
    event.data = mysql.select_values('SH000300', 'trade_date,open_price,close_price,highest_price,lowest_price')
    event.set_stock_data(event.data)
    event.set_time_period(datetime.date(2019,1,1), datetime.date(2020,1,1))
    event.detect_cross()
    event.profit()
    
Beispiel #10
0
def event_initial_database():
    mysql = mysqlBase(GLOBAL_HEADER)
    create_table(formTemplate, mysql.engine)
    create_table(formFinanceTemplate, mysql.engine)
    create_table(formInfomation, mysql.engine)
 def __init__(self, header, path):
     self.mysql = mysqlBase(header)
     self.url_list = []
     self.href = []
     self.article_set = []
     self.path = path + 'config/'
Beispiel #12
0
 def __init__(self):
     self.mysql = mysqlBase(VIEWER_HEADER)