| | |
| | | |
| | | def OnRtnStockIndexData(self, pStockIndexData): |
| | | # 指数数据 |
| | | print("收到指数行情应答") |
| | | logger_debug.info(f"指数行情应答:{pStockIndexData}") |
| | | pass |
| | | |
| | |
| | | from huaxin_client.l2_data_transform_protocol import L2DataCallBack |
| | | from log_module import log, async_log_util |
| | | from log_module.async_log_util import huaxin_l2_log |
| | | from log_module.log import logger_local_huaxin_l2_subscript, logger_system, logger_local_huaxin_l2_transaction, \ |
| | | logger_local_huaxin_g_cancel, logger_l2_codes_subscript, printlog, logger_debug, logger_local_huaxin_l2_market |
| | | from log_module.log import logger_local_huaxin_l2_subscript, logger_system,logger_l2_codes_subscript, printlog, logger_debug, logger_local_huaxin_l2_market |
| | | from utils import tool |
| | | |
| | | ###B类### |
| | |
| | | filter=lambda record: record["extra"].get("name") == "kpl_jingxuan_in", |
| | | rotation="00:00", compression="zip", enqueue=True) |
| | | |
| | | logger.add(self.get_path("common", "common"), |
| | | filter=lambda record: record["extra"].get("name") == "common", |
| | | rotation="00:00", compression="zip", enqueue=True) |
| | | |
| | | def get_path(self, dir_name, log_name): |
| | | path_str = "{}/{}/gp/{}/{}".format(constant.get_path_prefix(), constant.LOG_DIR, dir_name, |
| | | log_name) + ".{time:YYYY-MM-DD}.log" |
| | |
| | | hx_logger_trade_loop = __mylogger.get_logger("hx_trade_loop") |
| | | |
| | | # -------------------------------华鑫本地日志--------------------------------- |
| | | logger_local_huaxin_l2_transaction = __mylogger.get_logger("local_huaxin_transaction") |
| | | logger_local_huaxin_l2_orderdetail = __mylogger.get_logger("local_huaxin_orderdetail") |
| | | logger_local_huaxin_l2_upload = __mylogger.get_logger("local_huaxin_upload") |
| | | logger_local_huaxin_l2_error = __mylogger.get_logger("local_huaxin_error") |
| | | logger_local_huaxin_l2_subscript = __mylogger.get_logger("local_huaxin_subscript") |
| | | logger_local_huaxin_l2_market = __mylogger.get_logger("local_huaxin_l2_market") |
| | | logger_local_huaxin_contact_debug = __mylogger.get_logger("local_huaxin_debug") |
| | | logger_local_huaxin_trade_debug = __mylogger.get_logger("local_huaxin_trade_debug") |
| | | logger_local_huaxin_l1 = __mylogger.get_logger("local_huaxin_l1_show_info") |
| | | logger_local_huaxin_g_cancel = __mylogger.get_logger("local_huaxin_g_cancel") |
| | | logger_local_huaxin_l2_buy_no = __mylogger.get_logger("local_huaxin_l2_buy_no") |
| | | logger_local_huaxin_l1_trade_info = __mylogger.get_logger("local_huaxin_l1_trade_info") |
| | | logger_local_huaxin_l2_special_volume = __mylogger.get_logger("local_huaxin_l2_special_volume") |
| | | |
| | | logger_kpl_jingxuan_in = __mylogger.get_logger("kpl_jingxuan_in") |
| | | |
| | | logger_common = __mylogger.get_logger("common") |
| | | |
| | | |
| | | |
| | | |
| | | def close_print(): |
| | | logging.basicConfig(level=logging.ERROR) |
| | |
| | | import constant |
| | | # 引入掘金桥梁API |
| | | import utils.juejin_api |
| | | from log_module.log import logger_common |
| | | # 引入开盘啦API模块 |
| | | # 引入全局变量模块 |
| | | # 引入定时器模块 |
| | |
| | | from trade import huaxin_trade_data_update |
| | | from utils import hx_qc_value_util |
| | | |
| | | # 引入日志模块 |
| | | from strategy.logging_config import get_logger |
| | | # 获取logger实例 |
| | | logger = get_logger() |
| | | # 引入行情订阅模块 |
| | | # import subscribe_market |
| | | |
| | |
| | | # 初始化数据 函数 |
| | | def init_data(): |
| | | # logging.info("main初始化数据开始") |
| | | logger.info(f"main初始化数据开始") |
| | | logger_common.info(f"main初始化数据开始") |
| | | ''' |
| | | 资金管理初始化 |
| | | 仓位管理初始化 |
| | |
| | | """ |
| | | 账户管理模块【管理账户下面的资金管理方法及仓位管理方法等】 |
| | | """ |
| | | from log_module.log import logger_common |
| | | # import time |
| | | # import datetime |
| | | # import decimal |
| | |
| | | # 引入全局变量模块 |
| | | from strategy import data_cache |
| | | |
| | | # 引入日志模块 |
| | | from strategy.logging_config import get_logger |
| | | # 获取logger实例 |
| | | logger = get_logger() |
| | | logger = logger_common |
| | | |
| | | |
| | | # 资金管理函数 |
| | |
| | | logger.info(f"冻结的资金==={frozenCash}") |
| | | logger.info(f"可取资金==={fetchLimit}") |
| | | logger.info(f"上日结存==={preDeposit}") |
| | | |
| | | |
| | | # finance_management() |
| | | |
| | |
| | | securityID = i['securityID'] # 当前个股代码 |
| | | # symbol_code = symbol.split('.')[1] # 将symbol转为纯数字编号 |
| | | historyPos = i['historyPos'] # 昨日仓位转入数量(昨仓) |
| | | historyPosFrozen = i['historyPosFrozen'] # 昨仓冻结 |
| | | todayBSPos = i['todayBSPos'] # 今日买卖仓位转入转出数量 |
| | | historyPosFrozen = i['historyPosFrozen'] # 昨仓冻结 |
| | | todayBSPos = i['todayBSPos'] # 今日买卖仓位转入转出数量 |
| | | todayBSPosFrozen = i['todayBSPosFrozen'] # 今买卖仓冻结 |
| | | historyPosPrice = i['historyPosPrice'] # 昨仓成本价 |
| | | totalPosCost = i['totalPosCost'] # 持仓成本 |
| | |
| | | data_cache.addition_position_symbols_set.add(securityID) |
| | | # todo 自主的计算持仓数量 管用 还是 服务端即时查询同步有用 有待验证 |
| | | logger.info(f"今日可用持仓数量====================================【{len(data_cache.available_symbols_set)}】") |
| | | logger.info(f"今日新增持仓数量====================================【{len(data_cache.addition_position_symbols_set)}】") |
| | | |
| | | logger.info( |
| | | f"今日新增持仓数量====================================【{len(data_cache.addition_position_symbols_set)}】") |
| | | |
| | | # position_management() |
| | | |
| | |
| | | import json |
| | | |
| | | import constant |
| | | from log_module.log import logger_common |
| | | # 引入掘金API |
| | | # import utils.juejin_api |
| | | # import kpl_api |
| | |
| | | # 引入基础算法模块 |
| | | from strategy import basic_methods |
| | | # 引入本地日志模块 |
| | | from strategy.logging_config import get_logger |
| | | from utils import hx_qc_value_util, tool |
| | | |
| | | # 获取logger实例 |
| | | logger = get_logger() |
| | | logger = logger_common |
| | | |
| | | start_time = time.time() |
| | | print(f"all_K_line开始运行--{start_time}") |
| | |
| | | from __future__ import print_function, absolute_import, unicode_literals |
| | | |
| | | import decimal |
| | | |
| | | from log_module.log import logger_common |
| | | # from datetime import datetime |
| | | from strategy import data_cache |
| | | from strategy.logging_config import get_logger |
| | | from utils import hx_qc_value_util |
| | | |
| | | # 获取logger实例 |
| | | logger = get_logger() |
| | | logger = logger_common |
| | | |
| | | |
| | | # 将纯数字代码转化为=》掘金格式股票代码 |
| | |
| | | # from datetime import timedelta |
| | | import time |
| | | import utils.tool |
| | | from log_module.log import logger_kpl_jingxuan_in |
| | | from log_module.log import logger_kpl_jingxuan_in, logger_common |
| | | # import dateutil |
| | | # 引入掘金API |
| | | # from gm.api import * |
| | |
| | | from strategy import account_management |
| | | from strategy import order_methods |
| | | |
| | | from strategy.logging_config import get_logger |
| | | from utils import tool, huaxin_util |
| | | |
| | | # 获取logger实例 |
| | | logger = get_logger() |
| | | logger = logger_common |
| | | |
| | | |
| | | # 构建获取个股记录下来的实时当日开盘价函数 |
| | |
| | | logger.info( |
| | | f"最新价: {current_price}, 当日最高价:{current_high},瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%,公司名称:{k_line_data[0]['sec_name']},当前时间:{current_created_at},低于水位线:{deep_low:.2f},交易量今日与昨日的比例{round(current_volume / k_line_data[0]['volume'], 2)}") |
| | | # 调用下单方法下单 |
| | | order_methods.buy_order_by_value(symbol, 1000, |
| | | k_line_data[0]['sec_name'], |
| | | current_price) |
| | | # order_methods.buy_order_by_value(symbol, 1000, |
| | | # k_line_data[0]['sec_name'], |
| | | # current_price) |
| | | # 将有概念买入次数自加1 |
| | | data_cache.have_plate_buy_times += 1 |
| | | # 将买入个股的当时概念添加到全局变量中存储 |
| | |
| | | """ |
| | | import datetime |
| | | import time |
| | | |
| | | from log_module.log import logger_common |
| | | from strategy import data_cache |
| | | from strategy import kpl_api |
| | | from strategy import instant_time_market |
| | | from strategy.logging_config import get_logger |
| | | |
| | | # 获取logger实例 |
| | | logger = get_logger() |
| | | logger = logger_common |
| | | |
| | | |
| | | # 构建一个项目整体的定时器对象 |
| | |
| | | import constant |
| | | # 引入掘金API |
| | | import utils.juejin_api |
| | | from log_module.log import logger_common |
| | | # from logging_config import get_logger |
| | | from strategy.logging_config import get_logger |
| | | from utils import tool, hx_qc_value_util |
| | | |
| | | # 获取logger实例 |
| | | logger = get_logger() |
| | | logger = logger_common |
| | | |
| | | # 全局日志配置 如果不想用就把 logging.ERROR 如果要打就=logging.INFO |
| | | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') |
| | |
| | | import time |
| | | import datetime |
| | | import utils |
| | | from log_module.log import logger_common |
| | | from utils import huaxin_util |
| | | # 引入华鑫API(小辉整理) |
| | | from strategy import l1_data_api |
| | |
| | | from strategy import basic_methods |
| | | from strategy import buying_strategy |
| | | from strategy import selling_strategy |
| | | from strategy.logging_config import get_logger |
| | | # from low_suction.shared_memory_util import SharedMemoryObj |
| | | |
| | | # 获取logger实例 |
| | | logger = get_logger() |
| | | logger = logger_common |
| | | |
| | | ''' |
| | | 创建一个函数来对主要指数的实时行情作处理 |
| | |
| | | import requests |
| | | |
| | | import constant |
| | | from log_module.log import logger_common |
| | | # import requests |
| | | from strategy import data_cache |
| | | from strategy import basic_methods |
| | | |
| | | from strategy.logging_config import get_logger |
| | | from trade import middle_api_protocol |
| | | from utils import hx_qc_value_util |
| | | |
| | | # 获取logger实例 |
| | | logger = get_logger() |
| | | logger = logger_common |
| | | |
| | | now = time.time() |
| | | print(f"kpl_api开始运行--{now}") |
| | |
| | | # 设定当前时间点 |
| | | now_time = datetime.datetime.now().strftime("%H:%M:%S") |
| | | # print(f"now_time===={now_time}") |
| | | if data_cache.opening_time < now_time < data_cache.update_data_time: |
| | | if data_cache.server_restart_time < now_time < data_cache.update_data_time: |
| | | # print(f"在时间内使用--------------------------") |
| | | # 获取涨停信息列表 |
| | | limit_up_info = get_limit_up_info() |
| | |
| | | |
| | | from strategy import data_cache, account_management |
| | | import data_server |
| | | from log_module.log import logger_debug |
| | | |
| | | from log_module.log import logger_debug, logger_common |
| | | |
| | | from trade import huaxin_trade_api, huaxin_trade_data_update, middle_api_protocol |
| | | from utils import huaxin_util, tool |
| | | |
| | | # 引入日志模块 |
| | | from strategy.logging_config import get_logger |
| | | # 获取logger实例 |
| | | logger = get_logger() |
| | | logger = logger_common |
| | | |
| | | |
| | | # 下单买入函数(按金额,以限价买)【按金额买 基础版】 |
| | |
| | | # 调用笼子价计算工具计算下单价格 |
| | | order_price = tool.get_buy_max_price(current_price) |
| | | buy_order = huaxin_trade_api.order(1, symbol[-6:], volume, order_price, blocking=True) |
| | | logger.info(f"current_price===={current_price} order_price===={order_price}") |
| | | logger.info(f"buy_order===={buy_order}") |
| | | orderStatusMsg = buy_order['data'].get('orderStatusMsg', None) |
| | | statusMsg = buy_order['data'].get('statusMsg', None) |
| | |
| | | # 调用笼子价计算工具计算下单价格 |
| | | order_price = tool.get_buy_min_price(current_price) |
| | | sell_order = huaxin_trade_api.order(2, symbol[-6:], volume, order_price, blocking=True) |
| | | logger.info(f"current_price===={current_price} order_price===={order_price}") |
| | | logger.info(f"sell_order===={sell_order}") |
| | | orderStatusMsg = sell_order['data'].get('orderStatusMsg', None) |
| | | statusMsg = sell_order['data'].get('statusMsg', None) |
| | |
| | | """ |
| | | # import decimal |
| | | import datetime |
| | | |
| | | from log_module.log import logger_common |
| | | # import time |
| | | # 引入掘金API |
| | | # from gm.api import * |
| | |
| | | |
| | | # import account_management |
| | | from strategy import order_methods |
| | | from strategy.logging_config import get_logger |
| | | |
| | | # 获取logger实例 |
| | | logger = get_logger() |
| | | logger = logger_common |
| | | |
| | | |
| | | # 构建获取个股记录下来的实时当日开盘价函数 |