provinzio / CoinTaxman

Calculate your taxes from cryptocurrency gains
GNU Affero General Public License v3.0
143 stars 31 forks source link

Retrieving local fiat prices when (Asset)(local fiat) pair is not available. #17

Open provinzio opened 3 years ago

provinzio commented 3 years ago

_get_prices_binance already realizes a method, to retrieve the local fiat price for an asset, for which the exchange does not provide a direct pair.

We could implement the logic from _get_prices_binance genericly, so that every get_prices function is able to handle this kind of case.

Idea taken from /u/frugaleringenieur from reddit [1] [2]

provinzio commented 3 years ago

16 is currently implementing the module ccxt for (initially only binance) price gathering. ccxt supports quite a lot of different exchanges. We might be able to realize this issue through #16 using the library to gather all of our prices from different exchanges.

wearymanateevedaknotstabooresisting commented 3 years ago

_get_price_kraken fails for certain pairs at certain times, see warning below. Additionally, XDGEUR does not always fail, requesting the ticker before and after this timestamp succeeded.

2021-03-06 13:37:41,195 price_data   DEBUG    Querying trades for XDGEUR at 2018-01-28 XX:XX:XX+00:00 (offset=120m): Calling https://api.kraken.com/0/public/Trades?pair=XDGEUR&since=15171XXXXX000000000
2021-03-06 13:37:41,543 price_data   WARNING  Querying trades for XDGEUR at 2018-01-28 XX:XX:XX+00:00: Failed to find matching exchange rate. Please create an Issue or PR.

The API call, however, does produce a valid response with no error, so the actual issue which is triggering the warning, seems to be the processing of the API response.

Further, the pair XDGEUR is often also referred at kraken with XXDGZEUR.

wearymanateevedaknotstabooresisting commented 3 years ago

@shredEngineer I tried some more runs with my exports and had the fail regarding matching exchange rates quite some times. So, I could imagine that OHLC Endpoint with volume weighted averag price (vwap) is also an option. Though, the resolution decreases the more you go into the past (they offer at least daily data, afaik).

https://www.kraken.com/features/api#get-ohlc-data

shredEngineer commented 3 years ago

@wearymanateevedaknotstabooresisting

wearymanateevedaknotstabooresisting commented 3 years ago

I second that weekly data is a too broad time frame for tax calculations. Daily average price would have been somehow ok, I guess. However, this demands different price sources or increase the Trades API time delta, we could also use the exponential base 2 approach: at time, 1m, 2m, 4m, ... until greater than 1d.