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 get_market_pair_by_asset(self) -> Dict[MarketTradingPairTuple, List[MarketTradingPairTuple]]:
"""
sort market pair belonging to the same market as hedge market together
:return: market pair belonging to the same market as hedge market together
"""
self.logger().info(f"Market ... |
sort market pair belonging to the same market as hedge market together
:return: market pair belonging to the same market as hedge market together
| get_market_pair_by_asset | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def active_positions_df(self) -> pd.DataFrame:
"""
Get the active positions of all markets.
:return: The active positions of all markets.
"""
columns = ["Connector", "Symbol", "Type", "Entry", "Amount", "Leverage"]
data = []
for market_pair in self._all_markets:
... |
Get the active positions of all markets.
:return: The active positions of all markets.
| active_positions_df | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def wallet_df(self) -> pd.DataFrame:
"""
Processes the data required for wallet dataframe.
:return: wallet dataframe
"""
data = []
columns = ["Connector", "Asset", "Price", "Amount", "Value"]
def get_data(market_pair: MarketTradingPairTuple) -> List[Any]:
... |
Processes the data required for wallet dataframe.
:return: wallet dataframe
| wallet_df | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def format_status(self) -> str:
"""
Format the status of the strategy.
"""
def get_wallet_status_str() -> List[str]:
wallet_df = self.wallet_balance_data_frame(self._all_markets)
return ["", " Wallet:"] + [" " + line for line in str(wallet_df).split("\n")]
... |
Format the status of the strategy.
| format_status | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def apply_initial_setting(self) -> None:
"""
Check if the market is derivative, and if so, set the initial setting.
"""
if not self.is_derivative(self._hedge_market_pairs[0]):
return
if not self._enable_auto_set_position_mode:
logging.info("Auto set positi... |
Check if the market is derivative, and if so, set the initial setting.
| apply_initial_setting | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def interval_log(self, key: str, message: str) -> None:
"""
Log message at interval.
:param key: Key to identify the last recorded timestamp.
:param message: Message to log.
"""
if self._last_timestamp - self._last_report_timestamp.get(key, 0) > self._status_report_interv... |
Log message at interval.
:param key: Key to identify the last recorded timestamp.
:param message: Message to log.
| interval_log | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def tick(self, timestamp: float) -> None:
"""
Check if hedge interval has passed and process hedge if so
:param timestamp: clock timestamp
"""
if self.check_and_cancel_active_orders():
self.interval_log("hedge", "Active orders present. Skipping hedge check until activ... |
Check if hedge interval has passed and process hedge if so
:param timestamp: clock timestamp
| tick | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def get_positions(self, market_pair: MarketTradingPairTuple, position_side: PositionSide = None) -> List[Position]:
"""
Get the active positions of a market.
:param market_pair: Market pair to get the positions of.
:return: The active positions of the market.
"""
trading_... |
Get the active positions of a market.
:param market_pair: Market pair to get the positions of.
:return: The active positions of the market.
| get_positions | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def get_derivative_base_amount(self, market_pair: MarketTradingPairTuple) -> Decimal:
"""
Get the value of the derivative base asset.
:param market_pair: The market pair to get the value of the derivative base asset.
:return: The value of the derivative base asset.
"""
po... |
Get the value of the derivative base asset.
:param market_pair: The market pair to get the value of the derivative base asset.
:return: The value of the derivative base asset.
| get_derivative_base_amount | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def get_base_amount(self, market_pair: MarketTradingPairTuple) -> Decimal:
"""
Get the amount of the base asset of the market pair.
:params market_pair: The market pair to get the amount of the base asset of.
:returns: The amount of the base asset of the market pair.
"""
... |
Get the amount of the base asset of the market pair.
:params market_pair: The market pair to get the amount of the base asset of.
:returns: The amount of the base asset of the market pair.
| get_base_amount | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def get_base_value(self, market_pair: MarketTradingPairTuple) -> Decimal:
"""
Get the base asset value of a market. e.g BTC/USDT = BTC amount * BTC/USDT price.
:params market_pair: The market pair to get the base asset value of.
:returns: The base asset value of the market pair.
... |
Get the base asset value of a market. e.g BTC/USDT = BTC amount * BTC/USDT price.
:params market_pair: The market pair to get the base asset value of.
:returns: The base asset value of the market pair.
| get_base_value | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def get_hedge_direction_and_value(self) -> Tuple[bool, Decimal]:
"""
Calculate the value that is required to be hedged.
:returns: A tuple of the hedge direction (buy/sell) and the value to be hedged.
"""
total_value = sum(self.get_base_value(market_pair) for market_pair in self._... |
Calculate the value that is required to be hedged.
:returns: A tuple of the hedge direction (buy/sell) and the value to be hedged.
| get_hedge_direction_and_value | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def calculate_hedge_price_and_amount(self, is_buy: bool, value_to_hedge: Decimal) -> Tuple[Decimal, Decimal]:
"""
Calculate the price and amount to hedge.
:params is_buy: The direction of the hedge.
:params value_to_hedge: The value to hedge.
:returns: The price and amount to hed... |
Calculate the price and amount to hedge.
:params is_buy: The direction of the hedge.
:params value_to_hedge: The value to hedge.
:returns: The price and amount to hedge.
| calculate_hedge_price_and_amount | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def hedge_by_value(self) -> None:
"""
The main process of the strategy for value mode = True.
"""
is_buy, value_to_hedge = self.get_hedge_direction_and_value()
price, amount = self.calculate_hedge_price_and_amount(is_buy, value_to_hedge)
if amount == Decimal("0"):
... |
The main process of the strategy for value mode = True.
| hedge_by_value | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def get_hedge_direction_and_amount_by_asset(
self, hedge_pair: MarketTradingPairTuple, market_list: List[MarketTradingPairTuple]
) -> Tuple[bool, Decimal]:
"""
Calculate the amount that is required to be hedged.
:params hedge_pair: The market pair to hedge.
:params market_lis... |
Calculate the amount that is required to be hedged.
:params hedge_pair: The market pair to hedge.
:params market_list: The list of markets to get the amount of the base asset of.
:returns: The direction to hedge (buy/sell) and the amount of the base asset of the market pair.
| get_hedge_direction_and_amount_by_asset | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def get_perpetual_order_candidates(
self, market_pair: MarketTradingPairTuple, is_buy: bool, amount: Decimal, price: Decimal
) -> List[PerpetualOrderCandidate]:
"""
Check if the balance is sufficient to place an order.
if not, adjust the amount to the balance available.
retur... |
Check if the balance is sufficient to place an order.
if not, adjust the amount to the balance available.
returns the order candidate if the order meets the accepted criteria
else, return None
| get_perpetual_order_candidates | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def place_orders(
self, market_pair: MarketTradingPairTuple, orders: Union[List[OrderCandidate], List[PerpetualOrderCandidate]]
) -> None:
"""
Place an order refering the order candidates.
:params market_pair: The market pair to place the order.
:params orders: The list of or... |
Place an order refering the order candidates.
:params market_pair: The market pair to place the order.
:params orders: The list of orders to place.
| place_orders | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def check_and_cancel_active_orders(self) -> bool:
"""
Check if there are any active orders and cancel them
:return: True if there are active orders, False otherwise.
"""
if not self.active_orders:
return False
for market_pair, order in self.active_orders:
... |
Check if there are any active orders and cancel them
:return: True if there are active orders, False otherwise.
| check_and_cancel_active_orders | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py | Apache-2.0 |
def hedge_markets_prompt(mi: "HedgeConfigMap") -> str:
"""prompts for the markets to hedge"""
exchange = mi.hedge_connector
if mi.value_mode:
return f"Value mode: Enter the trading pair you would like to hedge on {exchange}. (Example: BTC-USDT)"
return (
f"Amount ... | prompts for the markets to hedge | hedge_markets_prompt | python | hummingbot/hummingbot | hummingbot/strategy/hedge/hedge_config_map_pydantic.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge_config_map_pydantic.py | Apache-2.0 |
def active_orders(self):
"""
List active orders (they have been sent to the market and have not been canceled yet)
"""
limit_orders = self.order_tracker.active_limit_orders
return [o[1] for o in limit_orders] |
List active orders (they have been sent to the market and have not been canceled yet)
| active_orders | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
async def active_orders_df(self) -> pd.DataFrame:
"""
Return the active orders in a DataFrame.
"""
size_q_col = f"Amt({self._token})" if self.is_token_a_quote_token() else "Amt(Quote)"
columns = ["Market", "Side", "Price", "Spread", "Amount", size_q_col, "Age"]
data = []
... |
Return the active orders in a DataFrame.
| active_orders_df | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def budget_status_df(self) -> pd.DataFrame:
"""
Return the trader's budget in a DataFrame
"""
data = []
columns = ["Market", f"Budget({self._token})", "Base bal", "Quote bal", "Base/Quote"]
for market, market_info in self._market_infos.items():
mid_price = mar... |
Return the trader's budget in a DataFrame
| budget_status_df | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def market_status_df(self) -> pd.DataFrame:
"""
Return the market status (prices, volatility) in a DataFrame
"""
data = []
columns = ["Market", "Mid price", "Best bid", "Best ask", "Volatility"]
for market, market_info in self._market_infos.items():
mid_price ... |
Return the market status (prices, volatility) in a DataFrame
| market_status_df | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
async def miner_status_df(self) -> pd.DataFrame:
"""
Return the miner status (payouts, rewards, liquidity, etc.) in a DataFrame
"""
data = []
g_sym = self._client_config_map.global_token.global_token_symbol
columns = ["Market", "Payout", "Reward/wk", "Liquidity", "Yield/y... |
Return the miner status (payouts, rewards, liquidity, etc.) in a DataFrame
| miner_status_df | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
async def format_status(self) -> str:
"""
Return the budget, market, miner and order statuses.
"""
if not self._ready_to_trade:
return "Market connectors are not ready."
lines = []
warning_lines = []
warning_lines.extend(self.network_warning(list(self.... |
Return the budget, market, miner and order statuses.
| format_status | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def _validate_order_book_for_markets(self):
"""
Verify that the active markets have non-empty order books. Put the trading on hold
for pairs with empty order books, in case it is a glitch?
"""
markets = self._market_infos.copy()
markets.update(self._empty_ob_market_infos)... |
Verify that the active markets have non-empty order books. Put the trading on hold
for pairs with empty order books, in case it is a glitch?
| _validate_order_book_for_markets | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def create_base_proposals(self):
"""
Each tick this strategy creates a set of proposals based on the market_info and the parameters from the
constructor.
"""
proposals = []
for market, market_info in self._market_infos.items():
spread = self._spread
... |
Each tick this strategy creates a set of proposals based on the market_info and the parameters from the
constructor.
| create_base_proposals | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def total_port_value_in_token(self) -> Decimal:
"""
Total portfolio value in self._token amount
"""
all_bals = self.adjusted_available_balances()
port_value = all_bals.get(self._token, s_decimal_zero)
for market, market_info in self._market_infos.items():
base... |
Total portfolio value in self._token amount
| total_port_value_in_token | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def create_budget_allocation(self):
"""
Create buy and sell budgets for every market
"""
self._sell_budgets = {m: s_decimal_zero for m in self._market_infos}
self._buy_budgets = {m: s_decimal_zero for m in self._market_infos}
portfolio_value = self.total_port_value_in_tok... |
Create buy and sell budgets for every market
| create_budget_allocation | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def is_within_tolerance(self, cur_orders: List[LimitOrder], proposal: Proposal):
"""
False if there are no buys or sells or if the difference between the proposed price and current price is less
than the tolerance. The tolerance value is strict max, cannot be equal.
"""
cur_buy =... |
False if there are no buys or sells or if the difference between the proposed price and current price is less
than the tolerance. The tolerance value is strict max, cannot be equal.
| is_within_tolerance | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def cancel_active_orders(self, proposals: List[Proposal]):
"""
Cancel any orders that have an order age greater than self._max_order_age or if orders are not within tolerance
"""
for proposal in proposals:
to_cancel = False
cur_orders = [o for o in self.active_ord... |
Cancel any orders that have an order age greater than self._max_order_age or if orders are not within tolerance
| cancel_active_orders | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def execute_orders_proposal(self, proposals: List[Proposal]):
"""
Execute a list of proposals if the current timestamp is less than its refresh timestamp.
Update the refresh timestamp.
"""
for proposal in proposals:
maker_order_type: OrderType = self._exchange.get_mak... |
Execute a list of proposals if the current timestamp is less than its refresh timestamp.
Update the refresh timestamp.
| execute_orders_proposal | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def is_token_a_quote_token(self):
"""
Check if self._token is a quote token
"""
quotes = self.all_quote_tokens()
if len(quotes) == 1 and self._token in quotes:
return True
return False |
Check if self._token is a quote token
| is_token_a_quote_token | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def all_base_tokens(self) -> Set[str]:
"""
Get the base token (left-hand side) from all markets in this strategy
"""
tokens = set()
for market in self._market_infos:
tokens.add(market.split("-")[0])
return tokens |
Get the base token (left-hand side) from all markets in this strategy
| all_base_tokens | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def all_quote_tokens(self) -> Set[str]:
"""
Get the quote token (right-hand side) from all markets in this strategy
"""
tokens = set()
for market in self._market_infos:
tokens.add(market.split("-")[1])
return tokens |
Get the quote token (right-hand side) from all markets in this strategy
| all_quote_tokens | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def all_tokens(self) -> Set[str]:
"""
Return a list of all tokens involved in this strategy (base and quote)
"""
tokens = set()
for market in self._market_infos:
tokens.update(market.split("-"))
return tokens |
Return a list of all tokens involved in this strategy (base and quote)
| all_tokens | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def adjusted_available_balances(self) -> Dict[str, Decimal]:
"""
Calculates all available balances, account for amount attributed to orders and reserved balance.
:return: a dictionary of token and its available balance
"""
tokens = self.all_tokens()
adjusted_bals = {t: s_... |
Calculates all available balances, account for amount attributed to orders and reserved balance.
:return: a dictionary of token and its available balance
| adjusted_available_balances | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def apply_inventory_skew(self, proposals: List[Proposal]):
"""
Apply an inventory split between the quote and base asset
"""
for proposal in proposals:
buy_budget = self._buy_budgets[proposal.market]
sell_budget = self._sell_budgets[proposal.market]
mi... |
Apply an inventory split between the quote and base asset
| apply_inventory_skew | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def did_fill_order(self, event):
"""
Check if order has been completed, log it, notify the hummingbot application, and update budgets.
"""
order_id = event.order_id
market_info = self.order_tracker.get_shadow_market_pair_from_order_id(order_id)
if market_info is not None:... |
Check if order has been completed, log it, notify the hummingbot application, and update budgets.
| did_fill_order | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def update_mid_prices(self):
"""
Query asset markets for mid price
"""
for market in self._market_infos:
mid_price = self._market_infos[market].get_mid_price()
self._mid_prices[market].append(mid_price)
# To avoid memory leak, we store only the last pa... |
Query asset markets for mid price
| update_mid_prices | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def update_volatility(self):
"""
Update volatility data from the market
"""
self._volatility = {market: s_decimal_nan for market in self._market_infos}
for market, mid_prices in self._mid_prices.items():
last_index = len(mid_prices) - 1
atr = []
... |
Update volatility data from the market
| update_volatility | python | hummingbot/hummingbot | hummingbot/strategy/liquidity_mining/liquidity_mining.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/liquidity_mining/liquidity_mining.py | Apache-2.0 |
def update(self, timestamp: float, price: Decimal) -> None:
"""
Updates the price band.
:param timestamp: current timestamp of the strategy/connector
:param price: reference price to set price band
"""
self._price_floor = (Decimal("100") + self.price_floor_pct) / Decimal... |
Updates the price band.
:param timestamp: current timestamp of the strategy/connector
:param price: reference price to set price band
| update | python | hummingbot/hummingbot | hummingbot/strategy/pure_market_making/moving_price_band.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/pure_market_making/moving_price_band.py | Apache-2.0 |
def convert_decimal_string_to_list(string: Optional[str], divisor: Decimal = Decimal("1")) -> List[Decimal]:
'''convert order level spread string into a list of decimal divided by divisor '''
if string is None:
return []
string_list = list(string.split(","))
return [Decimal(v... | convert order level spread string into a list of decimal divided by divisor | convert_decimal_string_to_list | python | hummingbot/hummingbot | hummingbot/strategy/pure_market_making/start.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/pure_market_making/start.py | Apache-2.0 |
def __init__(self,
spot_side: ArbProposalSide,
perp_side: ArbProposalSide,
order_amount: Decimal):
"""
Creates ArbProposal
:param spot_side: An ArbProposalSide on spot market
:param perp_side: An ArbProposalSide on perpetual market
... |
Creates ArbProposal
:param spot_side: An ArbProposalSide on spot market
:param perp_side: An ArbProposalSide on perpetual market
:param order_amount: An order amount for both spot and perpetual market
| __init__ | python | hummingbot/hummingbot | hummingbot/strategy/spot_perpetual_arbitrage/arb_proposal.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/spot_perpetual_arbitrage/arb_proposal.py | Apache-2.0 |
def profit_pct(self) -> Decimal:
"""
Calculates and returns arbitrage profit (in percentage value).
"""
buy_price = self.spot_side.order_price if self.spot_side.is_buy else self.perp_side.order_price
sell_price = self.spot_side.order_price if not self.spot_side.is_buy else self.p... |
Calculates and returns arbitrage profit (in percentage value).
| profit_pct | python | hummingbot/hummingbot | hummingbot/strategy/spot_perpetual_arbitrage/arb_proposal.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/spot_perpetual_arbitrage/arb_proposal.py | Apache-2.0 |
def init_params(self,
spot_market_info: MarketTradingPairTuple,
perp_market_info: MarketTradingPairTuple,
order_amount: Decimal,
perp_leverage: int,
min_opening_arbitrage_pct: Decimal,
min_closing_arb... |
:param spot_market_info: The spot market info
:param perp_market_info: The perpetual market info
:param order_amount: The order amount
:param perp_leverage: The leverage level to use on perpetual market
:param min_opening_arbitrage_pct: The minimum spread to open arbitrage posit... | init_params | python | hummingbot/hummingbot | hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | Apache-2.0 |
async def main(self, timestamp):
"""
The main procedure for the arbitrage strategy.
"""
self.update_strategy_state()
if self._strategy_state in (StrategyState.Opening, StrategyState.Closing):
return
if self.strategy_state == StrategyState.Closed and self._next... |
The main procedure for the arbitrage strategy.
| main | python | hummingbot/hummingbot | hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | Apache-2.0 |
def update_strategy_state(self):
"""
Updates strategy state to either Opened or Closed if the condition is right.
"""
if self._strategy_state == StrategyState.Opening and len(self._completed_opening_order_ids) == 2 and \
self.perp_positions:
self._strategy_sta... |
Updates strategy state to either Opened or Closed if the condition is right.
| update_strategy_state | python | hummingbot/hummingbot | hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | Apache-2.0 |
async def create_base_proposals(self) -> List[ArbProposal]:
"""
Creates a list of 2 base proposals, no filter.
:return: A list of 2 base proposals.
"""
tasks = [self._spot_market_info.market.get_order_price(self._spot_market_info.trading_pair, True,
... |
Creates a list of 2 base proposals, no filter.
:return: A list of 2 base proposals.
| create_base_proposals | python | hummingbot/hummingbot | hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | Apache-2.0 |
def apply_slippage_buffers(self, proposal: ArbProposal):
"""
Updates arb_proposals by adjusting order price for slipper buffer percentage.
E.g. if it is a buy order, for an order price of 100 and 1% slipper buffer, the new order price is 101,
for a sell order, the new order price is 99.
... |
Updates arb_proposals by adjusting order price for slipper buffer percentage.
E.g. if it is a buy order, for an order price of 100 and 1% slipper buffer, the new order price is 101,
for a sell order, the new order price is 99.
:param proposal: the arbitrage proposal
| apply_slippage_buffers | python | hummingbot/hummingbot | hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | Apache-2.0 |
def check_budget_available(self) -> bool:
"""
Checks if there's any balance for trading to be possible at all
:return: True if user has available balance enough for orders submission.
"""
spot_base, spot_quote = self._spot_market_info.trading_pair.split("-")
perp_base, p... |
Checks if there's any balance for trading to be possible at all
:return: True if user has available balance enough for orders submission.
| check_budget_available | python | hummingbot/hummingbot | hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | Apache-2.0 |
def check_spot_budget_constraint(self, proposal: ArbProposal) -> bool:
"""
Check balance on spot exchange.
:param proposal: An arbitrage proposal
:return: True if user has available balance enough for both orders submission.
"""
proposal_side = proposal.spot_side
... |
Check balance on spot exchange.
:param proposal: An arbitrage proposal
:return: True if user has available balance enough for both orders submission.
| check_spot_budget_constraint | python | hummingbot/hummingbot | hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | Apache-2.0 |
def execute_arb_proposal(self, proposal: ArbProposal):
"""
Execute both sides of the arbitrage trades concurrently.
:param proposal: the arbitrage proposal
"""
if proposal.order_amount == s_decimal_zero:
return
spot_side = proposal.spot_side
spot_order... |
Execute both sides of the arbitrage trades concurrently.
:param proposal: the arbitrage proposal
| execute_arb_proposal | python | hummingbot/hummingbot | hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | Apache-2.0 |
def active_positions_df(self) -> pd.DataFrame:
"""
Returns a new dataframe on current active perpetual positions.
"""
columns = ["Symbol", "Type", "Entry Price", "Amount", "Leverage", "Unrealized PnL"]
data = []
for pos in self.perp_positions:
data.append([
... |
Returns a new dataframe on current active perpetual positions.
| active_positions_df | python | hummingbot/hummingbot | hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | Apache-2.0 |
async def format_status(self) -> str:
"""
Returns a status string formatted to display nicely on terminal. The strings composes of 4 parts: markets,
assets, spread and warnings(if any).
"""
columns = ["Exchange", "Market", "Sell Price", "Buy Price", "Mid Price"]
data = []... |
Returns a status string formatted to display nicely on terminal. The strings composes of 4 parts: markets,
assets, spread and warnings(if any).
| format_status | python | hummingbot/hummingbot | hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py | Apache-2.0 |
async def create_arb_proposals(market_info_1: MarketTradingPairTuple,
market_info_2: MarketTradingPairTuple,
order_amount: Decimal) -> List[ArbProposal]:
"""
Creates base arbitrage proposals for given markets without any filtering.
:param market_... |
Creates base arbitrage proposals for given markets without any filtering.
:param market_info_1: The first market
:param market_info_2: The second market
:param order_amount: The required order amount.
:return A list of 2 proposal - (market_1 buy, market_2 sell) and (market_1 sell, market_2 buy)
... | create_arb_proposals | python | hummingbot/hummingbot | hummingbot/strategy/spot_perpetual_arbitrage/utils.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/spot_perpetual_arbitrage/utils.py | Apache-2.0 |
def __init__(self,
market_infos: List[MarketTradingPairTuple],
is_buy: bool,
target_asset_amount: Decimal,
order_step_size: Decimal,
order_price: Decimal,
order_delay_time: float = 10.0,
execution_stat... |
:param market_infos: list of market trading pairs
:param is_buy: if the order is to buy
:param target_asset_amount: qty of the order to place
:param order_step_size: amount of base asset to be configured in each order
:param order_price: price to place the order at
:para... | __init__ | python | hummingbot/hummingbot | hummingbot/strategy/twap/twap.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/twap/twap.py | Apache-2.0 |
def did_fill_order(self, order_filled_event):
"""
Output log for filled order.
:param order_filled_event: Order filled event
"""
order_id: str = order_filled_event.order_id
market_info = self.order_tracker.get_shadow_market_pair_from_order_id(order_id)
if market_... |
Output log for filled order.
:param order_filled_event: Order filled event
| did_fill_order | python | hummingbot/hummingbot | hummingbot/strategy/twap/twap.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/twap/twap.py | Apache-2.0 |
def log_complete_order(self, order_completed_event):
"""
Output log for completed order.
:param order_completed_event: Order completed event
"""
order_id: str = order_completed_event.order_id
market_info = self.order_tracker.get_market_pair_from_order_id(order_id)
... |
Output log for completed order.
:param order_completed_event: Order completed event
| log_complete_order | python | hummingbot/hummingbot | hummingbot/strategy/twap/twap.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/twap/twap.py | Apache-2.0 |
def process_market(self, market_info):
"""
Checks if enough time has elapsed from previous order to place order and if so, calls place_orders_for_market() and
cancels orders if they are older than self._cancel_order_wait_time.
:param market_info: a market trading pair
"""
... |
Checks if enough time has elapsed from previous order to place order and if so, calls place_orders_for_market() and
cancels orders if they are older than self._cancel_order_wait_time.
:param market_info: a market trading pair
| process_market | python | hummingbot/hummingbot | hummingbot/strategy/twap/twap.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/twap/twap.py | Apache-2.0 |
def tick(self, timestamp: float):
"""
Clock tick entry point.
For the TWAP strategy, this function simply checks for the readiness and connection status of markets, and
then delegates the processing of each market info to process_market().
:param timestamp: current tick timestam... |
Clock tick entry point.
For the TWAP strategy, this function simply checks for the readiness and connection status of markets, and
then delegates the processing of each market info to process_market().
:param timestamp: current tick timestamp
| tick | python | hummingbot/hummingbot | hummingbot/strategy/twap/twap.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/twap/twap.py | Apache-2.0 |
def process_tick(self, timestamp: float):
"""
Clock tick entry point.
For the TWAP strategy, this function simply checks for the readiness and connection status of markets, and
then delegates the processing of each market info to process_market().
"""
current_tick = times... |
Clock tick entry point.
For the TWAP strategy, this function simply checks for the readiness and connection status of markets, and
then delegates the processing of each market info to process_market().
| process_tick | python | hummingbot/hummingbot | hummingbot/strategy/twap/twap.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/twap/twap.py | Apache-2.0 |
def place_orders_for_market(self, market_info):
"""
Places an individual order specified by the user input if the user has enough balance and if the order quantity
can be broken up to the number of desired orders
:param market_info: a market trading pair
"""
market: Excha... |
Places an individual order specified by the user input if the user has enough balance and if the order quantity
can be broken up to the number of desired orders
:param market_info: a market trading pair
| place_orders_for_market | python | hummingbot/hummingbot | hummingbot/strategy/twap/twap.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/twap/twap.py | Apache-2.0 |
def has_enough_balance(self, market_info, amount: Decimal):
"""
Checks to make sure the user has the sufficient balance in order to place the specified order
:param market_info: a market trading pair
:param amount: order amount
:return: True if user has enough balance, False if ... |
Checks to make sure the user has the sufficient balance in order to place the specified order
:param market_info: a market trading pair
:param amount: order amount
:return: True if user has enough balance, False if not
| has_enough_balance | python | hummingbot/hummingbot | hummingbot/strategy/twap/twap.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/twap/twap.py | Apache-2.0 |
def validate_order_step_size(value: str = None):
"""
Invalidates non-decimal input and checks if order_step_size is less than the target_asset_amount value
:param value: User input for order_step_size parameter
:return: Error message printed in output pane
"""
result = validate_decimal(value, mi... |
Invalidates non-decimal input and checks if order_step_size is less than the target_asset_amount value
:param value: User input for order_step_size parameter
:return: Error message printed in output pane
| validate_order_step_size | python | hummingbot/hummingbot | hummingbot/strategy/twap/twap_config_map.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/twap/twap_config_map.py | Apache-2.0 |
def __init__(self, update_interval: float = 0.5):
"""
Initialize a new instance of the SmartComponentBase class.
:param update_interval: The interval at which the control loop should be executed, in seconds.
"""
self.update_interval = update_interval
self._status: Runnab... |
Initialize a new instance of the SmartComponentBase class.
:param update_interval: The interval at which the control loop should be executed, in seconds.
| __init__ | python | hummingbot/hummingbot | hummingbot/strategy_v2/runnable_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/runnable_base.py | Apache-2.0 |
def start(self):
"""
Start the control loop of the smart component.
If the component is not already started, it will start the control loop.
"""
if self._status == RunnableStatus.NOT_STARTED:
self.terminated.clear()
self._status = RunnableStatus.RUNNING
... |
Start the control loop of the smart component.
If the component is not already started, it will start the control loop.
| start | python | hummingbot/hummingbot | hummingbot/strategy_v2/runnable_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/runnable_base.py | Apache-2.0 |
def stop(self):
"""
Stop the control loop of the smart component.
If the component is active or not started, it will stop the control loop.
"""
if self._status != RunnableStatus.TERMINATED:
self._status = RunnableStatus.TERMINATED
self.terminated.set() |
Stop the control loop of the smart component.
If the component is active or not started, it will stop the control loop.
| stop | python | hummingbot/hummingbot | hummingbot/strategy_v2/runnable_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/runnable_base.py | Apache-2.0 |
async def control_loop(self):
"""
The main control loop of the smart component.
This method is responsible for executing the control task at the specified interval.
"""
await self.on_start()
while not self.terminated.is_set():
try:
await self.c... |
The main control loop of the smart component.
This method is responsible for executing the control task at the specified interval.
| control_loop | python | hummingbot/hummingbot | hummingbot/strategy_v2/runnable_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/runnable_base.py | Apache-2.0 |
async def on_start(self):
"""
Method to be executed when the control loop is started.
This method should be overridden in subclasses to provide specific behavior.
"""
pass |
Method to be executed when the control loop is started.
This method should be overridden in subclasses to provide specific behavior.
| on_start | python | hummingbot/hummingbot | hummingbot/strategy_v2/runnable_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/runnable_base.py | Apache-2.0 |
async def control_task(self):
"""
The main task to be executed in the control loop.
This method should be overridden in subclasses to provide specific behavior.
"""
pass |
The main task to be executed in the control loop.
This method should be overridden in subclasses to provide specific behavior.
| control_task | python | hummingbot/hummingbot | hummingbot/strategy_v2/runnable_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/runnable_base.py | Apache-2.0 |
def quantize_order_amount(self, connector_name: str, trading_pair: str, amount: Decimal):
"""
Quantizes the order amount based on the trading pair's minimum order size.
:param connector_name: str
:param trading_pair: str
:param amount: Decimal
:return: Quantized amount.
... |
Quantizes the order amount based on the trading pair's minimum order size.
:param connector_name: str
:param trading_pair: str
:param amount: Decimal
:return: Quantized amount.
| quantize_order_amount | python | hummingbot/hummingbot | hummingbot/strategy_v2/backtesting/backtesting_data_provider.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/backtesting/backtesting_data_provider.py | Apache-2.0 |
def quantize_order_price(self, connector_name: str, trading_pair: str, price: Decimal):
"""
Quantizes the order price based on the trading pair's minimum price increment.
:param connector_name: str
:param trading_pair: str
:param price: Decimal
:return: Quantized price.
... |
Quantizes the order price based on the trading pair's minimum price increment.
:param connector_name: str
:param trading_pair: str
:param price: Decimal
:return: Quantized price.
| quantize_order_price | python | hummingbot/hummingbot | hummingbot/strategy_v2/backtesting/backtesting_data_provider.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/backtesting/backtesting_data_provider.py | Apache-2.0 |
async def simulate_execution(self, trade_cost: float) -> list:
"""
Simulates market making strategy over historical data, considering trading costs.
Args:
trade_cost (float): The cost per trade.
Returns:
List[ExecutorInfo]: List of executor information objects d... |
Simulates market making strategy over historical data, considering trading costs.
Args:
trade_cost (float): The cost per trade.
Returns:
List[ExecutorInfo]: List of executor information objects detailing the simulation results.
| simulate_execution | python | hummingbot/hummingbot | hummingbot/strategy_v2/backtesting/backtesting_engine_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/backtesting/backtesting_engine_base.py | Apache-2.0 |
async def update_processed_data(self, row: pd.Series):
"""
Updates processed data in the controller with the current price and timestamp.
Args:
row (pd.Series): The current row of market data.
"""
raise NotImplementedError("update_processed_data method must be implem... |
Updates processed data in the controller with the current price and timestamp.
Args:
row (pd.Series): The current row of market data.
| update_processed_data | python | hummingbot/hummingbot | hummingbot/strategy_v2/backtesting/backtesting_engine_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/backtesting/backtesting_engine_base.py | Apache-2.0 |
def prepare_market_data(self) -> pd.DataFrame:
"""
Prepares market data by merging candle data with strategy features, filling missing values.
Returns:
pd.DataFrame: The prepared market data with necessary features.
"""
backtesting_candles = self.controller.market_da... |
Prepares market data by merging candle data with strategy features, filling missing values.
Returns:
pd.DataFrame: The prepared market data with necessary features.
| prepare_market_data | python | hummingbot/hummingbot | hummingbot/strategy_v2/backtesting/backtesting_engine_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/backtesting/backtesting_engine_base.py | Apache-2.0 |
def simulate_executor(self, config: Union[PositionExecutorConfig, DCAExecutorConfig], df: pd.DataFrame,
trade_cost: float) -> Optional[ExecutorSimulation]:
"""
Simulates the execution of a trading strategy given a configuration.
Args:
config (PositionExecut... |
Simulates the execution of a trading strategy given a configuration.
Args:
config (PositionExecutorConfig): The configuration of the executor.
df (pd.DataFrame): DataFrame containing the market data from the start time.
trade_cost (float): The cost per trade.
... | simulate_executor | python | hummingbot/hummingbot | hummingbot/strategy_v2/backtesting/backtesting_engine_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/backtesting/backtesting_engine_base.py | Apache-2.0 |
def handle_stop_action(self, action: StopExecutorAction, timestamp: float):
"""
Handles stop actions for executors, terminating them as required.
Args:
action (StopExecutorAction): The action indicating which executor to stop.
active_executors (list): The list of active ... |
Handles stop actions for executors, terminating them as required.
Args:
action (StopExecutorAction): The action indicating which executor to stop.
active_executors (list): The list of active executors.
timestamp (pd.Timestamp): The current timestamp.
| handle_stop_action | python | hummingbot/hummingbot | hummingbot/strategy_v2/backtesting/backtesting_engine_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/backtesting/backtesting_engine_base.py | Apache-2.0 |
def get_controller_class(self):
"""
Dynamically load and return the controller class based on the controller configuration.
"""
try:
module = importlib.import_module(self.__module__)
base_classes = ["ControllerBase", "MarketMakingControllerBase", "DirectionalTradi... |
Dynamically load and return the controller class based on the controller configuration.
| get_controller_class | python | hummingbot/hummingbot | hummingbot/strategy_v2/controllers/controller_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/controllers/controller_base.py | Apache-2.0 |
def start(self):
"""
Allow controllers to be restarted after being stopped.=
"""
if self._status != RunnableStatus.RUNNING:
self.terminated.clear()
self._status = RunnableStatus.RUNNING
self.executors_update_event.set()
safe_ensure_future(s... |
Allow controllers to be restarted after being stopped.=
| start | python | hummingbot/hummingbot | hummingbot/strategy_v2/controllers/controller_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/controllers/controller_base.py | Apache-2.0 |
def update_config(self, new_config: ControllerConfigBase):
"""
Update the controller configuration. With the variables that in the client_data have the is_updatable flag set
to True. This will be only available for those variables that don't interrupt the bot operation.
"""
for n... |
Update the controller configuration. With the variables that in the client_data have the is_updatable flag set
to True. This will be only available for those variables that don't interrupt the bot operation.
| update_config | python | hummingbot/hummingbot | hummingbot/strategy_v2/controllers/controller_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/controllers/controller_base.py | Apache-2.0 |
async def update_processed_data(self):
"""
This method should be overridden by the derived classes to implement the logic to update the market data
used by the controller. And should update the local market data collection to be used by the controller to
take decisions.
"""
... |
This method should be overridden by the derived classes to implement the logic to update the market data
used by the controller. And should update the local market data collection to be used by the controller to
take decisions.
| update_processed_data | python | hummingbot/hummingbot | hummingbot/strategy_v2/controllers/controller_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/controllers/controller_base.py | Apache-2.0 |
async def update_processed_data(self):
"""
Update the processed data based on the current state of the strategy. Default signal 0
"""
self.processed_data = {"signal": 0, "features": pd.DataFrame()} |
Update the processed data based on the current state of the strategy. Default signal 0
| update_processed_data | python | hummingbot/hummingbot | hummingbot/strategy_v2/controllers/directional_trading_controller_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/controllers/directional_trading_controller_base.py | Apache-2.0 |
def create_actions_proposal(self) -> List[ExecutorAction]:
"""
Create actions based on the provided executor handler report.
"""
create_actions = []
signal = self.processed_data["signal"]
if signal != 0 and self.can_create_executor(signal):
price = self.market... |
Create actions based on the provided executor handler report.
| create_actions_proposal | python | hummingbot/hummingbot | hummingbot/strategy_v2/controllers/directional_trading_controller_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/controllers/directional_trading_controller_base.py | Apache-2.0 |
def can_create_executor(self, signal: int) -> bool:
"""
Check if an executor can be created based on the signal, the quantity of active executors and the cooldown time.
"""
active_executors_by_signal_side = self.filter_executors(
executors=self.executors_info,
fil... |
Check if an executor can be created based on the signal, the quantity of active executors and the cooldown time.
| can_create_executor | python | hummingbot/hummingbot | hummingbot/strategy_v2/controllers/directional_trading_controller_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/controllers/directional_trading_controller_base.py | Apache-2.0 |
def get_required_base_amount(self, reference_price: Decimal) -> Decimal:
"""
Get the required base asset amount for sell orders.
"""
_, sell_amounts_quote = self.get_spreads_and_amounts_in_quote(TradeType.SELL)
total_sell_amount_quote = sum(sell_amounts_quote)
return tota... |
Get the required base asset amount for sell orders.
| get_required_base_amount | python | hummingbot/hummingbot | hummingbot/strategy_v2/controllers/market_making_controller_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/controllers/market_making_controller_base.py | Apache-2.0 |
def get_price_and_amount(self, level_id: str) -> Tuple[Decimal, Decimal]:
"""
Get the spread and amount in quote for a given level id.
"""
level = self.get_level_from_level_id(level_id)
trade_type = self.get_trade_type_from_level_id(level_id)
spreads, amounts_quote = self... |
Get the spread and amount in quote for a given level id.
| get_price_and_amount | python | hummingbot/hummingbot | hummingbot/strategy_v2/controllers/market_making_controller_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/controllers/market_making_controller_base.py | Apache-2.0 |
def check_position_rebalance(self) -> Optional[CreateExecutorAction]:
"""
Check if position needs rebalancing and create OrderExecutor to acquire missing base asset.
Only applies to spot trading (not perpetual contracts).
"""
# Skip position rebalancing for perpetual contracts
... |
Check if position needs rebalancing and create OrderExecutor to acquire missing base asset.
Only applies to spot trading (not perpetual contracts).
| check_position_rebalance | python | hummingbot/hummingbot | hummingbot/strategy_v2/controllers/market_making_controller_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/controllers/market_making_controller_base.py | Apache-2.0 |
def get_current_base_position(self) -> Decimal:
"""
Get current base asset position from positions held.
"""
total_base_amount = Decimal("0")
for position in self.positions_held:
if (position.connector_name == self.config.connector_name and
positi... |
Get current base asset position from positions held.
| get_current_base_position | python | hummingbot/hummingbot | hummingbot/strategy_v2/controllers/market_making_controller_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/controllers/market_making_controller_base.py | Apache-2.0 |
def create_position_rebalance_order(self, side: TradeType, amount: Decimal) -> CreateExecutorAction:
"""
Create an OrderExecutor to rebalance position.
"""
reference_price = self.processed_data["reference_price"]
# Use market price for quick execution
order_config = Orde... |
Create an OrderExecutor to rebalance position.
| create_position_rebalance_order | python | hummingbot/hummingbot | hummingbot/strategy_v2/controllers/market_making_controller_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy_v2/controllers/market_making_controller_base.py | Apache-2.0 |
def __init__(self, strategy: ScriptStrategyBase, connectors: List[str], config: ExecutorConfigBase, update_interval: float = 0.5):
"""
Initializes the executor with the given strategy, connectors and update interval.
:param strategy: The strategy to be used by the executor.
:param conne... |
Initializes the executor with the given strategy, connectors and update interval.
:param strategy: The strategy to be used by the executor.
:param connectors: The connectors to be used by the executor.
:param update_interval: The update interval for the executor.
| __init__ | 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 |
async def on_start(self):
"""
Called when the executor is started.
"""
await self.validate_sufficient_balance() |
Called when the executor is started.
| on_start | 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 |
async def validate_sufficient_balance(self):
"""
Validates that the executor has sufficient balance to place orders.
"""
raise NotImplementedError |
Validates that the executor has sufficient balance to place orders.
| validate_sufficient_balance | 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 register_events(self):
"""
Registers the events with the connectors.
"""
for connector in self.connectors.values():
for event_pair in self._event_pairs:
connector.add_listener(event_pair[0], event_pair[1]) |
Registers the events with the connectors.
| register_events | 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 unregister_events(self):
"""
Unregisters the events from the connectors.
"""
for connector in self.connectors.values():
for event_pair in self._event_pairs:
connector.remove_listener(event_pair[0], event_pair[1]) |
Unregisters the events from the connectors.
| unregister_events | 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 place_order(self,
connector_name: str,
trading_pair: str,
order_type: OrderType,
side: TradeType,
amount: Decimal,
position_action: PositionAction = PositionAction.NIL,
price=D... |
Places an order with the specified parameters.
:param connector_name: The name of the connector.
:param trading_pair: The trading pair for the order.
:param order_type: The type of the order.
:param side: The side of the order (buy or sell).
:param amount: The amount fo... | place_order | 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 process_order_completed_event(self,
event_tag: int,
market: ConnectorBase,
event: Union[BuyOrderCompletedEvent, SellOrderCompletedEvent]):
"""
Processes the order completed event. This m... |
Processes the order completed 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_completed_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 process_order_created_event(self,
event_tag: int,
market: ConnectorBase,
event: Union[BuyOrderCreatedEvent, SellOrderCreatedEvent]):
"""
Processes the order created event. This method should b... |
Processes the order created 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_created_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 process_order_canceled_event(self,
event_tag: int,
market: ConnectorBase,
event: OrderCancelledEvent):
"""
Processes the order canceled event. This method should be overridden by subclasses... |
Processes the order canceled 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_canceled_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 process_order_filled_event(self,
event_tag: int,
market: ConnectorBase,
event: OrderFilledEvent):
"""
Processes the order filled event. This method should be overridden by subclasses.
:p... |
Processes the order filled 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_filled_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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.