Calculating indicators like moving average or average true range

trader007
Hi,

Is there a function to calculate indicators such as moving averages, true range, etc.,

Either through sockets or historical api
  • AnkitDoshi
    There are many available over Internet. Google them out
  • trader007
    I'm actually looking to calculate my indicators at server end instead of writing a function after downloading the entire data.

    Are there fns builtin in kite library of python?
  • sujith
    Hi,
    KiteConnect is purely an execution platform. It doesn't have any methods for indicators.
  • trader007
    how can i get the current day data entire, say every minute close price of today.

    i cant get it through sockets right?
  • sujith
    Yes you get only day's OHLC in Websocket.
    For minute's OHLC you need to use Historical API
  • chaudhariapurva
    hi ,
    download TA LIB API .
    It works really well
  • trader007
    trader007 edited December 2016
    @chaudhariapurva Thanks for your suggestion. can you please give an example. also how the input data should be changed to (i suppose which is sourced from historic api)
  • chaudhariapurva
    @trader007 kindly tell me the language you want to use it in ?? , i have used it in c#
  • AnkitDoshi
    @trader007 You will have to convert the historic data to pandas dataframe.

    I am assuming you understand python and pandas and numpy library to do backtest
  • trader007
    @chaudhariapurva i use python..Thanks for the info.

    1 last question. can i use sockets to calculate those (i dont think so. just want to know of something is there)
  • chaudhariapurva
    chaudhariapurva edited December 2016
    hi @trader007 It depends on your time horizon , if trading intraday with time horizon of 1 day u can save the ticks to calculate indicators othervise u will have to subcribe to the historical API and feed data to library to get the outputs. It really depends on your strategy. As for the technical asspect of feeding data to TALIB ,Its api is quite flexible so if want to change input mechanism simply write a wrapper for it
  • trader007
    @chaudhariapurva .. if i'm storing ticks from web sockets, then i need to run a different code right?
    since once you connect to sockets your rest of the code runs ( which means strategy will not run)

    also isnt there a chance that ticks received are incomplete or missing which means my strategy is comprimised. so dont you think its safe & convenient to use historical api?
  • chaudhariapurva
    @trader007 the granularity on historical ApI is of 1 min ,so if u want to use indicators like PVT(Price volume trend),or VWAP,or market profile visualization which really work well on tick data(or atleast one sec data) you will have to store the tics, and to store the tics just start a thread and use some synchronization mechanism to send data to and fro.For incomplete or erroneous tics you need to do sanity checks ,this is also true for historical api where the api gives you [""] data if you call a date where there was a holiday.Lol(maby they solved it now).
  • trader007
    @chaudhariapurva any sample on how to do in a different thread and also how to sync between the process. It will be really helpful.

    Also where do we need to store data.. I a sql database or variable?
  • chaudhariapurva
    Hi @trader007 ,
    Im not that good in python , but there will always be someone who has faced a problem like yours in such a popular language like python(use text file as db ,sql also works fine and gives you greater flexibility),my advice at this point will be to explore your options carefully ,if there is a library avaialble you will find it or try to develop your own and us stackexchange or others like it for reference.
    with python you can even use c++(super fast libraries),checkout-->http://www.swig.org/
    the pseudicode should be like this
    Thread1()
    {
    lock(obj)
    {
    write tick as they arrive from websocket buffer toa suitable storage location
    }
    }

    Thread2 OR MAIN ()
    {
    lock(obj)
    {
    read the data
    }
    process and place trades
    }
  • chaudhariapurva
    chaudhariapurva edited December 2016
    Hi @trader007 ,
    Im not that good in python , but there will always be someone who has faced a problem like yours in such a popular language like python(use text file as db ,sql also works fine and gives you greater flexibility),my advice at this point will be to explore your options carefully ,if there is a library avaialble you will find it or try to develop your own and us stackexchange or others like it for reference.
    with python you can even use c++(super fast libraries),checkout-->http://www.swig.org/
    the pseudicode should be like this
    Thread1()
    {
    lock(obj)
    {
    write tick as they arrive from websocket buffer toa suitable storage location
    }
    }

    Thread2 OR MAIN ()
    {
    lock(obj)
    {
    read the data
    }
    process and place trades
    }
  • trader007
    Thanks a lot for your info.

    This will be very helpful
This discussion has been closed.