Dear all, As i'm new to python as well as new to algo trading, i'm writing my first algo code and it is 15min ORB strategy so following is the code i have written and i need some help regarding this matter, as i need to know weather my code will work or not.
def on_ticks(ws,ticks): for data in ticks: current_time = datetime.datetime.now() crt_time = current_time.time() break_out_start_time = datetime.time(9, 15) break_out_end_time = datetime.time(9, 30)
so with the above code what is happening is sometime updates are not there and all the time h_value and l_value are updated even after my breakout time of 9:30 is elapsed, please help me on this from any of members ,it would be great help.
hii @samphel if you are a beginner in algo trading then this series can help you... also, I have shown how to make full orb code in some last lectures.
hi @Imran i have gone through your video and i'm not able to find my answer in that , as you can see above i need to save high and low value of first 15 minute in a variable then only i can further go for 15 minute orb strategy , but in your videos it simply compared ltp of current high and low.
@samphel First of all this program is a total mess. You don't do so much condition inside on_tick. Anyway I wouldn't want to get into that detail
To answer your question, I need to see indented python code as you can see your code copy paste has lost indentation. I don't know what is within if and what is not. And I don't want to make a guess to answer your question
If you have to run the strategy at specific time and strategy is only based on OHLC data, you don't need tick data. Just get kite.ohlc(symbol), which is more stable to get. Let me know if you need more help.
Although I really wonder why wrote all this if you really want to just work on ORB. But let me tell you the issue is that your first if condition would always keep working as it is >= start time
And worst your second condition is a == for an exact match, where crt_time would be in Hour and Minute, Seconds, Milli Second whereas your breakout time is in Hour and Minute. It would never match
I think you should learn proper python before delving into Algorithmic trading. Take my honest advice, your style of coding is very bad. Even if you are the best of trader, wrong coding would wipe you out
if you are a beginner in algo trading then this series can help you...
also, I have shown how to make full orb code in some last lectures.
https://kite.trade/forum/discussion/6216/python-and-kiteconnect-series#latest
To answer your question, I need to see indented python code as you can see your code copy paste has lost indentation. I don't know what is within if and what is not. And I don't want to make a guess to answer your question
And worst your second condition is a == for an exact match, where crt_time would be in Hour and Minute, Seconds, Milli Second whereas your breakout time is in Hour and Minute. It would never match
I think you should learn proper python before delving into Algorithmic trading. Take my honest advice, your style of coding is very bad. Even if you are the best of trader, wrong coding would wipe you out
def pcl15min(token):
# starting_date="2019-12-01"
# ending_date="2020-01-01"
starting_date=datetime.datetime.now().strftime("%Y-%m-%d")
ending_date=(datetime.datetime.today() + datetime.timedelta(days=1)).strftime("%Y-%m-%d")
time_period="15minute"
zap=kite.historical_data(token,starting_date,ending_date,time_period,0)
zapp=pd.DataFrame(zap).tail(10)
print(zapp)
#print(zapp.iloc[-1,-1])
return zapp.iloc[-2,-3] #Selects 3rd Last Column and 2nd Last Row i.e. low of Previous 15m candle
#print(zapp.iloc[-2,-4]) #Selects High of Previous 15m candle
token=get_insToken("INFY","NSE")
pcl15min(token)
Please check indentation.
Simpler ===> str( datetime.date.today() )