[Add] open_interest in tick/bar data
This commit is contained in:
parent
48d1c71e8b
commit
7afbf720a5
@ -3,12 +3,12 @@ from vnpy.event import EventEngine
|
|||||||
from vnpy.trader.engine import MainEngine
|
from vnpy.trader.engine import MainEngine
|
||||||
from vnpy.trader.ui import MainWindow, create_qapp
|
from vnpy.trader.ui import MainWindow, create_qapp
|
||||||
|
|
||||||
from vnpy.gateway.binance import BinanceGateway
|
# from vnpy.gateway.binance import BinanceGateway
|
||||||
# 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
|
||||||
@ -36,10 +36,10 @@ def main():
|
|||||||
|
|
||||||
main_engine = MainEngine(event_engine)
|
main_engine = MainEngine(event_engine)
|
||||||
|
|
||||||
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)
|
||||||
|
@ -294,6 +294,7 @@ class CtpMdApi(MdApi):
|
|||||||
datetime=datetime.strptime(timestamp, "%Y%m%d %H:%M:%S.%f"),
|
datetime=datetime.strptime(timestamp, "%Y%m%d %H:%M:%S.%f"),
|
||||||
name=symbol_name_map[symbol],
|
name=symbol_name_map[symbol],
|
||||||
volume=data["Volume"],
|
volume=data["Volume"],
|
||||||
|
open_interest=data["OpenInterest"],
|
||||||
last_price=data["LastPrice"],
|
last_price=data["LastPrice"],
|
||||||
limit_up=data["UpperLimitPrice"],
|
limit_up=data["UpperLimitPrice"],
|
||||||
limit_down=data["LowerLimitPrice"],
|
limit_down=data["LowerLimitPrice"],
|
||||||
|
@ -36,6 +36,7 @@ class TickData(BaseData):
|
|||||||
|
|
||||||
name: str = ""
|
name: str = ""
|
||||||
volume: float = 0
|
volume: float = 0
|
||||||
|
open_interest: float = 0
|
||||||
last_price: float = 0
|
last_price: float = 0
|
||||||
last_volume: float = 0
|
last_volume: float = 0
|
||||||
limit_up: float = 0
|
limit_up: float = 0
|
||||||
@ -87,6 +88,7 @@ class BarData(BaseData):
|
|||||||
|
|
||||||
interval: Interval = None
|
interval: Interval = None
|
||||||
volume: float = 0
|
volume: float = 0
|
||||||
|
open_interest: float = 0
|
||||||
open_price: float = 0
|
open_price: float = 0
|
||||||
high_price: float = 0
|
high_price: float = 0
|
||||||
low_price: float = 0
|
low_price: float = 0
|
||||||
|
@ -177,11 +177,13 @@ class BarGenerator:
|
|||||||
high_price=tick.last_price,
|
high_price=tick.last_price,
|
||||||
low_price=tick.last_price,
|
low_price=tick.last_price,
|
||||||
close_price=tick.last_price,
|
close_price=tick.last_price,
|
||||||
|
open_interest=tick.open_interest
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.bar.high_price = max(self.bar.high_price, tick.last_price)
|
self.bar.high_price = max(self.bar.high_price, tick.last_price)
|
||||||
self.bar.low_price = min(self.bar.low_price, tick.last_price)
|
self.bar.low_price = min(self.bar.low_price, tick.last_price)
|
||||||
self.bar.close_price = tick.last_price
|
self.bar.close_price = tick.last_price
|
||||||
|
self.bar.open_interest = tick.open_interest
|
||||||
self.bar.datetime = tick.datetime
|
self.bar.datetime = tick.datetime
|
||||||
|
|
||||||
if self.last_tick:
|
if self.last_tick:
|
||||||
@ -221,6 +223,7 @@ class BarGenerator:
|
|||||||
# Update close price/volume into window bar
|
# Update close price/volume into window bar
|
||||||
self.window_bar.close_price = bar.close_price
|
self.window_bar.close_price = bar.close_price
|
||||||
self.window_bar.volume += int(bar.volume)
|
self.window_bar.volume += int(bar.volume)
|
||||||
|
self.window_bar.open_interest = bar.open_interest
|
||||||
|
|
||||||
# Check if window bar completed
|
# Check if window bar completed
|
||||||
finished = False
|
finished = False
|
||||||
|
Loading…
Reference in New Issue
Block a user