[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.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.futu import FutuGateway
|
||||
# from vnpy.gateway.ib import IbGateway
|
||||
# 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.tiger import TigerGateway
|
||||
# from vnpy.gateway.oes import OesGateway
|
||||
@ -36,10 +36,10 @@ def main():
|
||||
|
||||
main_engine = MainEngine(event_engine)
|
||||
|
||||
main_engine.add_gateway(BinanceGateway)
|
||||
# main_engine.add_gateway(BinanceGateway)
|
||||
# main_engine.add_gateway(XtpGateway)
|
||||
# main_engine.add_gateway(CtpGateway)
|
||||
# main_engine.add_gateway(CtptestGateway)
|
||||
main_engine.add_gateway(CtptestGateway)
|
||||
# main_engine.add_gateway(FemasGateway)
|
||||
# main_engine.add_gateway(IbGateway)
|
||||
# main_engine.add_gateway(FutuGateway)
|
||||
|
@ -294,6 +294,7 @@ class CtpMdApi(MdApi):
|
||||
datetime=datetime.strptime(timestamp, "%Y%m%d %H:%M:%S.%f"),
|
||||
name=symbol_name_map[symbol],
|
||||
volume=data["Volume"],
|
||||
open_interest=data["OpenInterest"],
|
||||
last_price=data["LastPrice"],
|
||||
limit_up=data["UpperLimitPrice"],
|
||||
limit_down=data["LowerLimitPrice"],
|
||||
|
@ -36,6 +36,7 @@ class TickData(BaseData):
|
||||
|
||||
name: str = ""
|
||||
volume: float = 0
|
||||
open_interest: float = 0
|
||||
last_price: float = 0
|
||||
last_volume: float = 0
|
||||
limit_up: float = 0
|
||||
@ -87,6 +88,7 @@ class BarData(BaseData):
|
||||
|
||||
interval: Interval = None
|
||||
volume: float = 0
|
||||
open_interest: float = 0
|
||||
open_price: float = 0
|
||||
high_price: float = 0
|
||||
low_price: float = 0
|
||||
|
@ -177,11 +177,13 @@ class BarGenerator:
|
||||
high_price=tick.last_price,
|
||||
low_price=tick.last_price,
|
||||
close_price=tick.last_price,
|
||||
open_interest=tick.open_interest
|
||||
)
|
||||
else:
|
||||
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.close_price = tick.last_price
|
||||
self.bar.open_interest = tick.open_interest
|
||||
self.bar.datetime = tick.datetime
|
||||
|
||||
if self.last_tick:
|
||||
@ -221,6 +223,7 @@ class BarGenerator:
|
||||
# Update close price/volume into window bar
|
||||
self.window_bar.close_price = bar.close_price
|
||||
self.window_bar.volume += int(bar.volume)
|
||||
self.window_bar.open_interest = bar.open_interest
|
||||
|
||||
# Check if window bar completed
|
||||
finished = False
|
||||
|
Loading…
Reference in New Issue
Block a user