Skip to content

Instantly share code, notes, and snippets.

View mrzechonek's full-sized avatar

Michał 'Khorne' Lowas-Rzechonek mrzechonek

View GitHub Profile
@mrzechonek
mrzechonek / svn2git.sh
Last active August 29, 2016 15:41
svn2git.sh
#!/bin/bash
if [ ! -d "$1" ]; then
echo "Please provide a single command to the repository"
echo "Subversion upstream should be cloned with:"
echo " git svn clone --prefix=svn/ -s <url>"
echo "Git upstream should be added with:"
echo " git remote add origin <url>"
exit 1
fi
@mrzechonek
mrzechonek / labirynth.py
Created April 26, 2015 18:28
Dijkstra's shortest path
class Tile:
def __init__(self, passable=False):
self.passable = passable
self.steps = float("inf")
def __bool__(self):
return self.passable
def create(f):
#########################
# # # # # # #
# # # # # ## # #### #
# # ### # # #S # # ## # #
# # # #### # # #
# ######### # # #### #
# # # #### # ## # #
# # #### # # # #### #
# # # ##### # # #### #
# ### # ####
# ADD AT THE END OF ~/.bashrc
source ~/.bash/prompt
#!/usr/bin/env python3
from collections import OrderedDict
import enum
import struct
class Field:
def __init__(self, format, type=int):
self.format = format
#!/usr/bin/env python3.4
import pyglet
from vector import Vector
class Entity:
def __init__(self, name, *args, **kwargs):
self.name = name
super().__init__(*args, **kwargs)
#!/usr/bin/env python3
from contextlib import suppress
import itertools
import sys
if __name__ == '__main__':
lhs_file = open(sys.argv[1])
rhs_file = open(sys.argv[2])
@pytest.mark.asyncio
@pytest.mark.django_db
async def test_refresh_existing_cash(zmq_context, event_loop,
update_task, broker_task,
admin_user, test_month):
stocks, sessions, quotes = test_month
portfolio = Portfolio.objects.create(user=admin_user, name='Test Portfolio')
transaction = Transaction.objects.create(portfolio=portfolio, session=sessions[0])
TransactionItemCash.objects.create(transaction=transaction, cash=10000, commission=30)
@pytest.mark.asyncio
@pytest.mark.django_db
async def test_request(zmq_client, feed_task, test_month):
stocks, sessions, quotes = test_month
subscription = zmq_client.subscribe('quotes', 'quote')
reply, count = await zmq_client._async(feed_task.request,
start=datetime(2017, 1, 1),
end=datetime(2017, 1, 3))
@pytest.mark.asyncio
@pytest.mark.indicators(ror_periods=(10, ))
async def test_strategy_momentum_automatic(zmq_client,
update_task, broker_task,
admin_user, stock_data, indicators):
stocks, sessions, quotes = stock_data
strategy = MomentumStrategy.objects.create(automatic=True, period=60, top_stocks=1, ror_period=10)
portfolio = Portfolio.objects.create(user=admin_user, name='Test Portfolio', strategy=strategy)
transaction = Transaction.objects.create(portfolio=portfolio, session=sessions[0])