Esempio n. 1
0
import os
from jt.utils.calendar.api_calendar import TradeCalendarDB
from jt.utils.fs.utils import Utils as fsutils
from jt.utils.misc.log import Logger

calendardb = TradeCalendarDB()
TODAY = calendardb.get_trading_date()  # get T0
_logger = Logger(module_name_=__name__)


def decompress_7Z(filePath_, save_dir_=None):
    """
    decompress 7z files
    input: filepath_ : full path of 7z files
    _7z_path_ : .exe of 7z
    save_dir_ : save path
    """
    _dir, _name = fsutils.extract_file_dir_and_name(filePath_)
    save_dir_ = _dir if save_dir_ is None else save_dir_
    # os.system(f'decompress.bat {_root} {_7z_path_} {_dir} {_name} {save_dir_}')
    os.system(f'7z x {filePath_} -o{save_dir_}')


def save_result(df_, db, table_name, keys_):
    _logger.info(f'Save result to DB {table_name}')
    db.upsert(table_name, df_=df_, keys_=keys_)


def attach_security_type(df_):
    df_copy = df_.copy(deep=True)
    df_copy['security_type'] = df_copy['symbol'].apply(get_security_type)
Esempio n. 2
0
import os

from jt.invest.constants import w_db, futils
from jt.utils.misc.log import Logger

from seo.constants import root

log = Logger()

def check_project(start_dt='20200401'):
    # 检查已完成项目是否已经归档
    all_project = futils.get_current_folder_dirs(os.path.join(root, '00 项目资料'))

    sql = f"""
        select b.S_INFO_NAME+'_'+left(a.S_INFO_WINDCODE,6) as symbol
        from ASHARESEO a, ASHAREDESCRIPTION b
        where a.S_FELLOW_PROGRESS='3'
        and a.S_FELLOW_DATE>='{start_dt}'
        and a.IS_NO_PUBLIC=1 
        and a.PRICINGMODE='275001000'
        and a.S_FELLOW_ISSUETYPE = '439006000'
        and a.S_INFO_WINDCODE = b.S_INFO_WINDCODE
        order by a.S_FELLOW_DATE desc;
    """
    df = w_db.read(sql)

    for _p in all_project:        
        if _p in df.symbol.values:
            f = os.path.join(root, '00 项目资料')
            t = os.path.join(root, '00 项目资料', '00 归档')
            log.info(f'Archive dir {_p}')
Esempio n. 3
0
from ps.calculation import daily_statistics
from ps.init_data import download_daily_data
from jt.utils.calendar import TradeCalendarDB
from jt.utils.misc.log import Logger

_logger = Logger(module_name_=__name__)

if __name__ == "__main__":
    calendar = TradeCalendarDB()
    date_list = calendar.get_trading_calendar(from_='20190829', to_='20190903')
    for d in date_list:
        _logger.info(f'Deal date {d}')
        download_daily_data(date_=d, is_overwrite_=False)
        daily_statistics(d)
Esempio n. 4
0
# @author Neo Lin
# @description SEO risk report
# @created 2020-05-26T14:19:21.122Z+08:00
# @last-modified 2021-03-23T13:33:27.921Z+08:00
#
import os
import docx

from datetime import datetime
from jt.invest.constants import w_db
from jt.utils.fs.utils import Utils as futils
from jt.utils.misc.log import Logger

from seo.constants import root, product_map

log = Logger(__name__)


def make_intent_letter(broker, project):
    """
    make yi xiang letter
    """
    _year = str(datetime.now().year)
    _month = str(datetime.now().month)
    _day = str(datetime.now().day)

    sql = f"""
        select S_INFO_CODE as code, s_info_name as name
        from [dbo].[ASHAREDESCRIPTION] where S_INFO_NAME in ('{"','".join(project)}')
    """
    ret = w_db.read(sql)