code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def process_order_failed_event(self,
event_tag: int,
market: ConnectorBase,
event: MarketOrderFailureEvent):
"""
Processes the order failed event. This method should be overridden by subclasses.
... |
Processes the order failed event. This method should be overridden by subclasses.
:param event_tag: The event tag.
:param market: The market where the event occurred.
:param event: The event.
| process_order_failed_event | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/executor_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/executor_base.py | Apache-2.0 |
def _initialize_cached_performance(self):
"""
Initialize cached performance by querying the database for stored executors and positions.
If initial positions are provided for a controller, skip loading database positions for that controller.
"""
db_executors = MarketsRecorder.get... |
Initialize cached performance by querying the database for stored executors and positions.
If initial positions are provided for a controller, skip loading database positions for that controller.
| _initialize_cached_performance | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/executor_orchestrator.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/executor_orchestrator.py | Apache-2.0 |
def _update_cached_performance(self, controller_id: str, executor_info: ExecutorInfo):
"""
Update the cached performance for a specific controller with an executor's information.
"""
report = self.cached_performance[controller_id]
report.realized_pnl_quote += executor_info.net_pn... |
Update the cached performance for a specific controller with an executor's information.
| _update_cached_performance | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/executor_orchestrator.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/executor_orchestrator.py | Apache-2.0 |
def _load_position_from_db(self, controller_id: str, db_position: Position):
"""
Load a position from the database and recreate it as a PositionHold object.
Since the database only stores net position data, we reconstruct the PositionHold
with the assumption that it represents the remain... |
Load a position from the database and recreate it as a PositionHold object.
Since the database only stores net position data, we reconstruct the PositionHold
with the assumption that it represents the remaining net position.
| _load_position_from_db | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/executor_orchestrator.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/executor_orchestrator.py | Apache-2.0 |
def _create_initial_positions(self):
"""
Create initial positions from config overrides.
Uses NaN for quote amounts initially - they will be calculated lazily when needed.
"""
for controller_id, initial_positions in self.initial_positions_by_controller.items():
if con... |
Create initial positions from config overrides.
Uses NaN for quote amounts initially - they will be calculated lazily when needed.
| _create_initial_positions | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/executor_orchestrator.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/executor_orchestrator.py | Apache-2.0 |
def stop(self):
"""
Stop the orchestrator task and all active executors.
"""
# first we stop all active executors
for controller_id, executors_list in self.active_executors.items():
for executor in executors_list:
if not executor.is_closed:
... |
Stop the orchestrator task and all active executors.
| stop | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/executor_orchestrator.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/executor_orchestrator.py | Apache-2.0 |
def store_all_positions(self):
"""
Store or update all positions in the database.
"""
markets_recorder = MarketsRecorder.get_instance()
for controller_id, positions_list in self.positions_held.items():
for position in positions_list:
mid_price = self.s... |
Store or update all positions in the database.
| store_all_positions | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/executor_orchestrator.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/executor_orchestrator.py | Apache-2.0 |
def execute_action(self, action: ExecutorAction):
"""
Execute the action and handle executors based on action type.
"""
controller_id = action.controller_id
if controller_id not in self.cached_performance:
self.active_executors[controller_id] = []
self.arc... |
Execute the action and handle executors based on action type.
| execute_action | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/executor_orchestrator.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/executor_orchestrator.py | Apache-2.0 |
def create_executor(self, action: CreateExecutorAction):
"""
Create an executor based on the configuration in the action.
"""
controller_id = action.controller_id
executor_config = action.executor_config
# For now, we replace the controller ID in the executor config with... |
Create an executor based on the configuration in the action.
| create_executor | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/executor_orchestrator.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/executor_orchestrator.py | Apache-2.0 |
def stop_executor(self, action: StopExecutorAction):
"""
Stop an executor based on the action details.
"""
controller_id = action.controller_id
executor_id = action.executor_id
executor = next(
(executor for executor in self.active_executors[controller_id] if... |
Stop an executor based on the action details.
| stop_executor | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/executor_orchestrator.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/executor_orchestrator.py | Apache-2.0 |
def store_executor(self, action: StoreExecutorAction):
"""
Store executor data based on the action details and update cached performance.
"""
controller_id = action.controller_id
executor_id = action.executor_id
executor = next(
(executor for executor in self... |
Store executor data based on the action details and update cached performance.
| store_executor | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/executor_orchestrator.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/executor_orchestrator.py | Apache-2.0 |
def get_positions_report(self) -> Dict[str, List[PositionSummary]]:
"""
Generate a report of all positions held.
"""
report = {}
for controller_id, positions_list in self.positions_held.items():
positions_summary = []
for position in positions_list:
... |
Generate a report of all positions held.
| get_positions_report | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/executor_orchestrator.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/executor_orchestrator.py | Apache-2.0 |
async def get_quote_asset_conversion_rate(self) -> Decimal:
"""
Fetch the conversion rate between the quote assets of the buying and selling markets.
Example: For M3M3/USDT and M3M3/SOL, fetch the SOL/USDT rate.
"""
# Fetch the conversion rate from the connector
try:
... |
Fetch the conversion rate between the quote assets of the buying and selling markets.
Example: For M3M3/USDT and M3M3/SOL, fetch the SOL/USDT rate.
| get_quote_asset_conversion_rate | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/arbitrage_executor/arbitrage_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/arbitrage_executor/arbitrage_executor.py | Apache-2.0 |
def current_market_price(self):
"""
This method is responsible for getting the current market price to be used as a reference for control barriers
"""
price_type = PriceType.BestBid if self.config.side == TradeType.BUY else PriceType.BestAsk
return self.get_price(self.config.conn... |
This method is responsible for getting the current market price to be used as a reference for control barriers
| current_market_price | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def close_price(self):
"""
This method is responsible for getting the close price, if the executor is active, it will return the current
market price, otherwise it will return the average price of the closed orders
"""
if self.status == RunnableStatus.TERMINATED and len(self._clo... |
This method is responsible for getting the close price, if the executor is active, it will return the current
market price, otherwise it will return the average price of the closed orders
| close_price | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def trade_pnl_pct(self):
"""
This method is responsible for calculating the trade pnl (Pure pnl without fees)
"""
if self.current_position_average_price != Decimal("0"):
if self.config.side == TradeType.BUY:
return (self.close_price - self.current_position_ave... |
This method is responsible for calculating the trade pnl (Pure pnl without fees)
| trade_pnl_pct | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def is_any_amount_lower_than_min_order_size(self):
"""
This method is responsible for checking if any amount is lower than the minimum order size
"""
notional_size_check = any([amount < self.connectors[self.config.connector_name].trading_rules[self.config.trading_pair].min_notional_size ... |
This method is responsible for checking if any amount is lower than the minimum order size
| is_any_amount_lower_than_min_order_size | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def get_cum_fees_quote(self) -> Decimal:
"""
This method is responsible for calculating the cumulative fees in quote asset
"""
all_orders = self._open_orders + self._close_orders
return sum([order.cum_fees_quote for order in all_orders]) |
This method is responsible for calculating the cumulative fees in quote asset
| get_cum_fees_quote | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def validate_sufficient_balance(self):
"""
This method is responsible for checking the budget
"""
order_candidates = []
for amount_quote, price in zip(self.config.amounts_quote, self.config.prices):
amount_base = amount_quote / price
is_maker = self.config... |
This method is responsible for checking the budget
| validate_sufficient_balance | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
async def control_task(self):
"""
This task is responsible for creating and closing position executors
"""
if self.status == RunnableStatus.RUNNING:
self.control_open_order_process()
self.control_barriers()
elif self.status == RunnableStatus.SHUTTING_DOWN:... |
This task is responsible for creating and closing position executors
| control_task | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def control_open_order_process(self):
"""
This method is responsible for controlling the opening process
"""
next_level = len(self._open_orders)
if next_level < self.n_levels:
close_price = self.get_price(connector_name=self.config.connector_name,
... |
This method is responsible for controlling the opening process
| control_open_order_process | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def create_dca_order(self, level: int):
"""
This method is responsible for creating a new DCA order
"""
price = self.config.prices[level]
amount = self.config.amounts_quote[level] / price
order_id = self.place_order(connector_name=self.config.connector_name,
... |
This method is responsible for creating a new DCA order
| create_dca_order | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def control_barriers(self):
"""
This method is responsible for controlling the active executors
"""
self.control_stop_loss()
self.control_trailing_stop()
self.control_take_profit()
self.control_time_limit() |
This method is responsible for controlling the active executors
| control_barriers | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def control_stop_loss(self):
"""
This method is responsible for controlling the stop loss. In order to trigger the stop loss all the orders must
be completed and the net pnl must be lower than the stop loss. If it's maker mode, the stop loss will be
triggered if the net pnl is lower than... |
This method is responsible for controlling the stop loss. In order to trigger the stop loss all the orders must
be completed and the net pnl must be lower than the stop loss. If it's maker mode, the stop loss will be
triggered if the net pnl is lower than the stop loss and all the orders were e... | control_stop_loss | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def control_trailing_stop(self):
"""
This method is responsible for controlling the trailing stop. In order to activated the trailing stop the net
pnl must be higher than the activation price delta. Once the trailing stop is activated, the trailing stop trigger
will be the activation pri... |
This method is responsible for controlling the trailing stop. In order to activated the trailing stop the net
pnl must be higher than the activation price delta. Once the trailing stop is activated, the trailing stop trigger
will be the activation price delta minus the trailing delta and the st... | control_trailing_stop | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def early_stop(self, keep_position: bool = False):
"""
This method allows strategy to stop the executor early.
"""
if keep_position:
self.close_type = CloseType.POSITION_HOLD
self.cancel_open_orders()
self.stop()
else:
self.close_ty... |
This method allows strategy to stop the executor early.
| early_stop | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def place_close_order_and_cancel_open_orders(self, price: Decimal = Decimal("NaN")):
"""
This method is responsible for placing the close order
"""
self.cancel_open_orders()
self.place_close_order(price)
self._status = RunnableStatus.SHUTTING_DOWN
self.close_times... |
This method is responsible for placing the close order
| place_close_order_and_cancel_open_orders | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def _is_within_activation_bounds(self, order_price: Decimal, close_price: Decimal) -> bool:
"""
This method is responsible for checking if the order is within the activation bounds
"""
activation_bounds = self.config.activation_bounds
if self.config.mode == DCAMode.MAKER:
... |
This method is responsible for checking if the order is within the activation bounds
| _is_within_activation_bounds | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
async def control_shutdown_process(self):
"""
This method is responsible for shutting down the process, ensuring that all orders are completed.
"""
if math.isclose(self.open_filled_amount, self.close_filled_amount):
self.close_execution_by(self.close_type)
elif len(se... |
This method is responsible for shutting down the process, ensuring that all orders are completed.
| control_shutdown_process | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def process_order_created_event(self,
event_tag: int,
market: ConnectorBase,
event: Union[BuyOrderCreatedEvent, SellOrderCreatedEvent]):
"""
This method is responsible for processing the order cre... |
This method is responsible for processing the order created event. Here we will add the InFlightOrder to the
active orders list.
| process_order_created_event | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def process_order_failed_event(self,
event_tag: int,
market: ConnectorBase,
event: MarketOrderFailureEvent):
"""
This method is responsible for processing the order failed event. Here we will add the... |
This method is responsible for processing the order failed event. Here we will add the InFlightOrder to the
failed orders list.
| process_order_failed_event | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def evaluate_max_retries(self):
"""
This method is responsible for evaluating the max retries. If the max retries is reached, the executor will be
stopped.
"""
if self._current_retries >= self._max_retries:
self.close_execution_by(CloseType.FAILED)
self.lo... |
This method is responsible for evaluating the max retries. If the max retries is reached, the executor will be
stopped.
| evaluate_max_retries | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def process_order_filled_event(self, event_tag: int, market: ConnectorBase, event: OrderFilledEvent):
"""
This method is responsible for processing the order filled event. Here we will update the value of
_total_executed_amount_backup, that can be used if the InFlightOrder
is not availab... |
This method is responsible for processing the order filled event. Here we will update the value of
_total_executed_amount_backup, that can be used if the InFlightOrder
is not available.
| process_order_filled_event | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/dca_executor/dca_executor.py | Apache-2.0 |
def __init__(self, strategy: ScriptStrategyBase, config: GridExecutorConfig,
update_interval: float = 1.0, max_retries: int = 10):
"""
Initialize the PositionExecutor instance.
:param strategy: The strategy to be used by the PositionExecutor.
:param config: The configur... |
Initialize the PositionExecutor instance.
:param strategy: The strategy to be used by the PositionExecutor.
:param config: The configuration for the PositionExecutor, subclass of PositionExecutoConfig.
:param update_interval: The interval at which the PositionExecutor should be updated... | __init__ | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
async def control_task(self):
"""
This method is responsible for controlling the task based on the status of the executor.
:return: None
"""
self.update_grid_levels()
self.update_metrics()
if self.status == RunnableStatus.RUNNING:
if self.control_trip... |
This method is responsible for controlling the task based on the status of the executor.
:return: None
| control_task | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def early_stop(self, keep_position: bool = False):
"""
This method allows strategy to stop the executor early.
:return: None
"""
self.cancel_open_orders()
self._status = RunnableStatus.SHUTTING_DOWN
self.close_type = CloseType.POSITION_HOLD if keep_position else ... |
This method allows strategy to stop the executor early.
:return: None
| early_stop | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
async def control_shutdown_process(self):
"""
Control the shutdown process of the executor, handling held positions separately
"""
self.close_timestamp = self._strategy.current_timestamp
open_orders_completed = self.open_liquidity_placed == Decimal("0")
close_orders_compl... |
Control the shutdown process of the executor, handling held positions separately
| control_shutdown_process | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
async def control_close_order(self):
"""
This method is responsible for controlling the close order. If the close order is filled and the open orders are
completed, it stops the executor. If the close order is not placed, it places the close order. If the close order
is not filled, it wa... |
This method is responsible for controlling the close order. If the close order is filled and the open orders are
completed, it stops the executor. If the close order is not placed, it places the close order. If the close order
is not filled, it waits for the close order to be filled and request... | control_close_order | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def adjust_and_place_open_order(self, level: GridLevel):
"""
This method is responsible for adjusting the open order and placing it.
:param level: The level to adjust and place the open order.
:return: None
"""
order_candidate = self._get_open_order_candidate(level)
... |
This method is responsible for adjusting the open order and placing it.
:param level: The level to adjust and place the open order.
:return: None
| adjust_and_place_open_order | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def get_open_orders_to_create(self):
"""
This method is responsible for controlling the open orders. Will check for each grid level if the order if there
is an open order. If not, it will place a new orders from the proposed grid levels based on the current price,
max open orders, max or... |
This method is responsible for controlling the open orders. Will check for each grid level if the order if there
is an open order. If not, it will place a new orders from the proposed grid levels based on the current price,
max open orders, max orders per batch, activation bounds and order freq... | get_open_orders_to_create | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def get_close_orders_to_create(self):
"""
This method is responsible for controlling the take profit. It will check if the net pnl percentage is greater
than the take profit percentage and place the close order.
:return: None
"""
close_orders_proposal = []
open_o... |
This method is responsible for controlling the take profit. It will check if the net pnl percentage is greater
than the take profit percentage and place the close order.
:return: None
| get_close_orders_to_create | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def get_close_order_ids_to_cancel(self):
"""
This method is responsible for controlling the close orders. It will check if the take profit is greater than the
current price and cancel the close order.
:return: None
"""
if self.config.activation_bounds:
close_... |
This method is responsible for controlling the close orders. It will check if the take profit is greater than the
current price and cancel the close order.
:return: None
| get_close_order_ids_to_cancel | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def take_profit_condition(self):
"""
Take profit will be when the mid price is above the end price of the grid and there are no active executors.
"""
if self.mid_price > self.config.end_price if self.config.side == TradeType.BUY else self.mid_price < self.config.start_price:
... |
Take profit will be when the mid price is above the end price of the grid and there are no active executors.
| take_profit_condition | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def stop_loss_condition(self):
"""
This method is responsible for controlling the stop loss. If the net pnl percentage is less than the stop loss
percentage, it places the close order and cancels the open orders.
:return: None
"""
if self.config.triple_barrier_config.sto... |
This method is responsible for controlling the stop loss. If the net pnl percentage is less than the stop loss
percentage, it places the close order and cancels the open orders.
:return: None
| stop_loss_condition | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def place_close_order_and_cancel_open_orders(self, close_type: CloseType, price: Decimal = Decimal("NaN")):
"""
This method is responsible for placing the close order and canceling the open orders. If the difference between
the open filled amount and the close filled amount is greater than the m... |
This method is responsible for placing the close order and canceling the open orders. If the difference between
the open filled amount and the close filled amount is greater than the minimum order size, it places the close
order. It also cancels the open orders.
:param close_type: The ... | place_close_order_and_cancel_open_orders | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def cancel_open_orders(self):
"""
This method is responsible for canceling the open orders.
:return: None
"""
open_order_placed = [level.active_open_order for level in
self.levels_by_state[GridLevelStates.OPEN_ORDER_PLACED]]
close_order_place... |
This method is responsible for canceling the open orders.
:return: None
| cancel_open_orders | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
async def on_start(self):
"""
This method is responsible for starting the executor and validating if the position is expired. The base method
validates if there is enough balance to place the open order.
:return: None
"""
await super().on_start()
self.update_metr... |
This method is responsible for starting the executor and validating if the position is expired. The base method
validates if there is enough balance to place the open order.
:return: None
| on_start | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def evaluate_max_retries(self):
"""
This method is responsible for evaluating the maximum number of retries to place an order and stop the executor
if the maximum number of retries is reached.
:return: None
"""
if self._current_retries > self._max_retries:
se... |
This method is responsible for evaluating the maximum number of retries to place an order and stop the executor
if the maximum number of retries is reached.
:return: None
| evaluate_max_retries | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def update_tracked_orders_with_order_id(self, order_id: str):
"""
This method is responsible for updating the tracked orders with the information from the InFlightOrder, using
the order_id as a reference.
:param order_id: The order_id to be used as a reference.
:return: None
... |
This method is responsible for updating the tracked orders with the information from the InFlightOrder, using
the order_id as a reference.
:param order_id: The order_id to be used as a reference.
:return: None
| update_tracked_orders_with_order_id | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def process_order_canceled_event(self, _, market: ConnectorBase, event: OrderCancelledEvent):
"""
This method is responsible for processing the order canceled event
"""
self.update_grid_levels()
levels_open_order_placed = [level for level in self.levels_by_state[GridLevelStates.O... |
This method is responsible for processing the order canceled event
| process_order_canceled_event | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def update_position_metrics(self):
"""
Calculate the unrealized pnl in quote asset
:return: The unrealized pnl in quote asset.
"""
open_filled_levels = self.levels_by_state[GridLevelStates.OPEN_ORDER_FILLED] + self.levels_by_state[
GridLevelStates.CLOSE_ORDER_PLACED]... |
Calculate the unrealized pnl in quote asset
:return: The unrealized pnl in quote asset.
| update_position_metrics | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def update_realized_pnl_metrics(self):
"""
Calculate the realized pnl in quote asset, excluding held positions
"""
if len(self._filled_orders) == 0:
self._reset_metrics()
return
# Calculate metrics only for fully closed trades (not held positions)
... |
Calculate the realized pnl in quote asset, excluding held positions
| update_realized_pnl_metrics | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def _reset_metrics(self):
"""Helper method to reset all PnL metrics"""
self.realized_buy_size_quote = Decimal("0")
self.realized_sell_size_quote = Decimal("0")
self.realized_imbalance_quote = Decimal("0")
self.realized_fees_quote = Decimal("0")
self.realized_pnl_quote = D... | Helper method to reset all PnL metrics | _reset_metrics | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def filled_amount_quote(self) -> Decimal:
"""
Calculate the total amount in quote asset
:return: The total amount in quote asset.
"""
matched_volume = self.realized_buy_size_quote + self.realized_sell_size_quote
return self.position_size_quote + matched_volume if self.cl... |
Calculate the total amount in quote asset
:return: The total amount in quote asset.
| filled_amount_quote | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
async def _sleep(self, delay: float):
"""
This method is responsible for sleeping the executor for a specific time.
:param delay: The time to sleep.
:return: None
"""
await asyncio.sleep(delay) |
This method is responsible for sleeping the executor for a specific time.
:param delay: The time to sleep.
:return: None
| _sleep | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/grid_executor/grid_executor.py | Apache-2.0 |
def __init__(self, strategy: ScriptStrategyBase, config: OrderExecutorConfig,
update_interval: float = 1.0, max_retries: int = 10):
"""
Initialize the OrderExecutor instance.
:param strategy: The strategy to be used by the OrderExecutor.
:param config: The configuration... |
Initialize the OrderExecutor instance.
:param strategy: The strategy to be used by the OrderExecutor.
:param config: The configuration for the OrderExecutor.
:param update_interval: The interval at which the OrderExecutor should be updated, defaults to 1.0.
:param max_retries: ... | __init__ | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/order_executor/order_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/order_executor/order_executor.py | Apache-2.0 |
def current_market_price(self) -> Decimal:
"""
Get the current market price based on the order side.
:return: The current market price.
"""
price_type = PriceType.BestBid if self.config.side == TradeType.BUY else PriceType.BestAsk
return self.get_price(self.config.connec... |
Get the current market price based on the order side.
:return: The current market price.
| current_market_price | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/order_executor/order_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/order_executor/order_executor.py | Apache-2.0 |
async def control_task(self):
"""
Control the order execution process based on the execution strategy.
"""
if self.status == RunnableStatus.RUNNING:
self.control_order()
elif self.status == RunnableStatus.SHUTTING_DOWN:
await self.control_shutdown_process(... |
Control the order execution process based on the execution strategy.
| control_task | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/order_executor/order_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/order_executor/order_executor.py | Apache-2.0 |
def control_order(self):
"""
Control the order based on the execution strategy.
"""
if not self._order:
self.place_open_order()
elif self.config.execution_strategy == ExecutionStrategy.LIMIT_CHASER:
self.control_limit_chaser() |
Control the order based on the execution strategy.
| control_order | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/order_executor/order_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/order_executor/order_executor.py | Apache-2.0 |
async def control_shutdown_process(self):
"""
Control the shutdown process of the executor.
"""
if self._order:
if self._order.is_open:
self.cancel_order()
elif self._order.is_filled:
self.close_type = CloseType.POSITION_HOLD
... |
Control the shutdown process of the executor.
| control_shutdown_process | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/order_executor/order_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/order_executor/order_executor.py | Apache-2.0 |
def place_open_order(self):
"""
Place the order based on the execution strategy.
"""
order_id = self.place_order(
connector_name=self.config.connector_name,
trading_pair=self.config.trading_pair,
order_type=self.get_order_type(),
amount=sel... |
Place the order based on the execution strategy.
| place_open_order | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/order_executor/order_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/order_executor/order_executor.py | Apache-2.0 |
def get_order_type(self) -> OrderType:
"""
Get the order type based on the execution strategy.
:return: The order type.
"""
if self.config.execution_strategy == ExecutionStrategy.MARKET:
return OrderType.MARKET
elif self.config.execution_strategy in [Executio... |
Get the order type based on the execution strategy.
:return: The order type.
| get_order_type | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/order_executor/order_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/order_executor/order_executor.py | Apache-2.0 |
def get_order_price(self) -> Decimal:
"""
Get the order price based on the execution strategy.
:return: The order price.
"""
if self.config.execution_strategy == ExecutionStrategy.MARKET:
return Decimal("NaN")
elif self.config.execution_strategy == ExecutionS... |
Get the order price based on the execution strategy.
:return: The order price.
| get_order_price | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/order_executor/order_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/order_executor/order_executor.py | Apache-2.0 |
def renew_order(self):
"""
Renew the order with a new price.
:param new_price: The new price for the order.
"""
self.cancel_order()
self.place_open_order()
self.logger().debug("Renewing order") |
Renew the order with a new price.
:param new_price: The new price for the order.
| renew_order | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/order_executor/order_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/order_executor/order_executor.py | Apache-2.0 |
def update_tracked_order_with_order_id(self, order_id: str):
"""
Update the tracked order with the information from the InFlightOrder.
:param order_id: The order ID to update.
"""
in_flight_order = self.get_in_flight_order(self.config.connector_name, order_id)
if self._o... |
Update the tracked order with the information from the InFlightOrder.
:param order_id: The order ID to update.
| update_tracked_order_with_order_id | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/order_executor/order_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/order_executor/order_executor.py | Apache-2.0 |
def get_custom_info(self) -> Dict:
"""
Get custom information about the executor.
:return: A dictionary containing custom information.
"""
return {
"level_id": self.config.level_id,
"current_retries": self._current_retries,
"max_retries": self... |
Get custom information about the executor.
:return: A dictionary containing custom information.
| get_custom_info | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/order_executor/order_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/order_executor/order_executor.py | Apache-2.0 |
def to_format_status(self, scale=1.0):
"""
Format the status of the executor.
:param scale: The scale for formatting.
:return: A list of formatted status lines.
"""
lines = [f"""
| Trading Pair: {self.config.trading_pair} | Exchange: {self.config.connector_name} | Action... |
Format the status of the executor.
:param scale: The scale for formatting.
:return: A list of formatted status lines.
| to_format_status | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/order_executor/order_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/order_executor/order_executor.py | Apache-2.0 |
async def _sleep(self, delay: float):
"""
Sleep for a specified delay.
:param delay: The delay in seconds.
"""
await asyncio.sleep(delay) |
Sleep for a specified delay.
:param delay: The delay in seconds.
| _sleep | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/order_executor/order_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/order_executor/order_executor.py | Apache-2.0 |
def open_filled_amount(self) -> Decimal:
"""
Get the filled amount of the open order.
:return: The filled amount of the open order if it exists, otherwise 0.
"""
if self._open_order:
if self._open_order.fee_asset == self.config.trading_pair.split("-")[0]:
... |
Get the filled amount of the open order.
:return: The filled amount of the open order if it exists, otherwise 0.
| open_filled_amount | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
def current_market_price(self) -> Decimal:
"""
This method is responsible for getting the current market price to be used as a reference for control barriers.
:return: The current market price.
"""
price_type = PriceType.BestBid if self.config.side == TradeType.BUY else PriceTyp... |
This method is responsible for getting the current market price to be used as a reference for control barriers.
:return: The current market price.
| current_market_price | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
def entry_price(self) -> Decimal:
"""
This method is responsible for getting the entry price. If the open order is done, it returns the average executed price.
If the entry price is set in the configuration, it returns the entry price from the configuration.
Otherwise, it returns the bes... |
This method is responsible for getting the entry price. If the open order is done, it returns the average executed price.
If the entry price is set in the configuration, it returns the entry price from the configuration.
Otherwise, it returns the best ask price for buy orders and the best bid p... | entry_price | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
def close_price(self) -> Decimal:
"""
This method is responsible for getting the close price. If the close order is done, it returns the average executed price.
Otherwise, it returns the current market price.
:return: The close price.
"""
if self._close_order and self._c... |
This method is responsible for getting the close price. If the close order is done, it returns the average executed price.
Otherwise, it returns the current market price.
:return: The close price.
| close_price | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
def trade_pnl_pct(self) -> Decimal:
"""
Calculate the trade pnl (Pure pnl without fees)
:return: The trade pnl percentage.
"""
if self.open_filled_amount != Decimal("0") and self.close_type not in [CloseType.FAILED, CloseType.POSITION_HOLD]:
if self.config.side == Tr... |
Calculate the trade pnl (Pure pnl without fees)
:return: The trade pnl percentage.
| trade_pnl_pct | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
def get_cum_fees_quote(self) -> Decimal:
"""
Calculate the cumulative fees in quote asset
:return: The cumulative fees in quote asset.
"""
orders = [self._open_order, self._close_order]
return sum([order.cum_fees_quote for order in orders if order]) |
Calculate the cumulative fees in quote asset
:return: The cumulative fees in quote asset.
| get_cum_fees_quote | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
def all_orders_completed(self):
"""
This method is responsible for checking if the open orders are completed.
:return: True if the open orders are completed, False otherwise.
"""
open_order_condition = not self._open_order or self._open_order.is_done
take_profit_conditio... |
This method is responsible for checking if the open orders are completed.
:return: True if the open orders are completed, False otherwise.
| all_orders_completed | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
async def control_shutdown_process(self):
"""
This method is responsible for controlling the shutdown process of the executor.
:return: None
"""
self.close_timestamp = self._strategy.current_timestamp
if self.all_orders_completed():
if self.close_type == Clos... |
This method is responsible for controlling the shutdown process of the executor.
:return: None
| control_shutdown_process | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
def control_open_order(self):
"""
This method is responsible for controlling the open order. It checks if the open order is not placed and if the
close price is within the activation bounds to place the open order.
:return: None
"""
if not self._open_order:
i... |
This method is responsible for controlling the open order. It checks if the open order is not placed and if the
close price is within the activation bounds to place the open order.
:return: None
| control_open_order | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
def _is_within_activation_bounds(self, order_price: Decimal, side: TradeType, order_type: OrderType) -> bool:
"""
This method is responsible for checking if the close price is within the activation bounds to place the open
order. If the activation bounds are not set, it returns True. This makes ... |
This method is responsible for checking if the close price is within the activation bounds to place the open
order. If the activation bounds are not set, it returns True. This makes the executor more capital efficient.
:param close_price: The close price to be checked.
:return: True if... | _is_within_activation_bounds | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
def place_open_order(self):
"""
This method is responsible for placing the open order.
:return: None
"""
order_id = self.place_order(
connector_name=self.config.connector_name,
trading_pair=self.config.trading_pair,
order_type=self.config.trip... |
This method is responsible for placing the open order.
:return: None
| place_open_order | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
def renew_take_profit_order(self):
"""
This method is responsible for renewing the take profit order.
:return: None
"""
self.cancel_take_profit()
self.place_take_profit_limit_order()
self.logger().debug("Renewing take profit order") |
This method is responsible for renewing the take profit order.
:return: None
| renew_take_profit_order | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
def cancel_take_profit(self):
"""
This method is responsible for canceling the take profit order.
:return: None
"""
self._strategy.cancel(
connector_name=self.config.connector_name,
trading_pair=self.config.trading_pair,
order_id=self._take_pr... |
This method is responsible for canceling the take profit order.
:return: None
| cancel_take_profit | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
def cancel_open_order(self):
"""
This method is responsible for canceling the open order.
:return: None
"""
self._strategy.cancel(
connector_name=self.config.connector_name,
trading_pair=self.config.trading_pair,
order_id=self._open_order.orde... |
This method is responsible for canceling the open order.
:return: None
| cancel_open_order | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
def process_order_completed_event(self, _, market, event: Union[BuyOrderCompletedEvent, SellOrderCompletedEvent]):
"""
This method is responsible for processing the order completed event. Here we will check if the id is one of the
tracked orders and update the state
"""
self._tot... |
This method is responsible for processing the order completed event. Here we will check if the id is one of the
tracked orders and update the state
| process_order_completed_event | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/position_executor/position_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/position_executor/position_executor.py | Apache-2.0 |
def process_order_failed_event(self,
event_tag: int,
market: ConnectorBase,
event: MarketOrderFailureEvent):
"""
This method is responsible for processing the order failed event. Here we will check i... |
This method is responsible for processing the order failed event. Here we will check if the order id is one of
the order plan and if it is we will move the order to the failed collection and retry with a new order.
| process_order_failed_event | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/twap_executor/twap_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/twap_executor/twap_executor.py | Apache-2.0 |
def process_order_completed_event(self,
event_tag: int,
market: ConnectorBase,
event: Union[BuyOrderCompletedEvent, SellOrderCompletedEvent]):
"""
This method is responsible for processing t... |
This method is responsible for processing the order completed event. Here we will check if the order id is one
of the order plan and if it is we will check if the rest of the orders are completed and if they are we will
pass the executor to SHUTTING_DOWN state.
| process_order_completed_event | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/twap_executor/twap_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/twap_executor/twap_executor.py | Apache-2.0 |
def get_net_pnl_pct(self) -> Decimal:
"""
This method is responsible for calculating the net pnl percentage
"""
total_executed_quote = self.get_total_executed_amount_quote()
return self.net_pnl_quote / total_executed_quote if total_executed_quote > Decimal("0") else Decimal("0") |
This method is responsible for calculating the net pnl percentage
| get_net_pnl_pct | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/twap_executor/twap_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/twap_executor/twap_executor.py | Apache-2.0 |
def get_average_executed_price(self) -> Decimal:
"""
Get the weighted average executed price of the orders.
"""
total_executed_amount = self.get_total_executed_amount()
if total_executed_amount == Decimal("0"):
return Decimal("0")
return sum([order.average_exe... |
Get the weighted average executed price of the orders.
| get_average_executed_price | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/twap_executor/twap_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/twap_executor/twap_executor.py | Apache-2.0 |
async def get_quote_asset_conversion_rate(self) -> Decimal:
"""
Fetch the conversion rate between the quote assets of the buying and selling markets.
Example: For M3M3/USDT and M3M3/USDC, fetch the USDC/USDT rate.
"""
try:
conversion_rate = self.rate_oracle.get_pair_r... |
Fetch the conversion rate between the quote assets of the buying and selling markets.
Example: For M3M3/USDT and M3M3/USDC, fetch the USDC/USDT rate.
| get_quote_asset_conversion_rate | python | hummingbot/hummingbot | hummingbot/strategy_v2/executors/xemm_executor/xemm_executor.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/executors/xemm_executor/xemm_executor.py | Apache-2.0 |
def parse_side(cls, v):
"""Parse side field from string to TradeType enum."""
if isinstance(v, str):
try:
return TradeType[v.upper()]
except KeyError:
# If direct enum name lookup fails, try numeric value
try:
re... | Parse side field from string to TradeType enum. | parse_side | python | hummingbot/hummingbot | hummingbot/strategy_v2/models/position_config.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/models/position_config.py | Apache-2.0 |
def linear(cls, n_levels: int, start: float = 0.0, end: float = 1.0) -> List[Decimal]:
"""
Generate a linear sequence of spreads.
Parameters:
- n_levels: The number of spread levels to be generated.
- start: The starting value of the sequence.
- end: The ending value of ... |
Generate a linear sequence of spreads.
Parameters:
- n_levels: The number of spread levels to be generated.
- start: The starting value of the sequence.
- end: The ending value of the sequence.
Returns:
List[Decimal]: A list containing the generated linear sequ... | linear | python | hummingbot/hummingbot | hummingbot/strategy_v2/utils/distributions.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/utils/distributions.py | Apache-2.0 |
def fibonacci(cls, n_levels: int, start: float = 0.01) -> List[Decimal]:
"""
Generate a Fibonacci sequence of spreads represented as percentages.
The Fibonacci sequence is a series of numbers in which each number (Fibonacci number)
is the sum of the two preceding ones. In this implement... |
Generate a Fibonacci sequence of spreads represented as percentages.
The Fibonacci sequence is a series of numbers in which each number (Fibonacci number)
is the sum of the two preceding ones. In this implementation, the sequence starts with
the provided initial_value (represented as a... | fibonacci | python | hummingbot/hummingbot | hummingbot/strategy_v2/utils/distributions.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/utils/distributions.py | Apache-2.0 |
def logarithmic(cls, n_levels: int, base: float = exp(1), scaling_factor: float = 1.0,
start: float = 0.4) -> List[Decimal]:
"""
Generate a logarithmic sequence of spreads.
Parameters:
- n_levels: The number of spread levels to be generated.
- base: The base ... |
Generate a logarithmic sequence of spreads.
Parameters:
- n_levels: The number of spread levels to be generated.
- base: The base value for the logarithm. Default is Euler's number.
- scaling_factor: The factor to scale the logarithmic value.
- initial_value: Initial va... | logarithmic | python | hummingbot/hummingbot | hummingbot/strategy_v2/utils/distributions.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/utils/distributions.py | Apache-2.0 |
def geometric(cls, n_levels: int, start: float, ratio: float) -> List[Decimal]:
"""
Generate a geometric sequence of spreads.
Parameters:
- n_levels: The number of spread levels to be generated.
- start: The starting value of the sequence.
- ratio: The ratio to multiply ... |
Generate a geometric sequence of spreads.
Parameters:
- n_levels: The number of spread levels to be generated.
- start: The starting value of the sequence.
- ratio: The ratio to multiply the current value in each iteration. Should be greater than 1 for increasing sequence.
... | geometric | python | hummingbot/hummingbot | hummingbot/strategy_v2/utils/distributions.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/utils/distributions.py | Apache-2.0 |
def resolve_input(self, input_data: Union[Decimal | float, List[Decimal | float], Dict[str, Any]]) -> List[Decimal | float | int]:
"""
Resolve the provided input data into a list of Decimal values.
Args:
input_data: The input data to resolve. Can be a single value, list, or dictiona... |
Resolve the provided input data into a list of Decimal values.
Args:
input_data: The input data to resolve. Can be a single value, list, or dictionary.
Returns:
List[Decimal | float | int]: List of resolved Decimal values.
| resolve_input | python | hummingbot/hummingbot | hummingbot/strategy_v2/utils/order_level_builder.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/utils/order_level_builder.py | Apache-2.0 |
def build_order_levels(self,
amounts: Union[Decimal, List[Decimal], Dict[str, Any]],
spreads: Union[Decimal, List[Decimal], Dict[str, Any]],
triple_barrier_confs: Union[TripleBarrierConfig, List[TripleBarrierConfig]] = TripleBarrierConfig(... |
Build a list of OrderLevels based on the given parameters.
Args:
amounts: Amounts to be used for each order level.
spreads: Spread factors for each order level.
triple_barrier_confs: Triple barrier configurations.
order_refresh_time: Time in seconds to w... | build_order_levels | python | hummingbot/hummingbot | hummingbot/strategy_v2/utils/order_level_builder.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/utils/order_level_builder.py | Apache-2.0 |
def _save_data_to_csv(self):
"""Save collected price data to CSV file"""
if not self.price_history:
return
df = pd.DataFrame(self.price_history)
# Check if file exists to determine whether to write header
file_exists = os.path.exists(self.file_path)
# Appen... | Save collected price data to CSV file | _save_data_to_csv | python | hummingbot/hummingbot | scripts/amm_data_feed_example.py | https://github.com/hummingbot/hummingbot/blob/master/scripts/amm_data_feed_example.py | Apache-2.0 |
async def check_price_and_trade(self):
"""Check current price and trigger trade if condition is met"""
if self.trade_in_progress or self.trade_executed:
return
self.trade_in_progress = True
current_price = None # Initialize current_price
side = "buy" if self.config... | Check current price and trigger trade if condition is met | check_price_and_trade | python | hummingbot/hummingbot | scripts/amm_trade_example.py | https://github.com/hummingbot/hummingbot/blob/master/scripts/amm_trade_example.py | Apache-2.0 |
async def check_gateway_status(self):
"""Check if Gateway server is online and verify wallet connection"""
self.logger().info("Checking Gateway server status...")
try:
gateway_http_client = GatewayHttpClient.get_instance()
if await gateway_http_client.ping_gateway():
... | Check if Gateway server is online and verify wallet connection | check_gateway_status | python | hummingbot/hummingbot | scripts/clmm_manage_position.py | https://github.com/hummingbot/hummingbot/blob/master/scripts/clmm_manage_position.py | Apache-2.0 |
async def fetch_pool_info(self):
"""Fetch pool information to get tokens and current price"""
try:
self.logger().info(f"Fetching information for pool {self.config.pool_address}...")
pool_info = await GatewayHttpClient.get_instance().pool_info(
self.config.connecto... | Fetch pool information to get tokens and current price | fetch_pool_info | python | hummingbot/hummingbot | scripts/clmm_manage_position.py | https://github.com/hummingbot/hummingbot/blob/master/scripts/clmm_manage_position.py | Apache-2.0 |
async def fetch_position_info(self):
"""Fetch actual position information including price bounds"""
if not self.position_address or not self.wallet_address:
return
try:
self.logger().info(f"Fetching position info for {self.position_address}...")
position_info... | Fetch actual position information including price bounds | fetch_position_info | python | hummingbot/hummingbot | scripts/clmm_manage_position.py | https://github.com/hummingbot/hummingbot/blob/master/scripts/clmm_manage_position.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.