pkweitai / hummingbotAI

Hummingbot AI enablement contributions from community
Other
3 stars 0 forks source link

[feature] Create a chat agent that does multi-step follow up with user on trading requests, and emits trade commands at the end #12

Open martinkou opened 2 weeks ago

martinkou commented 2 weeks ago

Why

In a free-form chat interface, a user may give a trade intent message with insufficient information to carry out an actual trade.

e.g.

Buy me some $MOTHER"

When it comes to executing a trade, the following information are needed and they should be precise

  1. Exchange and trading pair
  2. Amount
  3. Price and order type (limit or market)

To make things more complicated, some of these information can be inferred. e.g.

  1. If the user is only connected to one exchange, we can safely assume he wants to just that exchange;
  2. If the user wants to buy or sell a {token symbol} rather than a trading pair, and the biggest {token symbol} pairs on the selected exchange is {token symbol}-USD or {token symbol}-USDT, we can safely assume he wants to trade on the USD or USD stablecoin pair;
  3. If the user wants to trade without specifying an order type, we can safely assume he wants immediate execution and thus a market-like order (in crypto we usually do this with a limit order that crosses the order book, to control slippage, however);
  4. The user may not have enough balance on his exchange to carry out a proposed trade.

This means the system prompt and logic flow needs to be aware of the current Hummingbot settings (e.g. which exchange it is connected to); the user's current portfolio, and finally, keep following up with the user until it has enough information to form a trade command.

Finally, if the user starts to chat about other non-trading things, or wants to bail out from completing a trading order - the system prompt should allow for bailing out from the trading order mode and going back to the general chat interface.

What

  1. Craft a custom system prompt that satisfies the requirements above;
  2. Draft an API spec on how the chat agent interacts with trading backend (e.g. via MQTT) and the rest of the chat system;
  3. Craft a test script with a number of different test cases to demonstrate the system prompt works.