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
@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 / 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
@rahulmr
rahulmr / add_row.py
Created September 29, 2020 04:34 — forked from pbrumblay/add_row.py
Add row to pandas_ta dataframe and recompute
import pandas as pd
import pandas_ta as ta
from dateutil import parser
df = pd.read_csv('AUD_CAD.csv', sep=',', names=[
'datetime', 'bid_open', 'bid_high', 'bid_low', 'bid_close', 'ask_open', 'ask_high', 'ask_low', 'ask_close', 'mid_open', 'mid_high', 'mid_low', 'mid_close', 'volume'], error_bad_lines=False, parse_dates=['datetime'])
df.ta.atr(append=True, high='bid_high', low='bid_low', close='bid_close')
print(df)
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 14 columns, instead of 1. in line 8.
2020-04-20 21:00:00+00:00,0.89533,0.89664,0.88963,0.89218,0.89733,0.89733,0.88993,0.89287,0.89633,0.89677,0.8898,0.89252,236284
2020-04-21 21:00:00+00:00,0.89215,0.89983,0.89112,0.89502,0.8929,0.90124,0.89136,0.89557,0.89252,0.9005,0.89125,0.8953,177029
2020-04-22 21:00:00+00:00,0.8946,0.90112,0.89169,0.89633,0.89604,0.90164,0.89202,0.89676,0.89532,0.90128,0.89187,0.89654,187587
2020-04-23 21:00:00+00:00,0.89608,0.902,0.89324,0.90008,0.89722,0.9027,0.89365,0.90208,0.89665,0.90225,0.89346,0.90108,149012
2020-04-26 21:00:00+00:00,0.899,0.90973,0.89892,0.90706,0.901,0.91003,0.9009,0.90744,0.9,0.90982,0.89992,0.90725,146455
2020-04-27 21:00:00+00:00,0.90646,0.91077,0.90363,0.90832,0.9077,0.91095,0.90445,0.9088,0.90708,0.91086,0.90426,0.90856,153814
2020-04-28 21:00:00+00:00,0.90823,0.91213,0.90704,0.90972,0.90915,0.91235,0.9075,0.91017,0.90869,0.91222,0.90742,0.90994,130235
2020-04-29 21:00:00+00:00,0.90988,0.9113,0.90253,0.90792,0.91032,0.91162,0.90282,0.90843,0.9101,0.91146,0.90269,0.90818,191082
2020-04-30 21:
@rahulmr
rahulmr / multi_uvicorn.py
Created March 9, 2021 03:16 — forked from tenuki/multi_uvicorn.py
How to run multiple uvicorn server apps in the same process (thanks @a-d-j-i )
##
## How to run multiple uvicorn server apps in the same process
##
import asyncio
from uvicorn import Server, Config
class MyServer(Server):
async def run(self, sockets=None):
self.config.setup_event_loop()
return await self.serve(sockets=sockets)
@rahulmr
rahulmr / automatic-login-kiteconnect.py
Created September 21, 2020 05:24 — forked from GannyS/automatic-login-kiteconnect.py
Kite-connection using plain old requests library in python
# -*- coding: utf-8 -*-
import json
import os
import logmatic
import logging
from logging.config import dictConfig
import requests
from http import HTTPStatus
__author__ = "GannyS"