Merge pull request #63 into master
d5220d1hledger-flow: coinbase: rules: catch Advanced Trade 0-value txs (Aaron Fiore)e3d1fc4hledger-flow: coinbase: preprocess: fix Advanced Trade divide by zero (Aaron Fiore)
This commit was merged in pull request #63.
This commit is contained in:
@@ -144,12 +144,26 @@ function __parse()
|
|||||||
#
|
#
|
||||||
# Add new columns to calculate fees against native currency price
|
# Add new columns to calculate fees against native currency price
|
||||||
#
|
#
|
||||||
# - 0 is used because Coinbase does not accurately display fiat amount,
|
# WARNING:
|
||||||
# if satoshi is small (valued less than $0.00)
|
#
|
||||||
|
# - `amount_amount` and/or `native_amount_amount` may be given as 0
|
||||||
|
# because Coinbase does not display the full value of either column
|
||||||
|
# for token values (satoshi, gwei, etc.) valued less than a $0.00.
|
||||||
|
#
|
||||||
|
# Quite literally, the only value information that Coinbase will
|
||||||
|
# provide for these transactions is 0 or equivalent; so, an accurate
|
||||||
|
# calculation cannot be made nor inferred because the only other
|
||||||
|
# usable information is the fee. But, since it is unknown what
|
||||||
|
# percentage the fee-tier is for these transactions, no further
|
||||||
|
# calculations can be made.
|
||||||
|
#
|
||||||
|
# With that said, any 0-value transactions should skip the following
|
||||||
|
# calculations as to avoid a divide by zero error and, instead, be
|
||||||
|
# managed within the rules file.
|
||||||
#
|
#
|
||||||
|
|
||||||
if ($7 > 0) {printf("%.8f", $7 / $5)}; printf OFS # native_amount_price
|
if ($7 > 0 && $5 > 0) {printf("%.8f", $7 / $5)}; printf OFS # native_amount_price
|
||||||
if ($7 > 0) {printf("%.8f", ($7 / $5) * $16)}; printf OFS # native_network_transaction_fee_amount
|
if ($7 > 0 && $5 > 0) {printf("%.8f", ($7 / $5) * $16)}; printf OFS # native_network_transaction_fee_amount
|
||||||
|
|
||||||
#
|
#
|
||||||
# Add new column to calculate the difference between amount and network fee,
|
# Add new column to calculate the difference between amount and network fee,
|
||||||
|
|||||||
@@ -656,7 +656,6 @@ if %type ^advanced_trade_fill$
|
|||||||
|
|
||||||
if %type ^advanced_trade_fill$
|
if %type ^advanced_trade_fill$
|
||||||
& %advanced_trade_fill_order_side (^buy$|^sell$)
|
& %advanced_trade_fill_order_side (^buy$|^sell$)
|
||||||
& %advanced_trade_fill_real_value_amount [1-9]
|
|
||||||
account1 assets:coinbase:%subaccount:%advanced_trade_fill_pair_lhs
|
account1 assets:coinbase:%subaccount:%advanced_trade_fill_pair_lhs
|
||||||
account2 assets:coinbase:%subaccount:%advanced_trade_fill_pair_rhs
|
account2 assets:coinbase:%subaccount:%advanced_trade_fill_pair_rhs
|
||||||
amount3 -%advanced_trade_fill_commission %advanced_trade_fill_pair_rhs
|
amount3 -%advanced_trade_fill_commission %advanced_trade_fill_pair_rhs
|
||||||
@@ -664,6 +663,13 @@ if %type ^advanced_trade_fill$
|
|||||||
amount4 %advanced_trade_fill_commission %advanced_trade_fill_pair_rhs
|
amount4 %advanced_trade_fill_commission %advanced_trade_fill_pair_rhs
|
||||||
account4 expenses:coinbase:%subaccount:fees:trading:%advanced_trade_fill_pair_rhs
|
account4 expenses:coinbase:%subaccount:fees:trading:%advanced_trade_fill_pair_rhs
|
||||||
|
|
||||||
|
# NOTE: see WARNING in preprocess about $0.00 Advanced Trade txs
|
||||||
|
if %type ^advanced_trade_fill$
|
||||||
|
& %advanced_trade_fill_order_side (^buy$|^sell$)
|
||||||
|
& %advanced_trade_fill_real_value_amount ^[^1-9]*$
|
||||||
|
account1
|
||||||
|
account2
|
||||||
|
|
||||||
#
|
#
|
||||||
# BUY
|
# BUY
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user