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 / 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 / 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 / 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 / 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 / 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 / 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 / shell_colors
Created March 30, 2018 06:14
Shell colors
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset
@m-root
m-root / DJANGO_CURD.py
Created March 20, 2018 09:13
Django class CURD
####################### MODELS ##########################
class ModelAuthor(models.Model):
username = models.CharField(max_length=150, null=False, blank=False)
def __str__(self):
return self.username # This gets called for example when you create an user input, the text shown is the returned string
class ModelPost(models.Model):
title = models.CharField(max_length=200)
@m-root
m-root / restricted.py
Created March 20, 2018 09:07
Django provides many ways of implementing this goal, I just used 3 unique and two derive from the basic ones.
from django.contrib.auth.decorators import login_required
from django.shortcuts import render, redirect
from django.views.generic import TemplateView
from django.utils.decorators import method_decorator
from django.conf import settings
from django.contrib.auth.mixins import LoginRequiredMixin
from django.shortcuts import reverse
def restricted_view_manual(request):
@m-root
m-root / quick_tricks.md
Created March 19, 2018 07:06
Django Quick Start