IBCSharp

IBCSharp consists of an improved version of this
Interactive Brokers C# API (IBClient.dll), a WinForms C# algorithmic daytrading program (DayTrade.exe), a WinForms C# long-term trading program (LongTermTrade.exe), and a historical data downloader that downloads intraday data from IB and end-of-day data from moneycentral.msn.com in eSignal tick replay format (HistoricalDataDownloader.exe).
IBCSharp's IBClient corresponds to IB API 9.63.
DayTrade.exe subscribes to stock, future, or currency data and then submits orders based on trading decisions made by an instance of a subclass of abstract class TradingStrategy. Once an opening order is filled, the opened position is bracketed with a profit limit order, a trailing stop order, and a time stop order. Trading in a margin-safe way is only supported for stocks and futures. Currency trading happens without pre-order-submission margin checks because I do not understand
IB's unclear, single-example explanation of how IB calculates currency margin.
This is DayTrade.exe with Trader Workstation in the background:

For testing DayTrade.exe there is TestingTradingStrategy.cs, which is a moving average crossover strategy:

Indicators that come with DayTrade.exe:

LongTermTrade.exe submits limit orders for stocks with limit prices derived from yesterday's closing prices. Once the opening limit order is filled the new position is bracketed with the same three bracket orders as above but the time stop order becomes active after some number of days instead of minutes. The idea with LongTermTrade.exe is to decide upon trades tonight and then tomorrow morning before market open submit limit orders and then when the market opens the limit orders fill.
This is LongTermTrade.exe on 12/22/2009 6:25 AM PST after having submit three orders with limit prices derived from yesterday's closing prices. These three orders will fill some time after market open 6:30 AM PST:

This is LongTermTrade.exe on 12/22/2009 right after 6:30 AM PST. Note the 10-days-in-the-future Start Time of the time stop orders.

This is how the "Intraday Data From IB" tab of HistoricalDataDownloader.exe works:


1 year of intraday data can be downloaded for stocks and 1.5 years of intraday data can be downloaded for futures YM, ES, and NQ.
This is how the "EOD Data from moneycentral.msn.com" tab of HistoricalDataDownloader.exe works. You provide a list of stock symbols and then the good people at Microsoft send back 5 years of end-of-day data for each symbol. All the 5 years of data for each symbol is written to a single eSignal tick replay format .epf file.

Command Window aliases I find useful while developing IBCSharp. I have View.CommandWindow assigned to Ctrl+/.
alias account open account.cs
alias contract open contract.cs
alias five open fivesecondpricebarsubscription.cs
alias ib open ibclient.cs
alias main open daytrademainform.cs
alias man open fivesecondpricebarsubscriptionmanager.cs
alias fac open daytradefacade.cs
alias my open mytradingstrategy.cs
alias openorder open openordermanager.cs
alias creator open ordercreator.cs
alias ordersub open ordersubmitter.cs
alias port open portfolio.cs
alias program open daytradeprogram.cs
alias test open testingtradingstrategy.cs
alias trade open tradingstrategy.cs
IBCSharp unit tests:
