Click on charts with blue boarders for a larger image.
I have been advised to publish the following to share the gift of knowledge and
general peer review.
In my spare time I've been working on Automated Commodities
Trading in C# because it is fun, intellectually challenging, and it might make
me lots of money which would go towards increasing happiness on Earth. To learn
more read on.
A screen shot of our IB TWS windows application HT-TWSAPP is shown below in the
This C# TWS App retrieves and processes market data to make real time trades and
compute P & L which provides feedback to the
configured trade strategy.
Both the HT-TWSAPP and the PLStatus windows are shown. The ListBox in
HT-TWSAPP shows price and size events, etc as they arrive with a time stamp.
The PLStatus window contains a Datagrid where the individual cells are updated
as events occur.
The TWS Account window, shown in the background, is updated around every three
minutes or immediately when a change in position occurs.
I could not find a way to extract the P & L values for each contract via the TWS
API. So I had to compute P & L myself.
CPL (Closed P & L) is updated whenever a position is covered, partly or fully.
The OPL (Open P & L) is updated with every price tick. The UpTime (Updated Time)
is updated whenever any column is updated.
HT-TWSAPP is a multithreaded application with 3 thread priorities. GUI and TWS
events have normal priority. Generally, database operations have low priority
and writing to a log file has the lowest priority.
Our database stores tick by tick data for price and size events for
subscribed financial instruments. Currently, we are interested in securities of
the FUT type, symbols HG, SI, GC, CL, and ES. We try to choose the contract
expiration month with the highest open interest.
As part of our record keeping, we also store in our database events such as
submitted orders, order status, exec details and error messages.
These and other events are also written to a log file. All events have unique
time stamps. Both the database and the log files were very useful for debugging.
All this stored data is also very useful when we run in the SIM mode. More
about that later.
In the next section we will talk about trading strategy and evaluation.
Official Facebook Page
Goto Page 2