Have been running one currency algo and one commodity algo under quantindia.in platform (now running with kite 3.0). Both algos have passed through backtest, livetest and couple of months of live trading now. The biggest challenge has been not to in…
If Kite is providing m2m for everything, why should it be recalculated (especially if trade volume is high)? Also, Kite's m2m would be the closest to reality and also displayed in kiteweb for all users. So it makes sense to get it directly from api.
few thoughts,
1) Multi-indicator strategies are much less robust than simpler ones. Slippages (both data & price) affect them severely.
2) Observe slippages in actual trades and model it into backtesting. This is the best way to get reasonably …
@zartimus ok I am switching back to beta1 and using cancelOrder() directly instead of exitOrder(). It works. beta2 is continuing to fail in auth.
Please fix this issue properly in your next release.
@zartimus Thanks, but this is throwing exception "'Incorrect `api_key` or `access_token`.'\n\n thrown in kiteconnect.php on line 899"
My code is,
$kite = new KiteConnect($api_key);
$kite->setAccessToken( $key );
$order_id = $kite-&g…
@zartimus I have cut-pasted my code. You can see that order_id is being passed.
Obviously You and I are using different kiteconnect.php files.
To give you more info, I am using kiteconnect.php downloaded from https://github.com/zerodhatech/phpkite…
@sujith Can you please provide the correct equivalent call for the example I have given,
$params = array( "variety" => "co", "order_id" => "180222000270507", "parent_order_id" => "6546" );
$order_id = $kite->exitOrder( $params );
The kiteconnect.php has old documentation, but heading says "Zerodha Technology (c) 2017. Version 3.0.0". Anyone looking to do quick dev will waste a lot of time before realizing that the examples given under "getting started" are invalid.
Please u…
@sujith may be you are referring to individual account margins. The above link points to required margins at a global level. Or am I missing something?
I logged in the morning with v2.
Ok, so I understand it like this - don't login with v2 and again try it with v3. Use v3 for everything. Don't mix up v2 and v3 calls. Is this correct?
The margin info was downloaded in the morning, around 8:50am. I assumed that it would be there. Anyway, this is no longer an issue for us. Please close this.
Found the issue - it is internal; the change in order_type has triggered the MIS logic before it hit the CO part of the code.
Many thanks for the quick answers @sujith !
Did it fire a Cover Order or MIS? The API call I've quoted, has fired a MIS order, not CO. It would be great if you can check for CDS and MCX. Appreciate your help on this.
The order_type was 'CO' all this time & it was working. It broke because now the API expects 'MARKET' instead of 'CO'. And also additional parameters are expected now.
Anyway, good to know that this is not a 'breaking' change and that we will g…
Ok, changed all that and we are back online. Enabled the KC error logging too.
It would be great if you can send out and email to all API subscribers when APIs are updated (posting in the forum is not enough - we don't keep looking at it every day)…
Here are the datetimes of trade API calls,
Repeated 20 attempts have failed and the system has given up.
There has been no change in our system - APIs are called the same way over many months now & were working fine.
Just connect the apps to the same service point in your server and let the server collect & store the tokens in the DB. So when an algo (running in the server) wants to fire orders across many accts, just get the tokens from db and fire the orde…
It is not so difficult to link the strategy/position/order-id, if you take care of linking them together at the time of firing the order. Note that the order API returns the order ID, which can then be associated with the particular position in a pa…
You should make two processes, (1) to stream data into your system and (2) the algo that consumes the data.
For (1), you should be using a RDBMS such as MySQL. Use in-memory data tables if you need it fast. This way, you can have multiple algos run…
@sujith Cover Order is the most attractive option due to high leverage and volatility. If CO can't be reliably used by algo, then it greatly reduces the usability of system across the board. The SL ranges for MCX & CDS are wide enough, but not f…
Yes, we tried some price ranges to test the system behavior. Ok so the logic that the SLP should fall between co_lower and co_upper holds good, right?
If the price movement is high, it is almost impossible to get the SL number right - by the time …
Also, if you use trailing SL, the slippage tends to work against you - by the time your order gets executed, the price would've moved further out in the wrong direction. But if you have fixed Take-Profit, the slippage works in your favor mostly, bec…
Hi @ayush , It is a grey area, whether to get permission for Automated Trading. The very existence of kite API indicates that it may not be mandatory to get SEBI approval for AT. Many other brokers now offer AT APIs. It is worthwhile to search the …
Yes, for a client, socket is a not a good idea. I was more coming from an automated system that monitors the positions & P/L for auto-decisions, especially across several users.
Today we are using the APIs and live ticks to do this, but making …
When the list was refreshed in the evening around 6pm, it worked fine. Now also (9:51pm) it is working fine.
The partial list file is attached. Rename it as .csv before opening.
Usually it has 60,000+ symbols, but today it had only 5,000+ symbols…
Hi @sujith ,
There was no error when the CO was placed. The order got executed also. The SL-M order was pending (since the price hasn't reached). Then the cancelOrder was called on the SL-M order (so that it gets converted to market order). At that …
I know. I have been using kite-web for monitoring. I tried Pi because the position was not getting exited in kite. Yes, the logout/login happened. I am glad that the logout/login process between kite & pi is working without errors. At least some…
Yes @sujith it got resolved after re login. I have mentioned it in our private messages.
I am still stumped about why it worked fine with orders but not trades. It is better to understand the reason for these system behaviors, so that we don't get …
The urgency is that if this call doesn't work by today, I won't be able to get today's trade list at all, since it works only for a day!
Appreciate your quick reply.
Here are my experiences so far with Zerodha on latency & slippage, on CM and Index Options trading,
1) On latency - trades get executed within 10 seconds after my script makes the API call. Sometimes the first attempt fails and the trades goes …
With 200 scripts per socket, we can stream 600 scripts per user. If 3 users pool the data, then we have the capability to stream 1800 scripts! That is quite something.
@naz One possibility would be to use 3 or 4 zerodha accounts to stream data for 1000+ scripts. Basically, if a few like-minded traders co-operate, then everyone can share all that data. It is easy to set it up in a server, where the data streams int…
The same call succeeds after a few tries. There is nothing to get malformed - the URL call is very straightforward.
My guess is that you have some internal timeout mechanism and it returns an error if the data is not there in the server cache. Whe…
Colocation is too expensive for me at this point.
For now I am staggering the orders to workaround this issue. Ideally, I shouldn't be doing this - slippage also increases.
Hope you can increase the limits, at least to 20 trades per second, or buffe…
My backend is MySQL database. I have two streams of getting LTP data (for 300+ scripts in CM and 20+ symbols in FNO), of which python websocket is one. The algo scripts run asynchronously from data sourcing scripts. I am using RAM tables and optimiz…
I am not using threaded=true. I have one separate script for each websocket and run the scripts in parallel. That works fine. Haven't tried multi-threading yet.
Hi @sujith The timeout is 3 minutes in my script. The server does return error long before that. Sometimes I do get timeout (i.e. server doesn't respond for 3 mins), but this is quite rare, may be once in 1000+ calls.
Please check.
@naz The LTP mode is quite reliable - the websocket connection lives through the day. There may be issues with QUOTE and FULL modes. I would suggest that you have multiple sockets, atleast one with LTP.
I assume that the API will return error at 16th order in 1 second, because as per your comment, they won't go through.
I have 7 algos firing orders independently. Many of the initial orders are fired at 9:20am. It is quite possible that more than 1…
@pivottrading.net
You can run an infinite loop in php (say, with a while(1) loop and let it send data request every X seconds. You can access this URL just once in the morning and let it run through the day. The script can check for timelimits and e…
One workaround is to use multiple connections in parallel to download the same data at the same time and manage the duplication at db level. This will partially protect against spurious call failures. This is the strategy I am using to address the d…
Another alternative is to get a static IP from your ISP and setup a webserver in your laptop/desktop. This is easy to do and doesn't incur server costs.
In PHP script, the request_token comes in through $_GET['request_token']. Ideally it should come through an API call, like public_token, access_token, etc.
Hi Sujith, We are are PHP to connect to your server and call PHP from algo script to get the data. The response I posted here is the response from the PHP. Will try to get the KiteException message & code in the PHP and send across to you.
Hi Sujith,
I am talking about utilised.m2m_unrealised and utilised.m2m_realised . It is there in your API documentation. Your API is also returning this field, but always with value 0.
Ok, the correct figures are in data->utilised->debits and not in ...->m2m_realised - please update the documentation or explain how/why.
...and the "net" value is returning NULL always.
Today also it has failed,
INFO : Sending trade to market for DR0886 TCS-EQ, SHORT, MARKET, 29, NSE
INFO : Response : HTTP/1.1 500 Internal Server Error
Date: Tue, 11 Apr 2017 03:52:12 GMT
Server: Microsoft-IIS/10.0
Content-Length: 201
Content-Type…