studerw / td-ameritrade-client

TD Ameritrade Java Client
Apache License 2.0
69 stars 47 forks source link

Fetching Child Order Price #50

Open ajaythukral opened 3 years ago

ajaythukral commented 3 years ago

Hi All, I have submitted Trigger order (One triggers other Buy and Sell). My Buy order has been filled but my sell order has not been filled. I want to fetch my triggered sell order but I am not getting it. Is there any API I can call for the same.

studerw commented 3 years ago

@aja When you submit orders, the TDA API doesn't actually send you back any sort of confirmation that they were filled or not, because they put them on some internal queue (I believe), and it may or may not fill anytime soon, so you can 't just block indefinitely.

Other people have had this same question, and as far as I know, the only good way to deal with this is to submit an order, and then sit in a loop with exponentially increasing "sleep time" and continue to poll all orders until you've found a match or until some threshold is reached where you just give up (othewise you'll never escape the polling loop if there is an error on TDA's end).

Somebody had once mentioned that they saw TDA was returning a header with some callback URL that made available the status of a submitted order, but I didn't see any docs about that on their new dev site / API last time I looked.