|
|
Requesting live data through TWS API with Visual Basic .Net Part
2
Author: Joe
Tutorial Objective: Request live
volume data from Interactive Brokers TWS api using Visual Basic .Net
Souce Code: Download
the full source for this tutorial Here
Disclaimer
This tutorial is to be used at your own risk. By using this
tutorial
you agree not to hold the writers of this tutorial,
StockBotProgramming.com,
or anyone affiliated with StockBotProgrammign.com liable for any
damages
that may occur as a result of using this tutorial and/or
provided
source code.
This tutorial will assume you have a copy of Visual Studio 2005
and
have Interactive Broker's TWS API installed. You can get a copy
Visual
Studio Here,
and the TWS API is available for download Here.
It is highly recommended that you read Requesting live data through TWS API with Visual
Basic .Net before attempting this tutorial. If you have any suggestions
regarding this tutorial or if you notice any mistakes please suggest it here.
Today we are going to modify our code to receive tick volume updates and
display those updates in a ListBox control. Go ahead and open up your code
from Requesting live data through TWS API with Visual
Basic .Net . If you did not complete the tutorial, you can download the
full source code at the end of its page.
From the previous tutorial we have already made a request to TWS for data
updates. However, up to this point we only wrote the function needed catch
the price updates. Now we will add the function call needed to catch the
volume updates as well. Add the following function:
Private Sub Tws1_LiveVolumeData(ByVal eventSender
As System.Object, ByVal eventArgs As AxTWSLib._DTwsEvents_tickSizeEvent)
Handles Tws1.tickSize
Dim strData As String = ""
strData = "Volume Update: id=" & eventArgs.id & " Type" & eventArgs.tickType
& " Price=" & eventArgs.size
ListBox1.Items.Add(strData)
End Sub
Just like in the price update function we have 3 important pieces of
information. We have the eventArgs.id which matches to our requesting id.
We have event.size which is the volume/size information being sent, and we
have eventArgs.tickType which specifies what type of information we are
receiving.
tickType=0 means bid size
tickType=3 means ask size
tickType=5 means last trade size
tickType=6 means volume
Now you should be able to make TWS send you all the live price/volume
information you need to make your trading decisions.
Download the full source for this tutorial Here
Similar tutorials
|
|
|