Skip to content

Commit 4cc9a00

Browse files
authored
Merge pull request #32 from dxFeed/EN-1980-order-type-crash-fix
[EN-1980] Order type crash fix
2 parents cbd0b6c + 10186c4 commit 4cc9a00

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

dxfeed/core/listeners/listener.pyx

+9-7
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ cdef void trade_default_listener(int event_type,
3131
events[i] = TradeTuple(symbol=unicode_from_dxf_const_string_t(symbol_name),
3232
sequence=trades[i].sequence,
3333
price=trades[i].price,
34-
exchange_code=unicode_from_dxf_const_string_t(&trades[i].exchange_code),
34+
exchange_code=unicode_from_dxf_const_string_t(&trades[i].exchange_code, size=1),
3535
size=trades[i].size,
3636
tick=trades[i].tick,
3737
change=trades[i].change,
@@ -66,11 +66,13 @@ cdef void quote_default_listener(int event_type,
6666
time=quotes[i].time,
6767
time_nanos=quotes[i].time_nanos,
6868
bid_time=quotes[i].bid_time,
69-
bid_exchange_code=unicode_from_dxf_const_string_t(&quotes[i].bid_exchange_code),
69+
bid_exchange_code=unicode_from_dxf_const_string_t(&quotes[i].bid_exchange_code,
70+
size=1),
7071
bid_price=quotes[i].bid_price,
7172
bid_size=quotes[i].bid_size,
7273
ask_time=quotes[i].ask_time,
73-
ask_exchange_code=unicode_from_dxf_const_string_t(&quotes[i].ask_exchange_code),
74+
ask_exchange_code=unicode_from_dxf_const_string_t(&quotes[i].ask_exchange_code,
75+
size=1),
7476
ask_price=quotes[i].ask_price,
7577
ask_size=quotes[i].ask_size,
7678
scope=<int> quotes[i].scope)
@@ -102,7 +104,7 @@ cdef void summary_default_listener(int event_type, dxf_const_string_t symbol_nam
102104
prev_day_volume=summary[i].prev_day_volume,
103105
open_interest=summary[i].open_interest,
104106
raw_flags=summary[i].raw_flags,
105-
exchange_code=unicode_from_dxf_const_string_t(&summary[i].exchange_code),
107+
exchange_code=unicode_from_dxf_const_string_t(&summary[i].exchange_code, size=1),
106108
day_close_price_type=summary[i].day_close_price_type,
107109
prev_day_close_price_type=summary[i].prev_day_close_price_type,
108110
scope=summary[i].scope)
@@ -166,7 +168,7 @@ cdef void time_and_sale_default_listener(int event_type,
166168
event_flags=tns[i].event_flags,
167169
index=tns[i].index,
168170
time=tns[i].time,
169-
exchange_code=unicode_from_dxf_const_string_t(&tns[i].exchange_code),
171+
exchange_code=unicode_from_dxf_const_string_t(&tns[i].exchange_code, size=1),
170172
price=tns[i].price,
171173
size=tns[i].size,
172174
bid_price=tns[i].bid_price,
@@ -243,8 +245,8 @@ cdef void order_default_listener(int event_type,
243245
count=order[i].count,
244246
scope=order[i].scope,
245247
side=order[i].side,
246-
exchange_code=unicode_from_dxf_const_string_t(&order[i].exchange_code),
247-
source=unicode_from_dxf_const_string_t(&order[i].source[DXF_RECORD_SUFFIX_SIZE]),
248+
exchange_code=unicode_from_dxf_const_string_t(&order[i].exchange_code, size=1),
249+
source=unicode_from_dxf_const_string_t(&order[i].source[0]),
248250
market_maker=unicode_from_dxf_const_string_t(order[i].market_maker),
249251
spread_symbol=unicode_from_dxf_const_string_t(order[i].spread_symbol))
250252
py_data.cython_internal_update_method(events)

dxfeed/core/utils/helpers.pxd

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ cdef extern from *:
55
PyObject * PyUnicode_FromWideChar(dxf_const_string_t w, Py_ssize_t size)
66
dxf_const_string_t PyUnicode_AsWideCharString(object, Py_ssize_t *)
77

8-
cdef object unicode_from_dxf_const_string_t(dxf_const_string_t wcs)
8+
cdef object unicode_from_dxf_const_string_t(dxf_const_string_t wcs, int size=*)
99

1010
cdef dxf_const_string_t dxf_const_string_t_from_unicode(object symbol)

dxfeed/core/utils/helpers.pyx

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ from dxfeed.core.pxd_include.DXTypes cimport *
55
from pathlib import Path
66
import dxfeed
77

8-
cdef object unicode_from_dxf_const_string_t(dxf_const_string_t wcs):
8+
cdef object unicode_from_dxf_const_string_t(dxf_const_string_t wcs, int size=-1):
99
"""
1010
Cython function, callable from C to convert dxf_const_string_t(wchar_t) to unicode
1111
1212
Parameters
1313
----------
1414
wcs: dxf_const_string_t, wchar_t
1515
C string
16+
size: int
17+
Number of characters. By default -1
1618
1719
Returns
1820
-------
@@ -21,7 +23,7 @@ cdef object unicode_from_dxf_const_string_t(dxf_const_string_t wcs):
2123
"""
2224
if wcs == NULL:
2325
return ''
24-
ret_val = <object>PyUnicode_FromWideChar(wcs, -1)
26+
ret_val = <object>PyUnicode_FromWideChar(wcs, size)
2527
return ret_val
2628

2729
cdef dxf_const_string_t dxf_const_string_t_from_unicode(object symbol):

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = 'dxfeed'
3-
version = '0.5.0'
3+
version = '0.5.1'
44
description = 'DXFeed Python API via C API'
55
authors = ['Index Management Team <[email protected]>']
66
build = 'build.py'

0 commit comments

Comments
 (0)