diff --git a/dxfeed/core/listeners/listener.pyx b/dxfeed/core/listeners/listener.pyx index a56c6c5..59ea437 100644 --- a/dxfeed/core/listeners/listener.pyx +++ b/dxfeed/core/listeners/listener.pyx @@ -31,7 +31,7 @@ cdef void trade_default_listener(int event_type, events[i] = TradeTuple(symbol=unicode_from_dxf_const_string_t(symbol_name), sequence=trades[i].sequence, price=trades[i].price, - exchange_code=unicode_from_dxf_const_string_t(&trades[i].exchange_code), + exchange_code=unicode_from_dxf_const_string_t(&trades[i].exchange_code, size=1), size=trades[i].size, tick=trades[i].tick, change=trades[i].change, @@ -66,11 +66,13 @@ cdef void quote_default_listener(int event_type, time=quotes[i].time, time_nanos=quotes[i].time_nanos, bid_time=quotes[i].bid_time, - bid_exchange_code=unicode_from_dxf_const_string_t("es[i].bid_exchange_code), + bid_exchange_code=unicode_from_dxf_const_string_t("es[i].bid_exchange_code, + size=1), bid_price=quotes[i].bid_price, bid_size=quotes[i].bid_size, ask_time=quotes[i].ask_time, - ask_exchange_code=unicode_from_dxf_const_string_t("es[i].ask_exchange_code), + ask_exchange_code=unicode_from_dxf_const_string_t("es[i].ask_exchange_code, + size=1), ask_price=quotes[i].ask_price, ask_size=quotes[i].ask_size, scope= quotes[i].scope) @@ -102,7 +104,7 @@ cdef void summary_default_listener(int event_type, dxf_const_string_t symbol_nam prev_day_volume=summary[i].prev_day_volume, open_interest=summary[i].open_interest, raw_flags=summary[i].raw_flags, - exchange_code=unicode_from_dxf_const_string_t(&summary[i].exchange_code), + exchange_code=unicode_from_dxf_const_string_t(&summary[i].exchange_code, size=1), day_close_price_type=summary[i].day_close_price_type, prev_day_close_price_type=summary[i].prev_day_close_price_type, scope=summary[i].scope) @@ -166,7 +168,7 @@ cdef void time_and_sale_default_listener(int event_type, event_flags=tns[i].event_flags, index=tns[i].index, time=tns[i].time, - exchange_code=unicode_from_dxf_const_string_t(&tns[i].exchange_code), + exchange_code=unicode_from_dxf_const_string_t(&tns[i].exchange_code, size=1), price=tns[i].price, size=tns[i].size, bid_price=tns[i].bid_price, @@ -243,8 +245,8 @@ cdef void order_default_listener(int event_type, count=order[i].count, scope=order[i].scope, side=order[i].side, - exchange_code=unicode_from_dxf_const_string_t(&order[i].exchange_code), - source=unicode_from_dxf_const_string_t(&order[i].source[DXF_RECORD_SUFFIX_SIZE]), + exchange_code=unicode_from_dxf_const_string_t(&order[i].exchange_code, size=1), + source=unicode_from_dxf_const_string_t(&order[i].source[0]), market_maker=unicode_from_dxf_const_string_t(order[i].market_maker), spread_symbol=unicode_from_dxf_const_string_t(order[i].spread_symbol)) py_data.cython_internal_update_method(events) diff --git a/dxfeed/core/utils/helpers.pxd b/dxfeed/core/utils/helpers.pxd index 6cc4cda..9722442 100644 --- a/dxfeed/core/utils/helpers.pxd +++ b/dxfeed/core/utils/helpers.pxd @@ -5,6 +5,6 @@ cdef extern from *: PyObject * PyUnicode_FromWideChar(dxf_const_string_t w, Py_ssize_t size) dxf_const_string_t PyUnicode_AsWideCharString(object, Py_ssize_t *) -cdef object unicode_from_dxf_const_string_t(dxf_const_string_t wcs) +cdef object unicode_from_dxf_const_string_t(dxf_const_string_t wcs, int size=*) cdef dxf_const_string_t dxf_const_string_t_from_unicode(object symbol) \ No newline at end of file diff --git a/dxfeed/core/utils/helpers.pyx b/dxfeed/core/utils/helpers.pyx index 4c55b20..c1fd9ec 100644 --- a/dxfeed/core/utils/helpers.pyx +++ b/dxfeed/core/utils/helpers.pyx @@ -5,7 +5,7 @@ from dxfeed.core.pxd_include.DXTypes cimport * from pathlib import Path import dxfeed -cdef object unicode_from_dxf_const_string_t(dxf_const_string_t wcs): +cdef object unicode_from_dxf_const_string_t(dxf_const_string_t wcs, int size=-1): """ Cython function, callable from C to convert dxf_const_string_t(wchar_t) to unicode @@ -13,6 +13,8 @@ cdef object unicode_from_dxf_const_string_t(dxf_const_string_t wcs): ---------- wcs: dxf_const_string_t, wchar_t C string + size: int + Number of characters. By default -1 Returns ------- @@ -21,7 +23,7 @@ cdef object unicode_from_dxf_const_string_t(dxf_const_string_t wcs): """ if wcs == NULL: return '' - ret_val = PyUnicode_FromWideChar(wcs, -1) + ret_val = PyUnicode_FromWideChar(wcs, size) return ret_val cdef dxf_const_string_t dxf_const_string_t_from_unicode(object symbol): diff --git a/pyproject.toml b/pyproject.toml index 4051e56..7607b05 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = 'dxfeed' -version = '0.5.0' +version = '0.5.1' description = 'DXFeed Python API via C API' authors = ['Index Management Team '] build = 'build.py'