コード例 #1
0
def test3():
    email_utils = EmailUtils(EmailUtils.group4)
    date_str = '2017-08-09'
    out_put_list = []
    for server_name in ('huabao', 'guoxin'):
        out_put_list.extend(daily_return_calculation4(server_name, date_str))

    title = 'server_name,fund_name,strategy_group_name,stock_value_total,hedge_value_total,net_value,CSI300_value,ZZ500_value,Other_value,CSI300_weight,ZZ500_weight,Other_weight,IF,IC,CSI300_IF,ZZ500_IC,Other_IC,IF_diff,IC_idff'
    out_put_list.insert(0, title)

    save_file_path = 'E:/report.csv'
    with open(save_file_path, 'w') as fr:
        fr.write('\n'.join(out_put_list))
    email_utils.send_email_path('股票仓位分指数构成报告_%s' % date_str, '', save_file_path, 'html')
コード例 #2
0
# -*- coding: utf-8 -*-
import pandas as pd
from eod_aps.model.eod_const import const
from eod_aps.model.schema_common import Instrument, FutureMainContract
from eod_aps.tools.date_utils import DateUtils
from eod_aps.model.server_constans import server_constant
from eod_aps.tools.email_utils import EmailUtils
from eod_aps.tools.stock_utils import StockUtils
from eod_aps.tools.ysquant_manager_tools import get_basic_info_data

date_utils = DateUtils()
stock_utils = StockUtils()
email_utils2 = EmailUtils(const.EMAIL_DICT['group2'])


class InstrumentCheckTools(object):
    """
        Instrument檢查工具类
    """
    def __init__(self, check_server='host'):
        self.__trading_future_list = self.__query_future_main_contract()

        server_model = server_constant.get_server_model(check_server)
        session_common = server_model.get_db_session('common')
        self.__instrument_df = self.__query_instrument_df(session_common)
        self.__error_ticker_dict = dict()

    def check_index(self):
        self.__check_pre_close()
        self.__check_track_undl_tickers()
        # self.__check_option()
コード例 #3
0
ファイル: pl_cal_sql_info.py プロジェクト: dsjmhjs/python_eod
                    'tq.absolute_return.max_long_position', 'tq.absolute_return.max_short_position',
                    'tq.absolute_return.qty_per_trade', 'tq.steady_return.max_long_position',
                    'tq.steady_return.max_short_position', 'tq.steady_return.qty_per_trade']

strategy_fileter_list = ['PairTrading.j_jm', 'PairTrading.j_jm_para2', 'PairTrading.j_jm_para3',
                         'PairTrading.j_jm_para4', 'PairTrading.m_rm_para1', 'PairTrading.m_rm_para2',
                         'PairTrading.m_rm_para3', 'PairTrading.m_rm_para4']

trade_start_date_dict = dict()
trade_start_date_dict['nanhua_web'] = '2016-10-01'
trade_start_date_dict['guoxin'] = '2017-02-14'
trade_start_date_dict['zhongxin'] = '2017-02-15'
trade_start_date_dict['luzheng'] = '2017-09-05'
trade_start_date_dict['guangfa'] = '2018-02-01'

email_utils = EmailUtils(EmailUtils.group14)


def clear_folder(folder):
    if os.path.exists(folder):
        for root, dirs, files in os.walk(folder):
            for file_name in files:
                os.remove(folder + file_name)
            for file_name in dirs:
                shutil.rmtree(folder + file_name)
    else:
        os.makedirs(folder)


def get_holiday_list():
    task_logger.info('getting holiday list...')
コード例 #4
0
# -*- coding: utf-8 -*-
# md5校验
import os
import hashlib
from eod_aps.model.server_constans import server_constant
from eod_aps.model.eod_const import const
from eod_aps.tools.date_utils import DateUtils
from eod_aps.tools.email_utils import EmailUtils
from cfg import custom_log

date_utils = DateUtils()
email_utils = EmailUtils(const.EMAIL_DICT['group6'])
interval_time = 60


def __read_chunks(fh):
    fh.seek(0)
    chunk = fh.read(8096)
    while chunk:
        yield chunk
        chunk = fh.read(8096)
    else:
        fh.seek(0)  # 最后要将游标放回文件开头


# 获取文件大小
def get_file_size(local_file_path):
    if os.path.exists(local_file_path):
        size = os.path.getsize(local_file_path)
        size = '%.2f' % (size / float(1024 * 1024 * 1024))
    else:
