How to get 9:15 open price

chiragkeswani
Hi,
Through API function we get the Open price which is of pre-market session. Along with that Open price, I also want the price on first tick received at 9:15 market open. How do I get it?
Regards-
Chirag Keswani
  • chiragkeswani
    Hi @sujith,
    If I use getOHLC method at 9:15:15, will it return the Open price of 9:15:00?
    Also, do we need Historic API subscription for getOHLC method?
  • sujith
    The getOHLC method will return day's open, you can fetch OHLC at 9:15:15 then it will give open of the day.
    You don't need to historical API subscription to use this.

    Order receiving happens till 9:07 AM and then there will be one match at 9:08 AM which is the first tick of the day.
    So, the first tick is decided at 9:08 AM. I think you should try it.
  • chiragkeswani
    @sujith, I am not able to find the getOHLC method in KiteXL. How do I call it, and what are it's parameters?
  • botany02
    botany02 edited November 2017
    @chiragkeswani
    getOHLC method is not available in KiteXL, even if available it will not fulfill your requirement.
    Because, it always returns the Day Open only.

    With Historical data, your purpose may be solved, but it will collapse your system when you try to fetch n number of symbols, you need to parse the data for all symbols and also will cost extra Rs2000/- pm.

    But what you actually need is, a simple VBA function that will capture the first tick after 09:14:59.
    This will use nil resource.
  • botany02
    botany02 edited December 2017
    @chiragkeswani
    Use the below code.
    1.
    Add reference to 'Microsoft Scripting Runtime' in VBA

    2.
    Declare the below variable at the top of the module
    Public Dict_CapturedValue As Scripting.Dictionary

    3.
    Copy paste the below UDF to the module.
    This will capture the passed Price only once after IsValueCaptureTime is TRUE.
    Till IsValueCaptureTime is not TRUE, this will return zero.
    once the IsValueCaptureTime is TRUE,
    it will store the passed price in the dict key.
    return the captured price from now on wards.
    stop capturing any other new price passed further
    Public Function GetCapturedValue(ByVal TrdSym As String, ByVal Value As Double, ByVal IsValueCaptureTime As Boolean) As Double
    On Error GoTo ErrHandler:

    If Value = 0 Then
    GetCapturedValue = 0
    Exit Function
    End If

    Dim DictKey As String
    DictKey = TrdSym

    Dim captured_Value As Double
    captured_Value = Dict_CapturedValue(DictKey)

    If captured_Value = 0 Then
    If IsValueCaptureTime Then
    Dict_CapturedValue.Item(DictKey) = Value
    captured_Value = Value
    End If
    End If

    GetCapturedValue = captured_Value

    Exit Function
    ErrHandler:
    GetCapturedValue = 0
    End Function
    4.
    Example
    A1 = AXISBANK '''TRDSYM
    A2 = LTP '''RTD FUNCTION TO GET LTP
    A3 = TIME(HOUR(NOW()),MINUTE(NOW()),SECOND(NOW())) '''GET SYSTEM TIME - FORAMT THE CELL WITH CUSTOM hh:mm:ss
    A4 = 09:15:00 '''THRESHOLD TIME - FORAMT THE CELL WITH CUSTOM hh:mm:ss
    A5 = A3>=A4 '''CHECK WHETHER THE SYSTIME IS ABOVE(ABOVE) 09:15:00, IF ABOVE RETURN TRUE ELSE FALSE
    A6 = GetCapturedValue(A1, A2, A5)
  • botany02
    Small correction, change the variable declaration to below

    Public Dict_CapturedValue As New Scripting.Dictionary

    See the 'New' keyword
  • VenkateshV
    @botany02
    Could this method can be used also to capture ltp of any particular times within trading hours for a symbol?...i.e ltp snapshot of specific time for a symbol?
  • chiragkeswani
    @botany02, it worked perfectly. Thanks a lot.
Sign In or Register to comment.