代码整理

This commit is contained in:
2025-11-25 17:27:58 +08:00
parent 60af627806
commit 6b3b1a1f76
5 changed files with 4 additions and 18 deletions
+3 -5
View File
@@ -1,10 +1,9 @@
import tkinter as tk import tkinter as tk
from tkinter import ttk from tkinter import ttk
from core.logger import LogLevel, LogData, PrintLog from core.logger import LogLevel, LogData, PrintLog
from core.qmt import qmtv
from core.sfgrid.sfgrid_ui import TradeTargetUI from core.sfgrid.sfgrid_ui import TradeTargetUI
from tkinter import ttk, messagebox from tkinter import ttk
from core.eventbus import EventPrintLog from core.eventbus import EventPrintLog
from core.eventbus import event_bus as eBus from core.eventbus import event_bus as eBus
@@ -15,6 +14,8 @@ class MainWindow:
self.root.title("神之一手 - 交易系统") self.root.title("神之一手 - 交易系统")
self.root.geometry("1400x700") self.root.geometry("1400x700")
self.logLevel = LogLevel[configLogLevel]
PrintLog(LogLevel.DEBUG, f"系统启动成功 {self.logLevel.name}")
# 当前选中的策略Tab索引 # 当前选中的策略Tab索引
self.current_strategy_index = 0 self.current_strategy_index = 0
# 存储各个Frame的引用 # 存储各个Frame的引用
@@ -23,9 +24,6 @@ class MainWindow:
self.log_visible = False self.log_visible = False
self.create_ui() self.create_ui()
self.logLevel = LogLevel[configLogLevel]
PrintLog(LogLevel.DEBUG, f"系统启动成功 {self.logLevel.name}")
eBus.subscribe(EventPrintLog, self.on_log_event) eBus.subscribe(EventPrintLog, self.on_log_event)
-2
View File
@@ -1,2 +0,0 @@
GridTypePercentage = "Percentage"
GridTypeFixed = "PriceBreak"
-7
View File
@@ -1,7 +0,0 @@
from core.sfgrid.model import SFGridTradeTarget as TradeTarget
class GridFixData:
def __init__(self, grid_index, tradeTarget:TradeTarget):
self.grid_index = grid_index
self.tradeTarget = tradeTarget
+1 -3
View File
@@ -1,4 +1,3 @@
from core import util
from core.logger import LogLevel, PrintLog from core.logger import LogLevel, PrintLog
from core.qmt import qmtv from core.qmt import qmtv
from core.sfgrid import bus_events from core.sfgrid import bus_events
@@ -6,7 +5,6 @@ from core.sfgrid.bus_events import EventTradeTargetUpdate
import core.sfgrid.model as model import core.sfgrid.model as model
from core.eventbus import event_bus from core.eventbus import event_bus
from core.constants import OrderTypeBuy, OrderTypeSell, OrderTypeInit from core.constants import OrderTypeBuy, OrderTypeSell, OrderTypeInit
from core.util import is_trading_time
from xtquant import xtconstant from xtquant import xtconstant
from xtquant.xttype import XtOrderResponse, XtTrade from xtquant.xttype import XtOrderResponse, XtTrade
@@ -96,7 +94,7 @@ class SFGridStrategy:
print(f'length: {len(self.tradeTarget.getPriceGrid())}, currentIdx = {currentIdx}') print(f'length: {len(self.tradeTarget.getPriceGrid())}, currentIdx = {currentIdx}')
buyIdx = currentIdx + 1 buyIdx = currentIdx + 1
buyPrice = self.tradeTarget.getPriceGrid()[buyIdx] buyPrice = self.tradeTarget.getPriceGrid()[buyIdx]
remark = f'{OrderTypeInit},{buyIdx},{self.tradeTarget.stock_code}' remark = f'{OrderTypeBuy},{buyIdx},{self.tradeTarget.stock_code}'
if len([order for order in orders if order.order_type == xtconstant.STOCK_BUY and order.price == buyPrice]) == 0: if len([order for order in orders if order.order_type == xtconstant.STOCK_BUY and order.price == buyPrice]) == 0:
tmpOrderSeq = qmtv.orderAsync( tmpOrderSeq = qmtv.orderAsync(
str(self.tradeTarget.stock_code), str(self.tradeTarget.stock_code),
-1
View File
@@ -1,4 +1,3 @@
from mimetypes import inited
from typing import Any from typing import Any
import tkinter as tk import tkinter as tk