コード例 #5
0
def __strategy_parameter_check(server_name_list):
    session = server_host.get_db_session('common')
    query = session.query(Instrument)
    future_dict = dict()
    for instrument_db in query.filter(Instrument.type_id == 1):
        future_dict[instrument_db.ticker] = instrument_db

    maincontract_dict = dict()
    query = session.query(FutureMainContract)
    for future_maincontract_db in query:
        maincontract_dict[
            future_maincontract_db.ticker_type] = future_maincontract_db

    for server_name in server_name_list:
        email_list.append('<font>Strategy Parameter Check: %s</font><br/>' %
                          server_name)
        server_model = ServerConstant().get_server_model(server_name)
        server_session = server_model.get_db_session('strategy')

        strategy_check_result = []
        for strategy_name_group in server_session.query(
                StrategyParameter.name).group_by(StrategyParameter.name).all():
            strategy_name = strategy_name_group[0]
            if 'Calendar' not in strategy_name:
                continue
            strategy_parameter_db = server_session.query(
                StrategyParameter).filter(
                    StrategyParameter.name == strategy_name).order_by(
                        desc(StrategyParameter.time)).first()
            strategy_parameter_dict = json.loads(strategy_parameter_db.value)

            calendar_future_dict = dict()
            for (dict_key, dict_value) in strategy_parameter_dict.items():
                if 'BackFuture' in dict_key:
                    back_future_name = dict_value
                    if back_future_name not in future_dict:
                        email_list.append(
                            '<font color=red>strategy:%s BackFuture:%s can not find!</font><br/>'
                            % (strategy_name, back_future_name))
                    else:
                        back_future_db = future_dict[back_future_name]
                        if back_future_db.exchange_id != 25 and (
                                datetime.strptime(
                                    str(back_future_db.expire_date),
                                    '%Y-%m-%d') - datetime.now()).days <= 33:
                            strategy_check_result.append('<font color=red>strategy:%s BackFuture:%s expire_date:%s less than 30days!</font><br/>' % \
                                          (strategy_name, back_future_name,
                                           back_future_db.expire_date.strftime("%Y-%m-%d")))

                    ticker_type = filter(lambda x: not x.isdigit(),
                                         back_future_name)
                    if ticker_type in calendar_future_dict:
                        calendar_future_dict[ticker_type].append(
                            back_future_name)
                    else:
                        calendar_future_dict[ticker_type] = [
                            back_future_name,
                        ]

                    ticker_month = filter(lambda x: x.isdigit(),
                                          back_future_name)
                    future_maincontract_db = maincontract_dict[ticker_type]
                    main_symbol_month = filter(
                        lambda x: x.isdigit(),
                        future_maincontract_db.main_symbol)
                    if str(ticker_month) < str(main_symbol_month):
                        strategy_check_result.append(
                            '<font color=red>strategy:%s BackFuture:%s, Main Contract is:%s</font><br/>'
                            % (strategy_name, back_future_name,
                               future_maincontract_db.main_symbol))
                elif 'FrontFuture' in dict_key:
                    front_future_name = dict_value
                    if front_future_name not in future_dict:
                        email_list.append(
                            '<font color=red>strategy:%s FrontFuture:%s can not find!</font><br/>'
                            % (strategy_name, front_future_name))
                    else:
                        front_future_db = future_dict[front_future_name]
                        if front_future_db.exchange_id != 25 and (
                                datetime.strptime(
                                    str(front_future_db.expire_date),
                                    '%Y-%m-%d') - datetime.now()).days <= 30:
                            strategy_check_result.append('<font color=red>strategy:%s FrontFuture:%s expire_date:%s less than 30days!</font><br/>' % \
                                          (strategy_name, front_future_name,
                                           front_future_db.expire_date.strftime("%Y-%m-%d")))

                    ticker_type = filter(lambda x: not x.isdigit(),
                                         front_future_name)
                    if ticker_type in calendar_future_dict:
                        calendar_future_dict[ticker_type].append(
                            front_future_name)
                    else:
                        calendar_future_dict[ticker_type] = [
                            front_future_name,
                        ]

                    ticker_month = filter(lambda x: x.isdigit(),
                                          front_future_name)
                    future_maincontract_db = maincontract_dict[ticker_type]
                    main_symbol_month = filter(
                        lambda x: x.isdigit(),
                        future_maincontract_db.main_symbol)
                    if str(ticker_month) < str(main_symbol_month):
                        strategy_check_result.append(
                            '<font color=red>strategy:%s FrontFuture:%s, Main Contract is:%s</font><br/>'
                            % (strategy_name, front_future_name,
                               future_maincontract_db.main_symbol))

            for (key, ticker_list) in calendar_future_dict.items():
                if len(ticker_list) != 2:
                    continue
                if ticker_list[0] == ticker_list[1]:
                    strategy_check_result.append(
                        '<font color=red>Ticker:%s FrontFuture and BackFuture is same!</font><br/>'
                        % ticker_list[0])

        if len(strategy_check_result) > 0:
            strategy_check_result.insert(
                0,
                '<li>server:%s, Check Strategy Parameter</li>' % server_name)
            email_list.extend(strategy_check_result)
            EmailUtils(EmailUtils.group4).send_email_group_all(
                '[Error]Strategy Parameter Check',
                '\n'.join(strategy_check_result), 'html')
        server_model.close()
