I'm writing code that needs to calculate the gain/loss of trading activity. On most brokerages you will have transaction history that tells you the amount of stock purchased, the price you paid, and the fees associated with that trade. With this information, if you have your entire account history, you can simply run through all the transactions and sum them up and you'll arrive at your current account balance. With Bitstamp, I wrote the code in about 5 minutes and got the exact same output from my code as shows on the Bitstamp website.
Not so BTC-E. I've tried both the transactions and trades history, and summing them up I get two different results, both different from the balance shown on BTC-E. The difference is several percent, so it's not a floating-point rounding error.
BtceTransaction{transactionId='340479684', type=4, amount=0.12475, currency='BTC', description='Buy 0.125 BTC (-0.2%) from your order :order:146579020: by price 701 USD', status=2, timestamp=2014-02-09T13:05:38.000+08:00}
BtceTransaction{transactionId='340478469', type=5, amount=1864.93497426, currency='USD', description='In payment for a warrant :order:146579020:', status=2, timestamp=2014-02-09T13:04:48.000+08:00}
BtceTransaction{transactionId='340478467', type=5, amount=70.1, currency='USD', description='Buy 0.1 BTC (-0.2%) from order :order:146578463: by price 701 USD', status=2, timestamp=2014-02-09T13:04:48.000+08:00}
BtceTransaction{transactionId='338895753', type=4, amount=7.18549022, currency='USD', description='Sell 0.01 BTC from order :order:145830999: by price 719.989 USD total 7.19989 USD (-0.2%)', status=2, timestamp=2014-02-08T17:58:45.000+08:00}
BtceTransaction{transactionId='272388005', type=4, amount=0.00998, currency='BTC', description='Пoкyпкa 0.01 BTC (-0.2%) c вaшeгo opдepa :order:115285907: пo цeнe 870.87 USD', status=2, timestamp=2014-01-07T21:31:40.000+08:00}
The type is 4 or 5, which is totally inconsistent as to whether it's a purchase or sale, or whether it's your order or someone else's order. What the heck is a warrant order and how does it affect my account (not at all?).
Does anyone understand how to convert this mess into a simple tuple of (btc, usd, fee)?