I've started building a program to analyze my trading activities, but I'm having trouble with the API. So far I have a script that pulls everything out that I need (specifically the WalletTransactions and WalletJournal) and stores everything into a MySQL database.
But I'm having trouble linking my Buy/Sell orders in the Transactions table to Sales Tax and Broker Fees in the Journal table.
From what I understand, you should be able to link them via the journalTransactionID field in the transactions list, but that doesn't work.
Example 1: The Buy order shown below has a journalTransactionID of 4659187723, but there is no entry in the journal with that ID. However the last item shown in the journal below is the Market Escrow for the Buy Order, but 2 lines above it you can see the Broker Fees for the Buy Order, which has the refID of 4659084048.
Example 2: The Sell order shown below has a journalTransactionID of 4659094800, but there is nothing in the journal with that ID. However 4659094798 is the other player buying the item, and 4659094799 is the Sales Tax.
Here's a screenshot from PHPMyAdmin. The Transactions data is shown first, then the related Journal entries are shown beneath. I've hidden some elements that are not needed and to protect my trading activities Please visit your user settings to re-enable images.
So how do I link all this together properly?
This is my current thinking, but I'd like some feedback from those of you that have done this:
Sell Orders: Get the Sales Tax by taking the Sell Order journalTransactionID and subtracting 1. Or should I take the transID from the transactions table, find the journal entry, pull the refID, and increment that by 1 to get the Sales Tax? Either solution seems not very intelligent in terms of good coding, so I'm wondering if I'm missing something to link this stuff together.
Buy Orders: I'm totally lost on how I can pull out the Broker Fee, any suggestions?