@tahseen those two files have not just the name but also all the other details you'd need for fno contracts (both options and futures). How you'd download it and how you'd parse it is upto you
@Amit Ghosh Here's the code in case you want to use it. You'd need to download chromedriver and pass it's path to the code .... also set your download directory.
from time import sleep
from selenium import webdriver
import os
URL_SOS_SCHEME = 'http…
@Amit Ghosh You can use these:
https://www.nseindia.com/content/fo/sos_scheme.xls
https://www.nseindia.com/content/fo/fo_mktlots.csv
I use selenium to download these two using python.
@tahseen well my previous experience in coding is in java so that's the approach that came to my mind
However I think the approach you suggested with queues would be more appropriate to python..... Will do that. Thanks for taking out time to rev…
roguedelta.RogueDelta(portfolio, orderbook, x)
this just create instances of strategy class (in this case RogueDelta) for the instrument selected (in this case hardcoded bank nifty). Then the rest of the code in main flow calls on_connect and on_ti…
@tahseen This is the reconnect() function of watchlist after I made changes to subscribe again to tokens.
def reconnect(self, web_socket):
self.ws = web_socket
all_tokens = []
ltp_tokens = []
full_tokens = []
…
@tahseen This is my main flow:
# Load Traders Profile
# Load Trader's Portfolio and Order Book
# Create variable for Watchlist
logging.info("RogueTrader: Loading Traders Profile, Portfolio and Order Book")
user = user.User(kite=kite)
portfolio = po…
@zartimus Thanks for that info!
So here is what I have changed for now:
1. on_connect in first run initializes a watchlist object whose handle my main thread gets to manage subscriptions/read values etc.
2. on_connect in case of re-connection calls…
@zartimus @sujith @tahseen if that's the case shouldn't the code above start receiving the ticks again on re connection?
In log a few lines after disconnection it shows "Connected to WebSocket" which was logged from inside on_connect, so my assumpti…
@zartimus @sujith as per the code that zartimus posted it looks like the assumption that all old tokens are resubscribed is not true in case on unclean dis connection. And in my log it shows that connection was closed uncleanly. Does that mean in th…
@tahseen all my strategy instances use watchlist to manage subscriptions to websocket. So after re connection if one of the strategy wants to register a new instrument token it'd call watchlist function to do that. Watchlist in turn uses web socket …
ok.... if it's a new web socket handle does that mean I need to again subscribe to all the instrument with this new handle?
I think my assumption that on reconnect kite automatically switches all the registered tokens might be wrong.
Updated on_connect to pass the new handle to watchlist
This would take care of subscribe/unsubscribe after reconnect but it still doesn't solve the on_tick issue
def on_connect(ws, response):
# Callback on successful connect.
global ws_conne…
ws_connected is just to make sure that I do not initialize a new watchlist object on re connection. RogueDelta is the strategy code that's reading values from watchlist/portfolio and logging the strategy related details.
Based on your input I real…
This is all that I have in the three callback functions. on_tick passes the tick for updating ltp, timestamp etc to other objects. on_connect initializes a watchlist on it's first run and no ws.stop() inside on_close. The web socket is run in thread…
executor = concurrent.futures.ThreadPoolExecutor(max_workers=len(delta_runners))
for runner in delta_runners:
if not runner.in_process:
executor.submit(runner.on_ticks, ws, ticks)
this is what finally worked. Have removed th…
Yes you can.
I keep my kite logged in and do usual charting and keep track of positions and orderbook while my algo is managing my trades and positions in parallel.
In the end I decided to go for executing the function calls from on_tick in separate threads without waiting for these threads to join back. To make sure that I maintain sequence of flow by not calling the function while previous call to the functio…
ok I did that with a While True: at the end. That shouldn't cause any problems right? Given that I don't mind missing a few ticks data while my user function flow ends and it comes back to on_tick.
Another option I was considering, what if instead …
@rakeshr Thanks for that info! However one doubt. In non-Threaded implementation kws.connect() used to be the last statement that kept the flow in infinite loop till I called ws.stop() at the end of the day.
However now my kws.connect() with threa…
Another thing I'd like to add to that.
I have been running this code for few weeks now with just one instrument and it worked without any problem. In that case it used to be one function call from on_tick and the execution used to give the control b…
I ran the code with debug and this is what I get. No Error in code was thrown.
Following is the execution flow:
1) on_tick called couple of functions when certain conditions were meet.
2) These 2 function calls kept the control for about 5-6 second…
Yeah Sujith, I'd try to recreate the issue with debug mode.
However is it possible that WebSocket remains connected and keeps getting new ticks if API Key or access token is incorrect?
Ahh... Thanks for the clarification! That's a really weird format they have come up with but I guess nothing we or Zerodha can do bout it. Thanks again!!
Thanks sujith! Found the Jan contract based on the format mentioned in the thread you specified.
However one doubt, for Nov and even now for Dec the trading symbol for weekly contracts that I have been using use a different format i.e. NIFTY (YY) (F…
I even tried placing an order with trading symbol NIFTY20J0212100CE and it failed with error message 'Instrument is invalid'.
I don't expect those orders to be COMPLETED.... but I did expect them to show up in my order book with status REJECTED....…