コード例 #6
0
ファイル: __init__.py プロジェクト: dsjmhjs/python_eod
#!/usr/bin/env python
# _*_ coding:utf-8 _*_

from eod_aps.model.eod_const import const
from eod_aps.tools.email_utils import EmailUtils

email_utils2 = EmailUtils(const.EMAIL_DICT['group2'])
email_utils3 = EmailUtils(const.EMAIL_DICT['group3'])
email_utils4 = EmailUtils(const.EMAIL_DICT['group4'])
email_utils5 = EmailUtils(const.EMAIL_DICT['group5'])
email_utils6 = EmailUtils(const.EMAIL_DICT['group6'])
email_utils7 = EmailUtils(const.EMAIL_DICT['group7'])
email_utils8 = EmailUtils(const.EMAIL_DICT['group8'])
email_utils10 = EmailUtils(const.EMAIL_DICT['group10'])
email_utils11 = EmailUtils(const.EMAIL_DICT['group11'])
email_utils12 = EmailUtils(const.EMAIL_DICT['group12'])
email_utils13 = EmailUtils(const.EMAIL_DICT['group13'])
email_utils15 = EmailUtils(const.EMAIL_DICT['group15'])
email_utils16 = EmailUtils(const.EMAIL_DICT['group16'])
コード例 #7
0
# -*- coding: utf-8 -*-
import json
import csv
from eod_aps.model.server_constans import server_constant
from eod_aps.model.schema_strategy import StrategyOnline
from eod_aps.tools.email_utils import EmailUtils
from eod_aps.model.eod_const import const

email_utils = EmailUtils(const.EMAIL_DICT['group3'])
email_utils14 = EmailUtils(const.EMAIL_DICT['group14'])
email_content_list = []
instrument_db_dict = dict()

export_file_folder = 'H:/backtest_result_files'
date_file_base_path = 'Z:/data/future/backtest/data_history'
strategy_file_path = 'Z:/dailyjob/cta_update_info/strategy_parameter.csv'

account_dict = {
    'nanhua': ['All_Weather_1', 'All_Weather_2', 'All_Weather_3'],
    'zhongxin': ['absolute_return', 'steady_return'],
    'luzheng': [
        'All_Weather',
    ]
}
base_position_parameter_list = [
    'max_long_position', 'max_short_position', 'qty_per_trade'
]
filter_parameter_list = [
    'Account', 'max_long_position', 'max_short_position', 'qty_per_trade'
]
コード例 #8
0
from eod_aps.job.get_backtest_info_job import get_backtest_info_job
from eod_aps.job.tradeplat_init_index_job import tradeplat_init_index_job
from eod_aps.job.insert_strategy_state_sql_job import insert_strategy_state_sql_job
from eod_aps.job.oma_quota_build_job import oma_quota_build_job
from eod_aps.job.build_calendarma_transfer_parameter_job import build_calendarma_transfer_parameter_job
from eod_aps.tools.date_utils import DateUtils
from eod_aps.tools.email_utils import EmailUtils
from eod_aps.tools.server_manage_tools import restart_server_service, save_pf_position
from eod_aps.tools.vwap_stream_cal_tools import VwapCalTools
from eod_logger import log_trading_wrapper, log_wrapper
from eod_aps.model.eod_const import const
from eod_aps.job.stock_index_future_position_check import stock_index_future_position_check_job
from eod_aps.job.spider_cff_info_job import spider_cff_info_job

date_utils = DateUtils()
email_utils2 = EmailUtils(const.EMAIL_DICT['group2'])
email_utils9 = EmailUtils(const.EMAIL_DICT['group9'])
email_utils16 = EmailUtils(const.EMAIL_DICT['group16'])

BACKTEST_WSDL_ADDRESS = const.EOD_CONFIG_DICT['backtest_wsdl_address']
operation_enums = const.BASKET_FILE_OPERATION_ENUMS


@log_trading_wrapper
def zip_log_file():
    trade_servers_list = server_constant.get_trade_servers()
    zip_log_file_job(trade_servers_list)


@log_trading_wrapper
def db_backup():