Announcement

Collapse
No announcement yet.

NI225_M time and sales data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NI225_M time and sales data

    II would like to get historical time and sales data about NI225_M.

    but I can't get MOC(market on close data) at 15:10.

    Is wrong this source code ?


    Private Sub esignal_OnTimeSalesChanged(ByVal lHandle As Integer) Handles esignal.OnTimeSalesChanged
    If lHandle = tsHandle Then
    If esignal.IsTimeSalesReady(lHandle) Then
    StatusLabel.Text = "History Complete"
    Else
    StatusLabel.Text = "Receiving Data"
    End If

    Dim tick As IESignal.TimeSalesData
    Dim lNumBars As Long = esignal.GetNumTimeSalesBars(lHandle)

    tick = esignal.GetTimeSalesBar(lHandle, -(lNumBars - 1))

    log_print1(Str$(tick.dtTime.Year) & "-" & Str$(tick.dtTime.Month) & "-" & _
    Str$(tick.dtTime.Day) & " " & Str$(tick.dtTime.Hour) & ":" & Str$(tick.dtTime.Minute) & ":" & _
    Str$(tick.dtTime.Second) & " Price:" & Str$(tick.dPrice) & " Size:" & Str$(tick.lSize))
    End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim uname = "XXXXXXXX"
    Dim sname = "NI225_M M8-OSM"

    esignal.SetApplication(uname)

    UsernameTextBox.Enabled = False
    ConnectButton.Enabled = False
    SymbolTextBox.Enabled = True
    GetTimeSalesButton.Enabled = True

    If esignal.IsEntitled <> 1 Then
    MessageBox.Show("IsEntitled returned false. Can't send request.")
    StatusLabel.Text = "Not Entitled"
    Return
    End If

    Dim filter As IESignal.TimeSalesFilter

    If tsHandle <> -1 Then
    esignal.ReleaseTimeSales(tsHandle)
    End If

    filter = New IESignal.TimeSalesFilter
    filter.bFilterPrice = False
    filter.bFilterQuoteExchanges = False
    filter.bFilterTradeExchanges = False
    filter.bFilterVolume = False
    filter.bQuotes = False
    filter.bTrades = True
    filter.lNumDays = 1
    filter.sSymbol = sname
    tsHandle = esignal.RequestTimeSales(filter)
    End Sub

  • #2
    You may have some things out of sequence here. Try something like the code below. This is taken from the VB Desktop API Sample, which does retreive data for NI225_M M8-OSM.

    **************************************************
    Dim tsFilter As IESignal.TimeSalesFilter
    tsFilter.sSymbol = "NI225_M M8-OSM"
    tsFilter.bQuotes = True 'Request quotes
    tsFilter.bTrades = True 'Request trades
    tsFilter.lNumDays = 2 'Number of days for which you want data
    tsFilter.bFilterPrice = False 'True indicates that there is a price filter
    'associated with this request; False otherwise.
    'See page 4-7 of the documentation
    tsFilter.bFilterVolume = False 'True indicates that there is a volume filter
    'associated with this request; False otherwise.
    'See page 4-7 of the documentation
    tsFilter.bFilterQuoteExchanges = False 'True indicates that there is a filter of quote exchanges
    'associated with this request; False otherwise.
    'See page 4-7 of the documentation
    tsFilter.bFilterTradeExchanges = False 'True indicates that there is a filter of trade exchanges
    'associated with this request; False otherwise.
    'See page 4-7 of the documentation

    'Make request using info above. OnTimeSalesChanged will automatically
    'trigger once there is a value in requestHandle
    requestHandle = esignal.RequestTimeSales(tsFilter)

    End Sub

    Private Sub esignal_OnTimeSalesChanged(ByVal tsHandle As Long)
    'Debug.Print ("OnTimeSalesChanged Fired")
    If requestHandle = tsHandle Then

    Debug.Print ("OnTimeSalesChanged: " & tsHandle)
    'lHandle is the handle to the time sales request that requested
    'this data
    Dim lNumBars, lNumRtBars, lBar, lDiff As Long
    Dim item As IESignal.TimeSalesData

    lNumRtBars = esignal.GetNumTimeSalesRtBars(tsHandle) 'Gets number of
    'real-time bars

    lNumBars = esignal.GetNumTimeSalesBars(tsHandle) 'Gets number of
    'historical bars

    'Determine the number of new bars since the last event
    lDiff = (lNumRtBars - lLastTsRtCount) * -1

    For lBar = lDiff + 1 To 0
    item = esignal.GetTimeSalesBar(tsHandle, lBar) 'Gets a TimeSalesData structure.

    whatFlag = item.DataType

    Debug.Print ("The flag is: " & whatFlag & "(" & item.dtTime & ")")


    If item.DataType = tsdBID Then
    sBar = Format$(item.dtTime) & vbTab & Format$(item.dPrice) & " (Bid)" & vbTab & Format$(item.sExchange)
    ElseIf item.DataType = tsdASK Then
    sBar = Format$(item.dtTime) & vbTab & Format$(item.dPrice) & " (Ask)" & vbTab & Format$(item.sExchange)
    Else
    sBar = Format$(item.dtTime) & vbTab & Format$(item.dPrice) & vbTab & vbTab & Format$(item.sExchange)
    End If

    List1.AddItem sBar, 0
    Next lBar

    'Remember the number of real-time bars so you can track how many
    'new real-time bars occur the next time.
    lLastTsRtCount = lNumRtBars

    End If

    End Sub

    Comment

    Working...
    X