0% found this document useful (0 votes)
44 views1 page

Cheatsheet

The document provides an overview of using crypto trading bots, detailing how to access account data, manage connectors, and implement various trading strategies. It includes instructions for installation, coding scripts, and handling market events, as well as methods for querying order books and managing orders. Additionally, it outlines configuration and execution processes for scripts, including notifications and budget checking functionalities.

Uploaded by

monatata217
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views1 page

Cheatsheet

The document provides an overview of using crypto trading bots, detailing how to access account data, manage connectors, and implement various trading strategies. It includes instructions for installation, coding scripts, and handling market events, as well as methods for querying order books and managing orders. Additionally, it outlines configuration and execution processes for scripts, including notifications and budget checking functionalities.

Uploaded by

monatata217
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

> Account data > Connectors

Balance Accessing the connectors


Crypto Trading Bots self.get_balance_df()
Returns a DataFrame with the following columns:
They are stored in the instance variable connectors with the
following structure:
["Exchange", "Asset", "Total Balance", "Available Balance"] Dict["connector_name", ConnectorBase]
Scripts Strategies Cheat Sheet [Link]["binance"] will return the Binance
Open Orders
exchange class.
self.active_orders_df()

>
Returns a DataFrame with the following columns: Connectors Methods
Getting started ["Exchange", "Market", "Side", "Price", "Amount", "Age"]
Best ask: connector.get_price(trading_pair, is_buy: True)
Best bid: connector.get_price(trading_pair, is_buy: False)
Last edit: Dec, 2022 Mid-price: connector.get_mid_price(trading_pair)

>
Author: Federico Cardoso @dardonacci Order book: connector.get_order_book(trading_pair)

1. Install Anaconda
Events Returns a CompositeOrderBook and the most common methods are:
ask_entries() --> Iterator of OrderBookRow
2. Open a terminal and run: To handle different market events in the strategy by implementing bid_entries() --> Iterator of OrderBookRow
>>> git clone [Link] the following methods. snapshot() --> Tuple(Bids as DataFrame, Asks as DataFrame)
>>> cd hummingbot did_create_buy_order(self, event: BuyOrderCreatedEvent) Example:
>>> ./install did_create_sell_order(self, event: SellOrderCreatedEvent) [Link]["binance"].get_mid_price("ETH-USDT")
>>> conda activate hummingbot did_fill_order(self, event: OrderFilledEvent)
>>> ./compile did_fail_order(self, event: MarketOrderFailureEvent) Querying the Order Book
3. Code your script under the scripts folder! did_cancel_order(self, event: OrderCancelledEvent) Use these methods to compute metrics efficiently:
did_expire_order(self, event: OrderExpiredEvent) connector.get_vwap_for_volume(trading_pair, is_buy, volume)

>
did_complete_buy_order(self, event: BuyOrderCompletedEvent) connector.get_price_for_volume(trading_pair, is_buy, volume)
Scripts basics did_complete_sell_order(self, event: SellOrderCompletedEvent) connector.get_quote_volume_for_base_amount(trading_pair, is_buy,
base_amount)
Configuration connector.get_volume_for_price(trading_pair, is_buy, price)
connector.get_quote_volume_for_price(trading_pair, is_buy,

>
The Scripts are a subclass of ScriptStrategyBase price)
You can define the variables that you will use as class Other Returns a ClientOrderBookQueryResult class with:
variables, there is no configuration file for scripts. query_price
Rate Oracle query_volume
Markets result_price
Provides conversion rates for any given pair token symbols in both
Define the connectors and trading pairs, in the class variable result_volume
async and sync fashions.
markets, with the following structure: Sync method: RateOracle.get_instance().get_pair_rate(trading_pair)
Dict["connector_name", Set(Trading pairs)]

Execution
Async method: RateOracle.get_instance().rate_async(trading_pair)

Notifiers
> Accounting
Order Candidate
The method on_tick is executed every tick_size.
To send notifications to the Hummingbot Application using the OrderCandidate(trading_pair, is_maker, order_type, order_side,
The tick_size by default is 1 second.
following methods: amount, price)
self.notify_hb_app(msg) Has methods to populate the object with the collateral needed,

>
self.notify_hb_app_with_timestamp(msg) the fees, and potential returns.
Market operations Note: if you have the Telegram integration activated, you will
Budget Checker
receive the notifications there too. connector.budget_checker.adjust_candidate(OrderCandidate,
Create and Cancel orders
all_or_none=True)
[Link](connector_name, trading_pair, amount, order_type, Status
connector.budget_checker.adjust_candidates(List[OrderCandidate],
price, position_action) When you run the status command in the app, you will receive the all_or_none=True)
[Link](connector_name, trading_pair, amount, order_type, information that is coded under the method format_status.
price, position_action) You can implement this method in your script to show the info Note: This checks if the balance is enough to place the order,
[Link](connector_name, trading_pair, order_id) that you want all_or_none=True will set the amount to 0 on insufficient balance
By default, the format status shows the balances and active and all_or_none=False will adjust the order size to the available
Note: position_action is only used in perpetuals. orders. (check the implementation in ScriptStrategyBase) balance.

You might also like