All Projects → mr-karan → terraform-provider-kite

mr-karan / terraform-provider-kite

Licence: MIT license
Terraform provider for managing long term portfolio with Zerodha Kite

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to terraform-provider-kite

kha-ching
Algotrading strategies for Indian Stock Markets
Stars: ✭ 56 (+166.67%)
Mutual labels:  kite, zerodha
terraform-provider-rediscloud
Terraform Redis Enterprise Cloud Pro Provider: Deploy, update, and manage Redis Enterprise Cloud Pro databases as code through HashiCorp Terraform
Stars: ✭ 24 (+14.29%)
Mutual labels:  terraform-provider
terraform-provider-graylog
Terraform Provider for Graylog
Stars: ✭ 21 (+0%)
Mutual labels:  terraform-provider
terraform-provider-boundary
Manage Boundary's identity-based access controls for resources provisioned with Terraform. This provider is maintained internally by the HashiCorp Boundary team.
Stars: ✭ 87 (+314.29%)
Mutual labels:  terraform-provider
terraform-provider-concourse
A terraform provider for Concourse
Stars: ✭ 49 (+133.33%)
Mutual labels:  terraform-provider
terraform-provider-akamai
Terraform Akamai provider
Stars: ✭ 75 (+257.14%)
Mutual labels:  terraform-provider
terraform-provider-vra
Terraform VMware vRealize Automation provider
Stars: ✭ 82 (+290.48%)
Mutual labels:  terraform-provider
terraform-provider-nexus
Terraform provider for Sonatype Nexus
Stars: ✭ 74 (+252.38%)
Mutual labels:  terraform-provider
terraform-provider-opc
Terraform Oracle Public Cloud provider
Stars: ✭ 29 (+38.1%)
Mutual labels:  terraform-provider
terraform-provider-akamai
An Akamai GTM Terraform provider
Stars: ✭ 14 (-33.33%)
Mutual labels:  terraform-provider
terraform-provider-auth0
Please see https://github.com/alexkappa/terraform-provider-auth0
Stars: ✭ 28 (+33.33%)
Mutual labels:  terraform-provider
terraform-provider-k8s
Kubernetes Terraform provider with support for raw manifests
Stars: ✭ 99 (+371.43%)
Mutual labels:  terraform-provider
terraform-provider-phpipam
Terrform provider for PHPIPAM
Stars: ✭ 45 (+114.29%)
Mutual labels:  terraform-provider
terraform-provider-cloudhealth
Terraform provider for Cloudhealth
Stars: ✭ 14 (-33.33%)
Mutual labels:  terraform-provider
terraform-provider-signalfx
Terraform SignalFx provider
Stars: ✭ 26 (+23.81%)
Mutual labels:  terraform-provider
terraform-provider-civo
Terraform Civo provider
Stars: ✭ 54 (+157.14%)
Mutual labels:  terraform-provider
terraform-provider-servicenow
Terraform provider to manage ServiceNow objects.
Stars: ✭ 25 (+19.05%)
Mutual labels:  terraform-provider
terraform-provider-gotemplate
a custom terraform provider to use go text/template language instead of terraform's
Stars: ✭ 20 (-4.76%)
Mutual labels:  terraform-provider
terraform-provider-qingcloud
Terraform QingCloud Provider
Stars: ✭ 34 (+61.9%)
Mutual labels:  terraform-provider
terraform-provider-ignition
Terraform Ignition provider
Stars: ✭ 37 (+76.19%)
Mutual labels:  terraform-provider

Terraform Provider Kite

Terraform plugin for managing stock portfolio with Zerodha Kite

asciicast

Why

This provider lets you declaratively manage your long term holdings with Terraform and Zerodha Kite API. You can model your entire portfolio as Terraform "resource" blocks and let it handle all the future updates to your portfolio. With Terraform you get to see how your portfolio evolved over time with point-in-time snapshots of your portfolio, you can do multiple changes to your portfolio with one click, you can easily extend it to make your own SIP scheduler with a simple cron job - Possibilities are endless.

