Skip to content

Instantly share code, notes, and snippets.

View uneasyguy's full-sized avatar

Jeff Bingaman uneasyguy

View GitHub Profile
@uneasyguy
uneasyguy / binance_symbols.py
Created January 7, 2022 21:42
Random gist wrote primarily to kill time, showing how to to get exchange info in a single call, then re-use it to gather whatever random info you need from it. Primary focus here simply on filters because Telegram lol
import requests
class ExchangeInfo:
def __get__( self, *args ):
return self.value
def __set__( self, obj, value=None ):
if value is None:
@uneasyguy
uneasyguy / binance_rounding.py
Last active January 7, 2022 20:24
binance basic rounding example
from math import floor
def get_purchase_quantity( raw_quantity:float, step_size:str ) -> float:
if float( step_size ) % 1 == 0:
return round( raw_quantity / float( step_size ) ) * float( step_size )
return round( raw_quantity, step_size.index( '1' ) - 1 )
def get_sale_quantity( raw_quantity:float, step_size:str ) -> float:
if float( step_size ) % 1 == 0:
def get_binance_pairs(self,**kwargs):
base_currencies = kwargs.get('base_currencies','')
quote_currencies= kwargs.get('quote_currencies','')
input_pairs = None
binance_pairs = list()
def _clean(_input):
return _input.strip().upper()
exchange_info = binance.client.Client(None,None).get_exchange_info()
from time import sleep
from datetime import datetime
from binance.client import Client
from binance.helpers import date_to_milliseconds, interval_to_milliseconds
SECONDS_IN_MINUTE = 60
def _sample_crude_api_limiting(headers, threshold=1190, delay_buffer=5, weight_updates=False, sleep_updates=True, force_sleep=False):
if headers:
from time import sleep
from datetime import datetime
from binance.client import Client
SECONDS_IN_MINUTE = 60
def _sample_crude_api_limiting(headers, threshold=6, delay_buffer=5):
used_api_weight = headers.get('x-mbx-used-weight-1m', 0)
print(f'Used API Weight: {used_api_weight}')
from random import choice
def whisper_sweet_nothings(name):
sweet_nothings = [
"{}, you're a gift to those around you.".format(name),
"I appreciate you {}.".format(name),
"{}, when you say you will do something, I trust you.".format(name),
"{}, your eyes are breathtaking.".format(name),
"{}, you make me want to be the best version of myself.".format(name),
"{}, simply knowing you has made me a better person.".format(name),
from math import floor
from binance.client import Client
def purchase_rounding(step_size,trade_quantity):
if step_size == '1.00000000':
return round(trade_quantity,0)
else:
return round(trade_quantity,step_size.index("1")-1)
from flask import abort, make_response, jsonify
from decimal import Decimal
import random
import string
from time import time
from operator import itemgetter
import hashlib
import hmac
import json
from time import time
import requests
import hashlib
import hmac
import os
test = True
start = time()
api_key = os.getenv("api_key")
import os
for root, dirs, files in os.walk(os.getcwd(), topdown=False):
for name in files:
if name.endswith(".csv") and name[4:7] == "-9-":
new_name = name.replace("-9-","-09-")
old_filepath = os.path.join(root, name)
new_filepath = os.path.join(root, new_name)
command = f'mv {old_filepath} {new_filepath}'
os.system(command)