Automated Trading

qtrader
I am trying to automate a strategy. I employed bunch of while loops with time<3.30 pm. I feel thats not the most efficient way to automate a code. Ideas are welcome.
  • Ramkrishna
    what is the purpose of code, backtesting? in that case it is fine. develop a code such that you 'add' data points like open, high, low, close, volume every 1 min (or whatever ur timeframe is) and ur code should work on algo and return you buy/sell signals. mostly keep everything loosely coupled. e.g. keep zerodha api in separate class/component such that if you switch to any verndor, you dont need to change ur core component but just ur verndor specific class. shud use interfaces
  • qtrader
    Not backtesting executing the orders without manual intervention. Suppose buy the stock at some price say open is at 100 and I will buy at 98. stock may come anytime in the day to 98. I employed a while loop for this.
  • sujith
    @qtrader,
    RMS square off is done at 3:20, make sure you close in the money positions before that on expiry day otherwise you will end up paying huge STT. Check out this for more information.
  • AnkitDoshi
        
    import datetime
    import time
    day_num=datetime.datetime.now().day
    day_mon=datetime.datetime.now().month
    while datetime.datetime.now()<datetime.datetime(2016,day_mon,day_num,23,56):
    #my code goes here



    Why Bunch?
    Only One!!!
  • anupshinde
    @AnkitDoshi You should have a look at event driven programming

    With a while loop you are probably requesting the security information multiple times. It is inefficient for you and adds unnecessary load to Kite. And since Kite already provides websockets, you should use that and subscribe to your specific security. That way you can execute your conditions/orders when data is received over a websocket

    You can also reach me here: http://bit.ly/1pUAixJ. (But please don't ask me to write the code for you)
Sign In or Register to comment.