# -*- coding: utf-8 -*- import sys import xml.etree.cElementTree as ET from eod_aps.model.schema_common import Instrument from eod_aps.model.eod_const import CustomEnumUtils from eod_aps.server_python import * date_utils = DateUtils() Instrument_Type_Enum = const.INSTRUMENT_TYPE_ENUMS Exchange_Type_Enum = const.EXCHANGE_TYPE_ENUMS Market_Sector_Type_Enum = const.MARKETSECTOR_TYPE_ENUMS custom_enum_utils = CustomEnumUtils() SecruityIDSource_xml_dict = custom_enum_utils.enum(CS='102') class XmlModel(object): """ XmlModel """ def __init__(self): pass def __read_securities_xml(): try: tree = ET.parse( "Z:/dailyjob/daily_files/ETF/securities_20171220.xml") # 打开xml文档 # root = ET.fromstring(country_string) #从字符串传递xml root = tree.getroot() # 获得root节点
# -*- coding: utf-8 -*- from eod_aps.model.eod_const import const, CustomEnumUtils from eod_aps.tools.tradeplat_message_tools import * custom_enum_utils = CustomEnumUtils() exchange_type_dict = custom_enum_utils.enum_to_dict(const.EXCHANGE_TYPE_ENUMS) class InstrumentView(object): """ Instrument数据展示类 """ def __init__(self, instrument_msg, market_msg): self.Index = instrument_msg.index self.ID = instrument_msg.id self.Ticker = instrument_msg.ticker # self.ExchangeID = exchange_type_dict[instrument_msg.ExchangeIDWire] self.ExchangeID = instrument_msg.ExchangeIDWire self.UniqueSymbol = '%s %s' % (self.Ticker, self.ExchangeID) self.MarketSectorID = instrument_msg.MarketSectorIDWire self.TypeID = instrument_msg.TypeIDWire self.Type2ID = instrument_msg.Type2IDWire self.Name = instrument_msg.name self.BidMargin = instrument_msg.BidMargin self.AskMargin = instrument_msg.AskMargin self.ValPT = instrument_msg.ValPT self.BuyCommission = instrument_msg.BuyCommission self.SellCommission = instrument_msg.SellCommission self.ShortSellCommission = instrument_msg.ShortSellCommission self.Slippage = instrument_msg.Slippage
from eod_aps.model.schema_common import Instrument from eod_aps.model.market_data_bar_info import MinuteBarInfo, QuoteBarInfo from eod_aps.server_python import * instrument_dict = dict() trading_time_dict = dict() quote_dict = dict() minbar_dict = dict() interval_time = 60 quote_size = 4000 minbar_size = 500 Exchange_Type_Enum = const.EXCHANGE_TYPE_ENUMS custom_enum_utils = CustomEnumUtils() exchange_type_inversion_dict = custom_enum_utils.enum_to_dict( Exchange_Type_Enum, inversion_flag=True) def start_build_file(): build_quotes_minbar_file() def start(ctp_file_name): global server_host server_host = server_constant_local.get_server_model('host') start_build_quotes_base(ctp_file_name) build_quotes_minbar_file() server_host.close()
# -*- coding: utf-8 -*- from eod_aps.model.schema_history import PhoneTradeInfo from eod_aps.model.server_constans import server_constant from eod_aps.tools.date_utils import DateUtils from eod_aps.tools.email_utils import EmailUtils from eod_aps.tools.tradeplat_message_tools import socket_init, send_phone_trade_request_msg from eod_aps.model.eod_const import CustomEnumUtils, const date_utils = DateUtils() email_utils = EmailUtils(const.EMAIL_DICT['group2']) custom_enum_utils = CustomEnumUtils() inversion_direction_dict = custom_enum_utils.enum_to_dict( const.DIRECTION_ENUMS, inversion_flag=True) inversion_trade_type_dict = custom_enum_utils.enum_to_dict( const.TRADE_TYPE_ENUMS, inversion_flag=True) inversion_hedge_flag_dict = custom_enum_utils.enum_to_dict( const.HEDGEFLAG_TYPE_ENUMS, inversion_flag=True) inversion_io_type_dict = custom_enum_utils.enum_to_dict(const.IO_TYPE_ENUMS, inversion_flag=True) direction_dict = custom_enum_utils.enum_to_dict(const.DIRECTION_ENUMS) trade_type_dict = custom_enum_utils.enum_to_dict(const.TRADE_TYPE_ENUMS) io_type_dict = custom_enum_utils.enum_to_dict(const.IO_TYPE_ENUMS) table_title = 'fund,strategy1,symbol,direction,trade_type,hedge_flag,exprice,exqty,io_type,strategy2,\ connect_address' def send_phone_trade(server_name, phone_trade_list): """ 发送phone_trade
from eod_aps.tools.tradeplat_message_tools import * from eod_aps.model.eod_const import const, CustomEnumUtils from eod_aps.tools.tradeplat_position_tools import RiskView from eod_aps.tools.tradeplat_position_tools import InstrumentView ip = const.EOD_CONFIG_DICT['redis_address'].split('|')[0] port = const.EOD_CONFIG_DICT['redis_address'].split('|')[1] r = redis.Redis(host=ip, port=port, db=3) pipeline_redis = r.pipeline() market_latest_receive_time = None order_latest_receive_time = None trade_latest_receive_time = None custom_enum_utils = CustomEnumUtils() order_type_dict = custom_enum_utils.enum_to_dict(const.ORDER_TYPE_ENUMS, inversion_flag=True) hedgeflag_type_dict = custom_enum_utils.enum_to_dict( const.HEDGEFLAG_TYPE_ENUMS, True) order_status_dict = custom_enum_utils.enum_to_dict(const.ORDER_STATUS_ENUMS, True) operation_status_dict = custom_enum_utils.enum_to_dict( const.OPERATION_STATUS_ENUMS, True) trade_type_dict = custom_enum_utils.enum_to_dict(const.TRADE_TYPE_ENUMS, True) def __save_instrument_all(socket): # 往aggregator发送tradeserver的订阅消息 trade_server_info_msg = send_tradeserverinfo_request_msg(socket) trade_server_info_list = []
# -*- coding: utf-8 -*- import os import traceback from decimal import Decimal import pandas as pd import numpy as np from eod_aps.model.eod_const import const, CustomEnumUtils from eod_aps.model.schema_jobs import DailyVwapAnalyse from eod_aps.model.server_constans import server_constant data_path = const.EOD_CONFIG_DICT['data_file_folder'] Algo_Type_Enums = const.ALGO_TYPE_ENUMS custom_enum_utils = CustomEnumUtils() algo_type_dict = custom_enum_utils.enum_to_dict(Algo_Type_Enums, inversion_flag=True) include_algo_types = [ Algo_Type_Enums.SigmaVWAP_AI, Algo_Type_Enums.SigmaVWAP, Algo_Type_Enums.SigmaVWAP_3 ] def direct(x): if x > 0: return 'b' else: return 's' class VwapCalTools(): def __init__(self, start_date): self.__start_date = start_date
# BASE_STKINTRADAY_MODEL_FOLDER = '%s/model' % INTRADAY_DEEP_LEARNING_PATH # BASE_STKINTRADAY_CONFIG_FOLDER = '%s/config' % INTRADAY_DEEP_LEARNING_PATH # BASE_VWAP_CONFIG_VWAP_FOLDER = '%s/config_vwap' % INTRADAY_DEEP_LEARNING_PATH # BASE_VWAP_CONFIG_COMBINE_FOLDER = '%s/config_combine' % INTRADAY_DEEP_LEARNING_PATH # BASE_PARAMETER_DICT_FILE_PATH = '%s/parameter_dict.csv' % INTRADAY_DEEP_LEARNING_PATH INTRADAY_DEEP_LEARNING_PATH = const.EOD_CONFIG_DICT['intraday_stock_path'] BASE_STKINTRADAY_MODEL_FOLDER = '%s/model' % INTRADAY_DEEP_LEARNING_PATH BASE_STKINTRADAY_CONFIG_FOLDER = '%s/config' % INTRADAY_DEEP_LEARNING_PATH BASE_PARAMETER_DICT_FILE_PATH = '%s/parameter_dict.csv' % INTRADAY_DEEP_LEARNING_PATH INTRADAY_INDEX_FUTURE_PATH = const.EOD_CONFIG_DICT[ 'intraday_index_future_path'] BASE_INTRADAY_INDEX_MODEL_FOLDER = '%s/model' % INTRADAY_INDEX_FUTURE_PATH BASE_INTRADAY_INDEX_CONFIG_FOLDER = '%s/config' % INTRADAY_INDEX_FUTURE_PATH # --------------------常用字典数据---------------------------------------- ORDER_ROUTE_LOG_DICT = { 'guoxin': 'logon fail|Login CTP order route fail', 'huabao': 'Login LTS Order Route fail|Login CTP order route fail', 'nanhua': 'Login CTP order route fail', 'zhongxin': 'Login CTP order route fail' } custom_enum_utils = CustomEnumUtils() Instrument_Type_Enums = const.INSTRUMENT_TYPE_ENUMS Exchange_Type_Enums = const.EXCHANGE_TYPE_ENUMS Direction_Enums = const.DIRECTION_ENUMS Trade_Type_Enums = const.TRADE_TYPE_ENUMS Hedge_Flag_Type_Enums = const.HEDGEFLAG_TYPE_ENUMS IO_Type_Enums = const.IO_TYPE_ENUMS