Skip to content

Instantly share code, notes, and snippets.

View rahulmr's full-sized avatar
🏠
Working from home

Rahul Raut rahulmr

🏠
Working from home
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rahulmr
rahulmr / influx_schema.sql
Created June 13, 2020 01:35 — forked from bbc4468/influx_schema.sql
Influx DB Schema for OHLC
create database price_history_db
CREATE CONTINUOUS QUERY "cq_1m" ON "price_history_db" BEGIN SELECT MIN(price) as low, MAX(price) as high, FIRST(price) as open, LAST(price) as close, SUM(size) as volume INTO "price_1m" FROM "trade" GROUP BY time(1m), symbol END
CREATE CONTINUOUS QUERY "cq_5m" ON "price_history_db" BEGIN SELECT MIN(low) as low, MAX(high) as high, FIRST(open) as open, LAST(close) as close, SUM(volume) as volume INTO "price_5m" FROM "price_1m" GROUP BY time(5m), symbol END
CREATE CONTINUOUS QUERY "cq_15m" ON "price_history_db" BEGIN SELECT MIN(low) as low, MAX(high) as high, FIRST(open) as open, LAST(close) as close, SUM(volume) as volume INTO "price_15m" FROM "price_5m" GROUP BY time(15m), symbol END
CREATE CONTINUOUS QUERY "cq_1h" ON "price_history_db" BEGIN SELECT MIN(low) as low, MAX(high) as high, FIRST(open) as open, LAST(close) as close, SUM(volume) as volume INTO "price_1h" FROM "price_15m" GROUP BY time(1h), symbol END
CREATE CONTINUOUS QUERY "cq_6h" ON "price_history_db" BEGIN SELECT
@rahulmr
rahulmr / interactive_upstox_api_sample.py
Created July 2, 2020 08:39 — forked from svishi/interactive_upstox_api_sample.py
Python SDK - Sample Code - Interactive API
from upstox_api.api import *
from datetime import datetime
from pprint import pprint
import os, sys
from tempfile import gettempdir
try: input = raw_input
except NameError: pass
u = None
@rahulmr
rahulmr / ssl-check.py
Created July 3, 2020 07:19 — forked from gdamjan/ssl-check.py
Python script to check on SSL certificates
# -*- encoding: utf-8 -*-
# requires a recent enough python with idna support in socket
# pyopenssl, cryptography and idna
from OpenSSL import SSL
from cryptography import x509
from cryptography.x509.oid import NameOID
import idna
from socket import socket
@rahulmr
rahulmr / kitetickersample.html
Created August 27, 2020 10:56 — forked from ajinasokan/kitetickersample.html
Kite Ticker Pure JS Example
<script src="ticker.js"></script>
<script>
var ticker = new KiteTicker({api_key: "api_key", access_token: "access_token"});
ticker.connect();
ticker.on("ticks", onTicks);
ticker.on("connect", subscribe);
function onTicks(ticks) {
@rahulmr
rahulmr / app.py
Created August 27, 2020 11:00 — forked from ajinasokan/app.py
KiteConnect postback example
'''
Hi traders,
Here is a simple generic example for implementing a postback mechanism. You can host this in a remote server or in your local server itself.
Run Locally
===========
1. Install ngrok from https://ngrok.com/
@rahulmr
rahulmr / create-kiteconnect-candlestick-q.py
Created August 27, 2020 12:20 — forked from kiterobo/create-kiteconnect-candlestick-q.py
Implementation of ticks to 1min and 15 mins candles in zerodha kiteconnect using python queues. This code is modified version of the code given in http://ezeetrading.in/Articles/Candles_formation_from_tick_data_zerodha.html. The difference is that in on_ticks functions the only action performed is that the ticks are place in a event queue. This …
################## Ticks to candles in kiteconnect python ####################
# Author : Arun B
# Reference : http://ezeetrading.in/Articles/Candles_formation_from_tick_data_zerodha.html
# Purpose : Convert ticks to candles by putting ticks in a queue. This redues time wasted in on_ticks function
################################################################################
from kiteconnect import KiteTicker
import datetime
from copy import copy
import queue
@rahulmr
rahulmr / create-kiteconnect-candlestick-q.py
Created September 19, 2020 15:58 — forked from oldmonkABA/create-kiteconnect-candlestick-q.py
Implementation of ticks to 1min and 15 mins candles in zerodha kiteconnect using python queues. This code is modified version of the code given in http://ezeetrading.in/Articles/Candles_formation_from_tick_data_zerodha.html. The difference is that in on_ticks functions the only action performed is that the ticks are place in a event queue. This …
################## Ticks to candles in kiteconnect python ####################
# Author : Arun B
# Reference : http://ezeetrading.in/Articles/Candles_formation_from_tick_data_zerodha.html
# Purpose : Convert ticks to candles by putting ticks in a queue. This redues time wasted in on_ticks function
################################################################################
from kiteconnect import KiteTicker
import datetime
from copy import copy
import queue
# -*- coding: utf-8 -*-
import json
import os
import logmatic
import logging
from logging.config import dictConfig
import requests
from http import HTTPStatus
import re
from kiteconnect import KiteConnect
@rahulmr
rahulmr / automatic-login-kiteconnect-selenium.py
Created September 21, 2020 05:24 — forked from oldmonkABA/automatic-login-kiteconnect-selenium.py
This code demonstrates the automatic process of generating access token for kiteconnect using headless firefox browser
#######################################################################
# Author : Arun B
#
# Purpose : Automate the process of generating access token for kiteconnect in python
############################################################################
# For this code to run you have to download geckodriver and put it in /usr/local/bin
from kiteconnect import KiteConnect,KiteTicker
import requests
from selenium import webdriver
from selenium.webdriver.common.by import By