commit
3d1c794d5a
@ -72,7 +72,7 @@ def main():
|
||||
## 接口分类
|
||||
|
||||
| 接口 | 类型 |
|
||||
| ------ | :------: |
|
||||
| -------- | :----------------------------------------: |
|
||||
| CTP | 期货 |
|
||||
| FEMAS | 期货 |
|
||||
| OES | 国内股票 |
|
||||
@ -270,8 +270,11 @@ main_engine.add_gateway(IbGateway)
|
||||
|
||||
|
||||
#### 其他特点
|
||||
|
||||
可交易品种几乎覆盖全球的股票、期权、期权;手续费相对较低。
|
||||
|
||||
注意IB接口的合约代码较为特殊,请前往官网的产品查询板块查询,VN Trader中使用的是盈透证券对于每个合约在某一交易所的唯一标识符ConId来作为合约代码,而非Symbol或者LocalName。
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -17,8 +17,8 @@ from vnpy.trader.ui import MainWindow, create_qapp
|
||||
# from vnpy.gateway.onetoken import OnetokenGateway
|
||||
# from vnpy.gateway.okexf import OkexfGateway
|
||||
# from vnpy.gateway.xtp import XtpGateway
|
||||
# from vnpy.gateway.hbdm import HbdmGateway
|
||||
from vnpy.gateway.tap import TapGateway
|
||||
from vnpy.gateway.hbdm import HbdmGateway
|
||||
# from vnpy.gateway.tap import TapGateway
|
||||
|
||||
# from vnpy.app.cta_strategy import CtaStrategyApp
|
||||
# from vnpy.app.csv_loader import CsvLoaderApp
|
||||
@ -49,8 +49,8 @@ def main():
|
||||
# main_engine.add_gateway(BitfinexGateway)
|
||||
# main_engine.add_gateway(OnetokenGateway)
|
||||
# main_engine.add_gateway(OkexfGateway)
|
||||
# main_engine.add_gateway(HbdmGateway)
|
||||
main_engine.add_gateway(TapGateway)
|
||||
main_engine.add_gateway(HbdmGateway)
|
||||
# main_engine.add_gateway(TapGateway)
|
||||
|
||||
# main_engine.add_app(CtaStrategyApp)
|
||||
# main_engine.add_app(CtaBacktesterApp)
|
||||
|
@ -214,6 +214,8 @@ class BacktestingEngine:
|
||||
if not self.end:
|
||||
self.end = datetime.now()
|
||||
|
||||
self.history_data.clear() # Clear previously loaded history data
|
||||
|
||||
# Load 30 days of data each time and allow for progress update
|
||||
progress_delta = timedelta(days=30)
|
||||
total_delta = self.end - self.start
|
||||
|
@ -36,7 +36,7 @@ from vnpy.trader.constant import (
|
||||
Offset,
|
||||
Status
|
||||
)
|
||||
from vnpy.trader.utility import load_json, save_json, extract_vt_symbol
|
||||
from vnpy.trader.utility import load_json, save_json, extract_vt_symbol, round_to
|
||||
from vnpy.trader.database import database_manager
|
||||
from vnpy.trader.rqdata import rqdata_client
|
||||
|
||||
@ -465,6 +465,10 @@ class CtaEngine(BaseEngine):
|
||||
self.write_log(f"委托失败,找不到合约:{strategy.vt_symbol}", strategy)
|
||||
return ""
|
||||
|
||||
# Round order price and volume to nearest incremental value
|
||||
price = round_to(price, contract.pricetick)
|
||||
volume = round_to(volume, contract.min_volume)
|
||||
|
||||
if stop:
|
||||
if contract.stop_supported:
|
||||
return self.send_server_stop_order(strategy, contract, direction, offset, price, volume, lock)
|
||||
|
@ -958,6 +958,9 @@ class HbdmDataWebsocketApi(HbdmWebsocketApiBase):
|
||||
""""""
|
||||
self.gateway.write_log("行情Websocket API连接成功")
|
||||
|
||||
for ws_symbol in self.ticks.keys():
|
||||
self.subscribe_data(ws_symbol)
|
||||
|
||||
def subscribe(self, req: SubscribeRequest):
|
||||
""""""
|
||||
contract_type = symbol_type_map.get(req.symbol, "")
|
||||
@ -980,6 +983,10 @@ class HbdmDataWebsocketApi(HbdmWebsocketApiBase):
|
||||
)
|
||||
self.ticks[ws_symbol] = tick
|
||||
|
||||
self.subscribe_data(ws_symbol)
|
||||
|
||||
def subscribe_data(self, ws_symbol: str):
|
||||
""""""
|
||||
# Subscribe to market depth update
|
||||
self.req_id += 1
|
||||
req = {
|
||||
|
@ -416,6 +416,9 @@ class IbApi(EWrapper):
|
||||
accountName,
|
||||
)
|
||||
|
||||
if not contract.exchange:
|
||||
return
|
||||
|
||||
ib_size = contract.multiplier
|
||||
if not ib_size:
|
||||
ib_size = 1
|
||||
|
@ -299,7 +299,7 @@ class LogEngine(BaseEngine):
|
||||
file_path = log_path.joinpath(filename)
|
||||
|
||||
file_handler = logging.FileHandler(
|
||||
file_path, mode="w", encoding="utf8"
|
||||
file_path, mode="a", encoding="utf8"
|
||||
)
|
||||
file_handler.setLevel(self.level)
|
||||
file_handler.setFormatter(self.formatter)
|
||||
|
Loading…
Reference in New Issue
Block a user