zerodha / gokiteconnect Goto Github PK
View Code? Open in Web Editor NEWOfficial Go client for Kite Connect API's
License: MIT License
Official Go client for Kite Connect API's
License: MIT License
https://kite.trade/docs/connect/v3/portfolio/#holdings-authorisation
When we do readEnvelope from gokiteconnect, we over-ride the http error code in our custom error type with exception type. So when 428 status for holdings auth comes, it gets read as InputException and gets returned as BadRequest status code.
ticker.OnOrderUpdate fails to unmarshal order JSON
logs
message type 1
message: {order map[account_id:REMOVED app_id:00000 average_price:0 cancelled_quantity:0 checksum: disclosed_quantity:0 exchange:NSE exchange_order_id: exchange_timestamp: exchange_update_timestamp: filled_quantity:0 guid:10982Xg2D0yM5lJyIG instrument_token:41729 market_protection:0 meta:map[] meta_raw: order_id:200106003187256 order_timestamp:2020-01-06 17:34:22 order_type:LIMIT parent_order_id: pending_quantity:0 placed_by:KITEID price:160.65 product:BO quantity:1 status:REJECTED status_message:BO: auto square off executed status_message_raw:BO: auto square off executed tag:bs tags:[bs] tradingsymbol:APOLLOTYRE transaction_type:BUY trigger_price:0 unfilled_quantity:0 validity:DAY variety:bo]}
error parsing order json: cannot unmarshal object into Go struct field Order.data.meta of type string
error code: zerodhatech/gokiteconnect/ticker/ticker.go
error line: 604 if err := json.Unmarshal(inp, &order); err != nil {}
it was working good previous version. request for hot fix. thanks
Currenly github is handling the switch we made to the organization name but we should update and make a new release. Will have to update the README and go module files.
There is no depth information for any of the tokens subscribed.
{quote 951809 true false 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC 994 27 131528 99456 1161487 0 0 987.4 0 0 0 0 {0 999 1001.35 980.4 995.4} {[{0 0 0} {0 0 0} {0 0 0} {0 0 0} {0 0 0}] [{0 0 0} {0 0 0} {0 0 0} {0 0 0} {0 0 0}]}}
above is the sample for voltas. I have tested for option tokens as well getting zero on them as well.
Currently Ticker websocket checkConnectionAlive logic is based on the timestamp last message (Tick or OrderUpdate) was received.
The major issue with this is that If I only want to get OrderUpdates and have not subscribed for any tick data, the current checkConnectionAlive keeps on closing the connection and marking it for auto connect.
It would be better to change the checkConnectionAlive logic to be based on Ping/Pong message (i.e Client will send ping message on a regular interval and connection alive lease can be reseted once the Pong message is received). I see same is being done in pyKiteConnect too.
Let me know if this is something you find valid and I will raise a PR for same, else Pls correct my understanding.
when i try following I get below response for most of the quotes
quotes, err := s.kiteClient.GetQuote(symbols...)
response:
Error parsing JSON response: invalid character '<' looking for beginning of value
symbols are in format 'NSE:ADANIPOWER' so on...
Request to make
InstrumentToken int json:"instrument_token"
to
InstrumentToken uint32 json:"instrument_token"
The github.com/zerodhatech/gokiteconnect
uses Go modules and the current release version is v3
. And it’s module path is "github.com/zerodhatech/gokiteconnect"
, instead of "github.com/zerodhatech/gokiteconnect/v3"
. It must comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation. Quoting the specification:
A package that has opted in to modules must include the major version in the import path to import any v2+ modules
To preserve import compatibility, the go command requires that modules with major version v2 or later use a module path with that major version as the final element. For example, version v2.0.0 of example.com/m must instead use module path example.com/m/v2.
https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher
GO111MODULE=on, run go get
targeting any version >= v3.0.0 of the zerodhatech/gokiteconnect
:
$ go get github.com/zerodhatech/[email protected]
go: finding github.com/zerodhatech/gokiteconnect v3.0.0
go: finding github.com/zerodhatech/gokiteconnect v3.0.0
go get github.com/zerodhatech/[email protected]: github.com/zerodhatech/[email protected]: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v3
SO anyone using Go modules will not be able to easily use any newer version of zerodhatech/gokiteconnect
.
This would push them back to not being managed by Go modules (instead of incorrectly using Go modules).
Ensure compatibility for downstream module-aware projects and module-unaware projects projects
Patch the go.mod
file to declare the module path as github.com/zerodhatech/gokiteconnect/v3
as per the specs. And adjust all internal imports.
The downstream projects might be negatively affected in their building if they are module-unaware (Go versions older than 1.9.7 and 1.10.3; Or use third-party dependency management tools, such as: Dep, glide,govendor…).
If you don't want to break the above repos. This method can provides better backwards-compatibility.
Release a v2 or higher module through the major subdirectory strategy: Create a new v3 subdirectory
(github.com/zerodhatech/gokiteconnect/v3) and place a new go.mod file in that subdirectory. The module path
must end with /v3
. Copy or move the code into the v3 subdirectory. Update import statements
within the module to also use /v3
(import "github.com/zerodhatech/gokiteconnect/v3/…"). Tag the release with v3.x.y
.
If the standard rule of go modules conflicts with your development mode. Or not intended to be used as a library and does not make any guarantees about the API. So you can’t comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation.
Regardless, since it's against one of the design choices of Go, it'll be a bit of a hack. Instead of go get github.com/zerodhatech/gokiteconnect@version-tag
, module users need to use this following way to get the zerodhatech/gokiteconnect
:
(1) Search for the tag
you want (in browser)
(2) Get the commit hash
for the tag
you want
(3) Run go get github.com/zerodhatech/gokiteconnect@commit-hash
(4) Edit the go.mod file to put a comment about which version you actually used
This will make it difficult for module users to get and upgrade zerodhatech/gokiteconnect
.
[*] You can see who will be affected here: [6 module users, e.g., sp98/mm-analyser, sivamgr/mercury, mridul-sahu/zerodha-trading]
https://github.com/search?q=zerodhatech%2Fgokiteconnect+filename%3Ago.mod&type=Code
You can make a choice to fix DM issues by balancing your own development schedules/mode against the affects on the downstream projects.
For this issue, Solution 2
can maximize your benefits and with minimal impacts to your downstream projects the ecosystem.
I'm using latest go version 1.22.2
while installing with
go get github.com/zerodha/gokiteconnect/v4
getting the below error
'go get' is no longer supported outside a module.
To build and install a command, use 'go install' with a version,
like 'go install example.com/cmd@latest'
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.
with
go install -v github.com/zerodha/gokiteconnect/v4@latest
it give below error
go: downloading github.com/zerodha/gokiteconnect/v4 v4.3.2
go: downloading github.com/gocarina/gocsv v0.0.0-20180809181117-b8c38cb1ba36
go: downloading github.com/google/go-querystring v1.0.0
package github.com/zerodha/gokiteconnect/v4 is not a main package
with go install -x github.com/zerodha/gokiteconnect/v4@latest
get https://proxy.golang.org/github.com/@v/list
get https://proxy.golang.org/github.com/zerodha/gokiteconnect/v4/@v/list
get https://proxy.golang.org/github.com/zerodha/gokiteconnect/@v/list
get https://proxy.golang.org/github.com/zerodha/@v/list
get https://proxy.golang.org/github.com/@v/list: 404 Not Found (0.028s)
get https://proxy.golang.org/github.com/zerodha/gokiteconnect/@v/list: 404 Not Found (0.036s)
get https://proxy.golang.org/github.com/zerodha/gokiteconnect/v4/@v/list: 200 OK (0.037s)
get https://proxy.golang.org/github.com/zerodha/@v/list: 404 Not Found (0.037s)
package github.com/zerodha/gokiteconnect/v4 is not a main package
Right now Ticker.Serve()
doesn't seem to catch any signals/errors and doesn't return anything. We could enhance it to return an error. Maybe something similar along the lines of func (srv *Server) ListenAndServe() error
Even if we don't return any errors right now, it maybe nice to well define the signature and keep it open ended for the future?
I am getting this error when trying to install. Please HELP !
go get: github.com/zerodha/gokiteconnect/v3@none updating to
github.com/zerodha/gokiteconnect/[email protected]: parsing go.mod:
module declares its path as: github.com/zerodhatech/gokiteconnect/v3
but was required as: github.com/zerodha/gokiteconnect/v3
OS: MacOS Big Sur (Version 11.4)
go version: go1.16.4 darwin/amd64
Tried:
go clean -modcache
go mod edit -replace github.com/zerodhatech/gokiteconnect/v3=github.com/zerodha/gokiteconnect/v3
A lot of data is common yet they are separated like two island
Convert Order
object received via WebSocket to json and then convert again to Order
object. It is throwing error as unknown time format
The use case is WebSocket is running in a separate executable and order socket notifications are processed in a separate executable. Both communicate using unix socket.
hey, the go compiler is throwing following data race warning:
WARNING: DATA RACE
Read at 0x00c001f720f8 by goroutine 49:
github.com/zerodha/gokiteconnect/v4/ticker.(*Ticker).checkConnection()
/home/piyush/go/pkg/mod/github.com/zerodha/gokiteconnect/[email protected]/ticker/ticker.go:404 +0xf8
github.com/zerodha/gokiteconnect/v4/ticker.(*Ticker).ServeWithContext.func3()
/home/piyush/go/pkg/mod/github.com/zerodha/gokiteconnect/[email protected]/ticker/ticker.go:328 +0x64
Previous write at 0x00c001f720f8 by goroutine 48:
github.com/zerodha/gokiteconnect/v4/ticker.(*Ticker).readMessage()
/home/piyush/go/pkg/mod/github.com/zerodha/gokiteconnect/[email protected]/ticker/ticker.go:434 +0x168
github.com/zerodha/gokiteconnect/v4/ticker.(*Ticker).ServeWithContext.func2()
/home/piyush/go/pkg/mod/github.com/zerodha/gokiteconnect/[email protected]/ticker/ticker.go:323 +0x64
Ticker-Quote Mode is without Marketdepth and takes 64 bytes on wire
Ticker-Full Mode is with Marketdepth and takes 184 bytes on wire
Please add support for new ticker mode. QuoteWithTopOffer. In this mode, rather than 5 levels of depth, 1 level of depth shall be provided.
Ticker-QuoteWithTopOffer shall provide Best Bid, Besk Ask along with the Quote data. This only needs 20-24 bytes inaddition to Quote mode. 84 bytes(with no padding) - 88 bytes (with padding)
With this feature available for usecases needing only the top bid/asks, application need not to choose subscribing full-depths and help with reducing the network-streaming traffic by 50%
I have to go to the browser and then login into kite for request token then again need to past into code.
Why you not automatic this?
When creating a GTT (Good Till Triggered) order using the gokiteconnect library, the product type is assigned as CNC by default. However, in certain cases like trading in derivative instruments (e.g., NFO - Nifty Futures & Options), CNC product type is not allowed, and the order placement fails with the error message:
GTT for NIFTY2450222500CE was triggered: Order placement failed (Trading in NFO is not allowed using CNC product type). Try placing an order in NRML/MIS.
Proposed Solution:
Add a parameter for specifying the product type when creating a GTT order. If this parameter is left empty or not provided, the default product type can remain as CNC.
Example Usage:
gttParams := kiteconnect.GTTParams{
// Other parameters...
Product: "NRML", // or "MIS" for NFO
}
Additional Information:
Add support for:
https://kite.trade/docs/connect/v3/margins/#basket-margins
Ref #29. This is merged to develop, we can add a unit test for the same before the release.
I've used example code provided in your SDK and replaced api_key
& access_key
with proper credentials. Nodejs SDK is working as expected.
I'm getting this error -
Error: websocket: bad handshake
Reconnect attempt 1 in 2.000000s
Error: websocket: bad handshake
Reconnect attempt 2 in 4.000000s
Error: websocket: bad handshake
Reconnect attempt 3 in 8.000000s
Error: websocket: bad handshake
Reconnect attempt 4 in 16.000000s
Error: websocket: bad handshake
Reconnect attempt 5 in 32.000000s
Error: websocket: bad handshake
Reconnect attempt 6 in 60.000000s
Error: websocket: bad handshake
Reconnect attempt 7 in 60.000000s
Error: websocket: bad handshake
Reconnect attempt 8 in 60.000000s
Error: websocket: bad handshake
Reconnect attempt 9 in 60.000000s
Error: dial tcp: lookup ws.kite.trade: no such host
sahil@5511:~$ go get github.com/zerodha/gokiteconnect/v4
cannot find package "github.com/zerodha/gokiteconnect/v4" in any of:
/usr/local/go/src/github.com/zerodha/gokiteconnect/v4 (from $GOROOT)
/home/sahil/go/src/github.com/zerodha/gokiteconnect/v4 (from $GOPATH)
Kindly please guide me through this problem, same issue faced on Linux and Windows both.
Thanks in advance!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.