Computing and managing risk
The final component we still need to build before we can build our trading strategies is RiskManager
. The RiskManager
component tracks the active order quantities that a trading strategy has in the market through the same OrderManager
instance that a trading strategy uses. It also tracks the positions and realized and unrealized PnLs using the PositionKeeper
instance, which tracks the trading strategy’s positions and PnLs. It checks that the strategy stays within its assigned risk limits. If the trading strategy goes past its risk limits, such as if it loses more money than it’s allowed, tries to send an order larger than it’s allowed, or builds a position larger than it’s allowed, it prevents it from trading. To keep our RiskManager
simple, we will only implement risk checks on the maximum allowed order size, the maximum allowed position, and the maximum allowed loss for each trading instrument in the client’s trading...