Skip to content

Instantly share code, notes, and snippets.

View solalatus's full-sized avatar

Levente Szabados solalatus

View GitHub Profile
@solalatus
solalatus / fuzzy_date_detector.py
Created July 16, 2016 12:33
Dateparser based detctor for all dates in a string - untested
import dateparser
def detect_date(line=""):
"""Detect multiple, multi language date and datetime entries in a given string.
@param type: String to detect occuring_dates in, ideally a single line.
@type type: String
@return: Returns the list of found DateTime objects or None
@rtype: List or None
"""
def plot_digits(data):
fig, axes = plt.subplots(10, 10, figsize=(10, 10),
subplot_kw={'xticks':[], 'yticks':[]},
gridspec_kw=dict(hspace=0.1, wspace=0.1))
for i, ax in enumerate(axes.flat):
ax.imshow(data[i],
cmap='binary', interpolation='nearest',
clim=(0, 16))
plt.show()
class ABC():
def __init__(my_parameter):
self.my_object_variable = my_parameter
def whatever_shit():
print(self.my_object_variable)
import _thread
import ...whatever the orderbook needs to be..
def multi_order_sumit(thread_num):
print("This is thread",thread_num)
LOB = instance of an orderbook please ()
for i in range(1000):
result = LOB.submit_order( some test cases with incermentally groving price or such...) #or whatever it is callled
return whatever we ecpect result to be
# -*- coding: utf-8 -*-
import threading
import time
#import queue
#import logging
from unittest import TestCase
from HFTOrderbook.lob import LimitOrderBook, Order
my_dict={"key1":(1,2,13141), "key2":(1,2,4354365462)}
for k,v in my_dict.items():
tmp = my_dict[k]
tmp = (tmp[0],tmp[1],"owerwritten")
my_dict[k]=tmp
print(my_dict)
assert my_dict["key1"]==my_dict["key2"]
my_dict={"key1":13,"key2":14}
assert type(my_dict) == type({})
print(my_dict.keys())
print(my_dict.values())
print(my_dict.items())
for i in my_dict.items():
print(i)
import pandas as pd
from sqlalchemy import create_engine
...
engine = create_engine('postgresql://'+user+':'+password+'@'+host+':'+port+'/'+dbname,echo=False)
df_orderbook = pd.read_sql_query('select * from "public_orderbook"',con=engine)
Fltered by area and by contractid.
Unsorted is sorted only by created_at, "sorted" is sorted by revisionNo.
Unsorted: Sorted:
469 469
470 470
471 471
472 472
473 473
from orderbook import OrderBook
contract_ids = [111,2222,3333,4444]#df...contractId.unique()
orderbooks={}
for contract_id in contract_ids:
orderbooks[contract_id]=OrderBook()