API Reference¶
This page contains only automatically generated documentation to functions, classes, methods, etc.
API¶
-
class
dxfeed.wrappers.endpoint.
Endpoint
(connection_address: str = 'demo.dxfeed.com:7300', connect: bool = True)¶ Class for connection management. After successful creation Instance will be connected to server with provided credentials
-
connection_status
¶ Status of current connection
Type: str
-
address
¶ Current connection endpoint address
Type: str
-
close_connection
()¶ Method to close connections and all related subscriptions.
-
connect
(reconnect: bool = True)¶ Creates connection. If connection status differs from “Not connected” and reconnect is False, does nothing
Parameters: reconnect (bool) – When True closes previous connection. Default - True Returns: self Return type: Endpoint
-
create_subscription
(event_type: str, date_time: Union[str, datetime.datetime] = None)¶ Method creates certain event type subscription and returns Subscription class
Parameters: - event_type (str) – One of possible event types: ‘Trade’, ‘Quote’, ‘Summary’, ‘Profile’, ‘Order’, ‘TimeAndSale’, ‘Candle’, ‘TradeETH’, ‘SpreadOrder’, ‘Greeks’, ‘TheoPrice’, ‘Underlying’, ‘Series’, ‘Configuration’ or ‘’
- date_time (str or datetime.datetime) – If present timed subscription will be created (conflated stream). For sting date format is following: %Y-%m-%d %H:%M:%S.%f. If None - stream subscription will be created. Default - None.
Note
Some event types (e.g. Candle) support only timed subscription.
Returns: subscription – Subscription class related to current connection Return type: Subscription
-
-
class
dxfeed.wrappers.subscription.
Subscription
(connection, event_type: str, date_time: Union[str, datetime.datetime], exact_format: bool = True)¶ Class for subscription management. Recommended to be created only via create_subscription method in Endpoint class. Also stores incoming events
-
event_type
¶ One of possible event types: ‘Trade’, ‘Quote’, ‘Summary’, ‘Profile’, ‘Order’, ‘TimeAndSale’, ‘Candle’, ‘TradeETH’, ‘SpreadOrder’, ‘Greeks’, ‘TheoPrice’, ‘Underlying’, ‘Series’, ‘Configuration’ or ‘’
Type: str
-
symbols
¶ Symbols of current subscription.
Type: Iterable
Note
Some event types (e.g. Candle) support only timed subscription.
-
add_symbols
(symbols: Union[str, Iterable[str]])¶ Method to add symbol. Supports addition of one symbol as a string as well as list of symbols. If no event handler was set, DefaultHandler will be initialized.
Parameters: symbols (str, Iterable) – Symbols to add. Previously added and remained symbols are ignored on C-API level Returns: self Return type: Subscription
-
close_subscription
()¶ Method to close subscription. All received data will remain in the object.
-
get_event_handler
()¶ Method to get event handler. If no handlers passed previously returns None.
Returns: handler Return type: EventHandler
-
remove_symbols
(symbols: Union[str, Iterable[str], None] = None)¶ Method removes symbols from subscription. If no symbols provided removes all symbols
Parameters: symbols (str, Iterable) – One ticker or list of tickers to remove from subscription Returns: self Return type: Subscription
-
set_event_handler
(handler: dxfeed.core.utils.handler.EventHandler)¶ Method to set the handler.
Parameters: handler (EventHandler) – Event handler with update method defined. Returns: self Return type: Subscription
-
-
class
dxfeed.core.utils.handler.
DefaultHandler
¶ -
get_dataframe
()¶ Returns received data as pandas.DataFrame object.
Warning
There are no restriction on attaching one event handler to several subscriptions. In this case, method will work correctly if different subscriptions have same event type. Otherwise error will occur.
Parameters: keep (bool) – When False clears internal DequeWithLock object after call. Default True. Returns: df – Dataframe with received events. Return type: pandas.DataFrame
-
get_list
()¶ Method to get data stored in DequeWithLock as list.
Parameters: keep (bool) – When False clears internal DequeWithLock object after call. Default True. Returns: data – List of received events. Return type: list
-
update
()¶ Utility method that is called by underlying Cython level when new event is received. Stores events in DequeWithLock.
Parameters: event (list) – List of various data specific to certain event type.
-
-
class
dxfeed.core.utils.handler.
EventHandler
¶ Master class for user defined event handlers. update method should be considered as abstract.
-
columns
¶ After attaching listener the field contains one-word descriptors of the values in upcoming event the order coincides
Type: list
-
update
()¶ Method that is called, when event arrives to related Subscription. Currently (Cython version 0.29.17), abstract methods are not implemented, so this implementation is sort of stub method.
Parameters: event (list) – List of various data specific to certain event type
-
Low-level API¶
-
class
dxfeed.core.DXFeedPy.
ConnectionClass
¶ Data structure that contains connection
-
add_weakref
()¶ Method to link ConnectionClass with its users (e.g. SubscriptionClass) via weak reference.
Parameters: - obj (SubscriptionClass) – Object to be linked to ConnectionClass
- ------- –
-
get_weakrefs
()¶ Method to get list of references to all subscriptions related to current connection.
Returns: List of weakref objects. Empty list if no refs Return type: list
-
-
class
dxfeed.core.DXFeedPy.
SubscriptionClass
¶ Data structure that contains subscription and related fields
-
set_event_handler
()¶ Method to assign event handler to SubscriptionClass. If the SubscriptionClass already has active listener the method will save the listener. After that listener will be reattached.
Parameters: event_handler (EventHandler) – Handler to attach to SubscriptionClass
-
-
dxfeed.core.DXFeedPy.
dxf_add_symbols
()¶ Adds symbols to subscription
Parameters: - sc (SubscriptionClass) – SubscriptionClass with information about subscription
- symbols (list) – List of symbols to add
-
dxfeed.core.DXFeedPy.
dxf_attach_custom_listener
()¶ Attaches custom listener
Parameters: - sc (SubscriptionClass) – SubscriptionClass with information about subscription
- fw (FuncWrapper) – c function wrapped in FuncWrapper class with Cython
-
dxfeed.core.DXFeedPy.
dxf_attach_listener
()¶ Function attaches default listener according to subscription type
Parameters: sc (SubscriptionClass) – SubscriptionClass with information about subscription
-
dxfeed.core.DXFeedPy.
dxf_clear_symbols
()¶ Removes all symbols from the subscription
Parameters: sc (SubscriptionClass) – SubscriptionClass with information about subscription
-
dxfeed.core.DXFeedPy.
dxf_close_connection
()¶ Closes connection
Parameters: cc (ConnectionClass) – Variable with connection information
-
dxfeed.core.DXFeedPy.
dxf_close_subscription
()¶ Closes subscription
Parameters: sc (SubscriptionClass) – SubscriptionClass with information about subscription
-
dxfeed.core.DXFeedPy.
dxf_create_connection
()¶ Function creates connection to dxfeed given url address
Parameters: address (str) – One of possible connection addresses:
- the single address: host:port or just host
- address with credentials: host:port[username=xxx,password=yyy]
- multiple addresses: (host1:port1)(host2)(host3:port3[username=xxx,password=yyy])
- the data from file: /path/to/file on nix and drive:pathtofile on Windows
Default: demo.dxfeed.com:7300
Returns: cc – Cython ConnectionClass with information about connection Return type: ConnectionClass
-
dxfeed.core.DXFeedPy.
dxf_create_connection_auth_bearer
()¶ Function creates connection to dxfeed given url address and token
Parameters: - address (str) – dxfeed url address
- token (str) – dxfeed token
Returns: cc – Cython ConnectionClass with information about connection
Return type:
-
dxfeed.core.DXFeedPy.
dxf_create_subscription
()¶ Function creates subscription and writes all relevant information to SubscriptionClass.
Parameters: - cc (ConnectionClass) – Variable with connection information
- event_type (str) – Event types: ‘Trade’, ‘Quote’, ‘Summary’, ‘Profile’, ‘Order’, ‘TimeAndSale’, ‘Candle’, ‘TradeETH’, ‘SpreadOrder’, ‘Greeks’, ‘TheoPrice’, ‘Underlying’, ‘Series’, ‘Configuration’ or ‘’
Returns: sc – Cython SubscriptionClass with information about subscription
Return type:
-
dxfeed.core.DXFeedPy.
dxf_create_subscription_timed
()¶ Creates a timed subscription with the specified parameters.
Notes
Default limit for ‘Candle’ event type is 8000 records. The other event types have default limit of 1000 records.
Parameters: - cc (ConnectionClass) – Variable with connection information
- event_type (str) – Event types: ‘Trade’, ‘Quote’, ‘Summary’, ‘Profile’, ‘Order’, ‘TimeAndSale’, ‘Candle’, ‘TradeETH’, ‘SpreadOrder’, ‘Greeks’, ‘TheoPrice’, ‘Underlying’, ‘Series’, ‘Configuration’ or ‘’
- time (int) – UTC time in the past (unix time in milliseconds)
Returns: sc – Cython SubscriptionClass with information about subscription
Return type:
-
dxfeed.core.DXFeedPy.
dxf_detach_listener
()¶ Detaches any listener
Parameters: sc (SubscriptionClass) – SubscriptionClass with information about subscription
-
dxfeed.core.DXFeedPy.
dxf_get_current_connected_address
()¶ Returns current connected address
Parameters: cc (ConnectionClass) – Variable with connection information Returns: address – Current connected address Return type: str
-
dxfeed.core.DXFeedPy.
dxf_get_current_connection_status
()¶ Returns one of four possible statuses
Parameters: - cc (ConnectionClass) – Variable with connection information
- return_str (bool) – When True returns connection status in string format, otherwise internal c representation as integer
-
dxfeed.core.DXFeedPy.
dxf_get_subscription_event_types
()¶ Gets subscription event type
Parameters: - sc (SubscriptionClass) – SubscriptionClass with information about subscription
- return_str (bool) – When True returns event type in string format, otherwise internal c representation as integer
Returns: Subscription type
Return type: str or int
-
dxfeed.core.DXFeedPy.
dxf_get_symbols
()¶ Retrieves the list of symbols currently added to the subscription.
Parameters: sc (SubscriptionClass) – SubscriptionClass with information about subscription Returns: List of unicode strings of subscription symbols Return type: list
-
dxfeed.core.DXFeedPy.
dxf_initialize_logger
()¶ Initializes the internal logger. Various actions and events, including the errors, are being logged throughout the library. They may be stored into the file.
Parameters: - file_name (str) – A full path to the file where the log is to be stored
- rewrite_file (bool) – A flag defining the file open mode if it’s True then the log file will be rewritten
- show_timezone_info (bool) – A flag defining the time display option in the log file if it’s True then the time will be displayed with the timezone suffix
- verbose (bool) – A flag defining the logging mode if it’s True then the verbose logging will be enabled
-
dxfeed.core.DXFeedPy.
dxf_remove_symbols
()¶ Removes several symbols from the subscription
Parameters: - sc (SubscriptionClass) – SubscriptionClass with information about subscription
- symbols (list) – List of symbols to remove
-
dxfeed.core.DXFeedPy.
process_last_error
()¶ Function retrieves last error
Parameters: verbose (bool) – If True error description is printed Returns: error_code – Error code is returned Return type: int
Utils functions¶
-
dxfeed.core.utils.helpers.
event_type_convert
()¶ The function converts event type given as string to int, used in C dxfeed dxfeed
Parameters: event_type (str) – - Event type: ‘Trade’, ‘Quote’, ‘Summary’, ‘Profile’, ‘Order’, ‘TimeAndSale’, ‘Candle’, ‘TradeETH’, ‘SpreadOrder’,
- ’Greeks’, ‘TheoPrice’, ‘Underlying’, ‘Series’, ‘Configuration’ or ‘’
Returns: Integer that corresponds to event type in C dxfeed dxfeed Return type: int
-
dxfeed.core.utils.helpers.
get_include
()¶ Function returns paths to header files of dxfeed-c-api library. Used for writing custom listeners
Returns: out_dir – List of paths to header files Return type: list
-
class
dxfeed.core.utils.data_class.
DequeWithLock
(iterable=(), maxlen=None)¶ Class that provides lock mechanism to deque from collections for append, copy and get operations
-
append
()¶ Add an element to the right side of the deque.
-
appendleft
()¶ Add an element to the left side of the deque.
-
clear
()¶ Remove all elements from the deque.
-
copy
()¶ Return a shallow copy of a deque.
-
count
(value) → integer -- return number of occurrences of value¶
-
extend
()¶ Extend the right side of the deque with elements from the iterable
-
extendleft
()¶ Extend the left side of the deque with elements from the iterable
-
index
(value[, start[, stop]]) → integer -- return first index of value.¶ Raises ValueError if the value is not present.
-
insert
()¶ D.insert(index, object) – insert object before index
-
maxlen
¶ maximum size of a deque or None if unbounded
-
pop
()¶ Remove and return the rightmost element.
-
popleft
()¶ Remove and return the leftmost element.
-
remove
()¶ D.remove(value) – remove first occurrence of value.
-
reverse
()¶ D.reverse() – reverse IN PLACE
-
rotate
()¶ Rotate the deque n steps to the right (default n=1). If n is negative, rotates left.
-
safe_append
(data: Any)¶ Method appends data while locked :param data: Data to append :type data: any
-
safe_get
(keep: bool = True)¶ Method that pops all the data with subsequent clearing
Parameters: keep (bool) – When False clears internal collections.deque object after call. Default True. Returns: list_to_return – List filled with data Return type: list
-