Skip to content

Commit

Permalink
Merge pull request #32 from dxFeed/EN-1980-order-type-crash-fix
Browse files Browse the repository at this point in the history
[EN-1980] Order type crash fix
  • Loading branch information
alimantu authored Oct 7, 2020
2 parents cbd0b6c + 10186c4 commit 4cc9a00
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
16 changes: 9 additions & 7 deletions dxfeed/core/listeners/listener.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(&quotes[i].bid_exchange_code),
bid_exchange_code=unicode_from_dxf_const_string_t(&quotes[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(&quotes[i].ask_exchange_code),
ask_exchange_code=unicode_from_dxf_const_string_t(&quotes[i].ask_exchange_code,
size=1),
ask_price=quotes[i].ask_price,
ask_size=quotes[i].ask_size,
scope=<int> quotes[i].scope)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion dxfeed/core/utils/helpers.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 4 additions & 2 deletions dxfeed/core/utils/helpers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ 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
Parameters
----------
wcs: dxf_const_string_t, wchar_t
C string
size: int
Number of characters. By default -1
Returns
-------
Expand All @@ -21,7 +23,7 @@ cdef object unicode_from_dxf_const_string_t(dxf_const_string_t wcs):
"""
if wcs == NULL:
return ''
ret_val = <object>PyUnicode_FromWideChar(wcs, -1)
ret_val = <object>PyUnicode_FromWideChar(wcs, size)
return ret_val

cdef dxf_const_string_t dxf_const_string_t_from_unicode(object symbol):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>']
build = 'build.py'
Expand Down

0 comments on commit 4cc9a00

Please sign in to comment.