xts-interactive-api-ip 0.0.0-stage → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +303 -2
- package/examples/config/config.json +6 -0
- package/examples/interactiveTestClient.js +377 -0
- package/lib/config/app/config.json +4 -0
- package/lib/config/app/settings.json +28 -0
- package/lib/customError.js +27 -0
- package/lib/index.js +5 -0
- package/lib/interactiveRestAPI.js +1006 -0
- package/lib/interactiveSocket.js +355 -0
- package/lib/logger.js +125 -0
- package/lib/request.js +80 -0
- package/package.json +41 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 ajitkumar-sft
|
|
4
|
+
Copyright (c) 2026 multyfi
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,304 @@
|
|
|
1
|
-
#
|
|
1
|
+
# xts-interactive-api-ip
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Node.js client for the Symphony Fintech XTS-Interactive-API, with support for binding all REST and socket traffic to a specific local IP address.
|
|
4
|
+
|
|
5
|
+
> This is an unofficial fork of [xts-interactive-api](https://www.npmjs.com/package/xts-interactive-api) ([source](https://github.com/symphonyfintech/xts-interactive-nodeJS-api-v2)), maintained by multyfi. It is not affiliated with or supported by Symphony Fintech. It uses `axios` instead of the deprecated `request` library and requires Node.js 14 or later.
|
|
6
|
+
|
|
7
|
+
API Documentation for XTS-trading API can be found in the below link.
|
|
8
|
+
|
|
9
|
+
https://symphonyfintech.com/xts-trading-front-end-api/
|
|
10
|
+
|
|
11
|
+
The XTS Trading API provides developer, data-scientist, financial analyst and investor the functionality necessary to create automated trading strategies, as well as other trading related applications with support of XTS OEMS hosted by Financial Institutions to trade with Indian electronic exchanges.
|
|
12
|
+
|
|
13
|
+
With the use of the socket.io library, the API has streaming capability and will push data notifications in a JSON format. Your application can place orders and receive real-time trade notification.
|
|
14
|
+
|
|
15
|
+
There is also an examples folder available which illustrates how to create a connection to XTS OEMS hosted by Brokers to subscribe to real-time events.
|
|
16
|
+
Please request for apikeys with Symphony Fintech developer support team to start integrating your application with XTS OEMS.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install xts-interactive-api-ip
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
Access the interactive component of xts-interactive-api-ip like below.
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
var XTSInteractive = require('xts-interactive-api-ip').Interactive;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Creating the instance of xtsInteractive
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
xtsInteractive = new XTSInteractive('https://developers.symphonyfintech.in');
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
call the login API to generate the token
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
var loginRequest = {
|
|
42
|
+
secretKey: 'Abcd@123',
|
|
43
|
+
appKey: '5a75a3616cabe678',
|
|
44
|
+
source: 'WEBAPI',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
let logIn = await xtsInteractive.logIn(loginRequest);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Once the token is generated and userID is retrieved you can call any api provided in the documentation. All API’s are easy to integrate and implemented with async-await mechanism.
|
|
51
|
+
Below is the sample Code snippet which calls the balance API.
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
let balance = await xtsInteractive.getBalance();
|
|
55
|
+
|
|
56
|
+
console.log(balance);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Instantiating the XTSInteractiveWS
|
|
60
|
+
|
|
61
|
+
This component provides functionality to access the socket related events. All real-time events can be registered via XTSInteractiveWS.
|
|
62
|
+
After token is generated, you can access the socket component and instantiate the socket Instance and call the init method of the socket like below
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
var XTSInteractiveWS = require('xts-interactive-api-ip').WS;
|
|
66
|
+
xtsInteractiveWS = new XTSInteractiveWS(
|
|
67
|
+
'https://developers.symphonyfintech.in'
|
|
68
|
+
);
|
|
69
|
+
var socketInitRequest = {
|
|
70
|
+
userID: 'XYZ',
|
|
71
|
+
token: 'ABCDJGJKHK', // Token Generated after successful LogIn
|
|
72
|
+
};
|
|
73
|
+
xtsInteractiveWS.init(socketInitRequest);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
You can now register events to listen to the real time order and trade updates and will be receiving the json objects in the response.
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
var registerEvents = async function () {
|
|
80
|
+
//instantiating the listeners for all event related data
|
|
81
|
+
|
|
82
|
+
//"connect" event listener
|
|
83
|
+
xtsInteractiveWS.onConnect((connectData) => {
|
|
84
|
+
console.log(connectData);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
//"joined" event listener
|
|
88
|
+
xtsInteractiveWS.onJoined((joinedData) => {
|
|
89
|
+
console.log(joinedData);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
//"error" event listener
|
|
93
|
+
xtsInteractiveWS.onError((errorData) => {
|
|
94
|
+
console.log(errorData);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
//"disconnect" event listener
|
|
98
|
+
xtsInteractiveWS.onDisconnect((disconnectData) => {
|
|
99
|
+
console.log(disconnectData);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
//"order" event listener
|
|
103
|
+
xtsInteractiveWS.onOrder((orderData) => {
|
|
104
|
+
console.log(orderData);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
//"trade" event listener
|
|
108
|
+
xtsInteractiveWS.onTrade((tradeData) => {
|
|
109
|
+
console.log(tradeData);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
//"position" event listener
|
|
113
|
+
xtsInteractiveWS.onPosition((positionData) => {
|
|
114
|
+
console.log(positionData);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
//"logout" event listener
|
|
118
|
+
xtsInteractiveWS.onLogout((logoutData) => {
|
|
119
|
+
console.log(logoutData);
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Binding to a local IP
|
|
125
|
+
|
|
126
|
+
If your machine has more than one network interface or IP address (for example, when your broker only accepts orders from a registered static IP), pass that IP as the second constructor argument. All REST calls and the socket connection will then go out through it.
|
|
127
|
+
|
|
128
|
+
```js
|
|
129
|
+
var { Interactive, WS } = require('xts-interactive-api-ip');
|
|
130
|
+
|
|
131
|
+
var localIP = '192.168.1.6'; // an IP address assigned to this machine
|
|
132
|
+
|
|
133
|
+
var xtsInteractive = new Interactive('https://developers.symphonyfintech.in', localIP);
|
|
134
|
+
var xtsInteractiveWS = new WS('https://developers.symphonyfintech.in', localIP);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
The argument is optional. Leave it out and the library uses the system's default interface, the same as `xts-interactive-api`. You can also read or change it later with the `localIP` property.
|
|
138
|
+
|
|
139
|
+
## Detailed explanation of API and socket related events
|
|
140
|
+
|
|
141
|
+
Below is the brief information related to api’s provided by XTS-Interactive-API SDK.
|
|
142
|
+
|
|
143
|
+
## Orders API
|
|
144
|
+
|
|
145
|
+
## placeOrder
|
|
146
|
+
|
|
147
|
+
Calls POST /order.
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
let response = await xtsInteractive.placeOrder({
|
|
151
|
+
exchangeSegment: 'NSECM',
|
|
152
|
+
exchangeInstrumentID: 22,
|
|
153
|
+
productType: 'NRML',
|
|
154
|
+
orderType: 'MARKET',
|
|
155
|
+
orderSide: 'BUY',
|
|
156
|
+
timeInForce: 'DAY',
|
|
157
|
+
disclosedQuantity: 0,
|
|
158
|
+
orderQuantity: 20,
|
|
159
|
+
limitPrice: 1500.0,
|
|
160
|
+
stopPrice: 1600.0,
|
|
161
|
+
orderUniqueIdentifier: '45485',
|
|
162
|
+
clientID: userID,
|
|
163
|
+
};);
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## modifyOrder
|
|
167
|
+
|
|
168
|
+
Calls PUT /order.
|
|
169
|
+
|
|
170
|
+
```js
|
|
171
|
+
let response = await xtsInteractive.modifyOrder({
|
|
172
|
+
appOrderID: 1200037025,
|
|
173
|
+
modifiedProductType: 'CO',
|
|
174
|
+
modifiedOrderType: 'MARKET',
|
|
175
|
+
modifiedOrderQuantity: 100,
|
|
176
|
+
modifiedDisclosedQuantity: 0,
|
|
177
|
+
modifiedLimitPrice: 300,
|
|
178
|
+
modifiedStopPrice: 300,
|
|
179
|
+
modifiedTimeInForce: 'DAY',
|
|
180
|
+
orderUniqueIdentifier: '454845',
|
|
181
|
+
clientID: userID,
|
|
182
|
+
});
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## cancelOrder
|
|
186
|
+
|
|
187
|
+
Calls DELETE /order.
|
|
188
|
+
|
|
189
|
+
```js
|
|
190
|
+
let response = await xtsInteractive.cancelOrder({
|
|
191
|
+
appOrderID: 1828071433,
|
|
192
|
+
orderUniqueIdentifier: 155151,
|
|
193
|
+
});
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## placeCoverOrder
|
|
197
|
+
|
|
198
|
+
Calls POST /order/cover.
|
|
199
|
+
|
|
200
|
+
```js
|
|
201
|
+
let response = await xtsInteractive.placeCoverOrder({
|
|
202
|
+
exchangeSegment: 'NSECM',
|
|
203
|
+
exchangeInstrumentID: 22,
|
|
204
|
+
orderSide: 'Buy',
|
|
205
|
+
orderQuantity: 2,
|
|
206
|
+
disclosedQuantity: 0,
|
|
207
|
+
limitPrice: 2054,
|
|
208
|
+
stopPrice: 2054,
|
|
209
|
+
orderType: 'MARKET',
|
|
210
|
+
orderUniqueIdentifier: '45485',
|
|
211
|
+
clientID: userID,
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## exitCoverOrder
|
|
216
|
+
|
|
217
|
+
Calls PUT /order/cover.
|
|
218
|
+
|
|
219
|
+
```js
|
|
220
|
+
let response = await xtsInteractive.exitCoverOrder({
|
|
221
|
+
appOrderID: '1400070884',
|
|
222
|
+
clientID: userID,
|
|
223
|
+
orderUniqueIdentifier: '454845',
|
|
224
|
+
});
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## getOrderBook
|
|
228
|
+
|
|
229
|
+
calls GET /order
|
|
230
|
+
|
|
231
|
+
```js
|
|
232
|
+
let response = await xtsInteractive.getOrderBook();
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## getTradeBook
|
|
236
|
+
|
|
237
|
+
calls GET /order/trade
|
|
238
|
+
|
|
239
|
+
```js
|
|
240
|
+
let response = await xtsInteractive.getTradeBook();
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Positions API
|
|
244
|
+
|
|
245
|
+
## getPositions
|
|
246
|
+
|
|
247
|
+
calls GET /portfolio/position
|
|
248
|
+
|
|
249
|
+
```js
|
|
250
|
+
let response = await xtsInteractive.getPositions({
|
|
251
|
+
dayOrNet: 'NetWise',
|
|
252
|
+
clientID: userID,
|
|
253
|
+
});
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## positionConversion
|
|
257
|
+
|
|
258
|
+
Calls PUT /portfolio/position/convert
|
|
259
|
+
|
|
260
|
+
```js
|
|
261
|
+
let response = await xtsInteractive.positionConversion({
|
|
262
|
+
exchangeSegment: 'NSECM',
|
|
263
|
+
exchangeInstrumentID: 1922,
|
|
264
|
+
oldProductType: 'MIS',
|
|
265
|
+
newProductType: 'CNC',
|
|
266
|
+
isDayWise: false,
|
|
267
|
+
targetQty: '1',
|
|
268
|
+
clientID: userID,
|
|
269
|
+
});
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Holdings API
|
|
273
|
+
|
|
274
|
+
## getHoldings
|
|
275
|
+
|
|
276
|
+
Calls GET /portfolio/holding
|
|
277
|
+
|
|
278
|
+
```js
|
|
279
|
+
let response = await xtsInteractive.getHoldings();
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Balance API
|
|
283
|
+
|
|
284
|
+
## getBalance
|
|
285
|
+
|
|
286
|
+
Calls GET /users/balance
|
|
287
|
+
|
|
288
|
+
```js
|
|
289
|
+
let response = await xtsInteractive.getBalance();
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Profile API
|
|
293
|
+
|
|
294
|
+
## getProfile
|
|
295
|
+
|
|
296
|
+
Calls GET /users/profile
|
|
297
|
+
|
|
298
|
+
```js
|
|
299
|
+
let response = await xtsInteractive.getProfile();
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
We do have a market data component which will provide the streaming of our real-time streaming market data. For more info please check the following link.
|
|
303
|
+
|
|
304
|
+
https://symphonyfintech.com/xts-market-data-front-end-api/
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
//Accessing the Interactive and WS from xts-interactive-api-ip library
|
|
2
|
+
|
|
3
|
+
var XTSInteractive = require('xts-interactive-api-ip').Interactive;
|
|
4
|
+
var XTSInteractiveWS = require('xts-interactive-api-ip').WS;
|
|
5
|
+
//uncomment line 6 and 7 and comment line 3 and 4 if you directly want to use the code from the example
|
|
6
|
+
//var XTSInteractive = require('../lib/interactiveRestAPI');
|
|
7
|
+
//var XTSInteractiveWS = require('../lib/interactiveSocket');
|
|
8
|
+
var config = require('./config/config.json');
|
|
9
|
+
|
|
10
|
+
let secretKey = config.secretKey;
|
|
11
|
+
let appKey = config.appKey;
|
|
12
|
+
let source = config.source;
|
|
13
|
+
let url = config.url;
|
|
14
|
+
let userID = null;
|
|
15
|
+
|
|
16
|
+
//xtsInteractive for API calls and xtsInteractiveWS for events related functionality
|
|
17
|
+
var xtsInteractive = null;
|
|
18
|
+
var xtsInteractiveWS = null;
|
|
19
|
+
|
|
20
|
+
(async () => {
|
|
21
|
+
//creating the instance of XTSRest
|
|
22
|
+
xtsInteractive = new XTSInteractive(url);
|
|
23
|
+
|
|
24
|
+
//calling the logIn API
|
|
25
|
+
var loginRequest = {
|
|
26
|
+
secretKey,
|
|
27
|
+
appKey,
|
|
28
|
+
source,
|
|
29
|
+
};
|
|
30
|
+
let logIn = await xtsInteractive.logIn(loginRequest);
|
|
31
|
+
|
|
32
|
+
// checking for valid loginRequest
|
|
33
|
+
if (logIn && logIn.type == xtsInteractive.responseTypes.success) {
|
|
34
|
+
//creating the instance of XTSInteractiveWS
|
|
35
|
+
xtsInteractiveWS = new XTSInteractiveWS(url);
|
|
36
|
+
userID = logIn.result.userID;
|
|
37
|
+
|
|
38
|
+
//Instantiating the socket instance
|
|
39
|
+
var socketInitRequest = {
|
|
40
|
+
userID: logIn.result.userID,
|
|
41
|
+
token: logIn.result.token, // Token Generated after successful LogIn
|
|
42
|
+
};
|
|
43
|
+
xtsInteractiveWS.init(socketInitRequest);
|
|
44
|
+
|
|
45
|
+
//Registering the socket Events
|
|
46
|
+
await registerEvents();
|
|
47
|
+
|
|
48
|
+
//calling the remaining methods of the Interactive API
|
|
49
|
+
testAPI();
|
|
50
|
+
} else {
|
|
51
|
+
//In case of failure
|
|
52
|
+
console.error(logIn);
|
|
53
|
+
}
|
|
54
|
+
})();
|
|
55
|
+
|
|
56
|
+
async function testAPI() {
|
|
57
|
+
//calling to get the enums
|
|
58
|
+
let reqObject = {
|
|
59
|
+
userID: userID,
|
|
60
|
+
};
|
|
61
|
+
await getEnums(reqObject);
|
|
62
|
+
|
|
63
|
+
//get user margin details
|
|
64
|
+
reqObject = {
|
|
65
|
+
clientID: userID,
|
|
66
|
+
};
|
|
67
|
+
await getBalance(reqObject);
|
|
68
|
+
|
|
69
|
+
//get uuser profile details
|
|
70
|
+
|
|
71
|
+
reqObject = {
|
|
72
|
+
clientID: userID,
|
|
73
|
+
};
|
|
74
|
+
await getProfile(reqObject);
|
|
75
|
+
|
|
76
|
+
let positionRequest = {
|
|
77
|
+
dayOrNet: 'NetWise',
|
|
78
|
+
clientID: userID,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// get user daywise and net wise position
|
|
82
|
+
await getPositions(positionRequest);
|
|
83
|
+
|
|
84
|
+
//get user holdings
|
|
85
|
+
reqObject = {
|
|
86
|
+
clientID: userID,
|
|
87
|
+
};
|
|
88
|
+
await getHoldings(reqObject);
|
|
89
|
+
|
|
90
|
+
// get user order book details
|
|
91
|
+
await getOrderBook();
|
|
92
|
+
|
|
93
|
+
reqObject = {
|
|
94
|
+
clientID: userID,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
//get user trade book details
|
|
98
|
+
await getTradeBook(reqObject);
|
|
99
|
+
|
|
100
|
+
let placeOrderRequest = {
|
|
101
|
+
exchangeSegment: 'NSECM',
|
|
102
|
+
exchangeInstrumentID: 22,
|
|
103
|
+
productType: 'NRML',
|
|
104
|
+
orderType: 'MARKET',
|
|
105
|
+
orderSide: 'BUY',
|
|
106
|
+
timeInForce: 'DAY',
|
|
107
|
+
disclosedQuantity: 0,
|
|
108
|
+
orderQuantity: 20,
|
|
109
|
+
limitPrice: 1500.0,
|
|
110
|
+
stopPrice: 1600.0,
|
|
111
|
+
orderUniqueIdentifier: '45485',
|
|
112
|
+
clientID: userID,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
//place order
|
|
116
|
+
await placeOrder(placeOrderRequest);
|
|
117
|
+
|
|
118
|
+
let modifyOrderRequest = {
|
|
119
|
+
appOrderID: 1200037025,
|
|
120
|
+
modifiedProductType: 'CO',
|
|
121
|
+
modifiedOrderType: 'MARKET',
|
|
122
|
+
modifiedOrderQuantity: 100,
|
|
123
|
+
modifiedDisclosedQuantity: 0,
|
|
124
|
+
modifiedLimitPrice: 300,
|
|
125
|
+
modifiedStopPrice: 300,
|
|
126
|
+
modifiedTimeInForce: 'DAY',
|
|
127
|
+
orderUniqueIdentifier: '454845',
|
|
128
|
+
clientID: userID,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// modify order
|
|
132
|
+
await modifyOrder(modifyOrderRequest);
|
|
133
|
+
|
|
134
|
+
let cancelOrderRequest = {
|
|
135
|
+
appOrderID: 1828071433,
|
|
136
|
+
orderUniqueIdentifier: 155151,
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// cancel order
|
|
140
|
+
await cancelOrder(cancelOrderRequest);
|
|
141
|
+
|
|
142
|
+
let placeCoverOrderRequest = {
|
|
143
|
+
exchangeSegment: 'NSECM',
|
|
144
|
+
exchangeInstrumentID: 22,
|
|
145
|
+
orderSide: 'Buy',
|
|
146
|
+
orderQuantity: 2,
|
|
147
|
+
disclosedQuantity: 0,
|
|
148
|
+
limitPrice: 2054,
|
|
149
|
+
stopPrice: 2054,
|
|
150
|
+
orderType: 'MARKET',
|
|
151
|
+
orderUniqueIdentifier: '45485',
|
|
152
|
+
clientID: userID,
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
//place cover order
|
|
156
|
+
await placeCoverOrder(placeCoverOrderRequest);
|
|
157
|
+
|
|
158
|
+
let exitCoverOrderRequest = {
|
|
159
|
+
appOrderID: '1400070884',
|
|
160
|
+
clientID: userID,
|
|
161
|
+
orderUniqueIdentifier: '454845',
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
//exit cover order
|
|
165
|
+
await exitCoverOrder(exitCoverOrderRequest);
|
|
166
|
+
|
|
167
|
+
let positionConversionRequest = {
|
|
168
|
+
exchangeSegment: 'NSECM',
|
|
169
|
+
exchangeInstrumentID: 1922,
|
|
170
|
+
oldProductType: 'MIS',
|
|
171
|
+
newProductType: 'CNC',
|
|
172
|
+
isDayWise: false,
|
|
173
|
+
targetQty: '1',
|
|
174
|
+
clientID: userID,
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// position conversion
|
|
178
|
+
await positionConversion(positionConversionRequest);
|
|
179
|
+
|
|
180
|
+
let bracketOrderRequest = {
|
|
181
|
+
orderSide: 'BUY',
|
|
182
|
+
disclosedQuantity: 0,
|
|
183
|
+
exchangeSegment: 'NSECM',
|
|
184
|
+
exchangeInstrumentID: 22,
|
|
185
|
+
limitPrice: 1665.9,
|
|
186
|
+
orderType: 'MARKET',
|
|
187
|
+
orderQuantity: 1,
|
|
188
|
+
squarOff: '1',
|
|
189
|
+
stopLossPrice: 1,
|
|
190
|
+
trailingStoploss: 0,
|
|
191
|
+
};
|
|
192
|
+
//bracketOrder
|
|
193
|
+
await bracketOrder(bracketOrderRequest);
|
|
194
|
+
|
|
195
|
+
let modifyBracketOrderRequest = {
|
|
196
|
+
appOrderID: 2500070878,
|
|
197
|
+
limitPrice: 1396.4,
|
|
198
|
+
orderQuantity: 12,
|
|
199
|
+
stopLossPrice: 365.5,
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// modifyBracketOrder
|
|
203
|
+
await modifyBracketOrder(modifyBracketOrderRequest);
|
|
204
|
+
|
|
205
|
+
let deleteBracketOrderRequest = {
|
|
206
|
+
boEntryOrderId: 2500070879,
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
//cancelBracketOrder
|
|
210
|
+
await cancelBracketOrder(deleteBracketOrderRequest);
|
|
211
|
+
|
|
212
|
+
//exchange message
|
|
213
|
+
let exchangeMessageRequest = {
|
|
214
|
+
exchangeSegment: 'NSECM',
|
|
215
|
+
};
|
|
216
|
+
await exchangeMessage(exchangeMessageRequest);
|
|
217
|
+
|
|
218
|
+
let exchangeStatusRequest = {
|
|
219
|
+
userID: userID,
|
|
220
|
+
};
|
|
221
|
+
//exchange status
|
|
222
|
+
await exchangeStatus(exchangeStatusRequest);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
var getEnums = async function (reqObject) {
|
|
226
|
+
let response = await xtsInteractive.getEnums(reqObject);
|
|
227
|
+
console.log(response);
|
|
228
|
+
return response;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
var getBalance = async function (reqObject) {
|
|
232
|
+
let response = await xtsInteractive.getBalance();
|
|
233
|
+
console.log(response);
|
|
234
|
+
return response;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
var getProfile = async function (reqObject) {
|
|
238
|
+
let response = await xtsInteractive.getProfile(reqObject);
|
|
239
|
+
console.log(response);
|
|
240
|
+
return response;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
var getPositions = async function (positionRequest) {
|
|
244
|
+
let response = await xtsInteractive.getPositions(positionRequest);
|
|
245
|
+
console.log(response);
|
|
246
|
+
return response;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
var getHoldings = async function (reqObject) {
|
|
250
|
+
let response = await xtsInteractive.getHoldings(reqObject);
|
|
251
|
+
console.log(response);
|
|
252
|
+
return response;
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
var getOrderBook = async function () {
|
|
256
|
+
let response = await xtsInteractive.getOrderBook();
|
|
257
|
+
console.log(response);
|
|
258
|
+
return response;
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
var bracketOrder = async function (reqObject) {
|
|
262
|
+
let response = await xtsInteractive.bracketOrder(reqObject);
|
|
263
|
+
console.log(response);
|
|
264
|
+
return response;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
var cancelBracketOrder = async function (reqObject) {
|
|
268
|
+
let response = await xtsInteractive.cancelBracketOrder(reqObject);
|
|
269
|
+
console.log(response);
|
|
270
|
+
return response;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
var modifyBracketOrder = async function (reqObject) {
|
|
274
|
+
let response = await xtsInteractive.modifyBracketOrder(reqObject);
|
|
275
|
+
console.log(response);
|
|
276
|
+
return response;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
var getTradeBook = async function (reqObject) {
|
|
280
|
+
let response = await xtsInteractive.getTradeBook();
|
|
281
|
+
console.log(response);
|
|
282
|
+
return response;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
var placeOrder = async function (placeOrderRequest) {
|
|
286
|
+
let response = await xtsInteractive.placeOrder(placeOrderRequest);
|
|
287
|
+
console.log(response);
|
|
288
|
+
return response;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
var modifyOrder = async function (modifyOrderRequest) {
|
|
292
|
+
let response = await xtsInteractive.modifyOrder(modifyOrderRequest);
|
|
293
|
+
console.log(response);
|
|
294
|
+
return response;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
var cancelOrder = async function (cancelOrderRequest) {
|
|
298
|
+
let response = await xtsInteractive.cancelOrder(cancelOrderRequest);
|
|
299
|
+
console.log(response);
|
|
300
|
+
return response;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
var placeCoverOrder = async function (placeCoverOrderRequest) {
|
|
304
|
+
let response = await xtsInteractive.placeCoverOrder(placeCoverOrderRequest);
|
|
305
|
+
console.log(response);
|
|
306
|
+
return response;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
var exitCoverOrder = async function (exitCoverOrderRequest) {
|
|
310
|
+
let response = await xtsInteractive.exitCoverOrder(exitCoverOrderRequest);
|
|
311
|
+
console.log(response);
|
|
312
|
+
return response;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
var positionConversion = async function (positionConversionRequest) {
|
|
316
|
+
let response = await xtsInteractive.positionConversion(
|
|
317
|
+
positionConversionRequest
|
|
318
|
+
);
|
|
319
|
+
console.log(response);
|
|
320
|
+
return response;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
var exchangeMessage = async function (exchangeMessageRequest) {
|
|
324
|
+
let response = await xtsInteractive.exchangeMessage(exchangeMessageRequest);
|
|
325
|
+
console.log(response);
|
|
326
|
+
return response;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
var exchangeStatus = async function (exchangeStatusRequest) {
|
|
330
|
+
let response = await xtsInteractive.exchangeStatus(exchangeStatusRequest);
|
|
331
|
+
console.log(response);
|
|
332
|
+
return response;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
var registerEvents = async function () {
|
|
336
|
+
//instantiating the listeners for all event related data
|
|
337
|
+
|
|
338
|
+
//"connect" event listener
|
|
339
|
+
xtsInteractiveWS.onConnect((connectData) => {
|
|
340
|
+
console.log(connectData);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
//"joined" event listener
|
|
344
|
+
xtsInteractiveWS.onJoined((joinedData) => {
|
|
345
|
+
console.log(joinedData);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
//"error" event listener
|
|
349
|
+
xtsInteractiveWS.onError((errorData) => {
|
|
350
|
+
console.log(errorData);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
//"disconnect" event listener
|
|
354
|
+
xtsInteractiveWS.onDisconnect((disconnectData) => {
|
|
355
|
+
console.log(disconnectData);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
//"order" event listener
|
|
359
|
+
xtsInteractiveWS.onOrder((orderData) => {
|
|
360
|
+
console.log(orderData);
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
//"trade" event listener
|
|
364
|
+
xtsInteractiveWS.onTrade((tradeData) => {
|
|
365
|
+
console.log(tradeData);
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
//"position" event listener
|
|
369
|
+
xtsInteractiveWS.onPosition((positionData) => {
|
|
370
|
+
console.log(positionData);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
//"logout" event listener
|
|
374
|
+
xtsInteractiveWS.onLogout((logoutData) => {
|
|
375
|
+
console.log(logoutData);
|
|
376
|
+
});
|
|
377
|
+
};
|