-
Notifications
You must be signed in to change notification settings - Fork 4
/
Mediator.java
36 lines (29 loc) · 1021 Bytes
/
Mediator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package org.algonell.trading.dp.behavioral.mediator;
/**
* Mediator demo: manage portfolio exposure with different instruments.
*
* @author Andrew Kreimer
*/
public class Mediator {
private static final org.apache.logging.log4j.Logger LOGGER =
org.apache.logging.log4j.LogManager.getFormatterLogger(Mediator.class);
private static final String FORMAT = "portfolio exposure: %f";
public static void main(String[] args) {
// exposures manager
var manager = new IbExposureManager();
// add exposures
Exposure exposure = new StocksExposure(manager);
manager.addExposure(exposure);
exposure.add();
LOGGER.info(FORMAT, manager.calculateDelta());
exposure = new FuturesExposure(manager);
manager.addExposure(exposure);
exposure.add();
LOGGER.info(FORMAT, manager.calculateDelta());
// extra exposure
exposure = new FuturesExposure(manager);
manager.addExposure(exposure);
exposure.add();
LOGGER.info(FORMAT, manager.calculateDelta());
}
}