-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestTradingSystem.java
75 lines (48 loc) · 1.92 KB
/
TestTradingSystem.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
class TestTradingSystem {
@BeforeAll
public static void setUp() {
TradingSystemRunner runner = new TradingSystemRunner();
runner.buildTestSystem();
EquityMarketDataConnector EMDConnector = EquityMarketDataConnector.getInstance();
EMDConnector.readTxt("OrderBookTest.txt");
}
@Test
void testSystemLinkage() {
EquityTradeBookingService ETBService = EquityTradeBookingService.getInstance();
EquityPositionService EPService = EquityPositionService.getInstance();
System.out.println(String.valueOf(EPService.getData("Book1").getPositions()));
assertEquals(EquityPositionServiceListener.getInstance(),ETBService.getListeners().get(0));
}
@Test
void testPositionService() {
EquityPositionService EPService = EquityPositionService.getInstance();
System.out.println(String.valueOf(EPService.getData("Book1").getPositions()));
assertEquals(200,Math.abs(EPService.getData("Book1").getPositions()));
}
@Test
void testConnector() {
EquityMarketDataConnector EMDConnector = EquityMarketDataConnector.getInstance();
assertEquals(3,EMDConnector.getOrderBooks().size());
}
@Test
void testAlgoExecutionService() {
EquityAlgoExecutionService EAEService = EquityAlgoExecutionService.getInstance();
assertEquals(281.32,EAEService.getData("APPL").getPrice());
assertEquals(200,EAEService.getData("APPL").getQuantity());
}
@Test
void testTradeBookingService() {
EquityTradeBookingService ETBService = EquityTradeBookingService.getInstance();
assertEquals("APPL",ETBService.getData("Book1").getProduct().getTicker());
}
@Test
void testPnLService() {
EquityPnLService EPLService = EquityPnLService.getInstance();
assertEquals(56264.0,Math.abs(EPLService.getData("Book1").getPnl()));
}
}