Skip to content

Instantly share code, notes, and snippets.

View AloftLab's full-sized avatar

TokensQuant AloftLab

  • Europe
View GitHub Profile
@AloftLab
AloftLab / uniswapTheGraph.py
Created December 3, 2020 10:02
Download any data from Uniswap using TheGraph and Python
from python_graphql_client import GraphqlClient
import time
# Start the client with an endpoint.
client = GraphqlClient(endpoint="https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2")
class Calls:
def QueryDB(self, skipnumber):
query = """˛˛
{pairs(first:1000, skip:%s){
id
reserveUSD
@AloftLab
AloftLab / RoundingBinancePython.py
Last active September 6, 2021 11:56
Rounding for Binance
import math
import pandas as pd
import mongo.mongodb as mongo
from binance.client import Client
import json
exchangeName = "binance"
with open('...config.json') as json_file:
config = json.load(json_file)
@AloftLab
AloftLab / WorspressAPi.py
Last active September 7, 2021 08:33
WordPress RestApi python
import requests
import base64
import json
with open('...config.json') as json_file:
pythonapp = json.load(json_file)
url = "https://tokensquant.com/wp-json/wp/v2/posts"
user = "user"
@AloftLab
AloftLab / socketBinance.py
Created September 16, 2021 11:14
Socket Binance
import json
from unicorn_binance_websocket_api.unicorn_binance_websocket_api_manager import BinanceWebSocketApiManager
# channels to record
channels = ['kline_1m']
exchangeName = "binance"
# Pairs you wish to monitor
market = ["ETHUSDT", "BTCUSDT"]
# Connection class for Binance
@AloftLab
AloftLab / GmailPython.py
Created September 20, 2021 07:43
GmailPython
import smtplib, ssl
import json
with open("...//mailDetails.json", 'r') as json_file:
config = json.load(json_file)
port = 465 # For SSL
smtp_server = "smtp.gmail.com"
sender_email = config["username"] # Enter your address
@AloftLab
AloftLab / mongodb.py
Created September 21, 2021 10:20
mongoDB
client_glob = None
class DBConnection:
def login(self):
global client_glob
#client_glob = None
if client_glob is None:
client_glob = pymongo.MongoClient("mongodb://localhost:27017/")
return client_glob
def createDB(self, exchange):
@AloftLab
AloftLab / RSI.py
Created October 8, 2021 10:17
RSI indicator and chart
import yfinance as yf
import talib
import matplotlib.pyplot as plt
# Get symbol OHLC data
data = yf.download("BTC-USD", start="2021-10-06", end="2021-10-07", interval = "1m")
def RSI(data, window=14, adjust=False):
delta = data['Close'].diff(1).dropna()
loss = delta.copy()