Skip to content

Instantly share code, notes, and snippets.

View m-root's full-sized avatar
💭
I may be slow to respond.

m-root

💭
I may be slow to respond.
View GitHub Profile
@m-root
m-root / speed.md
Last active March 31, 2018 11:27
Markets Speed Calculator

speed = (arctan(h/b)/90) * (h/b)

Scale

Slow 0 =< speed

High 1 =< speed

@m-root
m-root / iterations.py
Created April 14, 2018 19:27
How to get specific key values from a list with a dictionary in it. I do hope that it helps someone.
sd = [{'id': 'e270648a-d4c3-4c04-8bb8-65fbb304d6c8', 'price': '9060.00000000', 'size': '0.20000000', 'product_id': 'BTC-USD', 'side': 'sell', 'type': 'limit', 'time_in_force': 'GTC', 'post_only': True, 'created_at': '2018-03-22T03:34:41.985706Z', 'fill_fees': '0.0000000000000000', 'filled_size': '0.00000000', 'executed_value': '0.0000000000000000', 'status': 'open', 'settled': False},
{'id': '8c13b41f-2037-4a6a-b7e2-f02e06c3b10e', 'price': '9238.58000000', 'size': '0.50000000', 'product_id': 'BTC-USD', 'side': 'sell', 'type': 'limit', 'time_in_force': 'GTC', 'post_only': True, 'created_at': '2018-03-14T04:03:01.41252Z', 'fill_fees': '0.0000000000000000', 'filled_size': '0.00000000', 'executed_value': '0.0000000000000000', 'status': 'active', 'settled': False},
]
for i in range(len(sd)):
if sd[i].get('price') and sd[i].get('status')=='active':
entryPrice = sd[i].get('price')
entryPrice = float(entryPrice)
if entryPrice > 9100:
fd = sd[i].get('id')
@m-root
m-root / python_time.py
Last active September 20, 2018 14:55
TIME CONVERSIONS WITH DATETIME
import datetime
datetime.datetime.utcnow().strftime('%s.%f')
#1526127635.078271
str(datetime.datetime.utcnow())
#2018-05-12 15:20:35.078341
datetime.strptime(str(datetime.utcnow()),"%Y-%m-%d %H:%M:%S.%f").strftime('%s.%f')
#'1526189163.717260'
@m-root
m-root / minute_countdown.py
Last active May 31, 2018 16:11
top of the minute
endtime = time.time() + 60
while time.time() < endtime:
value = datetime.utcnow().strftime("%S")
entTime = int(value)
print(60 - entTime)
time.sleep(1)
if entTime == 0:
break
############ SAME THING #############
currentTime = datetime.utcnow().strftime("%M")
@m-root
m-root / vsa.py
Last active July 22, 2024 15:16
Volume Spread Analysis
import talib
import statsmodels.api as sm
import pandas as pd
def initialize(context):
context.security = symbol('AAPL')
#set_universe(universe.DollarVolumeUniverse(floor_percentile=98.0,ceiling_percentile=100.0))
def bar_data(OHLC_type, bars_nr):
bar_data_func = (history((bars_nr + 1), '1d', OHLC_type).iloc[0]).astype('float')
@m-root
m-root / gitchange.RM
Created September 17, 2018 06:51
Changing remote git
$ git remote rm origin
$ git remote add origin [email protected]:aplikacjainfo/proj1.git
$ git config master.remote origin
$ git config master.merge refs/heads/master
@m-root
m-root / logger.py
Created August 16, 2019 08:21
Log File Auto Generator
import sys
from logging.handlers import TimedRotatingFileHandler
import logging
import logging.handlers
from datetime import date
from pathlib import Path
def get_project_root() -> Path:
return Path(__file__).parent.parent
d = [
[9, 4, 0, 0],
[0, 6, 0, 0],
[0, 0, 3, 0],
[0, 0, 0, 4]
] # List matrix
f = 0 # initilizing for the matrix columns
g = 3 # The starting point
h = [] # Final Sentence List
import bisect
import itertools
class World:
uid = 0
def __init__(self, nodes, lfunc, **kwargs):
@m-root
m-root / primebit-auth-wrapper.py
Created April 14, 2020 18:12
I really had a difficult time trying to come up with the authentication method for Primebit. I wouldn't want anyone else who is a developer to go through the same challenge. All the best. Happy Trading :-)
'''
I really had a difficult time trying to come up with the authentication method for Primebit. I wouldn't want anyone
else who is a developer to go through the same challenge.
All the best. Happy Trading :-)
'''
from typing import Optional, Dict, Any, List
from requests import Request, Session, Response, request, exceptions
import hmac
import time