@rupanshu this is a badly written code. Before writing your code, you should make a sequence diagram so that you know what you are doing.
You should have
1. Token generation program that starts everyday at 8:55am and stores token in an inmemory st…
There are two different use cases
1. When you get filled completely
2. When you get filled partially
In both the cases you should start placing SL orders as per the fill and update as more fills happen
If the orders are accepted via a bi-directional web socket then indeed it would be faster than an order accepted via https API. But Kite accepts orders over https API
@OnlyGains
1. If notification is basis some PnL of your trade then you cannot ask developer to have his own account to notify you because he won't know the PnL. There is a solution to this also but not very straight forward
2. If notifications are…
@shinde111ms first you have to tell what you did that you got this error response
You are showing error without sharing what you executed that resulted in this error, how will anyone be able to tell why this error is coming ?
From what I can und…
You mean in kite web socket data ? or data fetched from the api call ? Or you are talking about web ?
If you want help, you must elaborate your question, the more you write in detail along with screenshots, the faster and better response you get.
…
I tried like this and it worked for me
curl "https://api.kite.trade/portfolio/holdings" \
-H "X-Kite-Version: 3" \
-H "Authorization: Basic BASE64_OF(API_KEY:ACCESS_TOKEN)"
Please don't forget to have exactly same format
"Authorization: B…
Before all that please ensure that you access_token is passed to your code. Historically on this forum, this error in most of the cases has been related developers not passing their access token correctly or were not even aware that there was no tok…
Welcome, note you can replicate the consumer code and set it to 5 minutes
Then you would get two files - 1 minute and 5 minute candle stick file
So it is scalable
I limit the total instruments to 750-1000 for optimal performance.
Code also shows …
In python you can create a dataframe df which has index column as date time
INSTRUMENT and LASTPRICE column to be used as below. Then the group by would give you 1 Minute Candle
candles = df.groupby("INSTRUMENT")["LASTPRICE"].resample("1T").ohlc()
@kiteapi If there is then fine, no need for me to share the code. Also, I never stated time as my system time
@srinidhihebbar This thread is about code that am planning to share. I stated from cost benefit analysis. The discussion is not about impr…
@srinidhihebbar
Let us say we are talking about 1 minute candle then less than half a second after the time candle time finishes
Let us say time is HH:MM:SS:mmm, where mmm is milli second
So a 10:15:00:000 candles finishes at 10:16:00:000 and yo…
@saurabh123 I wrote it on 28th March as the first thing but you countered my point stating you are fetching it all correctly
Most of the developers make this mistake thinking there is a web socket issue just because they see the "connection was clo…
Service port and outgoing client requests are different thing. You don't have to stop Apache
Web Socket protocol is ws, check if Google has blocked socket protocol
@saurabh123 then it further confirms that this is not Kite API issue and probably something to do with Google. Maybe Google Firewall is closing / dropping the web socket connects
@Anoop
I mentioned at other place also. You code might have an issue and when it terminates what you get is the web socket error, which makes you believe into the fact that there is web socket error
Remember this error simply means that code exite…
@saurabh123
This is clearly a case of access_token issue.
Because of access_token issue, the application fails and as the thread with web socket is also killed, what you see is the unclean websocket disconnection error
The diverts the attention o…
@vaibhavsharma13 am talking of basic queue of python
from queue import Queue
messageQueue = Queue()
def read_queue():
while True:
bulk_ticks = messageQueue.get()
# do something like NASA or SpaceX here with this data
# thi…
No, you need to pass the ticks JSON as is in a queue within on_ticks
and there should be a separate thread that is running and consuming this queue of ticks to process
this way you have decoupled on_ticks from computational load
This is a very si…
@vaibhavsharma13 no, you won't have new thread for each tick. That would be terrible a code
@samirkelekar @vaibhavsharma13
For beginners
1. Initialize internal queue Q in the beginning of the program
2. Inside on_ticks you pass the data to the …
@rohitsharma666
You mean you want to migrate your code from Zerodha to Angel Brokering. That would mean change of code at point of integrations with the backend because Angel Brokering would have different APIs than Zerodha
@rj_stk maybe in 4.2 the web socket is used more optimally, which is considered as idling by Azure and it disconnects the socket. Whereas 3.9.4 version isn't optimal and continually uses socket thus not disconnected
Because if you read the link of …
@rj_stk
https://learn.microsoft.com/en-us/azure/load-balancer/load-balancer-tcp-idle-timeout?tabs=tcp-reset-idle-portal
Check there is no idle timeout configured. Honestly, I don't recommend environments where you have no idea about the layer cond…
@rj_stk
Assuming Zerodha Kite won't have 50% failures only with you and if overall it has 50% failures then it would be outage known all over twitter
Ping and see if you have packet drops, mediation router has issues or DNS of ISP has issues
Tr…
@wishabhilash You are using
tasks.process_quotes.delay(quote, True)
You have not posted what is in this
process_quotes
this function processing quotes might have been written incorrectly or might not be optimized
@nkotwar the issue is not the web socket here. That is what you are seeing as an error eventually. But that is not the root cause. Something else in your code causes error and when that results in code breaking up, it throws exception of "connection…
Why not to buy option at trigger price ? This would reduce profit but then save you from SL / Reentry. I don't know your strategy but this is what I can suggest
@moihanrahim
In past I wrote this to find the nearest expiry programmatically
df = pd.read_csv("INSTRUMENT_FILE_NAME", low_memory = False)
fno_nearest_expiry = sorted(df[(df.segment == 'NFO-FUT')].expiry)[0]
@KesharDev
def on_ticks(ws, ticks):
updateOrdersSQL_thread = Thread(target=updateQuotes,args=(ticks,))
updateOrdersSQL_thread.start()
You are initializing and starting thread inside on_ticks, which is not correct. You are fundamentally laun…
@Sandeep_Prakash Maybe the Zerodha team knows. Sometimes it is about cost benefit analysis. Do we really need so much Exception information ?
So long as you read the document and do it correct, you wouldn't need any Exception information
Best is to do real trading with very low position size. There are so many things that you would miss out on in simulated trading
1. Slippage
2. Spread loss
3. Taxes that ultimately reduce your real net profit
I have never heard of Black76
There is only Back-Scholes Option Pricing model.
Someone wrote it in C#
https://gist.github.com/achvaicer/598242286181f5c501498a645e96f8ac
and also one more guy
https://github.com/MichaelKono/BlackScholesOptionsCal…
Simple moving average is the simple average of the last 9 period Price
Exponential moving average different in that when your new value E
E_new = New_Data * factor + (1 - factor) * E_current
factor in your case would be 2 / (n + 1) means 2 / ( 9 +…
I wrote a program to connect to the SMPP server, which was sending sending data to me. So I used MSG_PEEK as the flag in recv to read the size of the incoming data, to malloc the buffer variable size exactly as much the incoming data
Unless am unde…
It sounds similar to C
In C programming if I have to optimally allocate memory to the data buffer, I must know the size of incoming data and for that MSG_PEEK flag is used with recv
Then with malloc exact size is allocated to the buffer. In next s…
@Gjain75
1. Remember no matter how much you disagree and avenge by taunting, what I said is the truth
2. Zerodha as well as you are using tech stack / language that is open source made by those who were never paid
@Rupali Yes, I was wondering why you are fetching via LTP
You can use web socket and write it to Redis and then any thread can read from there. This is best way
Note, don't do any computation inside
on_ticks
Just read and push it to a queue fro…
@Rupali
1. Install Redis or Memcache
2. Create an independent thread, whose task should be bulk batch polling for LTP of stocks you are looking for and it then updates a cache like Redis
3. Ensure this #1 thread internally honours the rate limit
…
@Gjain75 don't mind but I think you are learning python and Kite API together
Whereas you should learn python programming properly first and then get into kite api
You might disagree and I might be sounding discouraging but am telling you what is…
@Rupali
1. You can run as many threads as you want so long as you comply with rate limit. Read #3
2. How would upgrading hardware solve ? Putting a super computer at your side still won't permit you to hit millions requests per second. Your hardwa…
@durghy_trades
1. When you place the order, the function returns order id
2. Kite has on_update call back, which tells you order executed or not and how much filled
3. Also the same on_update call back will tell you if the order id is executed targ…
@Gjain75
I am not from Zerodha but with all the example and so much on youtube, every new joiner on forum cannot expect Zerodha team to handhold people on the very first step - token generation
Till date, I have not come across a single problem f…
@Gjain75
Could you share more part of your code to understand ? It seems you are trying to run something in thread and there is an uncaught error thrown in that thread and because of that the web socket connection is getting closed
While you are …
@damok If you requirement is just number of lots basis amount in your account then just
1. Find the margin for a single lot as per the API provided by Sujith
2. Let us say that comes to margin_required
then using python code, number of lots you can…
@chaklin
Now lets say for today i see holding based on BSE symbol and
i need to sell with NSE, how do i identify NSE symbol for the same either
using instrument list or API?
For this it means the instrument would have a name, but different tra…
I have never used Publisher based stuff you are mentioning. But am sure in that case you would have option to create your call back API and configure it in the Kite Trade Dashboard. Every time order gets executed, your API would be called with data
Those who know don't spend time in claiming that on YouTube. Those who know how to trade, spend time in learning instead of making YouTube videos on how they do things
Also 200 users simultaneously yes. Same price ? Depends if limit orders fill. Wi…
import pandas as pd
df = pd.read_csv('INSTRUMENT_FILE')
dataset = df[ df.exchange.isin( [ 'BSE' , 'NSE' ] ) ] [ [ 'exchange' , 'tradingsymbol' ] ]
Now, you know how you can use dataset data frame to find ?
@developer
I know on in python client, you have a call back function on_update and using that, you can get executed orders call back. In that JSON data you can get what you want
Am sure it would be applicable similarly in any other client that is…
@SelvaPK
You have to code this using Kite API and execute trade with limit order (entry and exit both) to ensure same returns. Also note that limit orders might not execute always as it depends on how much volume can be filled.
So it is not as st…
@tusharwagh10
I don't find your code complex, just saying approach is not optimal
Instead of all that data frame, you could simple create map of instrument token and trading symbol in the beginning of the program. Don't keep all instruments, just t…