shared.tmp_shared

class shared.tmp_shared.FunctionCall(func, *args, **kwargs)[source]

Bases: object

execute()[source]
shared.tmp_shared.calculate_sl_stop_prices(order_side, reference_price, sl_trigger_percentage, sl_price_offset)[source]

Calculate stop loss trigger and execute prices based on the order side.

Parameters:
  • order_side – Either ‘buy’ or ‘sell’.

  • current_market_price – Current market price of the asset.

  • sl_trigger_percentage – Percentage for calculating the stop loss trigger price.

  • sl_price_offset – Offset for calculating the stop loss execute price.

Returns:

Tuple containing sl_trigger_price, sl_execute_price.

Raises:

ValueError – If order_side is not ‘buy’ or ‘sell’.

shared.tmp_shared.calculate_sl_stop_prices_usd(order_side, reference_price, sl_trigger_usd, sl_execute_usd)[source]

Calculate stop loss trigger and execute prices based on the order side using USD values.

Parameters:
  • order_side – Either ‘buy’ or ‘sell’.

  • reference_price – Current market price of the asset.

  • sl_trigger_usd – USD value for calculating the stop loss trigger price.

  • sl_execute_usd – USD value for calculating the stop loss execute price.

Returns:

Tuple containing sl_trigger_price, sl_execute_price.

Raises:

ValueError – If order_side is not ‘buy’ or ‘sell’.

shared.tmp_shared.calculate_stop_prices(order_side, reference_price, sl_trigger_price_offset, stop_surplus_trigger_percentage, sl_execution_price_offset, stop_surplus_price_offset)[source]

Calculate stop loss and stop surplus trigger and execute prices based on the order side.

Parameters:
  • order_side – Either ‘buy’ or ‘sell’.

  • current_market_price – Current market price of the asset.

  • sl_trigger_price_offset – Percentage for calculating the stop loss trigger price.

  • stop_surplus_trigger_percentage – Percentage for calculating the stop surplus trigger price.

  • sl_execution_price_offset – Offset for calculating the stop loss execute price.

  • stop_surplus_price_offset – Offset for calculating the stop surplus execute price.

Returns:

Tuple containing stop_loss_trigger_price, stop_surplus_trigger_price, stop_loss_execute_price, stop_surplus_execute_price.

Raises:

ValueError – If order_side is not ‘buy’ or ‘sell’.

shared.tmp_shared.calculate_tp_stop_prices(order_side, reference_price, tp_trigger_percentage, tp_execution_price_offset)[source]

Calculate take profit trigger and execute prices based on the order side.

Parameters:
  • order_side – Either ‘buy’ or ‘sell’.

  • current_market_price – Current market price of the asset.

  • tp_trigger_percentage – Percentage for calculating the take profit trigger price.

  • tp_execution_price_offset – Offset for calculating the take profit execute price.

Returns:

Tuple containing tp_trigger_price, tp_execute_price.

Raises:

ValueError – If order_side is not ‘buy’ or ‘sell’.

shared.tmp_shared.calculate_tp_stop_prices_usd(order_side, reference_price, tp_trigger_usd, tp_execute_usd)[source]

Calculate take profit trigger and execute prices based on the order side using USD values.

Parameters:
  • order_side – Either ‘buy’ or ‘sell’.

  • reference_price – Current market price of the asset.

  • tp_trigger_usd – USD value for calculating the take profit trigger price.

  • tp_execute_usd – USD value for calculating the take profit execute price.

Returns:

Tuple containing tp_trigger_price, tp_execute_price.

Raises:

ValueError – If order_side is not ‘buy’ or ‘sell’.

shared.tmp_shared.ccy_contracts_to_usd(contracts_amount, ccy_contract_size, ccy_last_price, usd_base_ratio, leverage=None)[source]
shared.tmp_shared.ccy_usd_to_contracts(usd_equivalent, ccy_contract_size, ccy_last_price, minimum_contract_size, max_market_contract_size, usd_base_ratio, leverage, ctValCcy)[source]
shared.tmp_shared.execute_function_calls(function_calls)[source]
shared.tmp_shared.get_timestamp_from_days_ago(days_ago=0, hours_ago=0, minutes_ago=0, seconds_ago=0, reference_time: datetime | None = None)[source]
Inheritance diagram of shared.tmp_shared