winksaville / rust-binance-cli

Automatically sell all assets owned by the user on binance.us except USD, USDT plus a minimum of BNB is kept.
Apache License 2.0
2 stars 6 forks source link

Provide a way to validate transformations #11

Open winksaville opened 2 years ago

winksaville commented 2 years ago

Right now I can validate transformations by using vimdiff to compare displayed output after processing.

For example in b.us.cttf.sh:

wink@3900x:~/prgs/rust/myrepos/binance-cli (main)
$ cat -n b.us.cttf.sh 
     1  #!/usr/bin/env bash
     2
     3  set -euo pipefail
     4
     5  # Parse the filename
     6  source "$(dirname "$0")/filename.sh" "$1"
     7
     8  #cmd=binance-cli
     9  cmd="cargo run --release"
    10  $cmd pbudf --no-progress-info --no-usd-value-needed -f "$on" -o "$(mkfullname "$dn" "$bn" pbudf.csv)" | tee "$(mkfullname "$dn" "$bn" pbudf.csv.result.txt)"
    11  $cmd ttffbudf --no-progress-info -f "$(mkfullname "$dn" "$bn" pbudf.csv)" -o "$(mkfullname "$dn" "$bn" ttf.csv)"
    12  $cmd pttf --no-progress-info --no-usd-value-needed -f "$(mkfullname "$dn" "$bn" ttf.csv)" | tee "$(mkfullname "$dn" "$bn" ttf.csv.pttf.result.txt)"
    13  $cmd cttf --no-progress-info -f "$(mkfullname "$dn" "$bn" ttf.csv)" -o "$(mkfullname "$dn" "$bn" cttf.csv)"
    14  $cmd pttf --no-progress-info --no-usd-value-needed -f "$(mkfullname "$dn" "$bn" cttf.csv)" | tee "$(mkfullname "$dn" "$bn" cttf.csv.pttf.result.txt)"
    15
    16  echo Done "$0"

Takes one file as input, a raw "binance.us" distribution file, and transforms it to one where all the income records for a particular asset is consolidated to one record a month. So if the input file is named abc.csv the final output file will be abc.cttf.csv, which is a "consolidated TokenTax file" in CSV.

The full list of files created would be:

abc.pbudf.csv
abc.pbudf.csv.result.txt
abc.ttf.csv
abc.ttf.csv.pttf.result.txt
abc.cttf.csv
abc.cttf.csv.pttf.result.txt

You can now use vimdiff or other program to look at the differences in the *.result.txt files. Specifically looking at the asset list quantity column.

What I need to do is add a new output option or new commands which output the asset record "asset" and "quantity" fields in a CSV file. The values in these two fields should be consistent with the original data and you will be able to do a binary compare of the CSV file and they should be identical.