[ts-gen] Handling commissions and fees
paulq2o0 at yahoo.co.uk
Wed Sep 16 13:59:57 EDT 2009
On Thu, Sep 17, 2009 at 01:28:41AM +0900, Ken Feng wrote:
> Hi Michael,
> When I first read this, I got a bitter taste in my mouth - fees are so
> basic, but they don't seem to be accessible. But after thinking about
> it somewhat, I think your suggestion may be the only way to go. The
> problem with the 3/7/7 solution posted seems to be, not only is it a
> sum of realized p & l plus commissions, but also, I think because it
> only seems to show up when I query for acct, it seems to include all
> the trades that occurred during some unspecified time period (one
> day?) - or is it the last trade?
No, it accumulates as you make more trades. I assumed it was the
current days trades, for each instrument traded. It would probably get
messy, except in the simple case of alternately buying/selling the same
amount of the same thing. Myself, I see no other shim-based method.
> What I may have to do is, calculate my expected fees, and insert that
> value into MySQL and then, as a part of daily reconciliation run the
> Reports Management under "Activity Flex" as you mentioned, and keep
> reworking my code until I can get the two sides to match without
> What's worse is, I can't build this software until I start trading for
> real - there are no reports for paper accounts - the best I can do is
> calculated an expected_fee and then reconcile this value later...
> I wish there was a better way - anyone else with ideas or descriptions
> of how you deal with detecting your fees from upstream?
I used to do just what Mike suggested with the flex reports, albeit I
didn't automate it and so got fed up downloading them. The advantage is
you'll (presumably) get all the fee info you want; not just
I see the TWS "Trades" page has an option to 'export' the trades to a
file, but annoyingly this also has the commissions missing: if there's a setting
somewhere to include them, I can't see it....
The only other 'horrible' solution I can see is
File->Print->Html->File, and some parser to extract the relevant
fields from the html. I see you can specify exactly which columns you
want to appear in the html, so it's probably not too hard, but not a
pleasing solution. And of course you'd want to automate it, in a
similar way that logging in to the tws can be automated (?) (there's a Perl
script somewhere, as you probably know). All very messy. But at least you get the data
when you want it; I'm not sure about the flex reports (next day?).
That's all I can think of. Good luck!
More information about the ts-general