def connect(self, 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: Endpoint
        """
        if reconnect:
            dxp.dxf_close_connection(self.__connection)

        con_status = dxp.dxf_get_current_connection_status(self.__connection, return_str=True)

        if con_status == 'Not connected':
            self.__connection = dxp.dxf_create_connection(self.address)

        return self
def test_fail_to_use_subscription_without_connection(connection):
    sub = dxc.dxf_create_subscription(cc=connection, event_type='Trade')
    dxc.dxf_close_connection(connection)
    dxc.dxf_add_symbols(sc=sub, symbols=['AAPL'])
 def close_connection(self):
     """
     Method to close connections and all related subscriptions.
     """
     dxp.dxf_close_connection(self.__connection)
def connection():
    # Setup
    con = dxc.dxf_create_connection(ValueStorage.demo_address)
    yield con  # pass var to test and test itself
    # Teardown
    dxc.dxf_close_connection(con)