'________________________________________________________________________________________________________ '******************************************************************************************************** ' Application: HISTORICAL AND REAL TIME DATAFEED ' Created by : Hendra Kusumadi @2003 ' Function : Get historical and real time data from e-Signal ' ' Process : ' * Populate all stock and index information ' * Initialize Data Manager and Historical API ' * Initialize Grid Display ' * Initialize Real Time Data by requesting all symbols into the Data Manager ' * Run the time ticker to start feeding real time data ' Additional : ' * Get the historical data automatically run at 14:00 ' * The constant variables are found in module "modDataFeed.mod" ' * Menu "Run" to get the historical data manually ' * Everytime the aps requesting historical data, event "UpdateHistResponse" will also run ' * Every 100 milisecond, the apps will request a snapshot ' * Everytime the aps requesting real time data, event "UpdateLastRecord" will also run ' ' Documented : April 4, 2003 by Hendra Kusumadi ' '________________________________________________________________________________________________________ '******************************************************************************************************** Imports VB = Microsoft.VisualBasic Public Class fmDataFeed Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents ctlDataManager As AxDBCCTRLLib.AxDataManager Friend WithEvents ctlHistory As AxDBCCTRLLib.AxHistory Friend WithEvents stBar As System.Windows.Forms.StatusBar Friend WithEvents stPanel01 As System.Windows.Forms.StatusBarPanel Friend WithEvents stPanel02 As System.Windows.Forms.StatusBarPanel Friend WithEvents stPanel03 As System.Windows.Forms.StatusBarPanel Friend WithEvents stPanel04 As System.Windows.Forms.StatusBarPanel Friend WithEvents flHistory As C1.Win.C1FlexGrid.C1FlexGrid Friend WithEvents tmrRealTime As System.Windows.Forms.Timer Friend WithEvents mnuDataFeed As System.Windows.Forms.MainMenu Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem Friend WithEvents mnuRun As System.Windows.Forms.MenuItem Friend WithEvents mnuShow As System.Windows.Forms.MenuItem Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem Friend WithEvents iTray As System.Windows.Forms.NotifyIcon Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem6 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem7 As System.Windows.Forms.MenuItem Friend WithEvents mnuExit As System.Windows.Forms.MenuItem Friend WithEvents stPanel05 As System.Windows.Forms.StatusBarPanel Friend WithEvents lblInfo As System.Windows.Forms.Label Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(fmDataFeed)) Me.ctlDataManager = New AxDBCCTRLLib.AxDataManager() Me.ctlHistory = New AxDBCCTRLLib.AxHistory() Me.stBar = New System.Windows.Forms.StatusBar() Me.stPanel01 = New System.Windows.Forms.StatusBarPanel() Me.stPanel02 = New System.Windows.Forms.StatusBarPanel() Me.stPanel03 = New System.Windows.Forms.StatusBarPanel() Me.stPanel04 = New System.Windows.Forms.StatusBarPanel() Me.stPanel05 = New System.Windows.Forms.StatusBarPanel() Me.flHistory = New C1.Win.C1FlexGrid.C1FlexGrid() Me.tmrRealTime = New System.Windows.Forms.Timer(Me.components) Me.mnuDataFeed = New System.Windows.Forms.MainMenu() Me.MenuItem1 = New System.Windows.Forms.MenuItem() Me.mnuShow = New System.Windows.Forms.MenuItem() Me.MenuItem5 = New System.Windows.Forms.MenuItem() Me.mnuExit = New System.Windows.Forms.MenuItem() Me.mnuRun = New System.Windows.Forms.MenuItem() Me.MenuItem4 = New System.Windows.Forms.MenuItem() Me.MenuItem3 = New System.Windows.Forms.MenuItem() Me.MenuItem7 = New System.Windows.Forms.MenuItem() Me.MenuItem6 = New System.Windows.Forms.MenuItem() Me.iTray = New System.Windows.Forms.NotifyIcon(Me.components) Me.lblInfo = New System.Windows.Forms.Label() CType(Me.ctlDataManager, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.ctlHistory, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.stPanel01, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.stPanel02, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.stPanel03, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.stPanel04, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.stPanel05, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.flHistory, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'ctlDataManager ' Me.ctlDataManager.Enabled = True Me.ctlDataManager.Location = New System.Drawing.Point(8, 216) Me.ctlDataManager.Name = "ctlDataManager" Me.ctlDataManager.OcxState = CType(resources.GetObject("ctlDataManager.OcxState"), System.Windows.Forms.AxHost.State) Me.ctlDataManager.Size = New System.Drawing.Size(192, 200) Me.ctlDataManager.TabIndex = 0 Me.ctlDataManager.Visible = False ' 'ctlHistory ' Me.ctlHistory.Enabled = True Me.ctlHistory.Location = New System.Drawing.Point(216, 216) Me.ctlHistory.Name = "ctlHistory" Me.ctlHistory.OcxState = CType(resources.GetObject("ctlHistory.OcxState"), System.Windows.Forms.AxHost.State) Me.ctlHistory.Size = New System.Drawing.Size(168, 88) Me.ctlHistory.TabIndex = 1 Me.ctlHistory.Visible = False ' 'stBar ' Me.stBar.Location = New System.Drawing.Point(0, 173) Me.stBar.Name = "stBar" Me.stBar.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() {Me.stPanel01, Me.stPanel02, Me.stPanel03, Me.stPanel04, Me.stPanel05}) Me.stBar.ShowPanels = True Me.stBar.Size = New System.Drawing.Size(581, 22) Me.stBar.SizingGrip = False Me.stBar.TabIndex = 2 ' 'stPanel01 ' Me.stPanel01.Width = 140 ' 'stPanel02 ' Me.stPanel02.Text = "Ready" Me.stPanel02.Width = 140 ' 'stPanel03 ' Me.stPanel03.Width = 140 ' 'stPanel04 ' Me.stPanel04.Width = 120 ' 'stPanel05 ' Me.stPanel05.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring Me.stPanel05.Width = 41 ' 'flHistory ' Me.flHistory.AllowResizing = C1.Win.C1FlexGrid.AllowResizingEnum.None Me.flHistory.AllowSorting = C1.Win.C1FlexGrid.AllowSortingEnum.None Me.flHistory.BackColor = System.Drawing.SystemColors.Window Me.flHistory.ColumnInfo = "7,1,0,0,0,75,Columns:0{Width:25;Name:""Symbol"";}" & Microsoft.VisualBasic.ChrW(9) & "1{Width:90;Caption:""Symbol"";}" & Microsoft.VisualBasic.ChrW(9) & "2{W" & _ "idth:80;Name:""Symbol"";Caption:""DayOpen"";Format:""###.00"";TextAlignFixed:CenterCen" & _ "ter;}" & Microsoft.VisualBasic.ChrW(9) & "3{Width:80;Caption:""DayClose"";Format:""###.00"";TextAlignFixed:CenterCenter;" & _ "}" & Microsoft.VisualBasic.ChrW(9) & "4{Width:80;Caption:""DayHigh"";Format:""###.00"";TextAlignFixed:CenterCenter;}" & Microsoft.VisualBasic.ChrW(9) & "5{W" & _ "idth:80;Caption:""DayLow"";Format:""###.00"";TextAlignFixed:CenterCenter;}" & Microsoft.VisualBasic.ChrW(9) & "6{Width:1" & _ "10;Caption:""Volume"";Format:""###,###,###,###"";TextAlignFixed:CenterCenter;}" & Microsoft.VisualBasic.ChrW(9) Me.flHistory.ExtendLastCol = True Me.flHistory.Location = New System.Drawing.Point(6, 3) Me.flHistory.Name = "flHistory" Me.flHistory.Rows.Count = 1 Me.flHistory.Size = New System.Drawing.Size(570, 165) Me.flHistory.Styles = New C1.Win.C1FlexGrid.CellStyleCollection("Fixed{BackColor:Control;ForeColor:ControlText;Border:Flat,1,ControlDark,Both;}" & Microsoft.VisualBasic.ChrW(9) & "Hi" & _ "ghlight{BackColor:Highlight;ForeColor:HighlightText;}" & Microsoft.VisualBasic.ChrW(9) & "Search{BackColor:Highlight" & _ ";ForeColor:HighlightText;}" & Microsoft.VisualBasic.ChrW(9) & "Frozen{BackColor:Beige;}" & Microsoft.VisualBasic.ChrW(9) & "EmptyArea{BackColor:AppWorks" & _ "pace;Border:Flat,1,ControlDarkDark,Both;}" & Microsoft.VisualBasic.ChrW(9) & "GrandTotal{BackColor:Black;ForeColor:W" & _ "hite;}" & Microsoft.VisualBasic.ChrW(9) & "Subtotal0{BackColor:ControlDarkDark;ForeColor:White;}" & Microsoft.VisualBasic.ChrW(9) & "Subtotal1{BackColor" & _ ":ControlDarkDark;ForeColor:White;}" & Microsoft.VisualBasic.ChrW(9) & "Subtotal2{BackColor:ControlDarkDark;ForeColor" & _ ":White;}" & Microsoft.VisualBasic.ChrW(9) & "Subtotal3{BackColor:ControlDarkDark;ForeColor:White;}" & Microsoft.VisualBasic.ChrW(9) & "Subtotal4{BackCol" & _ "or:ControlDarkDark;ForeColor:White;}" & Microsoft.VisualBasic.ChrW(9) & "Subtotal5{BackColor:ControlDarkDark;ForeCol" & _ "or:White;}" & Microsoft.VisualBasic.ChrW(9)) Me.flHistory.TabIndex = 5 ' 'tmrRealTime ' ' 'mnuDataFeed ' Me.mnuDataFeed.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.mnuRun, Me.MenuItem4}) ' 'MenuItem1 ' Me.MenuItem1.Index = 0 Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuShow, Me.MenuItem5, Me.mnuExit}) Me.MenuItem1.Text = "&File" ' 'mnuShow ' Me.mnuShow.Index = 0 Me.mnuShow.Text = "&Show History" ' 'MenuItem5 ' Me.MenuItem5.Index = 1 Me.MenuItem5.Text = "-" ' 'mnuExit ' Me.mnuExit.Index = 2 Me.mnuExit.Text = "E&xit" ' 'mnuRun ' Me.mnuRun.Index = 1 Me.mnuRun.Text = "R&un" ' 'MenuItem4 ' Me.MenuItem4.Index = 2 Me.MenuItem4.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem3, Me.MenuItem7, Me.MenuItem6}) Me.MenuItem4.Text = "&About" ' 'MenuItem3 ' Me.MenuItem3.Index = 0 Me.MenuItem3.Text = "&Help" ' 'MenuItem7 ' Me.MenuItem7.Index = 1 Me.MenuItem7.Text = "-" ' 'MenuItem6 ' Me.MenuItem6.Index = 2 Me.MenuItem6.Text = "A&bout Aps" ' 'iTray ' Me.iTray.Icon = CType(resources.GetObject("iTray.Icon"), System.Drawing.Icon) Me.iTray.Text = "DataFeed" Me.iTray.Visible = True ' 'lblInfo ' Me.lblInfo.Location = New System.Drawing.Point(6, 1) Me.lblInfo.Name = "lblInfo" Me.lblInfo.Size = New System.Drawing.Size(568, 23) Me.lblInfo.TabIndex = 6 ' 'fmDataFeed ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(581, 195) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.flHistory, Me.stBar, Me.ctlHistory, Me.ctlDataManager, Me.lblInfo}) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) Me.MaximizeBox = False Me.Menu = Me.mnuDataFeed Me.Name = "fmDataFeed" Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide Me.Text = "Data Feed" CType(Me.ctlDataManager, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.ctlHistory, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.stPanel01, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.stPanel02, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.stPanel03, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.stPanel04, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.stPanel05, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.flHistory, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub #End Region Private Sub InitSig() Dim lret As Object Dim password, windir, username, returnstring As String Dim valid, size_Renamed As Short Dim ProcID As Integer Try ' Run Data Manager. ProcID = Shell("C:\Program Files\eSignal\winros.exe", AppWinStyle.NormalFocus) Catch shellEx As System.IO.FileNotFoundException 'shellEx.Message replace with custom message MsgBox("Unable to launch Data Manager. Please launch manually.", MsgBoxStyle.Critical) Exit Sub End Try returnstring = Space(128) size_Renamed = GetWindowsDirectory(returnstring, 128) System.Diagnostics.Debug.WriteLine("Size is " & Str(size_Renamed)) windir = VB.Left(returnstring, size_Renamed) windir = windir & "\winros.ini" System.Diagnostics.Debug.WriteLine(windir) returnstring = Space(128) size_Renamed = GetPrivateProfileString("winros", "InternetUserName", "", returnstring, 128, windir) username = VB.Left(returnstring, size_Renamed) System.Diagnostics.Debug.WriteLine(username) returnstring = Space(128) size_Renamed = GetPrivateProfileString("winros", "InternetPassword", "", returnstring, 128, windir) password = VB.Left(returnstring, size_Renamed) System.Diagnostics.Debug.WriteLine(password) lret = ctlDataManager.SetAppIdentifiers("Real-Time DataFeed", 1, 3, 28, 2003, "Beta") lret = ctlDataManager.OpenConnection("127.0.0.1", username, password) lret = ctlHistory.OpenConnection("cm*.eSignal.com", username, password) stPanel01.Text = "Connect as: " + username End Sub Private Sub InitDisplay() With flHistory .Cols(2).Format = "###.00" .Cols(3).Format = "###.00" .Cols(4).Format = "###.00" .Cols(5).Format = "###.00" .Cols(6).Format = "###,###,###" End With End Sub Private Sub Display_History() Dim i As Integer For i = 0 To intSHistory - 1 flHistory.AddItem((i + 1).ToString & vbTab & arrSHistory(i).strStockSymbol & vbTab & arrSHistory(i).dblDayOpen & vbTab & arrSHistory(i).dblDayClose & vbTab & arrSHistory(i).dblDayHigh & vbTab & arrSHistory(i).dblDayLow & vbTab & arrSHistory(i).intVolume) Next For i = 0 To intIHistory - 1 flHistory.AddItem((intSHistory + i + 1).ToString & vbTab & arrIHistory(i).strIndexSymbol & vbTab & arrIHistory(i).dblDayOpen & vbTab & arrIHistory(i).dblDayClose & vbTab & arrIHistory(i).dblDayHigh & vbTab & arrIHistory(i).dblDayLow & vbTab & arrIHistory(i).intVolume) Next End Sub Private Sub Get_History() Dim lret As Object Dim i As Integer Dim strSymbol As String Dim StartDate As DateTime = System.DateTime.Today Dim EndDate As DateTime = Now Dim iPeriod As Integer Dim bWeekend As Integer Dim bAjust As Integer Dim ID As Integer rPosition = 0 rStockPos = 0 rIndexPos = 0 'strSymbol = "MSFT" 'lret = ctlHistory.RequestHistData(strSymbol, StartDate, EndDate, HISTDAILY, 0, 1, 1021) For i = 0 To intSHistory - 1 strSymbol = RTrim(arrSHistory(i).strStockSymbol) lret = ctlHistory.RequestHistData(strSymbol, StartDate, EndDate, HISTDAILY, 0, 1, 1021) Next For i = 0 To intIHistory - 1 strSymbol = RTrim(arrIHistory(i).strIndexSymbol) lret = ctlHistory.RequestHistData(strSymbol, StartDate, EndDate, HISTDAILY, 0, 1, 1021) Next End Sub Private Sub InitRealTime() Dim i As Integer For i = 0 To intSHistory - 1 ctlDataManager.AdviseSymbol(arrSHistory(i).strStockSymbol) Next '4/17/03 RJP Add Index data For i = 0 To intIHistory - 1 ctlDataManager.AdviseSymbol(arrIHistory(i).strIndexSymbol) Next End Sub Private Sub Get_RealTimeFeed() 'Call next Symbol ctlDataManager.SnapshotSymbol(arrSHistory(iRTPos).strStockSymbol) If iRTPos = arrSHistory.Length - 1 Then iRTPos = 0 Else iRTPos += 1 End If End Sub Private Sub ctlDataManager_Connected(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctlDataManager.Connected System.Diagnostics.Debug.WriteLine("Data Manager Connected..") stPanel03.Text = "Data Manager Connected.." End Sub Private Sub ctlHistory_Connected(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctlHistory.Connected System.Diagnostics.Debug.WriteLine("History Server Connected..") stPanel03.Text = "History Server Connected.." End Sub Private Sub fmDataFeed_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Populate_Stock() Populate_Index() InitSig() InitDisplay() flHistory.Visible = False Me.Height = 88 'Me.Height = 240 iRTPos = 0 InitRealTime() tmrRealTime.Enabled = True End Sub Private Sub ctlHistory_UpdateHistResponse(ByVal sender As Object, ByVal e As AxDBCCTRLLib._IHistoryEvents_UpdateHistResponseEvent) Handles ctlHistory.UpdateHistResponse Dim dayrec As New DBCCTRLLib.HistDayRecord() Dim strSymb As String strSymb = Microsoft.VisualBasic.Left(e.histResponse.Symbol, 1) e.histResponse.GetDayRecordAt(1, dayrec) 'If System.DateTime.Today.DayOfWeek = DayOfWeek.Monday Then ' e.histResponse.GetDayRecordAt(2, dayrec) 'Else ' e.histResponse.GetDayRecordAt(2, dayrec) ' MsgBox(e.histResponse.Symbol + "-" + dayrec.tDate) ' + " " + dayrec.fOpen.ToString + " " + dayrec.fHigh.ToString + " " + dayrec.fLow.ToString + " " + dayrec.fClose.ToString + " " + dayrec.lVolume.ToString) 'End If 'lblInfo.Text = e.histResponse.Symbol + " " + dayrec.tDate + " " + dayrec.fOpen.ToString + " " + dayrec.fHigh.ToString + " " + dayrec.fLow.ToString + " " + dayrec.fClose.ToString + " " + dayrec.lVolume.ToString If strSymb = "$" Then arrIHistory(rIndexPos).dblDayOpen = Format(dayrec.fOpen, "###,###.00") arrIHistory(rIndexPos).dblDayClose = Format(dayrec.fClose, "###,###.00") arrIHistory(rIndexPos).dblDayHigh = Format(dayrec.fHigh, "###,###.00") arrIHistory(rIndexPos).dblDayLow = Format(dayrec.fLow, "###,###.00") arrIHistory(rIndexPos).intVolume = dayrec.lVolume rIndexPos += 1 Else arrSHistory(rStockPos).dblDayOpen = Format(dayrec.fOpen, "###.00") arrSHistory(rStockPos).dblDayClose = Format(dayrec.fClose, "###.00") arrSHistory(rStockPos).dblDayHigh = Format(dayrec.fHigh, "###.00") arrSHistory(rStockPos).dblDayLow = Format(dayrec.fLow, "###.00") arrSHistory(rStockPos).intVolume = dayrec.lVolume rStockPos += 1 End If stPanel02.Text = "Retrieving " + (rPosition + 1).ToString + " symbols" rPosition += 1 dayrec = Nothing If rPosition >= (intSHistory + intIHistory) Then 'If rPosition >= intSHistory Then stPanel02.Text = "Initialize.." InitDisplay() stPanel02.Text = "Write symbol to database.." Insert_StockInfo() stPanel02.Text = "Write index to database.." Insert_IndexInfo() mnuRun.Enabled = True stPanel02.Text = "Ready" End If End Sub Private Sub ctlDataManager_UpdateLastRecord(ByVal sender As Object, ByVal e As AxDBCCTRLLib._IDataManagerEvents_UpdateLastRecordEvent) Handles ctlDataManager.UpdateLastRecord Dim curPRice As Double Dim strSymbol As String Dim lret As Integer Dim lrt As DBCCTRLLib.LastRecordType e.lrt.MoveFirst() lret = e.lrt.Find(LRT_TYPE_KEY, LRT_FMT_CSTRING) If (lret = 0) Then strSymbol = e.lrt.GetString 'pull the stock symbol End If e.lrt.MoveFirst() lret = e.lrt.Find(LRT_TYPE_LAST, LRT_FMT_BASELONG) curPRice = e.lrt.GetBLDouble stPanel04.Text = "Get " & strSymbol Insert_RealTime(strSymbol, curPRice) End Sub Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click stopDataManager() Me.Close() End Sub Private Sub mnuRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuRun.Click mnuRun.Enabled = False Get_History() End Sub Private Sub mnuShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuShow.Click If mnuShow.Text = "&Show History" Then Me.Height = 240 Display_History() flHistory.Visible = True mnuShow.Text = "&Hide History" Else Me.Height = 88 flHistory.Visible = False mnuShow.Text = "&Show History" End If End Sub Private Sub iTray_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles iTray.DoubleClick Me.WindowState = FormWindowState.Normal End Sub Private Sub tmrRealTime_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrRealTime.Tick Me.Text = "Data Feed " & System.DateTime.Now.ToShortTimeString Get_RealTimeFeed() 'If (System.DateTime.Now.Hour = CONSTHOUR1 Or System.DateTime.Now.Hour = CONSTHOUR2) And System.DateTime.Now.Minute = CONSTMIN And System.DateTime.Now.Second = CONSTSEC And System.DateTime.Now.Millisecond < CONSTMSEC Then If (System.DateTime.Now.Hour = CONSTHOUR) And System.DateTime.Now.Minute >= CONSTMIN And flHistServer = False Then 'mnuRun.Enabled = False Get_History() flHistServer = True End If End Sub 'Private Sub dm_UpdateInternationalLong(ByVal Symbol As String, ByVal il As DBCCTRLLib.InternationalLong) ' Dim s As String ' Dim sfile As String ' Dim pricedata As Boolean ' Dim t As String ' Dim ts As String ' <--- time and sales string ' Dim tNow As Date ' Dim tDate As Date ' Dim fsaved As Boolean ' pricedata = False ' fsaved = False ' ' -- Test for category ' If (Str(il.CategoryCode) = CATEGORY_STOCK) Then ' s = "Stock," ' s = s + Symbol + "," ' ElseIf (Str(il.CategoryCode) = CATEGORY_INDICE) Then ' s = "Indice," ' s = s + Symbol + "," ' ElseIf (Str(il.CategoryCode) = CATEGORY_FUTURE) Then ' s = "Future.Bond.Fx," ' s = s + Symbol + "," ' ElseIf (Str(il.CategoryCode) = CATEGORY_STOCKOPTION) Then ' s = "StockOption," ' s = s + Symbol + "," ' Else ' s = "Unknown Category," + Symbol + "," ' End If ' ' TODO: Questionable change ' ' Originally g_timesales = True And Symbol = SymbolField.Text ' If (g_timesales = True Or g_saveall = True) And _ ' Symbol = SymbolField.Text Then ' ts = Symbol + "," ' stat = Asc(il.Status) ' ' -- Determine if this is a real-time trade ' If (stat Mod (ROSREALTIMETRADEORBIDASK * 2)) >= ROSREALTIMETRADEORBIDASK _ ' Or g_saveall = True Then ' fsaved = True ' t = Str(il.MonthUpdate) + "/" + Str(il.DayUpdate) + "/" + _ ' Str(il.YearUpdate) + " " + Str(il.HourUpdate) + ":" + _ ' Str(il.MinuteUpdate) + ":" + Str(il.SecondUpdate) ' tDate = t ' ts = ts + Str(tDate) ' ts = ts + "," ' ' -- Determine if this is a real-time trade or a real-time bid/ask ' ' -- and convert values to Double. ' If (stat Mod (ROSBIDASKMORECURRENT * 2)) >= ROSBIDASKMORECURRENT Then ' ts = ts + ",,," ' If il.Bid <> Empty Then ' ts = ts + Str(dm.BLToDouble(il.Bid, il.base)) '<---double format ' ts = ts + "," + Str(il.BidSize) ' ts = ts + "," + il.BidExg + "," ' Else ' ts = ts + ",,," ' End If ' If il.Ask <> Empty Then ' ts = ts + Str(dm.BLToDouble(il.Ask, il.base)) '<---double format ' ts = ts + "," + Str(il.AskSize) ' ts = ts + "," + il.AskExg + "," ' Else ' ts = ts + ",,," ' End If ' Else ' If il.Last <> Empty Then ' ts = ts + Str(dm.BLToDouble(il.Last, il.base)) '<---double format ' ts = ts + "," + Str(il.TradeVol) ' ts = ts + "," + il.TradeExg + "," ' Else ' ts = ts + ",,," ' End If ' ts = ts + ",,,,,," ' End If ' tNow = Now ' ts = ts + Str(tNow) ' g_streamtimesales.WriteLine(ts) ' End If ' End If ' sfile = s ' ' -- Convert values to Double ' If (il.Last <> Empty) Then ' pricedata = True ' sfile = sfile + Str(dm.BLToDouble(il.Last, il.base)) '<---double format ' End If ' sfile = sfile + "," ' If (il.Bid <> Empty) Then ' pricedata = True ' sfile = sfile + Str(dm.BLToDouble(il.Bid, il.base)) '<---double format ' End If ' sfile = sfile + "," ' If (il.BidSize <> Empty) Then ' pricedata = True ' sfile = sfile + Str(il.BidSize) '<---long format ' End If ' sfile = sfile + "," ' If (il.BidExg <> Empty) Then ' pricedata = True ' sfile = sfile + il.BidExg '<---string format ' End If ' sfile = sfile + "," ' If (il.Ask <> Empty) Then ' pricedata = True ' sfile = sfile + Str(dm.BLToDouble(il.Ask, il.base)) '<---double format ' End If ' sfile = sfile + "," ' If (il.AskSize <> Empty) Then ' pricedata = True ' sfile = sfile + Str(il.AskSize) '<---long format ' End If ' sfile = sfile + "," ' If (il.AskExg <> Empty) Then ' pricedata = True ' sfile = sfile + il.AskExg '<---string format ' End If ' sfile = sfile + "," ' If (il.High <> Empty) Then ' pricedata = True ' sfile = sfile + Str(dm.BLToDouble(il.High, il.base)) '<---double format ' End If ' sfile = sfile + "," ' If (il.Low <> Empty) Then ' pricedata = True ' sfile = sfile + Str(dm.BLToDouble(il.Low, il.base)) '<---double format ' End If ' sfile = sfile + "," ' If (il.Open <> Empty) Then ' pricedata = True ' sfile = sfile + Str(dm.BLToDouble(il.Open, il.base)) '<---double format ' End If ' sfile = sfile + "," ' If (il.Prev <> Empty) Then ' pricedata = True ' sfile = sfile + Str(dm.BLToDouble(il.Prev, il.base)) '<---double format ' End If ' sfile = sfile + "," ' If (il.TradeVol <> Empty) Then ' pricedata = True ' sfile = sfile + Str(il.TradeVol) '<---long format ' End If ' sfile = sfile + "," ' If (il.TradeExg <> Empty) Then ' pricedata = True ' sfile = sfile + il.TradeExg '<---string format ' End If ' sfile = sfile + "," ' If (il.TotalVol <> Empty) Then ' pricedata = True ' sfile = sfile + Str(il.TotalVol) '<---long format ' End If ' sfile = sfile + "," ' ' -- Company name and Earnings Per Share (EPS) information is not available ' ' -- for this data structure. If Company name and EPS information is ' ' -- required, then do not write data from this data structure; use the ' ' -- Last Record Type (LRT) parsing instead. ' ' -- Leave the next two fields blank (company name and EPS) ' sfile = sfile + "," ' sfile = sfile + "," ' 'Originally If g_saveall = True And g_timesales = True And fsaved = False Then ' If (g_saveall = True Or g_timesales = True) And fsaved = False Then ' g_streamtimesales.WriteLine(sfile) ' End If ' ' -- The following code is for demonstration purposes only. This code ' ' -- has no noticeable effects on the "TurboFeed Data Manager Functions" ' ' -- form, or the data handled by this event procedure. ' ' -- The following code demonstrates how to test the status byte bits. ' stat = Asc(il.Status) ' If stat Mod (ROSREALTIMETRADEORBIDASK * 2) >= ROSREALTIMETRADEORBIDASK Then ' Debug.Print("Realtime bit is on") ' End If ' If stat Mod (ROSBIDASKMORECURRENT * 2) >= ROSBIDASKMORECURRENT Then ' Debug.Print("Bidask bit more current is on") ' End If ' If stat Mod (ROSOPEN * 2) >= ROSOPEN Then ' Debug.Print("Open bit is on") ' End If ' Debug.Print(stat) ' ' -- The following code is for demonstration purposes only. This code ' ' -- has no noticeable effects on the "TurboFeed Data Manager Functions" ' ' -- form, or the data handled by this event procedure. ' ' -- The following code demonstrates how to differentiate FORMT ' ' -- trades (after hours trades) from real-time trades. ' stat = Asc(il.Status) ' If (stat Mod (ROSREALTIMETRADEORBIDASK * 2)) >= ROSREALTIMETRADEORBIDASK Then ' If (stat Mod (ROSBIDASKMORECURRENT * 2)) < ROSBIDASKMORECURRENT Then ' ' -- At this point in the code, the real-time bit is set and the ' ' -- BIDASKMORECURRENT bit is off. This means that this is a real-time ' ' -- trade. ' ' -- The next test determines if the FORMT bit is set. If the FORMT ' ' -- bit is set, then this is an after hours trade. ' ' -- Use the UndLong8 property to test the FORMT bit. If UndLong8 is ' ' -- less than zero, then the trade is a FORMT trade. ' If il.UndLong8 < 0 Then ' ' -- NOTE: The usual bit testing cannot be used here because the formt ' ' -- bit is the high or sign bit. ' Debug.Print("FormT trade") ' End If ' End If ' End If ' ' -- Write data to the file indicated in the "Data Output File" field if the ' ' -- appropriate flags are set to True. This data file is associated with ' ' -- the "Read From File" button on the "TurboFeed Data Manager Functions" ' ' -- form. ' If g_fileprocess Then ' ' -- Test if pricedata is True ' ' -- If pricedata is False it is possible that an update containing only ' ' -- the headline count may have been sent. The data is an ' ' -- asynchronous update coming from a remote server so a test made be ' ' -- performed to ensure that all of the appropriate data has been sent. ' If pricedata Then ' j = Symbols.ListCount ' Do While i < j ' Symbols.ListIndex = i ' If Symbol = Symbols.List(i) Then ' ' -- We are removing the symbol from the symbols list inside the ' ' -- dialog to indicate that data for the symbol has been returned. ' ' -- We keep the symbols in the dialog symbols list until data for ' ' -- symbol is returned, or until the time limit (5.5 seconds) is ' ' -- reached. ' Symbols.RemoveItem(i) ' ' -- Deleting the symbol is not required, but may be imployed to ' ' -- remove the symbol from the local TurboFeed Data Manager symbol ' ' -- list. ' dm.DeleteSymbol(Symbol) ' g_streamout.WriteLine(sfile) ' ' -- Force the loop to exit once the appropriate symbol has been ' ' -- found. ' i = j ' End If ' ' -- Continue to search for the appropriate symbol in the symbol list. ' i = i + 1 ' Loop ' End If ' End If ' ' -- Add the information to the "TurboFeed Data Manager Functions" form ' List1.AddItem(sfile, 0) 'End Sub End Class