ncortines / morgan-stanley-pl

MIT License
42 stars 8 forks source link

Wrong sale date with limited order #16

Closed RaNo99 closed 3 years ago

RaNo99 commented 4 years ago

When a sale originates from a limited order, a wrong date is used for the sale. The date when the order was placed is used. The actual sale date should be used instead.

ncortines commented 4 years ago

@RaNo99, unfortunately I don't have access to this sort of data. I'd need you to help me by providing some JSON files.

RaNo99 commented 4 years ago

Here you go:

endpoint: /sw-ptpapi/v1/withdrawals/realtimeTransactions/*

Response part of interest:

{ //... "order" : { "exchangeFriendlyTzShortName" : "EST", "fillsIfNotTooMany" : [ { "fillDateTime" : "2019-11-25T11:11:09", "fillPrice" : { "amount" : "CENSORED", "currency" : "USD" }, "fillQuantity" : "CENSORED" }, { "fillDateTime" : "2019-11-25T11:11:09", "fillPrice" : { "amount" : "CENSORED", "currency" : "USD" }, "fillQuantity" : "CENSORED" }, { "fillDateTime" : "2019-11-25T11:11:09", "fillPrice" : { "amount" : "CENSORED", "currency" : "USD" }, "fillQuantity" : "CENSORED" } ], "formattedSymbolAndExchange" : "CENSORED", "goodTillCancel" : true, "limitOrder" : true, "limitPrice" : { "amount" : "CENSORED", "currency" : "USD" }, "orderDate" : "2019-11-12", "orderQuantity" : "CENSORED", "orderStatusDescription" : "Order is done", "totalFillQuantity" : "CENSORED", "uniqueFillDate" : "2019-11-25", "weightedAverageFillPrice" : { "amount" : "CENSORED", "currency" : "USD" } }, //... }

The order was placed on 2019-11-12. Then it waited until 2019-11-25 when the stock price finally grew high enough to match the ordered price. Then, in this particular case, it was sold in three parts (because not immediately there were enough buyers to buy all the stock units at the price I ordered). It's possible that a sale like this could extend over a few days (fortunately in my case all parts were sold on the same day), and that's where I think uniqueFillDate becomes helpful.

RaNo99 commented 3 years ago

It works fine for me now. Thanks @ncortines .