Skip to content

Instantly share code, notes, and snippets.

View vividvilla's full-sized avatar

Vivek R vividvilla

View GitHub Profile
@vividvilla
vividvilla / README.md
Created November 10, 2017 09:31
Kite connect Python ticker save to database example

Instructions

@vividvilla
vividvilla / pykiteconnect_streaming_threaded.py
Last active March 9, 2022 17:54
Test Kite Connect data streaming with threaded Raw
import time
import logging
from kiteconnect import WebSocket
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# Initialise.
kws = WebSocket("api_key", "public_token", "zerodha_user_id")
# RELIANCE BSE and RELIANCE NSE
@vividvilla
vividvilla / kiteconnect_flask.py
Last active May 24, 2023 17:18
Kite Connect Python Flask Example
import json
from flask import Flask, request
from kiteconnect import KiteConnect
# Base settings
PORT = 5010
HOST = "127.0.0.1"
# Kite Connect App settings. Go to https://developers.kite.trade/apps/
# to create an app if you don't have one.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://d3js.org/d3.v4.min.js"></script>
<style id="jsbin-css">
.line {
fill: none;
@vividvilla
vividvilla / mailer.py
Last active August 5, 2022 20:14
Mailer - Simple Python wrapper to send email via SMTP
from smtplib import SMTP # Use this for standard SMTP protocol (port 25, no encryption)
# from smtplib import SMTP_SSL as SMTP # This invokes the secure SMTP protocol (port 465, uses SSL)
from email.mime.text import MIMEText
class Email(object):
SMTP_CONFIG = dict(
server="your_smtp_server_hostname",
username="your_smtp_server_username",
password="your_smtp_server_password"
@vividvilla
vividvilla / json_export_datatables.js
Created July 17, 2017 19:35
Datatable JSON export module for Buttons extension
DataTable.ext.buttons.json = {
bom: false,
className: 'buttons-json buttons-jsonhtml5',
available: function () {
return window.FileReader !== undefined && window.Blob;
},
text: function ( dt ) {
return 'JSON';
},
action: function ( e, dt, button, config ) {
log_format timed_combined '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'$request_time $upstream_response_time $pipe';
@vividvilla
vividvilla / random_string_generator.py
Created March 14, 2017 08:48
Random string generator in Python
import string
import random
def random_string(size):
"""Generate a random string from a given length"""
return "".join(random.SystemRandom()
.choice(string.ascii_lowercase + string.digits) for _ in range(size))
@vividvilla
vividvilla / test_streaming.py
Last active October 16, 2022 12:32
Kite Connect Python client websocket streaming example - https://github.com/rainmattertech/pykiteconnect
import logging
from kiteconnect import WebSocket
logging.basicConfig(filename='ticks.log', level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# Initialise.
kws = WebSocket("api_key", "public_token", "user_id")
tokens = [5215745, 633601, 1195009, 779521, 758529, 1256193, 194561, 1837825, 952577, 1723649, 3930881, 4451329, 593665, 3431425, 2905857, 3771393, 3789569, 3463169, 381697, 54273, 415745, 2933761, 3580417, 49409, 3060993, 4464129, 3375873, 4574465, 636673, 3721473, 2796801]
print("Tokens length", len(tokens))
@vividvilla
vividvilla / git-config.txt
Created March 19, 2015 12:59
Git flow config
[gitflow "branch"]
master = production
develop = develop
[gitflow "prefix"]
feature = feature-
release = release-
hotfix = hotfix-
support = support-
versiontag = v