probstj / ccGains

Python package for calculating cryptocurrency trading profits and creating capital gains reports
GNU Lesser General Public License v3.0
49 stars 13 forks source link

Fee currency different from buy_currency or sell_currency #22

Open bitphage opened 5 years ago

bitphage commented 5 years ago

Currently fee may be paid in buy_currency or sell_currency. I'm analyzing data from Bitshares decentralized exchange, and there are several types of fees. One of them is a fee for each transaction performed, and this fee may be paid in any asset.

Here is a withdrawal example where fee was paid in BTS core asset:

Kind,Date,Buy currency,Buy amount,Sell currency,Sell amount,Fee currency,Fee amount,Exchange,Mark,Comment
Withdrawal,2017-12-19T23:21:09,,0,STRANGE,185.0,BTS,0.21851,Bitshares,-1,1.11.105563860

To handle such situation probably an additional check into BagQueue.process_trade() may be added: if fee_currency != buy/sell currency THEN make virtual Trade object and recursively pass it into process_trade(). Similar check in Trade() which raises an exception may be changed to simply set self.feeval = 0.