Negative time estimation from estimatefees + mempool data I am currently writing a time estimation tool for Bitcoin, and it gives me wrong estimations, so I am not sure if it's accurate and if I am not doing some error in logic.

For example, I have this transaction

https://blockchain.info/tx/388f99d51cfce4f18f0c76257fff7666ffd272394ee0316df529383c6d22ed66


It has 10 sat/B (both virtual size and real size). It has 0 ancestors in mempool, all its inputs are confirmed. (all from getmempoolentry call)
Estimatesmartfee returns 11.089 sat/B for 192 blocks, that is 1 day and 8 hours.
The transaction was seen about 4 days ago (again, according to time in its mempool entry) and is still unconfirmed. 


That means it should have been confirmed 3 days ago. So its estimated confirmation time is -3 days, which is impossible.

What am I doing wrong?
Fee estimation is mostly progress free, in the same way as waiting for Bitcoin blocks, that is the estimate for how long it will take to get confirmed from now is unrelated to how long you have been waiting.  I say mostly, because there are clearly daily and weekly cycles in transaction activity that result in the fact that overnight or over the weekend there are greater chances of getting confirmed.

Aside from that, fee estimation in Core is purely backwards looking, and can only tell you what happened in the recent past to transactions of a certain fee rate.  It can not predict the future.  If 2/3 of the hash rate disappears as is the case with the transaction you presented, then it is to be expected that it could take many more blocks than the estimate had previously predicted.

Also, Core fee estimation tries to give a fairly conservative estimate, so in theory you should most of the time be confirmed in less than the target number of blocks. So you could ask for current estimates until you find one which is lower than the fee rate in question and this should give you some guess as to how much longer you might need to wait, but again it can't predict the future.

About only the definitive thing you might be able to get, is if you know you placed the transaction X blocks ago and if you ask for a fee estimate for X/2 blocks now and the answer is less than the fee rate you put on the transaction then it is reasonable to question why your transaction has not been confirmed yet.