这是indexloc提供的服务,不要输入任何密码
Skip to content

Feat/add new order types #7254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 55 commits into
base: development
Choose a base branch
from

Conversation

MementoRC
Copy link
Contributor

Before submitting this PR, please make sure:

  • Your code builds clean without any errors or warnings
  • You are using approved title ("feat/", "fix/", "docs/", "refactor/")

A description of the changes proposed in the pull request:
Adds **kwargs to StrategyBase class to enable support for other order type (STOP LIMIT, TAKE PROFIT, TRAILING STOP, etc...)

Tests performed by the developer:

  • coverage run -m nose test/hummingbot/strategy
  • tests with custom Kraken connector with these order types enabled

Tips for QA testing:

@MementoRC
Copy link
Contributor Author

@cardosofede FYI

@nikspz nikspz changed the base branch from master to development October 21, 2024 14:28
@MementoRC
Copy link
Contributor Author

@nikspz thanks

Copy link
Contributor

@cardosofede cardosofede left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solution might be a good approach to support multiple order types. Just add them to one connector and let QA test. Good work!

# New order types
STOP_LOSS = 4
TAKE_PROFIT = 5
TRAILING_STOP = 6

def is_limit_type(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we need to review carefully if there is a possibility that the take profit order type is limit for the is_liimit_type condition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Kraken, TAKE_PROFIT has a different entry form and it executes as a MARKET order when the % or the price difference is matched, same for the other. Kraken does have limit equivalent to these. I will commit my modifications of the Kraken connector then - It will take a bit longer, I need to clean-up and ad tests in this case

@MementoRC MementoRC marked this pull request as ready for review October 22, 2024 15:39
@MementoRC MementoRC marked this pull request as draft October 22, 2024 15:39
@MementoRC MementoRC marked this pull request as ready for review October 22, 2024 15:39
@MementoRC
Copy link
Contributor Author

Setting review to check on the tests

@rapcmia rapcmia self-requested a review October 28, 2024 14:58
Copy link

@rapcmia
Copy link
Contributor

rapcmia commented Oct 30, 2024

PR update:

  • Ran test on Kraken
  • Run simple pmm script-config, limit and limit_maker ✅
  • Run market order script, market ✅
  • Im still looking on how I can run tests the rest of order types stoploss, takeprofit and trailingstop by playing around with current available scripts and controller-configs in progress

@cardosofede
Copy link
Contributor

@MementoRC if you can provide a script so @rapcmia can test an advanced order will be cool!

@MementoRC
Copy link
Contributor Author

@MementoRC if you can provide a script so @rapcmia can test an advanced order will be cool!

Yes, I am working on a simplistic position executor for demonstration

@cardosofede
Copy link
Contributor

@nikspz @MementoRC
I reviewed the PR again and seems like what memento did makes sense, idk if you started testing Nikita but is time to do it

@MementoRC
Copy link
Contributor Author

Next we'll need to add the LIMIT versions. It's actually critical for the fees, on Kraken we can get to 0% fee on maker!

@nikspz
Copy link
Contributor

nikspz commented Feb 5, 2025

One thing is that the new orders do not seem to be Trades and they generate QueryTrades errors:

15:14:44 hummingbot.connector.exchange.kraken.kraken_exchange.KrakenExchange - DEBUG -   '-> Placed OrderType.STOP_LOSS {'txid': ['OOYF6D-GU6UW-YFGIPZ'], 'descr': {'order': 'sell 0.00006524 XBTUSD @ stop loss -0.1000%'}} with id OOYF6D-GU6UW-YFGIPZ
15:14:44 hummingbot.core.event.event_reporter - EVENT_LOG - {"timestamp": 1731100484.0, "type": "OrderType.STOP_LOSS", "trading_pair": "BTC-USD", "amount": "0.00006524", "price": "0.1", "order_id": "649485478", "creation_timestamp": 1731100484.0, "exchange_order_id": "OOYF6D-GU6UW-YFGIPZ", "leverage": 1, "position": "NIL", "event_name": "SellOrderCreatedEvent", "event_source": "kraken"}
15:16:00 hummingbot.connector.exchange.kraken.kraken_exchange.KrakenExchange - ERROR - Error fetching data from /0/private/QueryTrades, msg is {'error': ['EOrder:Invalid order']} for {'txid': 'OOYF6D-GU6UW-YFGIPZ'}
15:18:00 hummingbot.connector.exchange.kraken.kraken_exchange.KrakenExchange - ERROR - Error fetching data from /0/private/QueryTrades, msg is {'error': ['EOrder:Invalid order']} for {'txid': 'OOYF6D-GU6UW-YFGIPZ'}
15:18:23 hummingbot.core.event.event_reporter - EVENT_LOG - {"timestamp": 1731100703.0, "order_id": "649485478", "trading_pair": "BTC-USD", "trade_type": "TradeType.SELL", "order_type": "OrderType.STOP_LOSS", "price": "76554.40000", "amount": "0.00006524", "trade_fee": {"percent": "0", "percent_token": "USD", "flat_fees": [{"token": "USD", "amount": "0.01998"}]}, "exchange_trade_id": "TDAD3H-4KM22-PL734G", "exchange_order_id": "OOYF6D-GU6UW-YFGIPZ", "leverage": 1, "position": "NIL", "event_name": "OrderFilledEvent", "event_source": "kraken"}
15:18:23 hummingbot.core.event.event_reporter - EVENT_LOG - {"timestamp": 1731100703.0, "order_id": "649485478", "base_asset": "BTC", "quote_asset": "USD", "base_asset_amount": "0.00006524", "quote_asset_amount": "4.9944090560000", "order_type": "OrderType.STOP_LOSS", "exchange_order_id": "OOYF6D-GU6UW-YFGIPZ", "event_name": "SellOrderCompletedEvent", "event_source": "kraken"}

The order is placed (seen on exchange), but it is not showing-up in query trades, but then it is triggered

Yep, reproduced on the latest commit b8b0f9d
image

Also reproduced error #7397 using this PR

Steps:
Connect to kraken exchange on hummingbot
Start any V2 strategy with kraken exchange
Does not start the strategy and gives ValueError: '' is not a valid KrakenAPITier ` Error

image

@MementoRC
Copy link
Contributor Author

MementoRC commented Feb 5, 2025

Ok, I understand, but this PR should not include the Kraken part, I added it to help QA for the new order mechanics. I will look into how to add this support in the Kraken connector. It is not a Trade yet after being placed, so we need to intercept the request. Once completed, everything should return to normal
So actually I do have a Kraken PR, maybe I should simply , remove the Kraken-related commits from this PR and PR a new companion Kraken PR?
I would try to include the fix and other nagging things I found on Kraken like the "nonce" warning/error

@MementoRC
Copy link
Contributor Author

@nikspz I made a complete mess at my end and mistakenly pushed be fore realizing what had happened, hopefully it's completely cleaned up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Discussion
Development

Successfully merging this pull request may close these issues.

5 participants