2024-12-14 22:38:06 +00:00
|
|
|
import sys
|
|
|
|
import requests
|
|
|
|
import fin_depo
|
|
|
|
from . import secrets
|
|
|
|
from fin_defs import CryptoCurrency, AssetAmount, MPC, Asset, USDT
|
|
|
|
from decimal import Decimal
|
|
|
|
from collections import deque
|
|
|
|
from fin_depo.data import *
|
|
|
|
import datetime
|
|
|
|
import dataclasses
|
2024-12-22 05:10:23 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from . import compute_tax
|
2024-12-14 22:38:06 +00:00
|
|
|
|
|
|
|
KUCOIN_CLIENT = fin_depo.defi_kucoin.KucoinDepoFetcher(
|
|
|
|
secrets.KUCOIN_KEY,
|
|
|
|
secrets.KUCOIN_SECRET,
|
|
|
|
secrets.KUCOIN_PASS,
|
|
|
|
)
|
|
|
|
|
2024-12-22 05:03:47 +00:00
|
|
|
KRAKEN_CLIENT = fin_depo.defi_kraken.KrakenDepoFetcher(
|
|
|
|
secrets.KRAKEN_KEY,
|
|
|
|
secrets.KRAKEN_SECRET,
|
|
|
|
)
|
|
|
|
|
2024-12-22 05:10:23 +00:00
|
|
|
def main():
|
|
|
|
"""Main function."""
|
2024-12-14 22:38:06 +00:00
|
|
|
|
2024-12-22 05:25:07 +00:00
|
|
|
logging.basicConfig()
|
2024-12-22 05:10:23 +00:00
|
|
|
logger = logging.getLogger('crypto_tax')
|
|
|
|
logger.setLevel('INFO')
|
2024-12-14 22:38:06 +00:00
|
|
|
|
2024-12-22 05:10:23 +00:00
|
|
|
TRANSFERS = list(KRAKEN_CLIENT._get_double_registers())
|
|
|
|
#TRANSFERS += list(KUCOIN_CLIENT._get_double_registers())
|
|
|
|
tax_report = compute_tax(TRANSFERS)
|
2024-12-14 22:38:06 +00:00
|
|
|
|
2024-12-22 05:10:23 +00:00
|
|
|
logger.info('-'*80)
|
2024-12-14 22:38:06 +00:00
|
|
|
|
2024-12-22 05:25:07 +00:00
|
|
|
if True:
|
|
|
|
logger.info('Bought for:')
|
|
|
|
for asset, prices in tax_report.current_assets.items():
|
|
|
|
price_sum = sum((p.amount for p in prices), start=AssetAmount.ZERO)
|
|
|
|
sys.stdout.write(f' - {asset.raw_short_name():10} ({price_sum}): ')
|
|
|
|
for price in prices:
|
|
|
|
sys.stdout.write(str(price.amount.amount))
|
|
|
|
sys.stdout.write(', ')
|
|
|
|
del price
|
|
|
|
sys.stdout.write('\n')
|
|
|
|
del asset, prices
|
2024-12-14 22:38:06 +00:00
|
|
|
|
|
|
|
|
2024-12-22 05:25:07 +00:00
|
|
|
for bas in tax_report.bought_and_sold_for:
|
|
|
|
sys.stdout.write(f'{bas.amount} ({bas.time_bought} ----> {bas.time_sold})\n')
|
2024-12-14 22:38:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
|
|
|
|