Cost Basis is wrong on Exchange trade

Describe the problem:
Traded USDT for LTC and then sometime later the same LTC back to USDT.
The second exchange trade produced a very inaccurate. What I noticed the second trade Binance held a very tiny amount fraction of LTC back, this seemed to cause Koinly to apply some random cost basis for the second trade. There is no way of editing the cost basis because its all API and thus its wildly inaccurate and in this case shows a large loss when it should have been a small gain.

Which exchange/wallet is this regarding?

Binance SPOT
How did you import data into this wallet?
Its the SPOT trade

What have you tried to fix this so far?
unable to edit API data applied by Koinly

I tried to put in a manual transaction to replace the API one but I get the same cost basis amount applied to the second exchange of coins.
So whats happening is say I $700 usdt and traded that for LTC , which in turn gave me an amount in NZD dollars say $1200. When I go to exchange / trade that back again
LTC - USDT the system is giving me a brand new cost basis much higher than when I bough the LTC
$1400 , this does not make sense at all.
Even trying to add a manual transaction instead of the API still gets a similar result. ?
I should be able to edit the cost basis - how can I do this or get around this ?

Maybe you bought LTC before for a higher price and still hold it? With FIFO you sell first what you bought first. That could lead to the results you see.

Thanks yes it is like that.
I literally bought LTC with USDT and 8 hours later sold the same LTC back into USDT
But that second sell the system applys the current “cost basis” value of the LTC at that moment of time but the second exchange gives me a massive loss value which makes no sense.
The system does not allow me to edit the cost value or the time.
How do we get around this ? I should have an overall small gain

I still don’t understand. Did you own LTC already BEFORE you bought some at that day? Maybe you still have some other LTC you bought in 2018?

Yes I did actually on another platform and held in a different wallet, but not sure that comes into this ? I was affectively trying to buy some LTC and trade the same amount of LTC on binance while not touching the older LTC purchases. Does that that upset the calculations somehow ?

Try to change your settings. I think that switching “Wallet based cost tracking” on should do the job.

Thanks Don, setting that appears to have fixed that problem. Thanks so much.
I will have to try to understand what that setting does but it clearly seems to have fixed my issue.
Thanks again

It’s not so complicated. Let’s assume that that you bought 1 LTC in 2018 and put it in wallet 1. Then you bought 2 LTC in 2020 and put it in wallet 2. After that you sold the 2 LTC from wallet 2.
The standard FIFO (first in first out) approach does not care about the wallets but only at the total amount of coins you own. Therefore with this approach you effectively sold the one LTC you bought in 2018 and one from 2020.
With wallet based cost tracking, the LTC from 2018 keeps untouched and the two LTC from 2020 are sold. Clear now?

Yes, thankyou for your help

This article may also help:
https://help.koinly.io/en/articles/3661351-cost-tracking-method-explained