How to post your ATS trades in twitter using Excel

As an example, the following Excel script can be used to post your automated trading system trades into twitter via API.  This code can easily be changed to do whatever you want. But in this example it will just be for sending a trade.

Dim symbol As String
Dim Price As String
Dim xml, Username, Password, tweet
Set xml = CreateObject(“MSXML2.XMLHTTP”)
change this to your username in quotes
Username = “yourusername”
‘change this to your password in quotes
Password = “yourpassword”
‘let the symbol variable have the symbol name from your excel sheet
symbol = Workbooks(“yourworkbook.xls”).Worksheets(“yoursheetname”).Range(“a1 or your range”)
‘let the Price variable have the symbol name from your excel sheet
Price = Workbooks(“yourworkbook.xls”).Worksheets(“yoursheetname”).Range(“a2 or your range”)
‘contruct the “tweet” this would create “Just bought a gazillion shares of (whatever $SYMBOL you have in A1) @ (whatever price you have in A2)
tweet = “Just bought a gazillion shares of ” & “$” & symbol & ” @ ” & Price
‘post the tweet
xml.Open “POST”, “http://” & Username & “:” & Password & “” & tweet, False
xml.setRequestHeader “Content-Type”, “content=text/html; charset=iso-8859-1”
Set xml = Nothing
End Sub

If added to an existing excel trading system it may be best to set this to run 20 seconds or so after your actual trade is sent to avoid any interference which can be done as follows

Application.Ontime Now() + timeserial(0, 0, 20), “TWITTER”

Speak Your Mind