[Mod] update chinese display for new algos
This commit is contained in:
parent
0e540386c7
commit
e55138b80e
@ -7,8 +7,8 @@ from vnpy.trader.ui import MainWindow, create_qapp
|
|||||||
# from vnpy.gateway.bitmex import BitmexGateway
|
# from vnpy.gateway.bitmex import BitmexGateway
|
||||||
# from vnpy.gateway.futu import FutuGateway
|
# from vnpy.gateway.futu import FutuGateway
|
||||||
# from vnpy.gateway.ib import IbGateway
|
# from vnpy.gateway.ib import IbGateway
|
||||||
# from vnpy.gateway.ctp import CtpGateway
|
from vnpy.gateway.ctp import CtpGateway
|
||||||
from vnpy.gateway.ctptest import CtptestGateway
|
# from vnpy.gateway.ctptest import CtptestGateway
|
||||||
# from vnpy.gateway.femas import FemasGateway
|
# from vnpy.gateway.femas import FemasGateway
|
||||||
# from vnpy.gateway.tiger import TigerGateway
|
# from vnpy.gateway.tiger import TigerGateway
|
||||||
# from vnpy.gateway.oes import OesGateway
|
# from vnpy.gateway.oes import OesGateway
|
||||||
@ -22,7 +22,7 @@ from vnpy.gateway.ctptest import CtptestGateway
|
|||||||
|
|
||||||
# from vnpy.app.cta_strategy import CtaStrategyApp
|
# from vnpy.app.cta_strategy import CtaStrategyApp
|
||||||
# from vnpy.app.csv_loader import CsvLoaderApp
|
# from vnpy.app.csv_loader import CsvLoaderApp
|
||||||
# from vnpy.app.algo_trading import AlgoTradingApp
|
from vnpy.app.algo_trading import AlgoTradingApp
|
||||||
# from vnpy.app.cta_backtester import CtaBacktesterApp
|
# from vnpy.app.cta_backtester import CtaBacktesterApp
|
||||||
# from vnpy.app.data_recorder import DataRecorderApp
|
# from vnpy.app.data_recorder import DataRecorderApp
|
||||||
# from vnpy.app.risk_manager import RiskManagerApp
|
# from vnpy.app.risk_manager import RiskManagerApp
|
||||||
@ -38,8 +38,8 @@ def main():
|
|||||||
|
|
||||||
# main_engine.add_gateway(BinanceGateway)
|
# main_engine.add_gateway(BinanceGateway)
|
||||||
# main_engine.add_gateway(XtpGateway)
|
# main_engine.add_gateway(XtpGateway)
|
||||||
# main_engine.add_gateway(CtpGateway)
|
main_engine.add_gateway(CtpGateway)
|
||||||
main_engine.add_gateway(CtptestGateway)
|
# main_engine.add_gateway(CtptestGateway)
|
||||||
# main_engine.add_gateway(FemasGateway)
|
# main_engine.add_gateway(FemasGateway)
|
||||||
# main_engine.add_gateway(IbGateway)
|
# main_engine.add_gateway(IbGateway)
|
||||||
# main_engine.add_gateway(FutuGateway)
|
# main_engine.add_gateway(FutuGateway)
|
||||||
@ -56,7 +56,7 @@ def main():
|
|||||||
# main_engine.add_app(CtaStrategyApp)
|
# main_engine.add_app(CtaStrategyApp)
|
||||||
# main_engine.add_app(CtaBacktesterApp)
|
# main_engine.add_app(CtaBacktesterApp)
|
||||||
# main_engine.add_app(CsvLoaderApp)
|
# main_engine.add_app(CsvLoaderApp)
|
||||||
# main_engine.add_app(AlgoTradingApp)
|
main_engine.add_app(AlgoTradingApp)
|
||||||
# main_engine.add_app(DataRecorderApp)
|
# main_engine.add_app(DataRecorderApp)
|
||||||
# main_engine.add_app(RiskManagerApp)
|
# main_engine.add_app(RiskManagerApp)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ class GridAlgo(AlgoTemplate):
|
|||||||
}
|
}
|
||||||
|
|
||||||
variables = [
|
variables = [
|
||||||
"last_pos",
|
"last_pos",
|
||||||
"timer_count",
|
"timer_count",
|
||||||
"vt_orderid",
|
"vt_orderid",
|
||||||
"traded",
|
"traded",
|
||||||
@ -59,7 +59,7 @@ class GridAlgo(AlgoTemplate):
|
|||||||
def on_tick(self, tick: TickData):
|
def on_tick(self, tick: TickData):
|
||||||
""""""
|
""""""
|
||||||
self.last_tick = tick
|
self.last_tick = tick
|
||||||
|
|
||||||
def on_timer(self):
|
def on_timer(self):
|
||||||
""""""
|
""""""
|
||||||
if not self.last_tick:
|
if not self.last_tick:
|
||||||
@ -68,15 +68,17 @@ class GridAlgo(AlgoTemplate):
|
|||||||
self.timer_count += 1
|
self.timer_count += 1
|
||||||
if self.timer_count < self.interval:
|
if self.timer_count < self.interval:
|
||||||
self.put_variables_event()
|
self.put_variables_event()
|
||||||
return
|
return
|
||||||
self.timer_count = 0
|
self.timer_count = 0
|
||||||
|
|
||||||
if self.vt_orderid:
|
if self.vt_orderid:
|
||||||
self.cancel_all()
|
self.cancel_all()
|
||||||
|
|
||||||
# Calculate target volume to buy
|
# Calculate target volume to buy
|
||||||
target_buy_distance = (self.price - self.last_tick.ask_price_1) / self.step_price
|
target_buy_distance = (
|
||||||
target_buy_position = math.floor(target_buy_distance) * self.step_volume
|
self.price - self.last_tick.ask_price_1) / self.step_price
|
||||||
|
target_buy_position = math.floor(
|
||||||
|
target_buy_distance) * self.step_volume
|
||||||
target_buy_volume = target_buy_position - self.last_pos
|
target_buy_volume = target_buy_position - self.last_pos
|
||||||
|
|
||||||
# Buy when price dropping
|
# Buy when price dropping
|
||||||
@ -86,10 +88,12 @@ class GridAlgo(AlgoTemplate):
|
|||||||
self.last_tick.ask_price_1,
|
self.last_tick.ask_price_1,
|
||||||
min(target_buy_volume, self.last_tick.ask_volume_1)
|
min(target_buy_volume, self.last_tick.ask_volume_1)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Calculate target volume to sell
|
# Calculate target volume to sell
|
||||||
target_sell_distance = (self.price - self.last_tick.bid_price_1) / self.step_price
|
target_sell_distance = (
|
||||||
target_sell_position = math.ceil(target_sell_distance) * self.step_volume
|
self.price - self.last_tick.bid_price_1) / self.step_price
|
||||||
|
target_sell_position = math.ceil(
|
||||||
|
target_sell_distance) * self.step_volume
|
||||||
target_sell_volume = self.last_pos - target_sell_position
|
target_sell_volume = self.last_pos - target_sell_position
|
||||||
|
|
||||||
# Sell when price rising
|
# Sell when price rising
|
||||||
@ -117,7 +121,7 @@ class GridAlgo(AlgoTemplate):
|
|||||||
self.stop()
|
self.stop()
|
||||||
else:
|
else:
|
||||||
self.put_variables_event()
|
self.put_variables_event()
|
||||||
|
|
||||||
def update_last_pos(self, pos, trade: TradeData):
|
def update_last_pos(self, pos, trade: TradeData):
|
||||||
""""""
|
""""""
|
||||||
if trade.direction == Direction.LONG:
|
if trade.direction == Direction.LONG:
|
||||||
|
@ -12,5 +12,16 @@ NAME_DISPLAY_MAP = {
|
|||||||
"timer_count": "本轮读秒",
|
"timer_count": "本轮读秒",
|
||||||
"total_count": "累计读秒",
|
"total_count": "累计读秒",
|
||||||
"template_name": "算法模板",
|
"template_name": "算法模板",
|
||||||
"display_volume": "挂出数量"
|
"display_volume": "挂出数量",
|
||||||
|
"stop_price": "触发价格",
|
||||||
|
"price_add": "委托超价",
|
||||||
|
"trade_count": "交易次数限制",
|
||||||
|
"step_price": "网格交易间距",
|
||||||
|
"step_volume": "网格交易数量",
|
||||||
|
"order_type": "类型",
|
||||||
|
"active_vt_symbol": "主动腿",
|
||||||
|
"passive_vt_symbol": "被动腿",
|
||||||
|
"spread_up": "价差上限",
|
||||||
|
"spread_down": "价差下限",
|
||||||
|
"max_pos": "最大持仓"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user