Seriously why?

Well, honestly this is a fun project aimed at learning to build a Terraform Plugin. The Plugin SDK architecture is quite nice and I wanted to dig in some internals of how Terraform Provider works. This project helped me achieve that goal.

Installing

Download the latest binary from Releases and place it on your machine at $PLUGIN_DIRECTORY/$SOURCEHOSTNAME/$SOURCENAMESPACE/$NAME/$VERSION/$OS_$ARCH/. Follow the instructions to install Third-party Providers if you get stuck.

# Follow the steps if you are on Linux
cd /tmp
curl -sL https://github.com/mr-karan/terraform-provider-kite/releases/tag/v0.1.0 | tar xz
mv terraform-provider-kite ~/.terraform.d/plugins/mrkaran.dev/github/kite/0.1/linux_amd64/

You can view examples/versions.tf for the sample provider configuration.

Example Usage

# Buy 30 stocks of NSE:CASTROLIND
resource "kite_holding" "castrol" {
  tradingsymbol = "CASTROLIND"
  quantity      = 30
  exchange      = "NSE"
}

# Show the order id.
output "castrol_order_id" {
  value = kite_holding.castrol.order_id
}

Argument Reference

The following arguments are supported:

  • tradingsymbol - (Required, string) Tradingsymbol of the instrument.
  • quantity - (Required, int) Quantity to transact.
  • exchange - (Optional, string) Name of the exchange. Must be one of "NSE","BSE". Defaults to "BSE".

Attributes Reference

The following attributes are exported:

  • quantity - (int) Quantity held by the user. Includes the quantity in postion and holdings.
  • order_id - (string) Unique order ID.

Import

It is possible to import your existing holdings via terraform import command. This helps you to make your existing state file aware about the holdings bought without Terraform.

For eg, to import INFY from your holdings:

terraform import kite_holding.infy INFY

Configuring Provider

The provider requires the following environment variables to authenticate with Kite API:

  • KITE_API_KEY=<>
  • KITE_API_SECRET=<>
  • KITE_API_REQUEST_TOKEN=<>

You can generate these credentials using Kite Developer Console. To get KITE_API_REQUEST_TOKEN you need to visit the public Kite login endpoint at https://kite.zerodha.com/connect/login?v=3&api_key=xxx. You will get request_token as a URL parameter to the redirect URL registered for your app. This is a one time token and will expire after first succesful login attempt.

Please read point 3) in Warnings and Caveats section to know how the access token is persisted across multiple runs of terraform.

To initialise the provider:

provider "kite" {
}

Warnings and Caveats

  1. The author of this program is currently employed by Zerodha but this software isn't associated with Zerodha in any manner. This is a completely open and FOSS project.

  2. If you use this program and lose money, don't blame me. This software comes with absolutely no guarantees.

  3. Due to Indian Exchange regulations and guidelines the user(s) are expected to login to the trading platform every day before placing trades. To comply with that, the login cannot be automated. Since Terraform needs to call Kite API to get the latest state and modify the state, any kind of API call needs an access token. It is not possible to persist the Access Token across Terraform runs so this program persists it on the user's local path .tf-kite-secret. Future versions of this program will make the path to this file as a provider config. You are expected to keep this file private and not keep this open to shared environments. To repeat point 2), if you lose money while using/due to this program, don't blame me.

Develop

Test sample configuration

First, build and install the provider.

$ make install

Then, navigate to the examples directory.

$ cd examples

Run the following command to initialize the workspace and apply the sample configuration.

$ terraform init && terraform apply

Credits

LICENSE

See LICENSE for more details.

⭐️ Show your support

Give a ⭐️ if this project helped you!

Contributing

This is still an alpha release. For a full list of things to improve, see unchecked items in TODO. Contributions welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].