Skip to content

Commit 99e3876

Browse files
anonymous-ljfangjia
authored andcommitted
feat: Event contract tick、Fee commission and Options leveling direction
1 parent 125bc2c commit 99e3876

14 files changed

Lines changed: 136 additions & 9 deletions

‎samples/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.0.1'
1+
__version__ = '2.0.2'

‎samples/data/data_streaming_client_event.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def my_connect_success_func(client, api_client, quotes_session_id):
4343
print("connect success with session_id:%s" % quotes_session_id)
4444
# subscribe
4545
symbols = ['KXNHLGAME-26JAN21ANACOL-ANA', 'KXNBAGAME-26JAN20LACCHI-LAC']
46-
sub_types = [SubscribeType.QUOTE.name, SubscribeType.SNAPSHOT.name]
46+
sub_types = [SubscribeType.QUOTE.name, SubscribeType.SNAPSHOT.name, SubscribeType.TICK.name]
4747
client.subscribe(symbols, Category.US_EVENT.name, sub_types)
4848

4949
def my_quotes_message_func(client, topic, quotes):

‎samples/trade/trade_client_v3.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@
247247
# ============================================================
248248

249249
# normal option order
250+
# position_intent: Currently, only the US market is supported, and only options orders are allowed.
250251
normal_option_client_order_id = uuid.uuid4().hex
251252
new_normal_option_orders = [
252253
{
@@ -259,6 +260,7 @@
259260
"side": "BUY",
260261
"time_in_force": "GTC",
261262
"entrust_type": "QTY",
263+
"position_intent": "BUY_TO_OPEN",
262264
"legs": [
263265
{
264266
"side": "BUY",

‎webull/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.0.1'
1+
__version__ = '2.0.2'

‎webull/core/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '2.0.1'
1+
__version__ = '2.0.2'
22

33
import logging
44

‎webull/data/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# coding=utf-8
22

3-
__version__ = '2.0.1'
3+
__version__ = '2.0.2'

‎webull/data/data_streaming_client.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
from webull.data.quotes.market_streaming_data import MarketDataStreaming
1919
from webull.data.quotes.subscribe.event_depth_decoder import EventDepthDecoder
2020
from webull.data.quotes.subscribe.event_snapshot_decoder import EventSnapshotDecoder
21+
from webull.data.quotes.subscribe.event_tick_decoder import EventTickDecoder
2122
from webull.data.quotes.subscribe.payload_type import PAYLOAD_TYPE_QUOTE, PAYLOAD_TYPE_SHAPSHOT, PAYLOAD_TYPE_TICK, \
22-
PAYLOAD_TYPE_EVENT_SHAPSHOT, PAYLOAD_TYPE_EVENT_DEPTH
23+
PAYLOAD_TYPE_EVENT_SHAPSHOT, PAYLOAD_TYPE_EVENT_DEPTH, PAYLOAD_TYPE_EVENT_TICK
2324
from webull.data.quotes.subscribe.quote_decoder import QuoteDecoder
2425
from webull.data.quotes.subscribe.snapshot_decoder import SnapshotDecoder
2526
from webull.data.quotes.subscribe.tick_decoder import TickDecoder
@@ -44,6 +45,7 @@ def __init__(self, app_key, app_secret, region_id, session_id, http_host=None,
4445
self.register_payload_decoder(PAYLOAD_TYPE_TICK, TickDecoder())
4546
self.register_payload_decoder(PAYLOAD_TYPE_EVENT_DEPTH, EventDepthDecoder())
4647
self.register_payload_decoder(PAYLOAD_TYPE_EVENT_SHAPSHOT, EventSnapshotDecoder())
48+
self.register_payload_decoder(PAYLOAD_TYPE_EVENT_TICK, EventTickDecoder())
4749

4850
@property
4951
def on_connect_success(self):
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2022 Webull
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# coding=utf-8
15+
16+
from webull.data.quotes.subscribe.message_pb2 import EventTick
17+
from webull.data.quotes.subscribe.event_tick_result import EventTickResult
18+
19+
from webull.data.internal.quotes_payload_decoder import BaseQuotesPayloadDecoder
20+
21+
22+
23+
class EventTickDecoder(BaseQuotesPayloadDecoder):
24+
def __init__(self):
25+
super().__init__()
26+
27+
def parse(self, payload):
28+
eventTick = EventTick()
29+
eventTick.ParseFromString(payload)
30+
return EventTickResult(eventTick)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright 2022 Webull
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# coding=utf-8
16+
17+
from decimal import Decimal
18+
from webull.data.quotes.subscribe.basic_result import BasicResult
19+
20+
21+
class EventTickResult:
22+
def __init__(self, pb_event_tick):
23+
self.basic = BasicResult(pb_event_tick.basic)
24+
self.time = pb_event_tick.time
25+
self.yes_price = Decimal(pb_event_tick.yes_price) if pb_event_tick.yes_price else None
26+
self.no_price = Decimal(pb_event_tick.no_price) if pb_event_tick.no_price else None
27+
self.volume = pb_event_tick.volume
28+
self.side = pb_event_tick.side
29+
self.trade_id = pb_event_tick.trade_id
30+
31+
def get_basic(self):
32+
return self.basic
33+
34+
def get_time(self):
35+
return self.time
36+
37+
def get_yes_price(self):
38+
return self.yes_price
39+
40+
def get_no_price(self):
41+
return self.no_price
42+
43+
def get_volume(self):
44+
return self.volume
45+
46+
def get_side(self):
47+
return self.side
48+
49+
def get_trade_id(self):
50+
return self.trade_id
51+
52+
def __repr__(self):
53+
return "basic: %s,time: %s,yes_price: %s,no_price:%s,volume:%s,side:%s,trade_id:%s" % (self.basic, self.time, self.yes_price, self.no_price, self.volume, self.side, self.trade_id)
54+
55+
def __str__(self):
56+
return self.__repr__()

‎webull/data/quotes/subscribe/message.proto‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,14 @@ message EventQuote {
9292
message EventAskBid {
9393
string price = 1;
9494
string size = 2;
95+
}
96+
97+
message EventTick {
98+
Basic basic = 1;
99+
string yes_price = 2;
100+
string no_price = 3;
101+
string volume = 4;
102+
string side = 5;
103+
string trade_id = 6;
104+
string time = 7;
95105
}

0 commit comments

Comments
 (0)