Leaders Management

A collection of API methods to perform leaders’ lookup / creation / amendment / removal / querying info.

com.nj4x.node.trade_copier.leader.create(leader)

WAMP procedure to define new Leader account.

param leader:Leader object to create. ClientId, MtAccountRef, Name, Description, TradedSymbols and Status attributes must be defined.
return:(dict) {Entity: Leader, Exception: object} - Entity element represents newly registered Leader or None in case of error. Exception field is populated in case of Leader creation error (e.g. leader for a same mt account already exist)
Example:
@inlineCallbacks
def create(self, leader):
    """
    This function is a wrapper for :func:`~com.nj4x.node.trade_copier.leader.create` `WAMP <https://wamp-proto.org>`_ API method.

    :return: :class:`.Leader` - newly registered Leader or *None* in case of error.
    :raises: *Exception* in case of any server error.
    """
    self._check_session()
    #
    res = yield self._session.call(u"com.nj4x.node.trade_copier.leader.create", leader)
    #
    if res.get("Exception") is None:
        return res.get("Entity")
    raise Exception(res['Exception']["Message"])
com.nj4x.node.trade_copier.leader.update(leader)

WAMP procedure to amend Leader account.

param leader:Leader object to update. Id attribute must be defined.
return:(dict) {Entity: Leader, Exception: object} - Entity element represents updated Leader. Exception field is populated in case of Leader amendment error
Example:
@inlineCallbacks
def update(self, leader):
    """
    This function is a wrapper for :func:`~com.nj4x.node.trade_copier.leader.update` `WAMP <https://wamp-proto.org>`_ API method.

    :return: :class:`.Leader` - updated Leader or *None* in case of error.
    :raises: *Exception* in case of any server error.
    """
    self._check_session()
    #
    res = yield self._session.call(u"com.nj4x.node.trade_copier.leader.update", leader)
    #
    if res.get("Exception") is None:
        return res.get("Entity")
    raise Exception(res['Exception']["Message"])
com.nj4x.node.trade_copier.leader.delete(leader)

WAMP procedure to unregister Leader account.

param leader:Leader object to delete. Id attribute must be defined.
return:(dict) {Exception: object} - Exception field is populated in case of Leader removal error
Example:
@inlineCallbacks
def delete(self, leader):
    """
    This function is a wrapper for :func:`~com.nj4x.node.trade_copier.leader.delete` `WAMP <https://wamp-proto.org>`_ API method.

    :raises: *Exception* in case of Leader removal error
    """
    self._check_session()
    #
    res = yield self._session.call(u"com.nj4x.node.trade_copier.leader.delete", leader)
    #
    if res.get("Exception") is None:
        return res.get("Entity")
    raise Exception(res['Exception']["Message"])
com.nj4x.node.trade_copier.leader.find_by_client_id(clientId: int)

WAMP procedure to lookup Leader account by referenced Client ID.

param clientId:(long) External system client ID to lookup linked Leader accounts.
return:(dict) {Entities: Leader [], Exception: object} - Entities list will be empty in case no Leaders are found. Exception field is populated in case of any system error.
Example:
@inlineCallbacks
def find_by_client_id(self, client_id: int):
    """
    This function is a wrapper for :func:`~com.nj4x.node.trade_copier.leader.find_by_client_id` `WAMP <https://wamp-proto.org>`_ API method.

    :return: list of :class:`.Leader` objects (if found) or *None* in case no Leaders exists for a specified client.
    :raises: *Exception* in case of any server error.
    """
    self._check_session()
    #
    res = yield self._session.call(u"com.nj4x.node.trade_copier.leader.find_by_client_id", client_id)
    #
    if res.get("Exception") is None:
        return res.get("Entities")
    raise Exception(res['Exception']["Message"])
com.nj4x.node.trade_copier.leader.find_all()

WAMP procedure to lookup all Leader accounts defined in a system.

return:(dict) {Entities: Leader [], Exception: object} - Entities list will be empty in case no Leaders are defined. Exception field is populated in case of any system error.
Example:
@inlineCallbacks
def find_all(self):
    """
    This function is a wrapper for :func:`~com.nj4x.node.trade_copier.leader.find_all` `WAMP <https://wamp-proto.org>`_ API method.

    :return: list of :class:`.Leader` objects (if found) or *None* in case no Leaders are defined in a system.
    :raises: *Exception* in case of any server error.
    """
    self._check_session()
    #
    res = yield self._session.call(u"com.nj4x.node.trade_copier.leader.find_all")
    #
    if res.get("Exception") is None:
        return res.get("Entities")
    raise Exception(res['Exception']["Message"])
com.nj4x.node.trade_copier.leader.find_by_id(id: int)

WAMP procedure to lookup the Leader by its ID.

param id:(long) primary key of the Leader to lookup.
return:(dict) {Entity: Leader, Exception: object} - Entity element will be None in case a Leader with requested ID not found. Exception field is populated in case of any system error.
Example:
class com.nj4x.node.trade_copier.leader.Leader(*args, **kwargs)

A class used to represent copy trading Leader

Id: long
Primary key
ClientId: long
External CRM system’s client ID
MtAccountRef: long
Reference to the MTAccount (mt account’s ID)
Name: str
User-defined Leader’s name
Description: str
User-defined description
TradedSymbols: list
List of symbol identifiers (str) the Leader allows to follow, e.g. [‘AUDCAD’, ‘AUDJPY’, ‘EURUSD’]
Status: int
Administrator’s defined Leader’s status: Pending=0, Approved=1, Rejected=2, Deactivated=3, Deleted=4
SuggestedAmountToInvest: int
user-defined amount (in USD) suggested for the investment into this Leader
MonthlySubscriptionFee: dict {‘Amount’: float}
user-defined Leader’s subscription fee
TradedOrderFee: dict {‘Amount’: float}
user-defined Leader’s fee per traded order
TradedVolumeFee: dict {‘Amount’: float}
user-defined Leader’s fee per traded volume