CASTrader II's communications infrastructure/network is done. It works pretty well, with what looks like adequate throughput. Things I like about the method chosen (simple text files) are:
- Robustness: Program states can be remembered even when machines crash. Also, the lockup of one machine probably won't bring the whole system to a halt (assuming it's not the file server).
- Simplicity: Nothing could be simpler from a programming perspective, imo. Data can be automatically captured for posterity (backtesting) as part of the design.
- Easy to Debug: Simply open a text file and read it.
Things I don't like:
- Too simple: For now, the system is a little too simple for everything. For instance, each communication "channel" is a separate file, and for high traffic channels, these files will fill up fast - they need to be designed to act as a queue, where old communications are purged (or archived) from time to time. This is easy to fix.
- Channel overhead. I am envisioning lots of communication channels between the various programs that will make up CASTrader. Thus, there will be a lot of file tracking overhead. Since channels must be polled for new data by each channel listener, there may be a lot of wasted CPU cycles. If this ends up being a problem, I can fix it with a more complicated design.
I went ahead and created the first program to publish a channel on the network - a Yahoo real-time quote getter - a real time ticker, in other words. This will be a crucial channel used by the CASTrader dark market arbitrageurs. At first, the arbitrageurs will pop-up a window, proposing a real-market trade to bring the dark market in-line with the real market. Once I'm comfortable, I'll probably look into automated trading, probably via the Interactive Brokers API. The arbitageurs will have to at that point verify the Yahoo data and account for various problems with the feed that can occur.
Coding the real-time ticker was trivial. Yahoo has a vast array of data available in addition to their real time quotes. I believe you have to have a subscription to get real time data from Yahoo. Now all I need is an arbitrageur and a dark market signal for it to trade off of, and CASTrader II will be trading the markets. The arbitrageur is easy, the dark market is the hard part.
Update: Ooops! I didn't realize that a Yahoo real time quote download as coded using the above method does not actually give real-time quotes, probably due to cookies, as Yahoo must not realize I have an account. Fortunately the fix is even easier than the above, albeit at the overhead of running Internet Explorer:
Public Class Form1
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Dim element As System.Windows.Forms.HtmlElement
For Each element In Me.WebBrowser1.Document.GetElementsByTagName("PRE")
MsgBox(element.InnerText)
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.WebBrowser1.Navigate("http://finance.yahoo.com/d/quotes.csv?s=MSFT+IBM+GM+HSY+JNJ&f=snl1d1t1ohgdr")
End Sub
End Class
Update II: Yahoo is good, but Opentick is better.
Comments