jessecooper / pyetrade

Python E-Trade API Wrapper
GNU General Public License v3.0
209 stars 97 forks source link

change existing orders #15

Closed hz2018tv closed 4 years ago

hz2018tv commented 4 years ago

hi, can we change existing orders directly? I know it can be done by canceling the old ones and place new ones. ETRADE API doc seems to have /change/place.

jessecooper commented 4 years ago

This is definitely an area that needs some work and is listed out in the https://github.com/jessecooper/pyetrade/blob/master/pyetrade/order.py TODOs. Contributions are always welcome as I do not at the moment have any timeline on when I will be able to implement this.

hz2018tv commented 4 years ago

I did give it a shot, but got service not available, so not sure if it is doable, even it is listed in their docs.

jessecooper commented 4 years ago

What was the error? If you would like we can use this thread to try and troubleshoot the issue your having. Do you have a fork with a branch with these changes? I would be willing to take a look.

hz2018tv commented 4 years ago

I did not fork a branch. just some quick hacks to see how it goes.

In the preview function, I added an "orderNum"=order_id in the "order" section. then got Response status_code=405. sub error code=9999. I guess these mean "service not available". In the order placing function, change the url to /v1/accounts//orders//change/place, got error_code=9999.

jessecooper commented 4 years ago

Are you using a PUT or a POST? that might be the issue.

hz2018tv commented 4 years ago

that is it! passed with put.

hz2018tv commented 4 years ago

so, regarding modifications to pyetrade, it is up to you to add new functions for preview_change and place_change or add if..else in the existing functions. please let me know if I can help. thanks again.

jessecooper commented 4 years ago

It sounds like it might just make a good param with if/else but it really could go either way. Ill leave it up to you as the implementer to decide what would be the cleanest implementation. I would look at the params and see if it make sense as just a param or if it would be better as a method(s) given the args it takes are different enough to warrant its own method. I would also take into account the size of the method given you wouldn't want to over complicate a method. After saying all this. I think it would be best in its own method for speed. It would not have to perform any type of checks when placing an order or a change.

TL;DR lets go with each having its own method.

hz2018tv commented 4 years ago

Sorry, didnt see email notifications on this till this weekend. please review the pull request. Thanks