diff --git a/vnpy/app/spread_trading/__init__.py b/vnpy/app/spread_trading/__init__.py new file mode 100644 index 00000000..7ff1bf13 --- /dev/null +++ b/vnpy/app/spread_trading/__init__.py @@ -0,0 +1,17 @@ +from pathlib import Path + +from vnpy.trader.app import BaseApp + +from .engine import SpreadEngine, APP_NAME + + +class AlgoTradingApp(BaseApp): + """""" + + app_name = APP_NAME + app_module = __module__ + app_path = Path(__file__).parent + display_name = "价差交易" + engine_class = SpreadEngine + widget_name = "SpreadManager" + icon_name = "spread.ico" diff --git a/vnpy/app/spread_trading/engine.py b/vnpy/app/spread_trading/engine.py new file mode 100644 index 00000000..1e4584b9 --- /dev/null +++ b/vnpy/app/spread_trading/engine.py @@ -0,0 +1,13 @@ + +from vnpy.event import EventEngine, Event +from vnpy.trader.engine import BaseEngine, MainEngine + +APP_NAME = "SpreadTrading" + + +class SpreadEngine(BaseEngine): + """""" + + def __init__(self, main_engine: MainEngine, event_engine: EventEngine): + """Constructor""" + super().__init__(main_engine, event_engine, APP_NAME) diff --git a/vnpy/app/spread_trading/ui/__init__.py b/vnpy/app/spread_trading/ui/__init__.py new file mode 100644 index 00000000..c7639754 --- /dev/null +++ b/vnpy/app/spread_trading/ui/__init__.py @@ -0,0 +1 @@ +from .widget import SpreadManager diff --git a/vnpy/app/spread_trading/ui/spread.ico b/vnpy/app/spread_trading/ui/spread.ico new file mode 100644 index 00000000..05b3d571 Binary files /dev/null and b/vnpy/app/spread_trading/ui/spread.ico differ diff --git a/vnpy/app/spread_trading/ui/widget.py b/vnpy/app/spread_trading/ui/widget.py new file mode 100644 index 00000000..ced5317c --- /dev/null +++ b/vnpy/app/spread_trading/ui/widget.py @@ -0,0 +1,25 @@ +""" +Widget for spread trading. +""" + +from vnpy.event import EventEngine, Event +from vnpy.trader.engine import MainEngine +from vnpy.trader.ui import QtWidgets, QtCore + +from ..engine import ( + AlgoEngine, + AlgoTemplate, + APP_NAME, +) + + +class SpreadManager(QtWidgets.QWidget): + """""" + + def __init__(self, main_engine: MainEngine, event_engine: EventEngine): + """""" + super().__init__() + + self.main_engine = main_engine + self.event_engine = event_engine + self.spread_engine = main_engine.get_engine(APP_NAME)