MLThon Order Book Package

Submodules

mlthon.order.books.book_utils module

create_book_for_exchange(exch)[source]

mlthon.order.books.level module

class Level(id, side, price, qty)[source]

Bases: object

get_id()[source]
get_price()[source]
get_qty()[source]
get_side()[source]
update_qty(new_qty)[source]

mlthon.order.books.level_book module

class LevelBook[source]

Bases: object

add_lvl(id, side, price, qty)[source]

Add level to level book. Bid ask levels are SortedDicts to maintain order of prices. Two levels with same price are not allowed :param id: level id :param side: order side :param price: order price :param qty: order quantity :return:

clear()[source]
delete_lvl(id)[source]

Delete level using level id :param id: level id :return:

get_ask_levels()[source]
get_best_ask_level_with_aggregate_quantity(qty)[source]

Get best ask level at which aggregate quantity is reached :param qty: Aggregate quantity :return:

get_best_ask_lvl()[source]

Get best ask level :return:

get_best_bid_level_with_aggregate_quantity(qty)[source]

Get best bid level at which aggregate quantity is reached :param qty: Aggregate quantity :return:

get_best_bid_lvl()[source]

Get best bid level :return:

get_bid_levels()[source]
get_level(side, px)[source]
get_level_with_id(id)[source]
get_top_five_ask_lvls()[source]

Get best five ask levels. Check if best levels have updated since last time. Used to trigger BBO events :return:

get_top_five_bid_lvls()[source]

Get best five bid levels. Check if best levels have updated since last time. Used to trigger BBO events :return:

modify_lvl_qty(id, new_qty)[source]

Modify quantity of level based on level id :param id: level id :param new_qty: New quantity of level. This will update level in bid ask levels too by reference :return:

try_get_level_with_id(id)[source]

mlthon.order.books.order_book module

class OrderBook[source]

Bases: object

add_order(id, side, px, qty)[source]
clear()[source]
delete_order(id)[source]
get_ask_levels()[source]
get_bid_levels()[source]
get_level(side, px)[source]
modify_order(id, new_qty)[source]

mlthon.order.books.price_level module

class PriceLevel(side, price, qty)[source]

Bases: object

get_price()[source]
get_qty()[source]
get_side()[source]
update_qty(new_qty)[source]

mlthon.order.books.price_level_book module

class PriceLevelBook[source]

Bases: object

add_price_level(side, px, qty)[source]
clear()[source]
delete_price_level(side, px)[source]
get_ask_levels()[source]
get_best_ask_lvl()[source]

Get best ask level :return:

get_best_bid_lvl()[source]

Get best bid level :return:

get_bid_levels()[source]
get_level(side, px)[source]
modify_price_level(side, px, new_qty)[source]