side package

Submodules

side.side module

The side is a collection of limits, whose ordering (by price) depends wether it is a bid or ask side.

class fastlob.side.side.AskSide

Bases: Side

The bid side, where the best price level is the lowest.

apply_snapshot(asks)

Initialize side with predefined volume for price levels.

apply_updates(asks)

Apply price level updates to side.

immediately_matched(order)

Check that a market order (of the opposite side) can be immediately matched. This function is useful when checking that a FOK order is valid.

Return type:

bool

is_market(order)

Check if an order of the opposite side is market.

Return type:

bool

view(n=10)

Get a pretty-printed view of the side.

Return type:

str

class fastlob.side.side.BidSide

Bases: Side

The bid side, where the best price level is the highest.

apply_snapshot(bids)

Initialize side with predefined volume for price levels.

apply_updates(bids)

Apply price level updates to side.

immediately_matched(order)

Check that a market order (of the opposite side) can be immediately matched. This function is useful when checking that a FOK order is valid.

Return type:

bool

is_market(order)

Check if an order of the opposite side is market.

Return type:

bool

view(n=10)

Get a pretty-printed view of the side.

Return type:

str

class fastlob.side.side.Side

Bases: ABC

The Side is a collection of limits, whose ordering (by price) depends wether it is a bid or ask side.

abstractmethod apply_snapshot(snapshot)

Initialize side with predefined volume for price levels.

abstractmethod apply_updates(updates)

Apply price level updates to side.

best()

Get the best limit of the side.

Return type:

Limit

best_limits(n)

Returns a triplet (price, volume, #orders) for the best n price levels.

Return type:

list[tuple[Decimal, Decimal, int]]

cancel_order(order)

Cancel an order sitting in the side.

Return type:

None

check_market_order(order)

Check if a market order is valid.

Return type:

Optional[str]

delete_fakeorder(price)

Delete a fake order at price level price.

empty()

Check if side is empty (does not contain any limit).

Return type:

bool

get_limit(price)

Get the limit sitting at a certain price.

Return type:

Limit

abstractmethod immediately_matched(order)

Check that a market order (of the opposite side) can be immediately matched. This function is useful when checking that a FOK order is valid.

Return type:

bool

abstractmethod is_market(order)

Check if an order of the opposite side is market.

Return type:

bool

limits()

Get all limits (sorted).

Return type:

Sequence

lock()

Returns the side mutex lock.

place(order)

Place an order in the side at its corresponding limit.

Return type:

None

place_fakeorder(order)

Place a fake order in the side.

pop_limit(price)

Delete a limit from the side.

Return type:

None

side()

Get the side of the limit.

Return type:

OrderSide

size()

Get number of limits in the side.

Return type:

int

update_volume(update)

Add update to current side volume.

Return type:

None

abstractmethod view(n)

Get a pretty-printed view of the side.

Return type:

str

volume()

Getter for side volume, that is the sum of the volume of all limits.

Return type:

Decimal

side.utils module

Utility functions for side.

fastlob.side.utils.check_snapshot_pair(pair)

Raise an exception if the pair provided can not be processed as snapshot.

fastlob.side.utils.check_update_pair(pair)

Raise an exception if the pair provided can not be processed as update.

Return type:

None

fastlob.side.utils.todecimal_pair(pair)
Return type:

tuple[Decimal, Decimal]

Module contents

The side is a collection of limits, whose ordering (by price) depends wether it is a bid or ask side.