cefi.handler.capitalcom.CapitalHandler#
- class cefi.handler.capitalcom.CapitalHandler(**kwargs)[source]#
Bases:
CexClientCapital.com client using https://pypi.org/project/capitalcom-python/ via Capital.com API https://open-api.capital.com/
None
- Returns:
None
Initialize the client
Methods
calculate_pnl([period])no pnl info available via openapi endpoint
execute_order(order_params)Execute order
return account balance of a given ccxt exchange
get_account_pnl([period, from_date, to_date])Return account pnl.
Return account position.
get_bid(instrument)Asynchronously retrieves the bid for the specified instrument.
get_instrument_decimals(instrument)Get the number of decimal places for the instrument.
get_instrument_min_amount(instrument)Get the minimum amount needed for a specific instrument.
get_offer(instrument)Asynchronously fetches a ask/offer quote for the specified instrument.
get_order_amount(quantity, instrument[, ...])Calculate the order amount based on the risk percentage or money amount.
get_quote(instrument)Asynchronously fetches a ask/offer quote for the specified instrument.
get_trade_confirmation(trade, instrument, action)Asynchronously retrieves the trade confirmation for a given trade, instrument, and action.
Return the available balance of the trading asset from the account.
modify_position(order_params)Modify parameters such as SL / TP of a position that is opened No capability to modify amount to reduce
pre_order_checks(order_params)replace_instrument(instrument)Replace instrument by an alternative instrument, if the instrument is not in the mapping, it will be ignored.
shutdown()switch_account(account_number)Switches to the specified account.
- switch_account(account_number)[source]#
Switches to the specified account.
- Parameters:
account_number – The account number to switch to.
- Returns:
None
- async get_quote(instrument)[source]#
Asynchronously fetches a ask/offer quote for the specified instrument.
- Parameters:
instrument – The instrument for which the quote is to be fetched.
- Returns:
The fetched quote.
- async get_offer(instrument)#
Asynchronously fetches a ask/offer quote for the specified instrument.
- Parameters:
instrument – The instrument for which the quote is to be fetched.
- Returns:
The fetched quote.
- async get_bid(instrument)[source]#
Asynchronously retrieves the bid for the specified instrument.
- Parameters:
instrument – The instrument for which
retrieved. (the bid is to be)
- Returns:
The bid for the specified instrument.
- async get_account_balance()[source]#
return account balance of a given ccxt exchange
- Parameters:
None
- Returns:
balance
- async get_account_position()[source]#
Return account position. of a given exchange
- Parameters:
None
- Returns:
position
- async calculate_pnl(period=None)[source]#
no pnl info available via openapi endpoint
- Parameters:
None
- Returns:
pnl
- async get_trading_asset_balance()[source]#
Return the available balance of the trading asset from the account.
- Returns:
The available balance of the trading asset.
- Return type:
float
- async get_instrument_decimals(instrument)[source]#
Get the number of decimal places for the instrument.
- Returns:
The number of decimal places for the instrument.
- Return type:
int
- async get_instrument_min_amount(instrument)[source]#
Get the minimum amount needed for a specific instrument.
- Parameters:
instrument (str) – The instrument for which the minimum amount is needed.
- Returns:
The minimum amount needed for the specified instrument.
- Return type:
float
- async execute_order(order_params)[source]#
Execute order
- Parameters:
order_params (dict) – action(str) instrument(str) quantity(int)
- Returns:
trade_confirmation(dict)
- async modify_position(order_params)[source]#
Modify parameters such as SL / TP of a position that is opened No capability to modify amount to reduce
- Parameters:
order_params (dict) – action(str) instrument(str) quantity(int) stop_price(int) stop_distance(int) stop_amount(int) take_profit_price(int) take_profit_distance(int) take_profit_amount(int)
- Returns:
trade_confirmation(dict)
- async get_account_pnl(period=None, from_date=None, to_date=None)#
Return account pnl.
- Parameters:
None
- Returns:
pnl
- async get_order_amount(quantity, instrument, is_percentage=True)#
Calculate the order amount based on the risk percentage or money amount.
- Parameters:
quantity – The quantity of the order.
instrument – The instrument of the asset.
is_percentage – True if quantity is a risk percentage,
amount. (False if it is a money)
- Returns:
The calculated order amount.
- async get_trade_confirmation(trade, instrument, action)#
Asynchronously retrieves the trade confirmation for a given trade, instrument, and action.
- Parameters:
self – The object instance
trade – The trade object
instrument – The instrument for the trade
action – The action for the trade
- Returns:
A string containing the trade confirmation, or None if an error occurs.
- async replace_instrument(instrument)#
Replace instrument by an alternative instrument, if the instrument is not in the mapping, it will be ignored.
- Parameters:
order (dict)
- Returns:
dict
- async shutdown()#