-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathindex.html
125 lines (123 loc) · 5.05 KB
/
index.html
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="ROBOTS" content="INDEX, FOLLOW" />
<meta name="VIEWPORT" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://saxobank.github.io/openapi-samples-js/assets/css/style.css">
<link rel="shortcut icon" type="image/x-icon" href="https://saxobank.github.io/openapi-samples-js/favicon.ico">
<script type="text/javascript" src="../../assets/js/boilerplate.js" defer></script>
<script type="text/javascript" src="demo.js" defer></script>
<title>Demo for Monitoring the Order Events</title>
<style type="text/css" media="screen">
div.input-field {
width: 30%;
display: inline-block;
}
</style>
</head>
<body>
<section class="page-header">
<h1 class="project-name">Monitor Orders and Positions</h1>
<h2 class="project-tagline">Subscribe to Order and Position Events</h2>
<a href="https://saxobank.github.io/openapi-samples-js" class="btn">← Back to main page</a>
<a href="https://github.com/SaxoBank/openapi-samples-js/tree/main/websockets/order-events-monitoring" class="btn">View on GitHub</a>
</section>
<section class="main-content">
<div class="highlight">
<label><span>Add token <a href="https://www.developer.saxo/openapi/token" target="_blank" id="idHrefRetrieveToken">from here</a> to the box below:</span><br />
<input type="text" class="token-field" id="idBearerToken" value="" placeholder="Paste token here.." autofocus /></label>
<input type="button" class="action-button" value="Validate" id="idBtnValidate" /><br />
<label>
Account: <select class="selector" id="idCbxAccount">
<option value="-">Click Validate to populate</option>
</select>
</label>
</div>
<h1>Monitor order, positions and balance updates</h1>
This example shows how to setup real time monitoring for order events and position changes using websockets.
<p class="note">Be aware that ENS-events from partial fills might be received in a different order, due to the nature of the distributed system.</p>
<input type="button" class="action-button" value="Create websocket connection" id="idBtnCreateConnection" />
<input type="button" class="action-button" value="Start listener" id="idBtnStartListener" />
<br /><br />
<div>
<div class="input-field">ENS request arguments:<br />
<textarea class="json-input" id="idEnsRequestObject" rows="10" wrap="off">
{
"ContextId": "(added on first request)",
"ReferenceId": "MyEnsEvent",
"Arguments": {
"AccountKey": "(added on first request)",
"Activities": [
"AccountDepreciation",
"AccountFundings",
"CorporateActions",
"MarginCalls",
"Orders",
"PositionDepreciation",
"Positions"
],
"FromDateTime": "",
"FieldGroups": [
"DisplayAndFormat",
"ExchangeInfo"
]
}
}
</textarea>
<input type="button" class="action-button" value="Subscribe to events from ENS" id="idBtnSubscribeEns" />
</div>
<div class="input-field">Balance request arguments:<br />
<textarea class="json-input" id="idBalancesRequestObject" rows="10" wrap="off" wrap="off">
{
"ContextId": "(added on first request)",
"ReferenceId": "MyBalanceEvent",
"RefreshRate": 10000,
"Arguments": {
"AccountKey": "(added on first request)",
"ClientKey": "(added on first request)",
"FieldGroups": [
"CalculateCashForTrading",
"MarginOverview"
]
}
}
</textarea>
<input type="button" class="action-button" value="Subscribe to balance changes" id="idBtnSubscribeBalances" />
</div>
<div class="input-field">Position request arguments:<br />
<textarea class="json-input" id="idPositionsRequestObject" rows="10" wrap="off" wrap="off">
{
"ContextId": "(added on first request)",
"ReferenceId": "MyPositionEvent",
"RefreshRate": 60000,
"Arguments": {
"AccountKey": "(added on first request)",
"ClientKey": "(added on first request)",
"FieldGroups": [
"DisplayAndFormat",
"ExchangeInfo",
"Greeks",
"NetPositionBase",
"NetPositionView"
]
}
}
</textarea>
<input type="button" class="action-button" value="Subscribe to position changes" id="idBtnSubscribePositions" />
</div>
</div>
<br />
Place an order with <a href="https://www.saxotrader.com/sim" target="_blank">SaxoTraderGO</a> to see what happens.<br />
<input type="button" class="action-button" value="Switch account" id="idBtnSwitchAccount" />
<input type="button" class="action-button" value="Extend subscription" id="idBtnExtendSubscription" /><br />
<input type="button" class="action-button" value="Unsubscribe" id="idBtnUnsubscribe" />
<input type="button" class="action-button" value="Disconnect" id="idBtnDisconnect" />
<br /><br />
Response: <pre class="highlight" id="idResponse">Click button to launch function.</pre>
<br />
JS code: <pre class="code-block" id="idJavaScript">Click button to show code.</pre>
<footer class="site-footer"><span class="site-footer-credits" id="idFooter"></span></footer>
</section>
</body>
</html>