MLThon Risk Package

Submodules

mlthon.risk.risk_manager module

class RiskManager(max_order_size, max_long_position, max_short_position, max_order_submit_rate, submit_rate_window, max_open_orders_per_side, max_notional_per_side, max_directional_exposure)[source]

Bases: object

static create_risk_manager_from_json(config)[source]
Parameters

config – Json config dict like

Returns

RiskManager object

static create_risk_manager_from_json_file(json_path)[source]
Parameters

json_path – Json path with dict like config parameters

Returns

RiskManager object

is_valid_modify_to_send(exchange_id, symbol, qty, side, price, new_qty, new_price)[source]

Validates if new order added to portfolio exceeds risk metrics :param exchange_id: exchange id :param symbol: symbol of order :param qty: quantity of order :param side: side of order :param price: price of order :param new_qty: new quantity of order :param new_price: new price of order :return: True or False

is_valid_new_order_to_send(exchange_id, symbol, qty, side, price)[source]

Validates if new order added to portfolio exceeds risk metrics :param exchange_id: exchange id :param symbol: symbol of new order :param qty: quantity of new order :param side: side of new order :param price: price of new order :return: True or False

property max_directional_exposure
property max_long_position
property max_notional_per_side
property max_open_orders_per_side
property max_order_size
property max_order_submit_rate
property max_short_position
on_modify_ack(exchange_id, symbol, qty, side, price, new_qty, new_price)[source]

Update risk profile on order execution :param exchange_id: exchange id :param symbol: symbol of new order :param qty: quantity of new order :param side: side of new order :param price: price of new order :param new_qty: new quantity of order :param new_price: new price of order :return: True or False

on_modify_reject(exchange_id, symbol, qty, side, price, new_qty, new_price)[source]

Update risk profile on new order rejection i.e. remove position from risk profile :param exchange_id: exchange id :param symbol: symbol of new order :param qty: quantity of new order :param side: side of new order :param price: price of new order :param new_qty: new quantity of order :param new_price: new price of order :return: True or False

on_new_order_reject(exchange_id, symbol, qty, side, price)[source]

Update risk profile on new order rejection i.e. remove position from risk profile :param exchange_id: exchange id :param symbol: symbol of new order :param qty: quantity of new order :param side: side of new order :param price: price of new order :return: True or False

on_order_cancelled(exchange_id, symbol, qty, side, price)[source]

Update risk profile on order cancellation i.e. remove position from risk profile :param exchange_id: exchange id :param symbol: symbol of new order :param qty: quantity of new order :param side: side of new order :param price: price of new order :return: True or False

on_order_executed(exchange_id, symbol, qty, side, price)[source]

Update risk profile on order execution :param exchange_id: exchange id :param symbol: symbol of new order :param qty: quantity of new order :param side: side of new order :param price: price of new order :return: True or False

property submit_rate_window