adjust
This commit is contained in:
BIN
Binary file not shown.
@@ -4,7 +4,7 @@ import time, sys
|
||||
sys.stdout.reconfigure(encoding='utf-8') # 设置标准输出编码为UTF-8
|
||||
import strategy_db
|
||||
from trade_thread import StockTradeThread
|
||||
from util import getInstrumentName
|
||||
from util import getInstrumentName, interact
|
||||
from xtquant.xttrader import XtQuantTrader
|
||||
from xtquant.xttype import StockAccount
|
||||
|
||||
@@ -93,10 +93,6 @@ class SFGridController:
|
||||
else:
|
||||
print("\n当前无委托记录")
|
||||
|
||||
def interact(self):
|
||||
"""执行后进入repl模式"""
|
||||
import code
|
||||
code.InteractiveConsole(locals=globals()).interact()
|
||||
|
||||
def init_stock_trade_threads(self):
|
||||
for stock_code in self.instrument_pool:
|
||||
@@ -104,8 +100,10 @@ class SFGridController:
|
||||
new_job.name = f"StockTradeThread-{stock_code}"
|
||||
new_job.start()
|
||||
|
||||
def stock_trade_thread(self, stock_code):
|
||||
print(f"启动标的交易线程 {stock_code} {getInstrumentName(stock_code)}\n")
|
||||
def start_stock_trade_thread(self, stock: strategy_db.TradeTarget):
|
||||
stock.name = f"StockTradeThread-{stock.stock_code}"
|
||||
stock.start()
|
||||
print(f"启动标的交易线程 {stock.stock_code} {getInstrumentName(stock.stock_code)}\n")
|
||||
threading.Event().wait(2) # 模拟交易操作的等待时间
|
||||
|
||||
|
||||
@@ -117,6 +115,6 @@ if __name__ == '__main__':
|
||||
ctrl.init_stock_trade_threads()
|
||||
|
||||
# 交互阻塞
|
||||
ctrl.interact()
|
||||
interact()
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
from peewee import SqliteDatabase, Model, CharField, IntegerField, FloatField
|
||||
from peewee import SqliteDatabase, Model, CharField, IntegerField, FloatField, BooleanField
|
||||
|
||||
# 连接到SQLite数据库
|
||||
db = SqliteDatabase('example.db')
|
||||
@@ -17,4 +17,5 @@ class TradeTarget(BaseModel):
|
||||
last_trade_price = FloatField()
|
||||
current_buy_price = FloatField()
|
||||
current_sell_price = FloatField()
|
||||
status = IntegerField(default=1) # 1表示启用,0表示停止
|
||||
status = IntegerField(default=0) # 1表示启用,0表示停止
|
||||
enabled = BooleanField(default=False) # 是否启用该标的
|
||||
Reference in New Issue
Block a user