Skip to content

Add activation_price str and repr tests #2620

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

Merged
merged 1 commit into from
May 10, 2025

Conversation

hope2see
Copy link
Contributor

Pull Request

  • Add 'activation_price' property to Order class
  • Add tests for str(), repr() format of trailing stop orders to test_orders.py

Type of change

Delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • [v] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this change been tested?

Passed the existing pytests, and newly added pytests.

@cjdsellers cjdsellers changed the title Add 'activation_price' property, and tests for str(), repr() of trailing stop orders Add activation_price str and repr tests May 10, 2025
@cjdsellers
Copy link
Member

Hi @hope2see

Many thanks!

@cjdsellers cjdsellers merged commit 90c7c0a into nautechsystems:develop May 10, 2025
17 checks passed
@stastnypremysl
Copy link
Collaborator

Hi, @hope2see.

It's great, you have contributed tests for the activation price.

I see there some further space for improvements, concretely testing following cases:
For each activation_price in {<BID, =BID, =MID, =ASK, >ASK}, order side {BUY, SELL} testing these scenarios (when applicable)

  1. Market moves away from the activation_price
  2. Market moves towards the activation_price, with activation price still far from BID, ASK, MID
  3. Market moves through the activation_price
  4. Market moves exactly on activation_price by BID
  5. Market moves exactly on activation_price by ASK
  6. Market moves exactly on activation_price by MID

Further testing, whether trailing stop order behaves normally after activated would be also great. This can be done, I think, via blackbox test with further more test cases covered.

Would you be willing to add these to the testing? Adding any of these would reduce the possibility of bug present.

If you decide to add these, doing it by parametrized testing cases might be the right way to go.

@hope2see
Copy link
Contributor Author

@stastnypremysl
I've already added some tests in test_exchange_trailing_stops.py
Though they don't cover all the possible scenarios, I guess they cover major use cases.

test_trailing_stop_market_order_trail_activate_and_sell
test_trailing_stop_market_order_trail_activate_and_buy
test_trailing_stop_limit_order_trail_activate_and_sell
test_trailing_stop_limit_order_trail_activate_and_buy

@stastnypremysl
Copy link
Collaborator

@hope2see, I missed these before.

Yes, they cover the major use cases, but I still miss there some things from above like what happens on the other top of the book end and that it doesn't do anything else (this can be asserted via simple blackbox test - it's like writing a strategy with asserts, that trailing stop order behaves exactly as it should on the given data).

Let me know, if you decide to write further tests and you needed to assist with something (e.g. how should the asserts in blackbox test look like to test the behavior of trailing stop order) But I will be now at least one week off, so expect, I will respond later.

@hope2see
Copy link
Contributor Author

@stastnypremysl
Yes, there are many uncovered tests including those you mentioned.
However I don't think they are urgent, and I am tied up with other works.
When I decide to write additional tests for trailing stop orders, I'll let you know.
Thank you!

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

Successfully merging this pull request may close these issues.

3 participants