|
1 | 1 | <!-- START doctoc generated TOC please keep comment here to allow auto update --> |
2 | | - |
| 2 | +<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> |
3 | 3 | **Table of Contents** *generated with [DocToc](https://github.com/ktechhub/doctoc)* |
4 | 4 |
|
5 | | -<!---toc start--> |
6 | | - |
7 | | -* [ccapi](#ccapi) |
8 | | - * [Branches](#branches) |
9 | | - * [Build](#build) |
10 | | - * [C++](#c) |
11 | | - * [non-C++](#non-c) |
12 | | - * [Constants](#constants) |
13 | | - * [Examples](#examples) |
14 | | - * [Documentations](#documentations) |
15 | | - * [Simple Market Data](#simple-market-data) |
16 | | - * [Advanced Market Data](#advanced-market-data) |
17 | | - * [Complex request parameters](#complex-request-parameters) |
18 | | - * [Specify subscription market depth](#specify-subscription-market-depth) |
19 | | - * [Specify correlation id](#specify-correlation-id) |
20 | | - * [Multiple exchanges and/or instruments](#multiple-exchanges-andor-instruments) |
21 | | - * [Receive subscription events at periodic intervals](#receive-subscription-events-at-periodic-intervals) |
22 | | - * [Receive subscription events at periodic intervals including when the market depth snapshot hasn't changed](#receive-subscription-events-at-periodic-intervals-including-when-the-market-depth-snapshot-hasnt-changed) |
23 | | - * [Receive subscription market depth updates](#receive-subscription-market-depth-updates) |
24 | | - * [Receive subscription trade events](#receive-subscription-trade-events) |
25 | | - * [Receive subscription calculated-candlestick events at periodic intervals](#receive-subscription-calculated-candlestick-events-at-periodic-intervals) |
26 | | - * [Receive subscription exchange-provided-candlestick events at periodic intervals](#receive-subscription-exchange-provided-candlestick-events-at-periodic-intervals) |
27 | | - * [Send generic public requests](#send-generic-public-requests) |
28 | | - * [Make generic public subscriptions](#make-generic-public-subscriptions) |
29 | | - * [Send generic private requests](#send-generic-private-requests) |
30 | | - * [Simple Execution Management](#simple-execution-management) |
31 | | - * [Advanced Execution Management](#advanced-execution-management) |
32 | | - * [Specify correlation id](#specify-correlation-id-1) |
33 | | - * [Multiple exchanges and/or instruments](#multiple-exchanges-andor-instruments-1) |
34 | | - * [Multiple subscription fields](#multiple-subscription-fields) |
35 | | - * [Make Session::sendRequest blocking](#make-sessionsendrequest-blocking) |
36 | | - * [Provide API credentials for an exchange](#provide-api-credentials-for-an-exchange) |
37 | | - * [Override exchange urls](#override-exchange-urls) |
38 | | - * [Complex request parameters](#complex-request-parameters-1) |
39 | | - * [Send request by Websocket API](#send-request-by-websocket-api) |
40 | | - * [Specify instrument type](#specify-instrument-type) |
41 | | - * [FIX API](#fix-api) |
42 | | - * [More Advanced Topics](#more-advanced-topics) |
43 | | - * [Handle events in "immediate" vs. "batching" mode](#handle-events-in-immediate-vs-batching-mode) |
44 | | - * [Thread safety](#thread-safety) |
45 | | - * [Enable library logging](#enable-library-logging) |
46 | | - * [Set timer](#set-timer) |
47 | | - * [Heartbeat](#heartbeat) |
48 | | - * [Performance Tuning](#performance-tuning) |
49 | | - * [Known Issues and Workarounds](#known-issues-and-workarounds) |
50 | | - |
51 | | -<!---toc end--> |
| 5 | +- [ccapi](#ccapi) |
| 6 | + - [Branches](#branches) |
| 7 | + - [Build](#build) |
| 8 | + - [C++](#c) |
| 9 | + - [non-C++](#non-c) |
| 10 | + - [Constants](#constants) |
| 11 | + - [Examples](#examples) |
| 12 | + - [Documentations](#documentations) |
| 13 | + - [Simple Market Data](#simple-market-data) |
| 14 | + - [Advanced Market Data](#advanced-market-data) |
| 15 | + - [Complex request parameters](#complex-request-parameters) |
| 16 | + - [Specify subscription market depth](#specify-subscription-market-depth) |
| 17 | + - [Specify correlation id](#specify-correlation-id) |
| 18 | + - [Multiple exchanges and/or instruments](#multiple-exchanges-andor-instruments) |
| 19 | + - [Receive subscription events at periodic intervals](#receive-subscription-events-at-periodic-intervals) |
| 20 | + - [Receive subscription events at periodic intervals including when the market depth snapshot hasn't changed](#receive-subscription-events-at-periodic-intervals-including-when-the-market-depth-snapshot-hasnt-changed) |
| 21 | + - [Receive subscription market depth updates](#receive-subscription-market-depth-updates) |
| 22 | + - [Receive subscription trade events](#receive-subscription-trade-events) |
| 23 | + - [Receive subscription calculated-candlestick events at periodic intervals](#receive-subscription-calculated-candlestick-events-at-periodic-intervals) |
| 24 | + - [Receive subscription exchange-provided-candlestick events at periodic intervals](#receive-subscription-exchange-provided-candlestick-events-at-periodic-intervals) |
| 25 | + - [Send generic public requests](#send-generic-public-requests) |
| 26 | + - [Make generic public subscriptions](#make-generic-public-subscriptions) |
| 27 | + - [Send generic private requests](#send-generic-private-requests) |
| 28 | + - [Simple Execution Management](#simple-execution-management) |
| 29 | + - [Advanced Execution Management](#advanced-execution-management) |
| 30 | + - [Specify correlation id](#specify-correlation-id-1) |
| 31 | + - [Multiple exchanges and/or instruments](#multiple-exchanges-andor-instruments-1) |
| 32 | + - [Multiple subscription fields](#multiple-subscription-fields) |
| 33 | + - [Make Session::sendRequest blocking](#make-sessionsendrequest-blocking) |
| 34 | + - [Provide API credentials for an exchange](#provide-api-credentials-for-an-exchange) |
| 35 | + - [Override exchange urls](#override-exchange-urls) |
| 36 | + - [Complex request parameters](#complex-request-parameters-1) |
| 37 | + - [Send request by Websocket API](#send-request-by-websocket-api) |
| 38 | + - [Specify instrument type](#specify-instrument-type) |
| 39 | + - [FIX API](#fix-api) |
| 40 | + - [More Advanced Topics](#more-advanced-topics) |
| 41 | + - [Handle events in "immediate" vs. "batching" mode](#handle-events-in-immediate-vs-batching-mode) |
| 42 | + - [Thread safety](#thread-safety) |
| 43 | + - [Enable library logging](#enable-library-logging) |
| 44 | + - [Set timer](#set-timer) |
| 45 | + - [Heartbeat](#heartbeat) |
| 46 | + - [Use multiple sessions](#use-multiple-sessions) |
| 47 | + - [Performance Tuning](#performance-tuning) |
| 48 | + - [Known Issues and Workarounds](#known-issues-and-workarounds) |
52 | 49 |
|
53 | 50 | <!-- END doctoc generated TOC please keep comment here to allow auto update --> |
54 | 51 |
|
@@ -1067,6 +1064,18 @@ Subscription subscription("", "", "HEARTBEAT", "HEARTBEAT_INTERVAL_MILLISECONDS= |
1067 | 1064 | session.subscribe(subscription); |
1068 | 1065 | ``` |
1069 | 1066 |
|
| 1067 | +#### Use multiple sessions |
| 1068 | + |
| 1069 | +[C++](example/src/use_multiple_sessions/main.cpp) |
| 1070 | + |
| 1071 | +Multiple `session` instances, each with their own `SessionOptions` and `SessionConfigs`, can share a common `EventHandler`. If no `EventDispatcher` is provided, thread safety must be maintained by using a shared `ServiceContext`. |
| 1072 | +``` |
| 1073 | +Subscription subscription("", "", "HEARTBEAT", "HEARTBEAT_INTERVAL_MILLISECONDS=1000"); |
| 1074 | +session.subscribe(subscription); |
| 1075 | +``` |
| 1076 | + |
| 1077 | + |
| 1078 | + |
1070 | 1079 | ## Performance Tuning |
1071 | 1080 | * Turn on compiler optimization flags (e.g. `cmake -DCMAKE_BUILD_TYPE=Release ...`). |
1072 | 1081 | * Enable link time optimization (e.g. in CMakeLists.txt `set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)` before a target is created). Note that link time optimization is only applicable to static linking. |
|
0 commit comments