Skip to content
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

Fix creation of stop orders #370

Merged
merged 4 commits into from
Nov 22, 2020

Conversation

JonasSteur
Copy link
Contributor

@JonasSteur JonasSteur commented Jul 28, 2019

Related issue: #368

A 'stop' isn't an actual order type but is actually a special flavour of
a limit order. The 'stop' and 'stop_price' params need to be set.

There are 2 stop types:

  1. loss (triggers at or below the stop price) -> this has to be a sell
    order to be valid (the Coinbase Pro will respond with an error
    otherwise)
  2. entry (trigger at or above the stop price) -> has to be a buy

Modified existing test and added new test to check for invalid combinations.

A 'stop' isn't an actual order type but is actually a special flavour of
a limit order. The 'stop' and 'stop_price' params need to be set.

There are 2 stop types:
1. loss (triggers at or below the stop price) -> this has to be a sell
order to be valid (the Coinbase Pro will respond with an error
otherwise)
2. entry (trigger at or above the stop price) -> has to be a buy

Modified existing and added new test.
Copy link

@jacov jacov left a comment

Choose a reason for hiding this comment

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

running into this as well, please merge

@jacov
Copy link

jacov commented Jul 14, 2020

i was able to work around this using the regular .sell with limit function and adding the stop and stop_price args as follows:

    response = auth_client.sell(price=str(LIMIT_PRICE),
                    size=str(QTY),
                    order_type='limit',
                    stop='loss',
                    stop_price=str(LIMIT_PRICE),
                    product_id=str(SYMBOLUSD))

@mcardillo55
Copy link
Collaborator

This looks great! Just one minor thing - in the assert r['stop_price]' line in the test, I'm getting '100' back from the sandbox, not '100.00000000'. Perhaps this behavior has changed since your PR? Is this what you get now as well? I'd like to merge this with a passing test. Thanks!

@bryanminorphd
Copy link

bryanminorphd commented Nov 21, 2020

@jacov - So you set the 'price' and 'stop_price' to the desired Stop loss price? Since the Stop_Loss prices is typically below the current price, this will not be a problem with this Limit price?

Since you used the 'LIMIT_PRICE' for both 'price and 'stop_price' I was concerned.

@mcardillo55
Copy link
Collaborator

Made a few minor changes to get the merge in. Thanks again.

@mcardillo55 mcardillo55 merged commit 8186cf2 into danpaquin:master Nov 22, 2020
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.

None yet

4 participants