From 877a422126db455a32b69e58219680fda38b8cf8 Mon Sep 17 00:00:00 2001
From: admin <admin@example.com>
Date: 星期三, 19 三月 2025 13:59:03 +0800
Subject: [PATCH] 交易设置及接口

---
 strategy/order_methods.py |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/strategy/order_methods.py b/strategy/order_methods.py
index b5476b3..5388bd6 100644
--- a/strategy/order_methods.py
+++ b/strategy/order_methods.py
@@ -8,6 +8,7 @@
 from strategy import data_cache, account_management
 import data_server
 from log_module.log import logger_debug, logger_common
+from strategy.trade_setting import TradeSetting
 
 from trade import huaxin_trade_api, huaxin_trade_data_update, middle_api_protocol
 from utils import huaxin_util, tool
@@ -19,6 +20,12 @@
 
 # 涓嬪崟涔板叆鍑芥暟锛堟寜閲戦锛屼互闄愪环涔帮級銆愭寜閲戦涔� 鍩虹鐗堛��
 def buy_order_by_value(symbol, buy_order_value, sec_name, current_price):
+    # 鑷姩涔� 寮�鍏崇洃鍚柟娉�
+    if not TradeSetting().get_auto_buy():
+        # 鏆傚仠鑷姩涔�
+        logger.info(f"鍦ㄤ氦鏄撴柟娉曞嚱鏁板 鍏抽棴浜� 鑷姩涔�")
+        return
+
     price = round(float(current_price), 2)
     volume = (int(buy_order_value / price) // 100) * 100
     if volume < 100:
@@ -78,6 +85,11 @@
 
 # 涓嬪崟鍗栧嚭鍑芥暟锛堟寜鎸佷粨鏁伴噺锛屽湪闄愪环鍗栵級銆愭寜閲忓崠 鍩虹鐗堛��
 def sell_order_by_volume(symbol, volume, sec_name, current_price):
+    # 鑷姩鍗栧紑鍏崇洃鍚柟娉�
+    if not TradeSetting().get_auto_sell():
+        # 鏆傚仠鑷姩鍗�
+        logger.info(f"鍦ㄤ氦鏄撴柟娉曞嚱鏁板 鍏抽棴浜� 鑷姩鍗�")
+        return
     # price = round(float(price), 2)
     # 璋冪敤绗煎瓙浠疯绠楀伐鍏疯绠椾笅鍗曚环鏍�
     order_price = tool.get_buy_min_price(current_price)
@@ -111,6 +123,7 @@
     :param index:  鎸佷粨瀵硅薄鍒楄〃涓殑涓偂瀵瑰簲搴忓垪鍙�
     :return:  灏濊瘯杩斿洖鐨勮鍗曟暟鎹�
     """
+
     logger.info(f"褰撳墠涓偂鎸佷粨鎵嬫暟銆愬綋鍓嶅嚱鏁拌璋冪敤鏃朵紶杩涙潵鐨勫悓姝ユ暟鎹甦ata_cache涓殑鎸佷粨鏁版嵁銆�==={position_volume_yesterday}")
     # sell_order_volume = int(position_volume_yesterday * part_of_volume)
     sell_order_volume = round(position_volume_yesterday * part_of_volume / 100) * 100

--
Gitblit v1.8.0