I want to get the Bids and Offers from tick data in FULL mode. I am using below code to access that but I am getting error. The code and error are as below. Please let me know the code I should use to access the Bids and Offers from Tick in FULL Mode.
You can try splitting that string concatenation into different lines to narrow down the cause
I believe this is due to unavailability of bids and orders in that array. So when you subscribe to a token server immediately sends a quote tick. This is due to the network delay in reaching the mode change request to the server. So it is better to check if bids and orders array length before accessing the first element inside it.
Just add a check like:
If tickdata.Bids.Length > 0 And tickdata.Offers.Length > 0 Then DoSomething() Else 'No depth in the current tick. Check the next one.' End If
I have tried do the array length checking before writing but still the same exception as before is coming. It's coming only when I am trying to access bids or offers and NOT on others (like volume / open / high etc.). Please check an let me know the format through which I can access bids and offers.
Imports System.ComponentModel Imports System Imports System.IO Imports KiteConnect
Dim user As User Public WithEvents tickerPredefined As Ticker Public kite As Kite
Private Sub btnTestTicker_Click(sender As Object, e As EventArgs) Handles btnTestTicker.Click tickerPredefined = New Ticker(tbxAPIKey.Text, tbxUserID.Text, tbxPublicToken.Text) tickerPredefined.Connect() tickerPredefined.Subscribe(Tokens:={"53471751", "53466887", "53474823", "53372423", "53499143"}) tickerPredefined.SetMode(Tokens:={"53471751", "53466887", "53474823", "53372423", "53499143"}, Mode:="full") End Sub
Private Sub Ontick(tickdata As Tick) Handles tickerPredefined.OnTick
If tickdata.Bids.Length > 0 And tickdata.Offers.Length > 0 Then
Private Sub Onconnect() Handles tickerPredefined.OnConnect ConnectionStatus = tickerPredefined.IsConnected If ConnectionStatus = True Then MsgBox("Connection established") Else MsgBox("No connection established") End If End Sub
This code is running fine at our end without any issues. I would suggest you to double check whether other parts of your program is interfering with it.
You can try splitting that string concatenation into different lines to narrow down the cause
I believe this is due to unavailability of bids and orders in that array. So when you subscribe to a token server immediately sends a quote tick. This is due to the network delay in reaching the mode change request to the server. So it is better to check if bids and orders array length before accessing the first element inside it.
Just add a check like:
I have tried do the array length checking before writing but still the same exception as before is coming. It's coming only when I am trying to access bids or offers and NOT on others (like volume / open / high etc.). Please check an let me know the format through which I can access bids and offers.
The format you have written is correct. I think the way you check the array length is wrong. Can you post the code snippet?
Can you post complete code? This part of the code looks fine.
This code is running fine at our end without any issues. I would suggest you to double check whether other parts of your program is interfering with it.