Compare commits
212
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a89b0c964 | ||
|
|
1fba09cf94 | ||
|
|
0baa6b875e | ||
|
|
cdacc2d4d4 | ||
|
|
1433541947 | ||
|
|
1070ca7ace | ||
|
|
56fa27dd7e | ||
|
|
d87b522bc6 | ||
|
|
166cb03782 | ||
|
|
c3786d9d64 | ||
|
|
9080e3124b | ||
|
|
d9c536124a | ||
|
|
7de6b2907e | ||
|
|
75f017e9f8 | ||
|
|
7757ab3ea0 | ||
|
|
3186dd383c | ||
|
|
45f751c9c6 | ||
|
|
e4d3774980 | ||
|
|
eedb3ce05d | ||
|
|
6a7d38c0fd | ||
|
|
31ccbfcd19 | ||
|
|
c2abf90cc4 | ||
|
|
8dc4735248 | ||
|
|
d940d9f11d | ||
|
|
1e0c75c6c7 | ||
|
|
3bb9961af4 | ||
|
|
da8088fd8d | ||
|
|
748a65f671 | ||
|
|
66d80136bd | ||
|
|
81189bb2cc | ||
|
|
e5681a50f2 | ||
|
|
69fe4569e3 | ||
|
|
c7caf66f9c | ||
|
|
14504f4a94 | ||
|
|
5b601a4016 | ||
|
|
45aa75e8bb | ||
|
|
b2471d45b2 | ||
|
|
11e2df8c76 | ||
|
|
cba6852655 | ||
|
|
5eeaedde26 | ||
|
|
b63052dbaa | ||
|
|
29f5bc798e | ||
|
|
04603acbb9 | ||
|
|
bc6890055e | ||
|
|
ea94c09c78 | ||
|
|
e3c3bc78fc | ||
|
|
a11d390dcd | ||
|
|
7c74a961d4 | ||
|
|
5db21ad2ca | ||
|
|
f703dabdfe | ||
|
|
237d3eea4b | ||
|
|
818bdec130 | ||
|
|
d257cf2c77 | ||
|
|
079f46404f | ||
|
|
edcc73e934 | ||
|
|
0c4c2b7231 | ||
|
|
420351c093 | ||
|
|
f69e6b89c5 | ||
|
|
c3e22e4b23 | ||
|
|
3231ffb343 | ||
|
|
8d7f1738cf | ||
|
|
9101214e66 | ||
|
|
c6b2e2f21e | ||
|
|
2eac97c1a9 | ||
|
|
b4b0e10f29 | ||
|
|
38d9db4a90 | ||
|
|
6a679ff78c | ||
|
|
aba3f21020 | ||
|
|
fede19fd11 | ||
|
|
3fa8dbf112 | ||
|
|
77ae4703b3 | ||
|
|
a28bfa1175 | ||
|
|
4e4a48283d | ||
|
|
7a761d00ce | ||
|
|
968be6a99a | ||
|
|
03404eb3f1 | ||
|
|
ff1a970982 | ||
|
|
ed890b4d84 | ||
|
|
e87003cc41 | ||
|
|
bc06037843 | ||
|
|
a502c365e5 | ||
|
|
c4c7cebfc5 | ||
|
|
f18bcd2995 | ||
|
|
a6a1b6ac53 | ||
|
|
fdacd8b543 | ||
|
|
3d1de9a0c7 | ||
|
|
b2b3fa5949 | ||
|
|
86ecf69820 | ||
|
|
8c3da4e43c | ||
|
|
06b955dceb | ||
|
|
e75d15146c | ||
|
|
cb07384c9f | ||
|
|
fc9e502539 | ||
|
|
fcbf3388c0 | ||
|
|
899bea940f | ||
|
|
14b7509607 | ||
|
|
8f537a8fda | ||
|
|
01b9ff6b47 | ||
|
|
2609663d3e | ||
|
|
25668e8df0 | ||
|
|
fd89241611 | ||
|
|
a69118c5d3 | ||
|
|
5accd0e2b4 | ||
|
|
df5ad61cd2 | ||
|
|
4a7674eb29 | ||
|
|
5a458287f4 | ||
|
|
5921f9f6b5 | ||
|
|
4c73a63ae8 | ||
|
|
42b1c921a8 | ||
|
|
fab3334b1e | ||
|
|
7239dd3ade | ||
|
|
dd4c8eb649 | ||
|
|
76a29bdc8a | ||
|
|
06d708f3ea | ||
|
|
e2f70cbc19 | ||
|
|
9d54e47a03 | ||
|
|
5345ba8ff8 | ||
|
|
faccdf581e | ||
|
|
1a64714a54 | ||
|
|
3ba6792a85 | ||
|
|
10e75f30e6 | ||
|
|
20eac19c4f | ||
|
|
8c0765a2c7 | ||
|
|
7a1f88e813 | ||
|
|
3420f14c8a | ||
|
|
9bf05973bd | ||
|
|
86277dfbfe | ||
|
|
4839e464c6 | ||
|
|
dc2ad071a9 | ||
|
|
65e49992f9 | ||
|
|
afbb9ae92d | ||
|
|
ff088142d9 | ||
|
|
93b7cf346b | ||
|
|
cea4d05bc4 | ||
|
|
8ee9b84488 | ||
|
|
e3648f5373 | ||
|
|
facd3a9d81 | ||
|
|
84969cb481 | ||
|
|
6d521e77db | ||
|
|
82c49f8f49 | ||
|
|
e074309da1 | ||
|
|
2d622a5f39 | ||
|
|
d51d20e84c | ||
|
|
2ccdef9dc5 | ||
|
|
42e62a30bf | ||
|
|
0b7208784b | ||
|
|
c233c607fa | ||
|
|
462cb930f7 | ||
|
|
059ccbdab6 | ||
|
|
550a4e8d50 | ||
|
|
99b8221efc | ||
|
|
19e74c30f8 | ||
|
|
26693a4c98 | ||
|
|
d8bdb69a7c | ||
|
|
6d357a74e1 | ||
|
|
73f4e4814c | ||
|
|
312bc4be15 | ||
|
|
a0c3ba449a | ||
|
|
d5a2a7f3f0 | ||
|
|
eda8c94def | ||
|
|
9a8e80e149 | ||
|
|
6a7e3d739d | ||
|
|
e6b8274813 | ||
|
|
9783520c62 | ||
|
|
7e7f0bc37f | ||
|
|
75eaf8c3d4 | ||
|
|
1e8fcd794f | ||
|
|
726329c4bf | ||
|
|
2d01f3f0f4 | ||
|
|
2a595c0fd7 | ||
|
|
5f9866c9e8 | ||
|
|
78f1cf88e0 | ||
|
|
4877436877 | ||
|
|
1b43124756 | ||
|
|
a1feb3fddf | ||
|
|
024328bf8b | ||
|
|
80d7e34bf1 | ||
|
|
8ab69c919b | ||
|
|
99531bcfa0 | ||
|
|
6bd516d4f2 | ||
|
|
1a1d771e1b | ||
|
|
050fcf7c6e | ||
|
|
aadeae3201 | ||
|
|
b72e8aed02 | ||
|
|
0820cc3e9a | ||
|
|
b1ba9a1315 | ||
|
|
39ce4323a1 | ||
|
|
d9fcd290d9 | ||
|
|
05939b02c5 | ||
|
|
aa91638fe4 | ||
|
|
065fc54f73 | ||
|
|
95fb13f58b | ||
|
|
4eb2931cb8 | ||
|
|
5326015a48 | ||
|
|
fcbe319470 | ||
|
|
5ad21c88b2 | ||
|
|
3a9c1d557b | ||
|
|
6fb5b83249 | ||
|
|
95830fafdf | ||
|
|
d68b03bb91 | ||
|
|
e7062ce01e | ||
|
|
932738f98e | ||
|
|
1426b00e83 | ||
|
|
e724409b58 | ||
|
|
9cf828e9a4 | ||
|
|
41408fb609 | ||
|
|
4c21e32838 | ||
|
|
385f3ea402 | ||
|
|
8d6d8cab18 | ||
|
|
01615f824a | ||
|
|
c6779ddc90 | ||
|
|
46eff65435 |
No files matched your search
Vendored
+9
-5
@@ -8,13 +8,15 @@
|
||||
"program": "${workspaceRoot}/build/ninja_debug/server/sparkd",
|
||||
"args": [
|
||||
"run",
|
||||
// "test",
|
||||
// "-a",
|
||||
// "[ilink3]"
|
||||
"test",
|
||||
"-a",
|
||||
"OutrightVanillaOrder"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}/build/ninja_debug/server/",
|
||||
"environment": [],
|
||||
"environment": [
|
||||
{ "name": "TZ", "value": "America/Chicago" }
|
||||
],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
@@ -31,7 +33,9 @@
|
||||
"request": "launch",
|
||||
"program": "/home/bts/spark/build/ninja_debug/server/sparkd",
|
||||
"args": [
|
||||
"run"
|
||||
"test",
|
||||
"-a",
|
||||
"[ilink3]"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/ninja_debug/server/",
|
||||
|
||||
+2
-1
@@ -41,6 +41,7 @@ else ()
|
||||
-Wno-missing-braces -Wno-ignored-qualifiers \
|
||||
--std=c++17 -fdiagnostics-color")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -DNDEBUG -O3")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wno-undef")
|
||||
add_subdirectory(src/server/sparkd)
|
||||
add_subdirectory(src/lib)
|
||||
@@ -55,7 +56,7 @@ else ()
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/web ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/data_files ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/lib/libspark.so ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${EXTERNALS_ROOT}/lib/Release/libOnixS.IceImpactMulticastPriceFeedHandlerCpp.so.3.13.0.0 ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${EXTERNALS_ROOT}/lib/Release/libOnixS.IceImpactMulticastPriceFeedHandlerCpp.so.3.16.0.0 ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND ln ARGS -sf ${EXTERNALS_ROOT}/lib/Release/libACE-5.7.5.so ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND mkdir ARGS -p ${CMAKE_BINARY_DIR}/server/plugins
|
||||
COMMENT "Creating server runtime layout"
|
||||
|
||||
@@ -1,9 +1,22 @@
|
||||
+++
|
||||
+++
|
||||
title = "Release notes"
|
||||
weight = 3
|
||||
sort_by = "weight"
|
||||
insert_anchor_links = "right"
|
||||
+++
|
||||
## 2.16.2
|
||||
### User Visible Change
|
||||
- Synthetic creation dialog has a "fractional" checkbox next to the tick settings. Users may uncheck this box to enter integer tick sizes, so the synthetic security's prices will be displayed without decimals, or fractional units.
|
||||
## 2.16.1
|
||||
### Bug Fixes
|
||||
- OrderBook's algo state parameters (in the panel on the right side) are sorted alphabetically
|
||||
## 2.16.0
|
||||
### Bug Fixes
|
||||
- Solved an issue that could result in incorrect ladder levels
|
||||
- Solved an issue that could lead to incorrect routing of orders in the event of certain MSGW changes
|
||||
### API Changes
|
||||
- Add C# client side API samples for order entry, position monitoring and market data observation
|
||||
|
||||
## 2.15.10
|
||||
### Bug Fixes
|
||||
- Solved an issue that could cause the user interface to fail when playing some alert sounds
|
||||
@@ -715,3 +728,4 @@ insert_anchor_links = "right"
|
||||
- Start, Day and Total PnL columns are painted with a red or green background color based on if the pnl value is negative or positive respectively
|
||||
- Corrected cash per point values, used in pnl calculations, for a number of products
|
||||
- PnL report will now remember any customizations you make to filtering and/or sorting criteria
|
||||
|
||||
+1
-1
Submodule docker/linux updated: 0afd5e92de...6f0dd9324b.
+1
-1
Submodule externals updated: 38945c5f49...2ea5e355a6.
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "2.1.508",
|
||||
"rollForward": "latestMajor"
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,10 @@
|
||||
<GenDir>$(BaseOutputPath)\gen\$(MSBuildProjectName)</GenDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(VCTargetsPath)'==''">
|
||||
<VCTargetsPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets</VCTargetsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(ComputerSpecificConfig)" Condition="Exists($(ComputerSpecificConfig))" />
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,372 +1,370 @@
|
||||
using bts.api;
|
||||
using bts.api.orderman;
|
||||
using bts.collections;
|
||||
using mbts.co2;
|
||||
using mbts.spark.utilities;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.spark;
|
||||
using mbts.ui.utility;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace mbts.spark {
|
||||
partial class MarketViewVM {
|
||||
public class Row : SecurityMDRow, IDisposable, IEquatable<Row>, DIYGrid.IRowVM, DIYGrid.IActionableRowVM {
|
||||
readonly IBus _bus;
|
||||
readonly OrdersModel _orders_model;
|
||||
readonly AnimationManager _animation = new AnimationManager();
|
||||
readonly ObservableCollection<OrderRecordImmutable> _orders = new ObservableCollection<OrderRecordImmutable>();
|
||||
readonly ObservableFilterCollection<OrderRecordImmutable> _working_orders, _working_bids, _working_asks;
|
||||
readonly string _security_text, _security_key_text;
|
||||
readonly Property<double> _bid_price, _ask_price, _last_price, _day_change, _settlement, _session_high, _session_low;
|
||||
readonly Property<bool> _last_price_from_spread;
|
||||
readonly CellProperty<int> _position;
|
||||
readonly CellProperty<uint> _last_size;
|
||||
readonly CellProperty<ulong> _volume;
|
||||
readonly CellProperty<bool> _inside_bids, _inside_asks;
|
||||
readonly CellProperty<int> _working_bid_volume, _working_ask_volume;
|
||||
readonly CellProperty<double> _working_best_bid, _working_best_ask;
|
||||
readonly CellProperty<string> _working_bids_text, _working_asks_text;
|
||||
readonly MyOrderSummarizer _order_summarizer = new MyOrderSummarizer();
|
||||
readonly MDDisplayHelper.SizeFormatter _size_formatter = MDDisplayHelper.get_formatter(MarketSizeDisplay.get_default());
|
||||
Property<uint> _bid_direct_size, _bid_merged_size, _ask_direct_size, _ask_merged_size;
|
||||
double _raw_day_position;
|
||||
string _bid_merged_size_text, _ask_merged_size_text;
|
||||
ulong _bbo_ref, _last_ref;
|
||||
|
||||
public Row(IBus bus, SecurityMD smd, OrdersModel orders_model) : base(smd) {
|
||||
_bus = bus;
|
||||
_orders_model = orders_model;
|
||||
_security_text = smd.security.ToString();
|
||||
_security_key_text = security_key.ToString();
|
||||
string format_price(double price) => security.ContractSpec.format(price);
|
||||
_position = new CellProperty<int>(this, nameof(position), 0);
|
||||
_bid_price = backing(nameof(bid_price), double.NaN);
|
||||
_ask_price = backing(nameof(ask_price), double.NaN);
|
||||
_last_price = backing(nameof(last_price), double.NaN);
|
||||
_last_size = new CellProperty<uint>(this, nameof(last_size), 0);
|
||||
_day_change = backing(nameof(day_change), double.NaN);
|
||||
_session_low = backing(nameof(session_low), double.NaN);
|
||||
_session_high = backing(nameof(session_high), double.NaN);
|
||||
_last_price_from_spread = backing(nameof(last_price_from_spread), false);
|
||||
_settlement = backing(nameof(settlement), double.NaN);
|
||||
_volume = new CellProperty<ulong>(this, nameof(volume), 0);
|
||||
_inside_bids = new CellProperty<bool>(this, nameof(inside_bids));
|
||||
_inside_asks = new CellProperty<bool>(this, nameof(inside_asks));
|
||||
_working_bid_volume = new CellProperty<int>(this, nameof(working_bid_volume));
|
||||
_working_ask_volume = new CellProperty<int>(this, nameof(working_ask_volume));
|
||||
//
|
||||
_bid_direct_size = backing(nameof(bid_direct_size), default(uint));
|
||||
_bid_merged_size = backing(nameof(bid_merged_size), default(uint));
|
||||
_ask_direct_size = backing(nameof(ask_direct_size), default(uint));
|
||||
_ask_merged_size = backing(nameof(ask_merged_size), default(uint));
|
||||
//
|
||||
_working_orders = new ObservableFilterCollection<OrderRecordImmutable>(_orders, o => o.is_active());
|
||||
_working_bids = new ObservableFilterCollection<OrderRecordImmutable>(_working_orders, o => o.Def.Side == Side.Buy);
|
||||
_working_asks = new ObservableFilterCollection<OrderRecordImmutable>(_working_orders, o => o.Def.Side == Side.Sell);
|
||||
_working_best_bid = new CellProperty<double>(this, nameof(working_best_bid), format_price, double.NaN);
|
||||
_working_best_ask = new CellProperty<double>(this, nameof(working_best_ask), format_price, double.NaN);
|
||||
_working_bids_text = new CellProperty<string>(this, nameof(working_bids_text), string.Empty);
|
||||
_working_asks_text = new CellProperty<string>(this, nameof(working_asks_text), string.Empty);
|
||||
//
|
||||
default_command = new DelegateCommand(_show_ladder);
|
||||
bid_price_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.Bid));
|
||||
bid_merged_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.BidMergedSize));
|
||||
bid_direct_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.BidDirectSize));
|
||||
bid_implied_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.BidImpliedSize));
|
||||
working_bids_click = new DelegateCommand(() => _show_order_book(MarketViewView.Columns.WorkingBids));
|
||||
ask_price_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.Ask));
|
||||
ask_merged_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.AskMergedSize));
|
||||
ask_direct_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.AskDirectSize));
|
||||
ask_implied_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.AskImpliedSize));
|
||||
working_asks_click = new DelegateCommand(() => _show_order_book(MarketViewView.Columns.WorkingAsks));
|
||||
_animation.AnimationsChanged += on_animations_changed;
|
||||
void on_animations_changed() => RaisePropertyChanged(nameof(animations));
|
||||
_dispose = Disposable.Create(
|
||||
_orders_model.on_security_root_orders(security.Id).OnDispatcher().Subscribe(_on_orders),
|
||||
_position.OnDispatcher().Subscribe(v => _animation.animate_position(v.newval > v.oldval)),
|
||||
_orders_model.on_security_positions(security.Id).OnDispatcher().Subscribe(t => {
|
||||
if (Set(ref _raw_day_position, t.state.Values.Sum(p => p.Item2.raw_day_pos()), nameof(raw_day_position)))
|
||||
raise_invalidated();
|
||||
}),
|
||||
_inside_bids.OnDispatcher().Subscribe(v => _animation.animate_working_bids_inside(v.newval)),
|
||||
_inside_asks.OnDispatcher().Subscribe(v => _animation.animate_working_asks_inside(v.newval)),
|
||||
_day_change.OnDispatcher().Subscribe(v => _animation.animate_day_change(v.newval > v.oldval)),
|
||||
Disposable.Create(() => _animation.AnimationsChanged -= on_animations_changed)
|
||||
);
|
||||
}
|
||||
|
||||
public event Action invalidated;
|
||||
|
||||
#region Bound Properties
|
||||
public bool inside_bids => _inside_bids.value;
|
||||
public bool inside_asks => _inside_asks.value;
|
||||
public int position => _position.value;
|
||||
public double raw_day_position => _raw_day_position;
|
||||
public double last_price => _last_price.Value;
|
||||
public bool last_price_from_spread => _last_price_from_spread.Value;
|
||||
public uint last_size => _last_size.value;
|
||||
public double bid_price => _bid_price.Value;
|
||||
public uint bid_direct_size => _bid_direct_size.Value;
|
||||
public uint bid_implied_size => _bid_merged_size.Value - _bid_direct_size.Value;
|
||||
public uint bid_merged_size => _bid_merged_size.Value;
|
||||
public string bid_merged_size_text => _bid_merged_size_text ?? (_bid_merged_size_text = _size_formatter(_bid_merged_size.Value, bid_implied_size));
|
||||
public double ask_price => _ask_price.Value;
|
||||
public uint ask_direct_size => _ask_direct_size.Value;
|
||||
public uint ask_implied_size => _ask_merged_size.Value - _ask_direct_size.Value;
|
||||
public uint ask_merged_size => _ask_merged_size.Value;
|
||||
public string ask_merged_size_text => _ask_merged_size_text ?? (_ask_merged_size_text = _size_formatter(_ask_merged_size.Value, ask_implied_size));
|
||||
public ulong volume => _volume.value;
|
||||
public double settlement => _settlement.Value;
|
||||
public double day_change => _day_change.Value;
|
||||
public double session_low => _session_low.Value;
|
||||
public double session_high => _session_high.Value;
|
||||
public int working_bid_volume => _working_bid_volume.value;
|
||||
public int working_ask_volume => _working_ask_volume.value;
|
||||
public string working_bids_text => OrderUtils.order_collection_summary(_order_summarizer.best_working_bid, _order_summarizer.best_working_bid_qty, _order_summarizer.working_bid_qty, security.ContractSpec);
|
||||
public string working_asks_text => OrderUtils.order_collection_summary(_order_summarizer.best_working_ask, _order_summarizer.best_working_ask_qty, _order_summarizer.working_ask_qty, security.ContractSpec);
|
||||
public double working_best_bid => _working_best_bid.value;
|
||||
public double working_best_ask => _working_best_ask.value;
|
||||
// ice props
|
||||
public string market_description => security.market_description();
|
||||
public string cleared_alias => security.cleared_alias();
|
||||
public string product_description => security.product_name();
|
||||
public string hub_alias => security.hub_alias();
|
||||
public string strip_name => security.strip_name();
|
||||
public string mic_code => security.mic_code();
|
||||
// animations
|
||||
public IList<ui.spark.CellAnimation> animations => _animation.get_animations().ToList();
|
||||
using bts.api;
|
||||
using bts.api.orderman;
|
||||
using bts.collections;
|
||||
using mbts.co2;
|
||||
using mbts.spark.utilities;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.spark;
|
||||
using mbts.ui.utility;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace mbts.spark {
|
||||
partial class MarketViewVM {
|
||||
public class Row : SecurityMDRow, IDisposable, IEquatable<Row>, DIYGrid.IRowVM, DIYGrid.IActionableRowVM {
|
||||
readonly IBus _bus;
|
||||
readonly OrdersModel _orders_model;
|
||||
readonly AnimationManager _animation = new AnimationManager();
|
||||
readonly ObservableCollection<OrderRecordImmutable> _orders = new ObservableCollection<OrderRecordImmutable>();
|
||||
readonly ObservableFilterCollection<OrderRecordImmutable> _working_orders, _working_bids, _working_asks;
|
||||
readonly string _security_text, _security_key_text;
|
||||
readonly Property<double> _bid_price, _ask_price, _last_price, _day_change, _settlement, _session_high, _session_low;
|
||||
readonly Property<bool> _last_price_from_spread;
|
||||
readonly CellProperty<int> _position;
|
||||
readonly CellProperty<uint> _last_size;
|
||||
readonly CellProperty<ulong> _volume;
|
||||
readonly CellProperty<bool> _inside_bids, _inside_asks;
|
||||
readonly CellProperty<int> _working_bid_volume, _working_ask_volume;
|
||||
readonly CellProperty<double> _working_best_bid, _working_best_ask;
|
||||
readonly CellProperty<string> _working_bids_text, _working_asks_text;
|
||||
readonly MyOrderSummarizer _order_summarizer = new MyOrderSummarizer();
|
||||
readonly MDDisplayHelper.SizeFormatter _size_formatter = MDDisplayHelper.get_formatter(MarketSizeDisplay.get_default());
|
||||
Property<uint> _bid_direct_size, _bid_merged_size, _ask_direct_size, _ask_merged_size;
|
||||
double _raw_day_position;
|
||||
string _bid_merged_size_text, _ask_merged_size_text;
|
||||
ulong _bbo_ref, _last_ref;
|
||||
|
||||
public Row(IBus bus, SecurityMD smd, OrdersModel orders_model) : base(smd) {
|
||||
_bus = bus;
|
||||
_orders_model = orders_model;
|
||||
_security_text = smd.security.ToString();
|
||||
_security_key_text = security_key.ToString();
|
||||
string format_price(double price) => security.ContractSpec.format(price);
|
||||
_position = new CellProperty<int>(this, nameof(position), 0);
|
||||
_bid_price = backing(nameof(bid_price), double.NaN);
|
||||
_ask_price = backing(nameof(ask_price), double.NaN);
|
||||
_last_price = backing(nameof(last_price), double.NaN);
|
||||
_last_size = new CellProperty<uint>(this, nameof(last_size), 0);
|
||||
_day_change = backing(nameof(day_change), double.NaN);
|
||||
_session_low = backing(nameof(session_low), double.NaN);
|
||||
_session_high = backing(nameof(session_high), double.NaN);
|
||||
_last_price_from_spread = backing(nameof(last_price_from_spread), false);
|
||||
_settlement = backing(nameof(settlement), double.NaN);
|
||||
_volume = new CellProperty<ulong>(this, nameof(volume), 0);
|
||||
_inside_bids = new CellProperty<bool>(this, nameof(inside_bids));
|
||||
_inside_asks = new CellProperty<bool>(this, nameof(inside_asks));
|
||||
_working_bid_volume = new CellProperty<int>(this, nameof(working_bid_volume));
|
||||
_working_ask_volume = new CellProperty<int>(this, nameof(working_ask_volume));
|
||||
//
|
||||
_bid_direct_size = backing(nameof(bid_direct_size), default(uint));
|
||||
_bid_merged_size = backing(nameof(bid_merged_size), default(uint));
|
||||
_ask_direct_size = backing(nameof(ask_direct_size), default(uint));
|
||||
_ask_merged_size = backing(nameof(ask_merged_size), default(uint));
|
||||
//
|
||||
_working_orders = new ObservableFilterCollection<OrderRecordImmutable>(_orders, o => o.is_active());
|
||||
_working_bids = new ObservableFilterCollection<OrderRecordImmutable>(_working_orders, o => o.Def.Side == Side.Buy);
|
||||
_working_asks = new ObservableFilterCollection<OrderRecordImmutable>(_working_orders, o => o.Def.Side == Side.Sell);
|
||||
_working_best_bid = new CellProperty<double>(this, nameof(working_best_bid), format_price, double.NaN);
|
||||
_working_best_ask = new CellProperty<double>(this, nameof(working_best_ask), format_price, double.NaN);
|
||||
_working_bids_text = new CellProperty<string>(this, nameof(working_bids_text), string.Empty);
|
||||
_working_asks_text = new CellProperty<string>(this, nameof(working_asks_text), string.Empty);
|
||||
//
|
||||
default_command = new DelegateCommand(_show_ladder);
|
||||
bid_price_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.Bid));
|
||||
bid_merged_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.BidMergedSize));
|
||||
bid_direct_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.BidDirectSize));
|
||||
bid_implied_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.BidImpliedSize));
|
||||
working_bids_click = new DelegateCommand(() => _show_order_book(MarketViewView.Columns.WorkingBids));
|
||||
ask_price_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.Ask));
|
||||
ask_merged_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.AskMergedSize));
|
||||
ask_direct_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.AskDirectSize));
|
||||
ask_implied_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.AskImpliedSize));
|
||||
working_asks_click = new DelegateCommand(() => _show_order_book(MarketViewView.Columns.WorkingAsks));
|
||||
_animation.AnimationsChanged += on_animations_changed;
|
||||
void on_animations_changed() => RaisePropertyChanged(nameof(animations));
|
||||
_dispose = Disposable.Create(
|
||||
_orders_model.on_security_root_orders(security.Id).OnDispatcher().Subscribe(_on_orders),
|
||||
_position.OnDispatcher().Subscribe(v => _animation.animate_position(v.newval > v.oldval)),
|
||||
_orders_model.on_security_positions(security.Id).OnDispatcher().Subscribe(t => {
|
||||
if (Set(ref _raw_day_position, t.state.Values.Sum(p => p.Item2.raw_day_pos()), nameof(raw_day_position)))
|
||||
raise_invalidated();
|
||||
}),
|
||||
_inside_bids.OnDispatcher().Subscribe(v => _animation.animate_working_bids_inside(v.newval)),
|
||||
_inside_asks.OnDispatcher().Subscribe(v => _animation.animate_working_asks_inside(v.newval)),
|
||||
_day_change.OnDispatcher().Subscribe(v => _animation.animate_day_change(v.newval > v.oldval)),
|
||||
Disposable.Create(() => _animation.AnimationsChanged -= on_animations_changed)
|
||||
);
|
||||
}
|
||||
|
||||
public event Action invalidated;
|
||||
|
||||
#region Bound Properties
|
||||
public bool inside_bids => _inside_bids.value;
|
||||
public bool inside_asks => _inside_asks.value;
|
||||
public int position => _position.value;
|
||||
public double raw_day_position => _raw_day_position;
|
||||
public double last_price => _last_price.Value;
|
||||
public bool last_price_from_spread => _last_price_from_spread.Value;
|
||||
public uint last_size => _last_size.value;
|
||||
public double bid_price => _bid_price.Value;
|
||||
public uint bid_direct_size => _bid_direct_size.Value;
|
||||
public uint bid_implied_size => _bid_merged_size.Value - _bid_direct_size.Value;
|
||||
public uint bid_merged_size => _bid_merged_size.Value;
|
||||
public string bid_merged_size_text => _bid_merged_size_text ?? (_bid_merged_size_text = _size_formatter(_bid_merged_size.Value, bid_implied_size));
|
||||
public double ask_price => _ask_price.Value;
|
||||
public uint ask_direct_size => _ask_direct_size.Value;
|
||||
public uint ask_implied_size => _ask_merged_size.Value - _ask_direct_size.Value;
|
||||
public uint ask_merged_size => _ask_merged_size.Value;
|
||||
public string ask_merged_size_text => _ask_merged_size_text ?? (_ask_merged_size_text = _size_formatter(_ask_merged_size.Value, ask_implied_size));
|
||||
public ulong volume => _volume.value;
|
||||
public double settlement => _settlement.Value;
|
||||
public double day_change => _day_change.Value;
|
||||
public double session_low => _session_low.Value;
|
||||
public double session_high => _session_high.Value;
|
||||
public int working_bid_volume => _working_bid_volume.value;
|
||||
public int working_ask_volume => _working_ask_volume.value;
|
||||
public string working_bids_text => OrderUtils.order_collection_summary(_order_summarizer.best_working_bid, _order_summarizer.best_working_bid_qty, _order_summarizer.working_bid_qty, security.ContractSpec);
|
||||
public string working_asks_text => OrderUtils.order_collection_summary(_order_summarizer.best_working_ask, _order_summarizer.best_working_ask_qty, _order_summarizer.working_ask_qty, security.ContractSpec);
|
||||
public double working_best_bid => _working_best_bid.value;
|
||||
public double working_best_ask => _working_best_ask.value;
|
||||
public IList<ui.spark.CellAnimation> animations => _animation.get_animations().ToList();
|
||||
public ICommand bid_price_click { get; }
|
||||
public ICommand bid_merged_size_click { get; }
|
||||
public ICommand bid_direct_size_click { get; }
|
||||
public ICommand bid_implied_size_click { get; }
|
||||
public ICommand working_bids_click { get; }
|
||||
public ICommand ask_price_click { get; }
|
||||
public ICommand ask_merged_size_click { get; }
|
||||
public ICommand ask_direct_size_click { get; }
|
||||
public ICommand ask_implied_size_click { get; }
|
||||
public ICommand working_asks_click { get; }
|
||||
public ICommand default_command { get; }
|
||||
public string market_description {get;}
|
||||
public string cleared_alias { get; }
|
||||
public string product_description { get; }
|
||||
public string hub_alias { get; }
|
||||
public string strip_name{ get; }
|
||||
public string mic_code { get; }
|
||||
|
||||
public ObservableCollection<RowAnimation> row_animations { get; } = new ObservableCollection<RowAnimation>();
|
||||
// commands
|
||||
public ICommand bid_price_click { get; }
|
||||
public ICommand bid_merged_size_click { get; }
|
||||
public ICommand bid_direct_size_click { get; }
|
||||
public ICommand bid_implied_size_click { get; }
|
||||
public ICommand working_bids_click { get; }
|
||||
public ICommand ask_price_click { get; }
|
||||
public ICommand ask_merged_size_click { get; }
|
||||
public ICommand ask_direct_size_click { get; }
|
||||
public ICommand ask_implied_size_click { get; }
|
||||
public ICommand working_asks_click { get; }
|
||||
public ICommand default_command { get; }
|
||||
|
||||
public IReadOnlyList<DIYGrid.IGridCellStore> cell_stores => new DIYGrid.IGridCellStore[0];
|
||||
#endregion
|
||||
|
||||
public void raise_invalidated() => invalidated?.Invoke();
|
||||
|
||||
public void refresh() {
|
||||
bool dirty = false;
|
||||
if (md.md.get_bbo(ref _bbo_ref, out NativePriceSize b, out NativePriceSize a)) {
|
||||
_bid_price.set(b.price);
|
||||
refresh_size(ref b, _bid_direct_size, _bid_merged_size, ref _bid_merged_size_text, nameof(bid_merged_size_text));
|
||||
_ask_price.set(a.price);
|
||||
refresh_size(ref a, _ask_direct_size, _ask_merged_size, ref _ask_merged_size_text, nameof(ask_merged_size_text));
|
||||
_inside_bids.on_next_distinct(_bid_price.Value >= _working_best_bid.value, ref dirty);
|
||||
_inside_asks.on_next_distinct(_ask_price.Value <= _working_best_ask.value, ref dirty);
|
||||
}
|
||||
if (md.md.get_last_trade(ref _last_ref, out NativePriceSize ps, out DateTime ts, out ulong v, out bool from_spread)) {
|
||||
_last_price.set(ps.price);
|
||||
_last_price_from_spread.set(from_spread);
|
||||
_last_size.on_next_distinct(ps.size, ref dirty);
|
||||
_volume.on_next_distinct(v, ref dirty);
|
||||
}
|
||||
dirty |= _settlement.set_new(md.md.settlement_price);
|
||||
dirty |= _session_low.set_new(md.md.session_low);
|
||||
dirty |= _session_high.set_new(md.md.session_high);
|
||||
dirty |= _day_change.set_new(last_price - settlement);
|
||||
_volume.on_next_distinct(md.md.total_volume, ref dirty);
|
||||
if (dirty)
|
||||
invalidated?.Invoke();
|
||||
|
||||
void refresh_size(ref NativePriceSize nps, Property<uint> direct, Property<uint> merged, ref string text, string text_prop) {
|
||||
if (nps.size != merged.Value || nps.direct_size != direct.Value) {
|
||||
merged.set(nps.size);
|
||||
direct.set(nps.direct_size);
|
||||
text = null;
|
||||
dirty = true;
|
||||
RaisePropertyChanged(text_prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals(Row other) =>
|
||||
other != null &&
|
||||
other.security_key == security_key;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
Equals(obj as Row);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
security_key.GetHashCode();
|
||||
|
||||
#region Show Windows
|
||||
void _show_ladder() => _bus.post(SparkTags.ShowLadderTag, md);
|
||||
|
||||
void _show_order_book(MarketViewView.Columns col) {
|
||||
switch (col) {
|
||||
case MarketViewView.Columns.WorkingBids: _show_order_book(Side.Buy); break;
|
||||
case MarketViewView.Columns.WorkingAsks: _show_order_book(Side.Sell); break;
|
||||
}
|
||||
}
|
||||
|
||||
void _show_order_book(Side side) {
|
||||
var ob_settings = bts.shell.orderbook.OrderBookStartupData.Default;
|
||||
ob_settings.filters = new bts.shell.orderbook.FilterStates {
|
||||
statuses = new[] { OrderStatus.Working },
|
||||
sides = new[] { side },
|
||||
security_criteria = new SecurityCriteria(security)
|
||||
};
|
||||
_bus.post(SparkTags.ShowOrderBookTag, ob_settings);
|
||||
}
|
||||
|
||||
void _show_order_ticket(MarketViewView.Columns col) {
|
||||
var order = _orders_model.factory.order(security);
|
||||
switch (col) {
|
||||
case MarketViewView.Columns.Bid:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, 0u));
|
||||
break;
|
||||
case MarketViewView.Columns.BidMergedSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, bid_merged_size));
|
||||
break;
|
||||
case MarketViewView.Columns.BidDirectSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, bid_direct_size));
|
||||
break;
|
||||
case MarketViewView.Columns.BidImpliedSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, bid_implied_size));
|
||||
break;
|
||||
case MarketViewView.Columns.Ask:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Buy), ask_price, 0u));
|
||||
break;
|
||||
case MarketViewView.Columns.AskMergedSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Buy), ask_price, ask_merged_size));
|
||||
break;
|
||||
case MarketViewView.Columns.AskDirectSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), ask_price, ask_direct_size));
|
||||
break;
|
||||
case MarketViewView.Columns.AskImpliedSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), ask_price, ask_implied_size));
|
||||
break;
|
||||
case MarketViewView.Columns.Last:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, last_price, 0u));
|
||||
break;
|
||||
case MarketViewView.Columns.LastSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, last_price, last_size));
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Callbacks
|
||||
void _on_orders(ITableUpdateTransform<OrderRecordImmutable, uint> orders) {
|
||||
foreach (var o in orders.removed)
|
||||
_order_summarizer.remove_order(o);
|
||||
foreach (var o in orders.added)
|
||||
_order_summarizer.add_order(o);
|
||||
bool dirty = false;
|
||||
_refresh_orders(ref dirty);
|
||||
if (dirty)
|
||||
invalidated?.Invoke();
|
||||
}
|
||||
|
||||
void _refresh_orders(ref bool dirty) {
|
||||
_position.on_next_distinct(_order_summarizer.position, ref dirty);
|
||||
_working_bid_volume.on_next_distinct(_order_summarizer.working_bid_qty, ref dirty);
|
||||
_working_ask_volume.on_next_distinct(_order_summarizer.working_ask_qty, ref dirty);
|
||||
_working_best_bid.on_next_distinct(_order_summarizer.best_working_bid, ref dirty);
|
||||
_working_best_ask.on_next_distinct(_order_summarizer.best_working_ask, ref dirty);
|
||||
_inside_bids.on_next_distinct(_order_summarizer.best_working_bid >= bid_price, ref dirty);
|
||||
_inside_asks.on_next_distinct(_order_summarizer.best_working_ask <= ask_price, ref dirty);
|
||||
|
||||
RaisePropertyChanged(
|
||||
// Implied might not be ever set, so it probably does not RaisePropertyChanged either
|
||||
// This might be part of the filter funk?
|
||||
//nameof(bid_implied_size),
|
||||
//nameof(ask_implied_size),
|
||||
nameof(working_bids_text),
|
||||
nameof(working_asks_text)
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
class MyOrderSummarizer {
|
||||
SortedSetMap<double, OrderRecordImmutable> _bids, _asks;
|
||||
int _best_bid_working_qty, _best_ask_working_qty, _position, _working_bid_qty, _working_ask_qty;
|
||||
|
||||
public MyOrderSummarizer() {
|
||||
_bids = new SortedSetMap<double, OrderRecordImmutable>(
|
||||
OrderDataHelper.CompareUtils.bid_price_comparer,
|
||||
OrderDataHelper.CompareUtils.order_record_id_eq_comparer);
|
||||
_asks = new SortedSetMap<double, OrderRecordImmutable>(
|
||||
OrderDataHelper.CompareUtils.ask_price_comparer,
|
||||
OrderDataHelper.CompareUtils.order_record_id_eq_comparer);
|
||||
}
|
||||
|
||||
// bid
|
||||
public double best_working_bid => _bids.Count > 0 ? _bids.at_index(0).Key : double.NaN;
|
||||
public int best_working_bid_qty => _best_bid_working_qty;
|
||||
public int working_bid_qty => _working_bid_qty;
|
||||
// ask
|
||||
public double best_working_ask => _asks.Count > 0 ? _asks.at_index(0).Key : double.NaN;
|
||||
public int best_working_ask_qty => _best_ask_working_qty;
|
||||
public int working_ask_qty => _working_ask_qty;
|
||||
// pos
|
||||
public int position => _position;
|
||||
|
||||
public void add_order(OrderRecordImmutable o) {
|
||||
switch (o.side()) {
|
||||
case Side.Buy:
|
||||
_position += (int)o.filled();
|
||||
if (o.is_active()) {
|
||||
_working_bid_qty += o.working_quantity();
|
||||
_bids.add(o.price(), o);
|
||||
}
|
||||
break;
|
||||
case Side.Sell:
|
||||
_position -= (int)o.filled();
|
||||
if (o.is_active()) {
|
||||
_working_ask_qty += o.working_quantity();
|
||||
_asks.add(o.price(), o);
|
||||
}
|
||||
break;
|
||||
default: return;
|
||||
}
|
||||
_refresh();
|
||||
}
|
||||
|
||||
public void remove_order(OrderRecordImmutable o) {
|
||||
switch (o.side()) {
|
||||
case Side.Buy:
|
||||
_position -= (int)o.filled();
|
||||
if (o.is_active()) {
|
||||
_working_bid_qty -= o.working_quantity();
|
||||
_bids.remove(o.price(), o);
|
||||
}
|
||||
break;
|
||||
case Side.Sell:
|
||||
_position += (int)o.filled();
|
||||
if (o.is_active()) {
|
||||
_working_ask_qty -= o.working_quantity();
|
||||
_asks.remove(o.price(), o);
|
||||
}
|
||||
break;
|
||||
default: return;
|
||||
}
|
||||
_refresh();
|
||||
}
|
||||
|
||||
void _refresh() {
|
||||
_best_bid_working_qty = _bids.Count > 0 ? _bids.at_index(0).Sum(o => o.working_quantity()) : 0;
|
||||
_best_ask_working_qty = _asks.Count > 0 ? _asks.at_index(0).Sum(o => o.working_quantity()) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyList<DIYGrid.IGridCellStore> cell_stores => new DIYGrid.IGridCellStore[0];
|
||||
#endregion
|
||||
|
||||
public void raise_invalidated() => invalidated?.Invoke();
|
||||
|
||||
public void refresh() {
|
||||
bool dirty = false;
|
||||
if (md.md.get_bbo(ref _bbo_ref, out NativePriceSize b, out NativePriceSize a)) {
|
||||
_bid_price.set(b.price);
|
||||
refresh_size(ref b, _bid_direct_size, _bid_merged_size, ref _bid_merged_size_text, nameof(bid_merged_size_text));
|
||||
_ask_price.set(a.price);
|
||||
refresh_size(ref a, _ask_direct_size, _ask_merged_size, ref _ask_merged_size_text, nameof(ask_merged_size_text));
|
||||
_inside_bids.on_next_distinct(_bid_price.Value >= _working_best_bid.value, ref dirty);
|
||||
_inside_asks.on_next_distinct(_ask_price.Value <= _working_best_ask.value, ref dirty);
|
||||
}
|
||||
if (md.md.get_last_trade(ref _last_ref, out NativePriceSize ps, out DateTime ts, out ulong v, out bool from_spread)) {
|
||||
_last_price.set(ps.price);
|
||||
_last_price_from_spread.set(from_spread);
|
||||
_last_size.on_next_distinct(ps.size, ref dirty);
|
||||
_volume.on_next_distinct(v, ref dirty);
|
||||
}
|
||||
dirty |= _settlement.set_new(md.md.settlement_price);
|
||||
dirty |= _session_low.set_new(md.md.session_low);
|
||||
dirty |= _session_high.set_new(md.md.session_high);
|
||||
dirty |= _day_change.set_new(last_price - settlement);
|
||||
_volume.on_next_distinct(md.md.total_volume, ref dirty);
|
||||
if (dirty)
|
||||
invalidated?.Invoke();
|
||||
|
||||
void refresh_size(ref NativePriceSize nps, Property<uint> direct, Property<uint> merged, ref string text, string text_prop) {
|
||||
if (nps.size != merged.Value || nps.direct_size != direct.Value) {
|
||||
merged.set(nps.size);
|
||||
direct.set(nps.direct_size);
|
||||
text = null;
|
||||
dirty = true;
|
||||
RaisePropertyChanged(text_prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals(Row other) =>
|
||||
other != null &&
|
||||
other.security_key == security_key;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
Equals(obj as Row);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
security_key.GetHashCode();
|
||||
|
||||
#region Show Windows
|
||||
void _show_ladder() => _bus.post(SparkTags.ShowLadderTag, md);
|
||||
|
||||
void _show_order_book(MarketViewView.Columns col) {
|
||||
switch (col) {
|
||||
case MarketViewView.Columns.WorkingBids: _show_order_book(Side.Buy); break;
|
||||
case MarketViewView.Columns.WorkingAsks: _show_order_book(Side.Sell); break;
|
||||
}
|
||||
}
|
||||
|
||||
void _show_order_book(Side side) {
|
||||
var ob_settings = bts.shell.orderbook.OrderBookStartupData.Default;
|
||||
ob_settings.filters = new bts.shell.orderbook.FilterStates {
|
||||
statuses = new[] { OrderStatus.Working },
|
||||
sides = new[] { side },
|
||||
security_criteria = new SecurityCriteria(security)
|
||||
};
|
||||
_bus.post(SparkTags.ShowOrderBookTag, ob_settings);
|
||||
}
|
||||
|
||||
void _show_order_ticket(MarketViewView.Columns col) {
|
||||
var order = _orders_model.factory.order(security);
|
||||
switch (col) {
|
||||
case MarketViewView.Columns.Bid:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, 0u));
|
||||
break;
|
||||
case MarketViewView.Columns.BidMergedSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, bid_merged_size));
|
||||
break;
|
||||
case MarketViewView.Columns.BidDirectSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, bid_direct_size));
|
||||
break;
|
||||
case MarketViewView.Columns.BidImpliedSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, bid_implied_size));
|
||||
break;
|
||||
case MarketViewView.Columns.Ask:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Buy), ask_price, 0u));
|
||||
break;
|
||||
case MarketViewView.Columns.AskMergedSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Buy), ask_price, ask_merged_size));
|
||||
break;
|
||||
case MarketViewView.Columns.AskDirectSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), ask_price, ask_direct_size));
|
||||
break;
|
||||
case MarketViewView.Columns.AskImpliedSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), ask_price, ask_implied_size));
|
||||
break;
|
||||
case MarketViewView.Columns.Last:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, last_price, 0u));
|
||||
break;
|
||||
case MarketViewView.Columns.LastSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, last_price, last_size));
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Callbacks
|
||||
void _on_orders(ITableUpdateTransform<OrderRecordImmutable, uint> orders) {
|
||||
foreach (var o in orders.removed)
|
||||
_order_summarizer.remove_order(o);
|
||||
foreach (var o in orders.added)
|
||||
_order_summarizer.add_order(o);
|
||||
bool dirty = false;
|
||||
_refresh_orders(ref dirty);
|
||||
if (dirty)
|
||||
invalidated?.Invoke();
|
||||
}
|
||||
|
||||
void _refresh_orders(ref bool dirty) {
|
||||
_position.on_next_distinct(_order_summarizer.position, ref dirty);
|
||||
_working_bid_volume.on_next_distinct(_order_summarizer.working_bid_qty, ref dirty);
|
||||
_working_ask_volume.on_next_distinct(_order_summarizer.working_ask_qty, ref dirty);
|
||||
_working_best_bid.on_next_distinct(_order_summarizer.best_working_bid, ref dirty);
|
||||
_working_best_ask.on_next_distinct(_order_summarizer.best_working_ask, ref dirty);
|
||||
_inside_bids.on_next_distinct(_order_summarizer.best_working_bid >= bid_price, ref dirty);
|
||||
_inside_asks.on_next_distinct(_order_summarizer.best_working_ask <= ask_price, ref dirty);
|
||||
|
||||
RaisePropertyChanged(
|
||||
// Implied might not be ever set, so it probably does not RaisePropertyChanged either
|
||||
// This might be part of the filter funk?
|
||||
//nameof(bid_implied_size),
|
||||
//nameof(ask_implied_size),
|
||||
nameof(working_bids_text),
|
||||
nameof(working_asks_text)
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
class MyOrderSummarizer {
|
||||
SortedSetMap<double, OrderRecordImmutable> _bids, _asks;
|
||||
int _best_bid_working_qty, _best_ask_working_qty, _position, _working_bid_qty, _working_ask_qty;
|
||||
|
||||
public MyOrderSummarizer() {
|
||||
_bids = new SortedSetMap<double, OrderRecordImmutable>(
|
||||
OrderDataHelper.CompareUtils.bid_price_comparer,
|
||||
OrderDataHelper.CompareUtils.order_record_id_eq_comparer);
|
||||
_asks = new SortedSetMap<double, OrderRecordImmutable>(
|
||||
OrderDataHelper.CompareUtils.ask_price_comparer,
|
||||
OrderDataHelper.CompareUtils.order_record_id_eq_comparer);
|
||||
}
|
||||
|
||||
// bid
|
||||
public double best_working_bid => _bids.Count > 0 ? _bids.at_index(0).Key : double.NaN;
|
||||
public int best_working_bid_qty => _best_bid_working_qty;
|
||||
public int working_bid_qty => _working_bid_qty;
|
||||
// ask
|
||||
public double best_working_ask => _asks.Count > 0 ? _asks.at_index(0).Key : double.NaN;
|
||||
public int best_working_ask_qty => _best_ask_working_qty;
|
||||
public int working_ask_qty => _working_ask_qty;
|
||||
// pos
|
||||
public int position => _position;
|
||||
|
||||
public void add_order(OrderRecordImmutable o) {
|
||||
switch (o.side()) {
|
||||
case Side.Buy:
|
||||
_position += (int)o.filled();
|
||||
if (o.is_active()) {
|
||||
_working_bid_qty += o.working_quantity();
|
||||
_bids.add(o.price(), o);
|
||||
}
|
||||
break;
|
||||
case Side.Sell:
|
||||
_position -= (int)o.filled();
|
||||
if (o.is_active()) {
|
||||
_working_ask_qty += o.working_quantity();
|
||||
_asks.add(o.price(), o);
|
||||
}
|
||||
break;
|
||||
default: return;
|
||||
}
|
||||
_refresh();
|
||||
}
|
||||
|
||||
public void remove_order(OrderRecordImmutable o) {
|
||||
switch (o.side()) {
|
||||
case Side.Buy:
|
||||
_position -= (int)o.filled();
|
||||
if (o.is_active()) {
|
||||
_working_bid_qty -= o.working_quantity();
|
||||
_bids.remove(o.price(), o);
|
||||
}
|
||||
break;
|
||||
case Side.Sell:
|
||||
_position += (int)o.filled();
|
||||
if (o.is_active()) {
|
||||
_working_ask_qty -= o.working_quantity();
|
||||
_asks.remove(o.price(), o);
|
||||
}
|
||||
break;
|
||||
default: return;
|
||||
}
|
||||
_refresh();
|
||||
}
|
||||
|
||||
void _refresh() {
|
||||
_best_bid_working_qty = _bids.Count > 0 ? _bids.at_index(0).Sum(o => o.working_quantity()) : 0;
|
||||
_best_ask_working_qty = _asks.Count > 0 ? _asks.at_index(0).Sum(o => o.working_quantity()) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,294 +1,286 @@
|
||||
using bts.api;
|
||||
using bts.collections;
|
||||
using bts.utils;
|
||||
using mbts.persist;
|
||||
using mbts.spark.filters;
|
||||
using mbts.ui;
|
||||
using mbts.ui.settings;
|
||||
using mbts.ui.utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using static bts.shell.MarketViewWindowFactory;
|
||||
using static mbts.ui.controls.DIYGrid;
|
||||
using static mbts.ui.spark.MarketViewView;
|
||||
|
||||
namespace mbts.spark {
|
||||
partial class MarketViewVM : SecurityMDGrid<MarketViewVM.Row, SecurityMD> {
|
||||
static IReadOnlyList<Func<MarketViewVM, IDataGridColumnFilter<Row>>> _filter_getters =
|
||||
ObjectSnapshot.property_delegates_of_type<MarketViewVM, IDataGridColumnFilter<Row>>();
|
||||
|
||||
readonly IBus _bus;
|
||||
readonly OrdersModel _orders_model;
|
||||
IWindowSettingsManager<GridSettings> _settings_manager;
|
||||
|
||||
public MarketViewVM(IBus bus, OrdersModel orders_model, IObservable<StartupData> state, IWindowSettingsManager<GridSettings> settings_manager )
|
||||
: this(bus, orders_model, state, state.SelectManyInSeries(s => s.security_criteria.subscribe_md(bus)), settings_manager) { }
|
||||
|
||||
// securities_connectable should NOT be connected already.
|
||||
MarketViewVM(IBus bus, OrdersModel orders_model, IObservable<StartupData> state, IObservable<IEnumerable<SecurityMD>> securities_source, IWindowSettingsManager<GridSettings> settings_manager)
|
||||
: base(RXCollection.Create(securities_source, SecurityDataHelper.EqualityComparer.MDComparer), null) {
|
||||
_bus = bus;
|
||||
_orders_model = orders_model;
|
||||
security_filter = new RegexFilterVM<Row>(r => r.security.ToString(), nameof(Row.security));
|
||||
_settings_manager = settings_manager;
|
||||
// Columns
|
||||
const string merged_size_col_header = "Qty", direct_size_col_header = "Direct", implied_size_col_header = "Implied", working_col_header = "Working";
|
||||
const double working_orders_col_width = 105;
|
||||
IMultiValueConverter price_converter = new ui.spark.converters.TickDisplayConverter();
|
||||
add_col(Columns.Security, "Security", r => r.security.ToString(), nameof(Row.security), DefaultColumnWidths.Security, security_filter, DataGridFilterKnownTemplates.Regex);
|
||||
add_col(Columns.Volume, "Volume", r => r.volume.ToString(), nameof(Row.volume), DefaultColumnWidths.Volume, volume_filter, DataGridFilterKnownTemplates.ULongMinMax);
|
||||
add_col(Columns.LastSpd, "Spd", r => r.last_price_from_spread ? "S" : "", nameof(Row.last_price_from_spread), DefaultColumnWidths.Side, last_price_from_spread_filter, DataGridFilterKnownTemplates.Regex);
|
||||
add_col(Columns.Last, "Last", r => r.format_price(r.last_price), nameof(Row.last_price), DefaultColumnWidths.Price, last_price_filter, DataGridFilterKnownTemplates.DoubleMinMax);
|
||||
add_col(Columns.LastSize, merged_size_col_header, r => r.last_size.ToString(), nameof(Row.last_size), DefaultColumnWidths.Size, last_size_filter, DataGridFilterKnownTemplates.UIntMinMax, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.Position, "Pos", r => r.position.ToString(), nameof(Row.position), DefaultColumnWidths.Size, position_filter, DataGridFilterKnownTemplates.IntMinMax, true, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.RawDayPosition, "Raw Day Pos", r => SparkUtils.fmt_position(r.raw_day_position), nameof(Row.raw_day_position), DefaultColumnWidths.Size, raw_day_position_filter, DataGridFilterKnownTemplates.DoubleMinMax, true, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_working_orders_col(Columns.WorkingBids, working_col_header, nameof(Row.working_bids_text), nameof(Row.working_best_bid), nameof(Row.working_bids_click), working_bid_volume_filter, BTSColors.MarketData.bid, System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.BidImpliedSize, implied_size_col_header, r => r.bid_implied_size.ToString(), nameof(Row.bid_implied_size), DefaultColumnWidths.ImpliedDirectMergedSize, bid_implied_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.BidDirectSize, direct_size_col_header, r => r.bid_direct_size.ToString(), nameof(Row.bid_direct_size), DefaultColumnWidths.ImpliedDirectMergedSize, bid_direct_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_merged_size_col(Columns.BidMergedSize, merged_size_col_header, nameof(Row.bid_merged_size), nameof(Row.bid_merged_size_text), nameof(Row.bid_merged_size_click), bid_merged_size_filter, BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_price_col(Columns.Bid, "Bid", nameof(Row.bid_price), nameof(Row.bid_price_click), bid_price_filter, BTSColors.header_text, BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_price_col(Columns.Ask, "Ask", nameof(Row.ask_price), nameof(Row.ask_price_click), ask_price_filter, BTSColors.header_text, BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_merged_size_col(Columns.AskMergedSize, merged_size_col_header, nameof(Row.ask_merged_size), nameof(Row.ask_merged_size_text), nameof(Row.ask_merged_size_click), ask_merged_size_filter, BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.AskDirectSize, direct_size_col_header, r => r.ask_direct_size.ToString(), nameof(Row.ask_direct_size), DefaultColumnWidths.ImpliedDirectMergedSize, ask_direct_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.AskImpliedSize, implied_size_col_header, r => r.ask_implied_size.ToString(), nameof(Row.ask_implied_size), DefaultColumnWidths.ImpliedDirectMergedSize, ask_implied_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_working_orders_col(Columns.WorkingAsks, working_col_header, nameof(Row.working_asks_text), nameof(Row.working_best_ask), nameof(Row.working_asks_click), working_ask_volume_filter, BTSColors.MarketData.ask, System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.Settlement, "Settlement", r => r.format_price(r.settlement), nameof(Row.settlement), DefaultColumnWidths.Settlement, settlement_filter, DataGridFilterKnownTemplates.DoubleMinMax, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.DayChange, "Change", r => r.format_price(r.day_change), nameof(Row.day_change), DefaultColumnWidths.Price, day_change_filter, DataGridFilterKnownTemplates.DoubleMinMax, true, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.SessionLow, "Low", r => r.format_price(r.session_low), nameof(Row.session_low), DefaultColumnWidths.Price, session_low_filter, DataGridFilterKnownTemplates.DoubleMinMax, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.SessionHigh, "High", r => r.format_price(r.session_high), nameof(Row.session_high), DefaultColumnWidths.Price, session_high_filter, DataGridFilterKnownTemplates.DoubleMinMax, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.SecurityKey, "Security Key", r => r.security_key.ToString(), nameof(Row.security_key), DefaultColumnWidths.SecurityKey, security_key_filter, DataGridFilterKnownTemplates.Regex);
|
||||
|
||||
add_col(Columns.MarketDescription, "Market Description", r => r.security.market_description(), nameof(Row.market_description), DefaultColumnWidths.SecurityKey, market_description_filter, DataGridFilterKnownTemplates.Regex);
|
||||
add_col(Columns.ClearedAlias, "Cleared Alias", r => r.security.cleared_alias(), nameof(Row.cleared_alias), DefaultColumnWidths.SecurityKey, cleared_alias_filter, DataGridFilterKnownTemplates.Regex);
|
||||
add_col(Columns.ProductDescription, "Product Description", r => r.security.product_name(), nameof(Row.product_description), DefaultColumnWidths.SecurityKey, product_description_filter, DataGridFilterKnownTemplates.Regex);
|
||||
add_col(Columns.HubAlias, "Hub Alias", r => r.security.hub_alias(), nameof(Row.hub_alias), DefaultColumnWidths.SecurityKey, hub_alias_filter, DataGridFilterKnownTemplates.Regex);
|
||||
add_col(Columns.StripName, "Strip Name", r => r.security.strip_name(), nameof(Row.strip_name), DefaultColumnWidths.SecurityKey, strip_name_filter, DataGridFilterKnownTemplates.Regex);
|
||||
add_col(Columns.MicCode, "Mic Code", r => r.security.mic_code(), nameof(Row.mic_code), DefaultColumnWidths.SecurityKey, mic_code_filter, DataGridFilterKnownTemplates.Regex);
|
||||
//
|
||||
void add_col(Columns col_key, string header, Func<Row, string> get_text, string prop, double width, IDataGridColumnFilter filter, string filter_template, bool is_animatable = false, Color? font_color = null, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) =>
|
||||
columns.Add(new RenderTextColumn<Row, Columns>(col_key, get_text, filter, filter_template) {
|
||||
// it's necessary to have this id populated for grid settings
|
||||
id = bts.shell.MarketViewWindowFactory.col_id(col_key),
|
||||
Header = header,
|
||||
sort_member_path = prop,
|
||||
Width = width,
|
||||
padding = is_animatable ? AnimatableCellPadding : DefaultCellPadding,
|
||||
font_color_override = font_color,
|
||||
horizontal_alignment = h_alignment
|
||||
});
|
||||
|
||||
void add_hl_price_col(Columns col_key, string header, string prop, string command_prop, IDataGridColumnFilter filter, Color foreground, Color? background, System.Windows.HorizontalAlignment h_alignment) =>
|
||||
add_hl_col(col_key, header, price_binding(prop), prop, command_prop, filter, DataGridFilterKnownTemplates.DoubleMinMax, DefaultColumnWidths.MViewPrice, foreground, background, h_alignment);
|
||||
|
||||
void add_hl_merged_size_col(Columns col_key, string header, string sort_prop, string text_prop, string command_prop, IDataGridColumnFilter filter, Color foreground, System.Windows.HorizontalAlignment h_alignment) =>
|
||||
add_hl_col(col_key, header, new Binding(text_prop), sort_prop, command_prop, filter, DataGridFilterKnownTemplates.UIntMinMax, DefaultColumnWidths.ImpliedDirectMergedSize, foreground, null, h_alignment);
|
||||
|
||||
void add_hl_working_orders_col(Columns col_key, string header, string text_prop, string sort_prop, string command_prop, IDataGridColumnFilter filter, Color foreground, System.Windows.HorizontalAlignment h_alignment) =>
|
||||
add_hl_col(col_key, header, new Binding(text_prop), sort_prop, command_prop, filter, DataGridFilterKnownTemplates.IntMinMax, working_orders_col_width, foreground, null, h_alignment);
|
||||
|
||||
void add_hl_col(
|
||||
Columns col_key, string header, BindingBase binding, string prop, string command_prop,
|
||||
IDataGridColumnFilter filter, string filter_template, double width, Color foreground, Color? background, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) =>
|
||||
columns.Add(new HyperlinkElementColumn<Row, Columns>(
|
||||
col_key, binding, new Binding(command_prop), filter, filter_template) {
|
||||
// it's necessary to have this id populated for grid settings
|
||||
id = bts.shell.MarketViewWindowFactory.col_id(col_key),
|
||||
Header = header,
|
||||
sort_member_path = prop,
|
||||
font_color_override = foreground,
|
||||
background_color_override = background,
|
||||
Width = DefaultColumnWidths.Price,
|
||||
horizontal_alignment = h_alignment
|
||||
});
|
||||
|
||||
BindingBase price_binding(string prop) {
|
||||
var mb = new MultiBinding { Converter = price_converter };
|
||||
mb.Bindings.Add(new Binding(prop) { Mode = BindingMode.OneWay });
|
||||
mb.Bindings.Add(new Binding($"{nameof(Row.security)}.{nameof(SecurityImmutable.ContractSpec)}") { Mode = BindingMode.OneWay });
|
||||
return mb;
|
||||
}
|
||||
//
|
||||
// make font-color immutable for Side, Size, (the font-color rule is hard-coded: MarketData.bid for Buy orders, MarketData.ask for Sells)
|
||||
var col_settings_flags = new Dictionary<string, GridColumnSettingsFeatureFlags> {
|
||||
{ Columns.Bid.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor | GridColumnSettingsFeatureFlags.ImmutableBackgroundColor },
|
||||
{ Columns.Ask.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor | GridColumnSettingsFeatureFlags.ImmutableBackgroundColor},
|
||||
{ Columns.WorkingAsks.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor },
|
||||
{ Columns.WorkingBids.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor }
|
||||
};
|
||||
grid_settings_manager = new SimpleGridSettingsManager<Row>(columns, col_settings_flags, row_vms);
|
||||
// this will initialize the immutable properties that correspond to the col_settings_flags above (e.g. Bid/Ask font_color_override, etc.)
|
||||
grid_settings_manager.load_from(settings_manager.current_settings());
|
||||
//
|
||||
_resources.AddRange(
|
||||
state.OnDispatcher().Subscribe(s => {
|
||||
using (rows_view.DeferRefresh()) {
|
||||
if (s.grid != null) {
|
||||
// this means we are not using defaults,
|
||||
// Note: settings_manager in turn notifies grid_settings_manager of this update
|
||||
_settings_manager.instance_settings = s.grid;
|
||||
}
|
||||
if (s.filters is FilterStates filters) {
|
||||
security_filter.load_state(filters.security);
|
||||
bid_price_filter.load_state(filters.bid_price);
|
||||
bid_merged_size_filter.load_state(filters.bid_merged_size);
|
||||
bid_direct_size_filter.load_state(filters.bid_direct_size);
|
||||
bid_implied_size_filter.load_state(filters.bid_implied_size);
|
||||
ask_price_filter.load_state(filters.ask_price);
|
||||
ask_merged_size_filter.load_state(filters.ask_merged_size);
|
||||
ask_direct_size_filter.load_state(filters.ask_direct_size);
|
||||
ask_implied_size_filter.load_state(filters.ask_implied_size);
|
||||
last_price_filter.load_state(filters.last_price);
|
||||
last_price_from_spread_filter.load_state(filters.last_price_from_spread);
|
||||
last_size_filter.load_state(filters.last_size);
|
||||
day_change_filter.load_state(filters.day_change);
|
||||
settlement_filter.load_state(filters.settlement);
|
||||
session_low_filter.load_state(filters.session_low);
|
||||
session_high_filter.load_state(filters.session_high);
|
||||
position_filter.load_state(filters.position);
|
||||
raw_day_position_filter.load_state(filters.raw_day_position);
|
||||
working_bid_volume_filter.load_state(filters.working_bid_volume);
|
||||
working_ask_volume_filter.load_state(filters.working_ask_volume);
|
||||
volume_filter.load_state(filters.volume);
|
||||
security_key_filter.load_state(filters.security_key);
|
||||
market_description_filter.load_state(filters.market_description);
|
||||
cleared_alias_filter.load_state(filters.cleared_alias);
|
||||
product_description_filter.load_state(filters.product_description);
|
||||
hub_alias_filter.load_state(filters.hub_alias);
|
||||
strip_name_filter.load_state(filters.strip_name);
|
||||
mic_code_filter.load_state(filters.mic_code);
|
||||
}
|
||||
rows_view.set_sort_descriptions(s.sorting_criterion, columns);
|
||||
}
|
||||
}), DataGridFilterHelper.hook_filters(rows_view, _filters),
|
||||
settings_manager.subscribe_current().OnDispatcher().Subscribe(grid_settings_manager),
|
||||
WorkLoop.Start("MarketView", _refresh)
|
||||
);
|
||||
}
|
||||
|
||||
public ObservableCollection<ColumnBase> columns { get; } = new ObservableCollection<ColumnBase>();
|
||||
|
||||
public SimpleGridSettingsManager<Row> grid_settings_manager { get; }
|
||||
|
||||
public GridSettings get_grid_save_state() {
|
||||
if (_settings_manager.instance_settings == null)
|
||||
return null;
|
||||
else
|
||||
return grid_settings_manager.create();
|
||||
}
|
||||
|
||||
public static IComparer<Row> get_column_comparer(Columns column) {
|
||||
switch (column) {
|
||||
case Columns.Security: return wrap(r => r.security);
|
||||
case Columns.SecurityKey: return wrap(r => r.security.Id);
|
||||
case Columns.Volume: return wrap(r => r.volume);
|
||||
case Columns.Last: return wrap(r => r.last_price);
|
||||
case Columns.LastSize: return wrap(r => r.last_size);
|
||||
case Columns.Position: return wrap(r => r.position);
|
||||
case Columns.WorkingBids: return wrap(r => r.working_bid_volume);
|
||||
case Columns.BidImpliedSize: return wrap(r => r.bid_implied_size);
|
||||
case Columns.BidDirectSize: return wrap(r => r.bid_direct_size);
|
||||
case Columns.BidMergedSize: return wrap(r => r.bid_merged_size);
|
||||
case Columns.Bid: return wrap(r => r.bid_price);
|
||||
case Columns.Ask: return wrap(r => r.ask_price);
|
||||
case Columns.AskMergedSize: return wrap(r => r.ask_merged_size);
|
||||
case Columns.AskDirectSize: return wrap(r => r.ask_direct_size);
|
||||
case Columns.AskImpliedSize: return wrap(r => r.ask_implied_size);
|
||||
case Columns.WorkingAsks: return wrap(r => r.working_ask_volume);
|
||||
case Columns.Settlement: return wrap(r => r.settlement);
|
||||
case Columns.DayChange: return wrap(r => r.day_change);
|
||||
case Columns.SessionLow: return wrap(r => r.session_low);
|
||||
case Columns.SessionHigh: return wrap(r => r.session_high);
|
||||
case Columns.MarketDescription: return wrap(r => r.market_description);
|
||||
case Columns.ClearedAlias: return wrap(r => r.security.cleared_alias());
|
||||
case Columns.ProductDescription: return wrap(r => r.security.product_name());
|
||||
case Columns.HubAlias: return wrap(r => r.security.hub_alias());
|
||||
case Columns.StripName: return wrap(r => r.security.strip_name());
|
||||
case Columns.MicCode: return wrap(r => r.security.mic_code());
|
||||
default: return null;
|
||||
}
|
||||
IComparer<Row> wrap<T>(Func<Row, T> selector) =>
|
||||
Comparer<T>.Default.wrap(selector);
|
||||
}
|
||||
|
||||
#region Filters
|
||||
public IDataGridColumnPersistentFilter<Row, string> security_filter { get; }
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> bid_price_filter { get; } = new DoubleMinMax<Row>(r => r.bid_price, nameof(Row.bid_price));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> bid_merged_size_filter { get; } = new UIntMinMax<Row>(r => r.bid_merged_size, nameof(Row.bid_merged_size));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> bid_direct_size_filter { get; } = new UIntMinMax<Row>(r => r.bid_direct_size, nameof(Row.bid_direct_size));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> bid_implied_size_filter { get; } = new UIntMinMax<Row>(r => r.bid_implied_size, nameof(Row.bid_implied_size));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> ask_price_filter { get; } = new DoubleMinMax<Row>(r => r.ask_price, nameof(Row.ask_price));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> ask_merged_size_filter { get; } = new UIntMinMax<Row>(r => r.ask_merged_size, nameof(Row.ask_merged_size));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> ask_direct_size_filter { get; } = new UIntMinMax<Row>(r => r.ask_direct_size, nameof(Row.ask_direct_size));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> ask_implied_size_filter { get; } = new UIntMinMax<Row>(r => r.ask_implied_size, nameof(Row.ask_implied_size));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> last_price_filter { get; } = new DoubleMinMax<Row>(r => r.last_price, nameof(Row.last_price));
|
||||
public IDataGridColumnPersistentFilter<Row, string> last_price_from_spread_filter { get; } = new RegexFilterVM<Row>(r => r.last_price_from_spread.ToString(), nameof(Row.last_price_from_spread));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> last_size_filter { get; } = new UIntMinMax<Row>(r => r.last_size, nameof(Row.last_size));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> day_change_filter { get; } = new DoubleMinMax<Row>(r => r.day_change, nameof(Row.day_change));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> settlement_filter { get; } = new DoubleMinMax<Row>(r => r.settlement, nameof(Row.settlement));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> session_low_filter { get; } = new DoubleMinMax<Row>(r => r.session_low, nameof(Row.session_low));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> session_high_filter { get; } = new DoubleMinMax<Row>(r => r.session_high, nameof(Row.session_high));
|
||||
public IDataGridColumnPersistentFilter<Row, IntMinMaxState> position_filter { get; } = new IntMinMax<Row>(r => r.position, nameof(Row.position));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> raw_day_position_filter { get; } = new DoubleMinMax<Row>(r => r.raw_day_position, nameof(Row.raw_day_position));
|
||||
public IDataGridColumnPersistentFilter<Row, IntMinMaxState> working_bid_volume_filter { get; } = new IntMinMax<Row>(r => r.working_bid_volume, nameof(Row.working_bid_volume));
|
||||
public IDataGridColumnPersistentFilter<Row, IntMinMaxState> working_ask_volume_filter { get; } = new IntMinMax<Row>(r => r.working_ask_volume, nameof(Row.working_ask_volume));
|
||||
public IDataGridColumnPersistentFilter<Row, ULongMinMaxState> volume_filter { get; } = new ULongMinMax<Row>(r => r.volume, nameof(Row.volume));
|
||||
public IDataGridColumnPersistentFilter<Row, string> security_key_filter { get; } = new RegexFilterVM<Row>(r => r.security_key.ToString(), nameof(Row.security_key));
|
||||
|
||||
public IDataGridColumnPersistentFilter<Row, string> market_description_filter { get; } = new RegexFilterVM<Row>(r => r.market_description, nameof(Row.market_description));
|
||||
public IDataGridColumnPersistentFilter<Row, string> cleared_alias_filter { get; } = new RegexFilterVM<Row>(r => r.cleared_alias, nameof(Row.cleared_alias));
|
||||
public IDataGridColumnPersistentFilter<Row, string> product_description_filter { get; } = new RegexFilterVM<Row>(r => r.product_description, nameof(Row.product_description));
|
||||
public IDataGridColumnPersistentFilter<Row, string> hub_alias_filter { get; } = new RegexFilterVM<Row>(r => r.hub_alias, nameof(Row.hub_alias));
|
||||
public IDataGridColumnPersistentFilter<Row, string> strip_name_filter { get; } = new RegexFilterVM<Row>(r => r.strip_name, nameof(Row.strip_name));
|
||||
public IDataGridColumnPersistentFilter<Row, string> mic_code_filter { get; } = new RegexFilterVM<Row>(r => r.mic_code, nameof(Row.mic_code));
|
||||
|
||||
IEnumerable<IDataGridColumnFilter<Row>> _filters =>
|
||||
_filter_getters.Select(fn => fn(this));
|
||||
|
||||
public FilterStates get_filter_states() {
|
||||
return new FilterStates {
|
||||
security = security_filter.get_state(),
|
||||
bid_price = bid_price_filter.get_state(),
|
||||
bid_merged_size = bid_merged_size_filter.get_state(),
|
||||
bid_direct_size = bid_direct_size_filter.get_state(),
|
||||
bid_implied_size = bid_implied_size_filter.get_state(),
|
||||
ask_price = ask_price_filter.get_state(),
|
||||
ask_merged_size = ask_merged_size_filter.get_state(),
|
||||
ask_direct_size = ask_direct_size_filter.get_state(),
|
||||
ask_implied_size = ask_implied_size_filter.get_state(),
|
||||
last_price = last_price_filter.get_state(),
|
||||
last_price_from_spread = last_price_from_spread_filter.get_state(),
|
||||
last_size = last_size_filter.get_state(),
|
||||
day_change = day_change_filter.get_state(),
|
||||
settlement = settlement_filter.get_state(),
|
||||
session_low = session_low_filter.get_state(),
|
||||
session_high = session_high_filter.get_state(),
|
||||
position = position_filter.get_state(),
|
||||
raw_day_position = raw_day_position_filter.get_state(),
|
||||
working_bid_volume = working_bid_volume_filter.get_state(),
|
||||
working_ask_volume = working_ask_volume_filter.get_state(),
|
||||
volume = volume_filter.get_state(),
|
||||
security_key = security_key_filter.get_state(),
|
||||
market_description = market_description_filter.get_state(),
|
||||
cleared_alias = cleared_alias_filter.get_state(),
|
||||
product_description = product_description_filter.get_state(),
|
||||
hub_alias = hub_alias_filter.get_state(),
|
||||
strip_name = strip_name_filter.get_state(),
|
||||
mic_code = mic_code_filter.get_state(),
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override Row row_factory(SecurityMD smd) => new Row(_bus, smd, _orders_model);
|
||||
protected override void on_row_removed(Row row) => row.Dispose();
|
||||
protected override IEnumerable<SortingCriteria> get_default_sorting() { yield return new SortingCriteria(nameof(Row.security), true); }
|
||||
|
||||
void _refresh() {
|
||||
foreach (var r in _row_vms) r.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
using bts.api;
|
||||
using bts.collections;
|
||||
using bts.utils;
|
||||
using mbts.persist;
|
||||
using mbts.spark.filters;
|
||||
using mbts.ui;
|
||||
using mbts.ui.settings;
|
||||
using mbts.ui.utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using static bts.shell.MarketViewWindowFactory;
|
||||
using static mbts.ui.controls.DIYGrid;
|
||||
using static mbts.ui.spark.MarketViewView;
|
||||
|
||||
namespace mbts.spark {
|
||||
partial class MarketViewVM : SecurityMDGrid<MarketViewVM.Row, SecurityMD> {
|
||||
readonly IBus _bus;
|
||||
readonly OrdersModel _orders_model;
|
||||
IWindowSettingsManager<GridSettings> _settings_manager;
|
||||
|
||||
public MarketViewVM(IBus bus, OrdersModel orders_model, IObservable<StartupData> state, IWindowSettingsManager<GridSettings> settings_manager )
|
||||
: this(bus, orders_model, state, state.SelectManyInSeries(s => s.security_criteria.subscribe_md(bus)), settings_manager) { }
|
||||
|
||||
// securities_connectable should NOT be connected already.
|
||||
MarketViewVM(IBus bus, OrdersModel orders_model, IObservable<StartupData> state, IObservable<IEnumerable<SecurityMD>> securities_source, IWindowSettingsManager<GridSettings> settings_manager)
|
||||
: base(RXCollection.Create(securities_source, SecurityDataHelper.EqualityComparer.MDComparer), null) {
|
||||
_bus = bus;
|
||||
_orders_model = orders_model;
|
||||
security_filter = new RegexFilterVM<Row>(r => r.security.ToString(), nameof(Row.security));
|
||||
_settings_manager = settings_manager;
|
||||
// Columns
|
||||
const string merged_size_col_header = "Qty", direct_size_col_header = "Direct", implied_size_col_header = "Implied", working_col_header = "Working";
|
||||
const double working_orders_col_width = 105;
|
||||
IMultiValueConverter price_converter = new ui.spark.converters.TickDisplayConverter();
|
||||
add_col(Columns.Security, "Security", r => r.security.ToString(), nameof(Row.security), DefaultColumnWidths.Security, security_filter, DataGridFilterKnownTemplates.Regex);
|
||||
add_col(Columns.Volume, "Volume", r => r.volume.ToString(), nameof(Row.volume), DefaultColumnWidths.Volume, volume_filter, DataGridFilterKnownTemplates.ULongMinMax);
|
||||
add_col(Columns.LastSpd, "Spd", r => r.last_price_from_spread ? "S" : "", nameof(Row.last_price_from_spread), DefaultColumnWidths.Side, last_price_from_spread_filter, DataGridFilterKnownTemplates.Regex);
|
||||
add_col(Columns.Last, "Last", r => r.format_price(r.last_price), nameof(Row.last_price), DefaultColumnWidths.Price, last_price_filter, DataGridFilterKnownTemplates.DoubleMinMax);
|
||||
add_col(Columns.LastSize, merged_size_col_header, r => r.last_size.ToString(), nameof(Row.last_size), DefaultColumnWidths.Size, last_size_filter, DataGridFilterKnownTemplates.UIntMinMax, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.Position, "Pos", r => r.position.ToString(), nameof(Row.position), DefaultColumnWidths.Size, position_filter, DataGridFilterKnownTemplates.IntMinMax, true, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.RawDayPosition, "Raw Day Pos", r => SparkUtils.fmt_position(r.raw_day_position), nameof(Row.raw_day_position), DefaultColumnWidths.Size, raw_day_position_filter, DataGridFilterKnownTemplates.DoubleMinMax, true, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_working_orders_col(Columns.WorkingBids, working_col_header, nameof(Row.working_bids_text), nameof(Row.working_best_bid), nameof(Row.working_bids_click), working_bid_volume_filter, BTSColors.MarketData.bid, System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.BidImpliedSize, implied_size_col_header, r => r.bid_implied_size.ToString(), nameof(Row.bid_implied_size), DefaultColumnWidths.ImpliedDirectMergedSize, bid_implied_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.BidDirectSize, direct_size_col_header, r => r.bid_direct_size.ToString(), nameof(Row.bid_direct_size), DefaultColumnWidths.ImpliedDirectMergedSize, bid_direct_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_merged_size_col(Columns.BidMergedSize, merged_size_col_header, nameof(Row.bid_merged_size), nameof(Row.bid_merged_size_text), nameof(Row.bid_merged_size_click), bid_merged_size_filter, BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_price_col(Columns.Bid, "Bid", nameof(Row.bid_price), nameof(Row.bid_price_click), bid_price_filter, BTSColors.header_text, BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_price_col(Columns.Ask, "Ask", nameof(Row.ask_price), nameof(Row.ask_price_click), ask_price_filter, BTSColors.header_text, BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_merged_size_col(Columns.AskMergedSize, merged_size_col_header, nameof(Row.ask_merged_size), nameof(Row.ask_merged_size_text), nameof(Row.ask_merged_size_click), ask_merged_size_filter, BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.AskDirectSize, direct_size_col_header, r => r.ask_direct_size.ToString(), nameof(Row.ask_direct_size), DefaultColumnWidths.ImpliedDirectMergedSize, ask_direct_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.AskImpliedSize, implied_size_col_header, r => r.ask_implied_size.ToString(), nameof(Row.ask_implied_size), DefaultColumnWidths.ImpliedDirectMergedSize, ask_implied_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_working_orders_col(Columns.WorkingAsks, working_col_header, nameof(Row.working_asks_text), nameof(Row.working_best_ask), nameof(Row.working_asks_click), working_ask_volume_filter, BTSColors.MarketData.ask, System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.Settlement, "Settlement", r => r.format_price(r.settlement), nameof(Row.settlement), DefaultColumnWidths.Settlement, settlement_filter, DataGridFilterKnownTemplates.DoubleMinMax, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.DayChange, "Change", r => r.format_price(r.day_change), nameof(Row.day_change), DefaultColumnWidths.Price, day_change_filter, DataGridFilterKnownTemplates.DoubleMinMax, true, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.SessionLow, "Low", r => r.format_price(r.session_low), nameof(Row.session_low), DefaultColumnWidths.Price, session_low_filter, DataGridFilterKnownTemplates.DoubleMinMax, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.SessionHigh, "High", r => r.format_price(r.session_high), nameof(Row.session_high), DefaultColumnWidths.Price, session_high_filter, DataGridFilterKnownTemplates.DoubleMinMax, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.SecurityKey, "Security Key", r => r.security_key.ToString(), nameof(Row.security_key), DefaultColumnWidths.SecurityKey, security_key_filter, DataGridFilterKnownTemplates.Regex);
|
||||
|
||||
add_col(Columns.MarketDescription, "Market Description", r => r.security.market_description(), nameof(Row.market_description), DefaultColumnWidths.SecurityKey, market_description_filter, DataGridFilterKnownTemplates.Regex);
|
||||
add_col(Columns.ClearedAlias, "Cleared Alias", r => r.security.cleared_alias(), nameof(Row.cleared_alias), DefaultColumnWidths.SecurityKey, cleared_alias_filter, DataGridFilterKnownTemplates.Regex);
|
||||
add_col(Columns.ProductDescription, "Product Description", r => r.security.product_name(), nameof(Row.product_description), DefaultColumnWidths.SecurityKey, product_description_filter, DataGridFilterKnownTemplates.Regex);
|
||||
add_col(Columns.HubAlias, "Hub Alias", r => r.security.hub_alias(), nameof(Row.hub_alias), DefaultColumnWidths.SecurityKey, hub_alias_filter, DataGridFilterKnownTemplates.Regex);
|
||||
add_col(Columns.StripName, "Strip Name", r => r.security.strip_name(), nameof(Row.strip_name), DefaultColumnWidths.SecurityKey, strip_name_filter, DataGridFilterKnownTemplates.Regex);
|
||||
add_col(Columns.MicCode, "Mic Code", r => r.security.mic_code(), nameof(Row.mic_code), DefaultColumnWidths.SecurityKey, mic_code_filter, DataGridFilterKnownTemplates.Regex);
|
||||
//
|
||||
void add_col(Columns col_key, string header, Func<Row, string> get_text, string prop, double width, IDataGridColumnFilter filter, string filter_template, bool is_animatable = false, Color? font_color = null, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) =>
|
||||
columns.Add(new RenderTextColumn<Row, Columns>(col_key, get_text, filter, filter_template) {
|
||||
// it's necessary to have this id populated for grid settings
|
||||
id = bts.shell.MarketViewWindowFactory.col_id(col_key),
|
||||
Header = header,
|
||||
sort_member_path = prop,
|
||||
Width = width,
|
||||
padding = is_animatable ? AnimatableCellPadding : DefaultCellPadding,
|
||||
font_color_override = font_color,
|
||||
horizontal_alignment = h_alignment
|
||||
});
|
||||
|
||||
void add_hl_price_col(Columns col_key, string header, string prop, string command_prop, IDataGridColumnFilter filter, Color foreground, Color? background, System.Windows.HorizontalAlignment h_alignment) =>
|
||||
add_hl_col(col_key, header, price_binding(prop), prop, command_prop, filter, DataGridFilterKnownTemplates.DoubleMinMax, DefaultColumnWidths.MViewPrice, foreground, background, h_alignment);
|
||||
|
||||
void add_hl_merged_size_col(Columns col_key, string header, string sort_prop, string text_prop, string command_prop, IDataGridColumnFilter filter, Color foreground, System.Windows.HorizontalAlignment h_alignment) =>
|
||||
add_hl_col(col_key, header, new Binding(text_prop), sort_prop, command_prop, filter, DataGridFilterKnownTemplates.UIntMinMax, DefaultColumnWidths.ImpliedDirectMergedSize, foreground, null, h_alignment);
|
||||
|
||||
void add_hl_working_orders_col(Columns col_key, string header, string text_prop, string sort_prop, string command_prop, IDataGridColumnFilter filter, Color foreground, System.Windows.HorizontalAlignment h_alignment) =>
|
||||
add_hl_col(col_key, header, new Binding(text_prop), sort_prop, command_prop, filter, DataGridFilterKnownTemplates.IntMinMax, working_orders_col_width, foreground, null, h_alignment);
|
||||
|
||||
void add_hl_col(
|
||||
Columns col_key, string header, BindingBase binding, string prop, string command_prop,
|
||||
IDataGridColumnFilter filter, string filter_template, double width, Color foreground, Color? background, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) =>
|
||||
columns.Add(new HyperlinkElementColumn<Row, Columns>(
|
||||
col_key, binding, new Binding(command_prop), filter, filter_template) {
|
||||
// it's necessary to have this id populated for grid settings
|
||||
id = bts.shell.MarketViewWindowFactory.col_id(col_key),
|
||||
Header = header,
|
||||
sort_member_path = prop,
|
||||
font_color_override = foreground,
|
||||
background_color_override = background,
|
||||
Width = DefaultColumnWidths.Price,
|
||||
horizontal_alignment = h_alignment
|
||||
});
|
||||
|
||||
BindingBase price_binding(string prop) {
|
||||
var mb = new MultiBinding { Converter = price_converter };
|
||||
mb.Bindings.Add(new Binding(prop) { Mode = BindingMode.OneWay });
|
||||
mb.Bindings.Add(new Binding($"{nameof(Row.security)}.{nameof(SecurityImmutable.ContractSpec)}") { Mode = BindingMode.OneWay });
|
||||
return mb;
|
||||
}
|
||||
//
|
||||
// make font-color immutable for Side, Size, (the font-color rule is hard-coded: MarketData.bid for Buy orders, MarketData.ask for Sells)
|
||||
var col_settings_flags = new Dictionary<string, GridColumnSettingsFeatureFlags> {
|
||||
{ Columns.Bid.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor | GridColumnSettingsFeatureFlags.ImmutableBackgroundColor },
|
||||
{ Columns.Ask.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor | GridColumnSettingsFeatureFlags.ImmutableBackgroundColor},
|
||||
{ Columns.WorkingAsks.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor },
|
||||
{ Columns.WorkingBids.ToString(), GridColumnSettingsFeatureFlags.ImmutableFontColor }
|
||||
};
|
||||
grid_settings_manager = new SimpleGridSettingsManager<Row>(columns, col_settings_flags, row_vms);
|
||||
// this will initialize the immutable properties that correspond to the col_settings_flags above (e.g. Bid/Ask font_color_override, etc.)
|
||||
grid_settings_manager.load_from(settings_manager.current_settings());
|
||||
//
|
||||
_resources.AddRange(
|
||||
state.OnDispatcher().Subscribe(s => {
|
||||
using (rows_view.DeferRefresh()) {
|
||||
if (s.grid != null) {
|
||||
// this means we are not using defaults,
|
||||
// Note: settings_manager in turn notifies grid_settings_manager of this update
|
||||
_settings_manager.instance_settings = s.grid;
|
||||
}
|
||||
if (s.filters is FilterStates filters) {
|
||||
security_filter.load_state(filters.security);
|
||||
bid_price_filter.load_state(filters.bid_price);
|
||||
bid_merged_size_filter.load_state(filters.bid_merged_size);
|
||||
bid_direct_size_filter.load_state(filters.bid_direct_size);
|
||||
bid_implied_size_filter.load_state(filters.bid_implied_size);
|
||||
ask_price_filter.load_state(filters.ask_price);
|
||||
ask_merged_size_filter.load_state(filters.ask_merged_size);
|
||||
ask_direct_size_filter.load_state(filters.ask_direct_size);
|
||||
ask_implied_size_filter.load_state(filters.ask_implied_size);
|
||||
last_price_filter.load_state(filters.last_price);
|
||||
last_price_from_spread_filter.load_state(filters.last_price_from_spread);
|
||||
last_size_filter.load_state(filters.last_size);
|
||||
day_change_filter.load_state(filters.day_change);
|
||||
settlement_filter.load_state(filters.settlement);
|
||||
session_low_filter.load_state(filters.session_low);
|
||||
session_high_filter.load_state(filters.session_high);
|
||||
position_filter.load_state(filters.position);
|
||||
raw_day_position_filter.load_state(filters.raw_day_position);
|
||||
working_bid_volume_filter.load_state(filters.working_bid_volume);
|
||||
working_ask_volume_filter.load_state(filters.working_ask_volume);
|
||||
volume_filter.load_state(filters.volume);
|
||||
security_key_filter.load_state(filters.security_key);
|
||||
}
|
||||
rows_view.set_sort_descriptions(s.sorting_criterion, columns);
|
||||
}
|
||||
}), DataGridFilterHelper.hook_filters(rows_view, security_filter,
|
||||
bid_price_filter, bid_merged_size_filter, bid_direct_size_filter, bid_implied_size_filter,
|
||||
ask_price_filter, ask_merged_size_filter, ask_direct_size_filter, ask_implied_size_filter,
|
||||
last_price_filter, last_price_from_spread_filter, last_size_filter, day_change_filter, settlement_filter,
|
||||
session_low_filter, session_high_filter, position_filter, raw_day_position_filter, working_bid_volume_filter, working_ask_volume_filter, volume_filter, security_key_filter),
|
||||
settings_manager.subscribe_current().OnDispatcher().Subscribe(grid_settings_manager),
|
||||
WorkLoop.Start("MarketView", _refresh)
|
||||
);
|
||||
}
|
||||
|
||||
public ObservableCollection<ColumnBase> columns { get; } = new ObservableCollection<ColumnBase>();
|
||||
|
||||
public SimpleGridSettingsManager<Row> grid_settings_manager { get; }
|
||||
|
||||
public GridSettings get_grid_save_state() {
|
||||
if (_settings_manager.instance_settings == null)
|
||||
return null;
|
||||
else
|
||||
return grid_settings_manager.create();
|
||||
}
|
||||
|
||||
public static IComparer<Row> get_column_comparer(Columns column) {
|
||||
switch (column) {
|
||||
case Columns.Security: return wrap(r => r.security);
|
||||
case Columns.SecurityKey: return wrap(r => r.security.Id);
|
||||
case Columns.Volume: return wrap(r => r.volume);
|
||||
case Columns.Last: return wrap(r => r.last_price);
|
||||
case Columns.LastSize: return wrap(r => r.last_size);
|
||||
case Columns.Position: return wrap(r => r.position);
|
||||
case Columns.WorkingBids: return wrap(r => r.working_bid_volume);
|
||||
case Columns.BidImpliedSize: return wrap(r => r.bid_implied_size);
|
||||
case Columns.BidDirectSize: return wrap(r => r.bid_direct_size);
|
||||
case Columns.BidMergedSize: return wrap(r => r.bid_merged_size);
|
||||
case Columns.Bid: return wrap(r => r.bid_price);
|
||||
case Columns.Ask: return wrap(r => r.ask_price);
|
||||
case Columns.AskMergedSize: return wrap(r => r.ask_merged_size);
|
||||
case Columns.AskDirectSize: return wrap(r => r.ask_direct_size);
|
||||
case Columns.AskImpliedSize: return wrap(r => r.ask_implied_size);
|
||||
case Columns.WorkingAsks: return wrap(r => r.working_ask_volume);
|
||||
case Columns.Settlement: return wrap(r => r.settlement);
|
||||
case Columns.DayChange: return wrap(r => r.day_change);
|
||||
case Columns.SessionLow: return wrap(r => r.session_low);
|
||||
case Columns.SessionHigh: return wrap(r => r.session_high);
|
||||
case Columns.MarketDescription: return wrap(r => r.market_description);
|
||||
case Columns.ClearedAlias: return wrap(r => r.security.cleared_alias());
|
||||
case Columns.ProductDescription: return wrap(r => r.security.product_name());
|
||||
case Columns.HubAlias: return wrap(r => r.security.hub_alias());
|
||||
case Columns.StripName: return wrap(r => r.security.strip_name());
|
||||
case Columns.MicCode: return wrap(r => r.security.mic_code());
|
||||
default: return null;
|
||||
}
|
||||
IComparer<Row> wrap<T>(Func<Row, T> selector) =>
|
||||
Comparer<T>.Default.wrap(selector);
|
||||
}
|
||||
|
||||
#region Filters
|
||||
public IDataGridColumnPersistentFilter<Row, string> security_filter { get; }
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> bid_price_filter { get; } = new DoubleMinMax<Row>(r => r.bid_price, nameof(Row.bid_price));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> bid_merged_size_filter { get; } = new UIntMinMax<Row>(r => r.bid_merged_size, nameof(Row.bid_merged_size));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> bid_direct_size_filter { get; } = new UIntMinMax<Row>(r => r.bid_direct_size, nameof(Row.bid_direct_size));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> bid_implied_size_filter { get; } = new UIntMinMax<Row>(r => r.bid_implied_size, nameof(Row.bid_implied_size));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> ask_price_filter { get; } = new DoubleMinMax<Row>(r => r.ask_price, nameof(Row.ask_price));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> ask_merged_size_filter { get; } = new UIntMinMax<Row>(r => r.ask_merged_size, nameof(Row.ask_merged_size));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> ask_direct_size_filter { get; } = new UIntMinMax<Row>(r => r.ask_direct_size, nameof(Row.ask_direct_size));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> ask_implied_size_filter { get; } = new UIntMinMax<Row>(r => r.ask_implied_size, nameof(Row.ask_implied_size));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> last_price_filter { get; } = new DoubleMinMax<Row>(r => r.last_price, nameof(Row.last_price));
|
||||
public IDataGridColumnPersistentFilter<Row, string> last_price_from_spread_filter { get; } = new RegexFilterVM<Row>(r => r.last_price_from_spread.ToString(), nameof(Row.last_price_from_spread));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> last_size_filter { get; } = new UIntMinMax<Row>(r => r.last_size, nameof(Row.last_size));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> day_change_filter { get; } = new DoubleMinMax<Row>(r => r.day_change, nameof(Row.day_change));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> settlement_filter { get; } = new DoubleMinMax<Row>(r => r.settlement, nameof(Row.settlement));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> session_low_filter { get; } = new DoubleMinMax<Row>(r => r.session_low, nameof(Row.session_low));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> session_high_filter { get; } = new DoubleMinMax<Row>(r => r.session_high, nameof(Row.session_high));
|
||||
public IDataGridColumnPersistentFilter<Row, IntMinMaxState> position_filter { get; } = new IntMinMax<Row>(r => r.position, nameof(Row.position));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> raw_day_position_filter { get; } = new DoubleMinMax<Row>(r => r.raw_day_position, nameof(Row.raw_day_position));
|
||||
public IDataGridColumnPersistentFilter<Row, IntMinMaxState> working_bid_volume_filter { get; } = new IntMinMax<Row>(r => r.working_bid_volume, nameof(Row.working_bid_volume));
|
||||
public IDataGridColumnPersistentFilter<Row, IntMinMaxState> working_ask_volume_filter { get; } = new IntMinMax<Row>(r => r.working_ask_volume, nameof(Row.working_ask_volume));
|
||||
public IDataGridColumnPersistentFilter<Row, ULongMinMaxState> volume_filter { get; } = new ULongMinMax<Row>(r => r.volume, nameof(Row.volume));
|
||||
public IDataGridColumnPersistentFilter<Row, string> security_key_filter { get; } = new RegexFilterVM<Row>(r => r.security_key.ToString(), nameof(Row.security_key));
|
||||
|
||||
public IDataGridColumnPersistentFilter<Row, string> market_description_filter { get; } = new RegexFilterVM<Row>(r => r.security.HasIce ? r.security.Ice.MarketDescription : "", nameof(Row.market_description));
|
||||
public IDataGridColumnPersistentFilter<Row, string> cleared_alias_filter { get; } = new RegexFilterVM<Row>(r => r.security.HasIce ? r.security.Ice.ClearedAlias : "", nameof(Row.cleared_alias));
|
||||
public IDataGridColumnPersistentFilter<Row, string> product_description_filter { get; } = new RegexFilterVM<Row>(r => r.security.HasIce ? r.security.Ice.ProductName : "", nameof(Row.product_description));
|
||||
public IDataGridColumnPersistentFilter<Row, string> hub_alias_filter { get; } = new RegexFilterVM<Row>(r => r.security.HasIce ? r.security.Ice.HubAlias : "", nameof(Row.hub_alias));
|
||||
public IDataGridColumnPersistentFilter<Row, string> strip_name_filter { get; } = new RegexFilterVM<Row>(r => r.security.HasIce ? r.security.Ice.StripName : "", nameof(Row.strip_name));
|
||||
public IDataGridColumnPersistentFilter<Row, string> mic_code_filter { get; } = new RegexFilterVM<Row>(r => r.security.HasIce ? r.security.Ice.MicCode : "", nameof(Row.mic_code));
|
||||
|
||||
|
||||
public FilterStates get_filter_states() {
|
||||
return new FilterStates {
|
||||
security = security_filter.get_state(),
|
||||
bid_price = bid_price_filter.get_state(),
|
||||
bid_merged_size = bid_merged_size_filter.get_state(),
|
||||
bid_direct_size = bid_direct_size_filter.get_state(),
|
||||
bid_implied_size = bid_implied_size_filter.get_state(),
|
||||
ask_price = ask_price_filter.get_state(),
|
||||
ask_merged_size = ask_merged_size_filter.get_state(),
|
||||
ask_direct_size = ask_direct_size_filter.get_state(),
|
||||
ask_implied_size = ask_implied_size_filter.get_state(),
|
||||
last_price = last_price_filter.get_state(),
|
||||
last_price_from_spread = last_price_from_spread_filter.get_state(),
|
||||
last_size = last_size_filter.get_state(),
|
||||
day_change = day_change_filter.get_state(),
|
||||
settlement = settlement_filter.get_state(),
|
||||
session_low = session_low_filter.get_state(),
|
||||
session_high = session_high_filter.get_state(),
|
||||
position = position_filter.get_state(),
|
||||
raw_day_position = raw_day_position_filter.get_state(),
|
||||
working_bid_volume = working_bid_volume_filter.get_state(),
|
||||
working_ask_volume = working_ask_volume_filter.get_state(),
|
||||
volume = volume_filter.get_state(),
|
||||
security_key = security_key_filter.get_state(),
|
||||
market_description = market_description_filter.get_state(),
|
||||
cleared_alias = cleared_alias_filter.get_state(),
|
||||
product_description = product_description_filter.get_state(),
|
||||
hub_alias = hub_alias_filter.get_state(),
|
||||
strip_name = strip_name_filter.get_state(),
|
||||
mic_code = mic_code_filter.get_state(),
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override Row row_factory(SecurityMD smd) => new Row(_bus, smd, _orders_model);
|
||||
protected override void on_row_removed(Row row) => row.Dispose();
|
||||
protected override IEnumerable<SortingCriteria> get_default_sorting() { yield return new SortingCriteria(nameof(Row.security), true); }
|
||||
|
||||
void _refresh() {
|
||||
foreach (var r in _row_vms) r.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -549,24 +549,48 @@
|
||||
</u:BindingUpdateGroupCollection>
|
||||
</u:Behavior.BindingUpdateGroups>
|
||||
</TextBox>
|
||||
<TextBlock
|
||||
<StackPanel
|
||||
x:Name="PART_TickFactors_Label"
|
||||
Grid.Column="2"
|
||||
VerticalAlignment="Center"
|
||||
Margin="{StaticResource Margin.LHeaderPanelItem}"
|
||||
Text="Ticks"
|
||||
IsEnabled="True"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{Binding LegTuples.Count, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource IntNotZeroVisibilityConverter}}"
|
||||
/>
|
||||
<c:TickFactorsPicker
|
||||
>
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Margin="{StaticResource Margin.LHeaderPanelItem}"
|
||||
Text="Ticks ("
|
||||
/>
|
||||
<CheckBox
|
||||
Margin="1,0,0,0"
|
||||
IsChecked="{Binding UseFractionalTicks, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
VerticalAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
Padding="0"
|
||||
>
|
||||
fractional
|
||||
</CheckBox>
|
||||
<TextBlock VerticalAlignment="Center" Margin="1,0,0,0">)</TextBlock>
|
||||
</StackPanel>
|
||||
<Grid
|
||||
x:Name="PART_TickFactors_Picker"
|
||||
Grid.Column="3"
|
||||
Margin="{StaticResource Margin.LHeaderPanelItem}"
|
||||
HorizontalAlignment="Stretch"
|
||||
IsEnabled="True"
|
||||
SelectedTickFactors="{Binding TickFactors, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
||||
Margin="{StaticResource Margin.LHeaderPanelItem}"
|
||||
Visibility="{Binding LegTuples.Count, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource IntNotZeroVisibilityConverter}}"
|
||||
/>
|
||||
>
|
||||
<c:TickFactorsPicker
|
||||
HorizontalAlignment="Stretch"
|
||||
SelectedTickFactors="{Binding TickFactors, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
||||
Visibility="{Binding UseFractionalTicks, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static cv:BooleanToVisibilityConverter.HiddenInstance}}"
|
||||
/>
|
||||
<c:TickUpDownInt
|
||||
HorizontalAlignment="Stretch"
|
||||
Minimum="1"
|
||||
Value="{Binding IntegerTickSize, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Visibility="{Binding UseFractionalTicks, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource FalseVisibilityConverter}}"
|
||||
/>
|
||||
</Grid>
|
||||
<TextBlock
|
||||
x:Name="PART_Pricing_Label"
|
||||
Grid.Column="4"
|
||||
|
||||
@@ -52,6 +52,26 @@ namespace mbts.ui.spark {
|
||||
public TickFactors TickFactors { get => GetValue(TickFactorsProperty) as TickFactors; set => SetValue(TickFactorsProperty, value); }
|
||||
#endregion
|
||||
|
||||
#region UseFractionalTicks
|
||||
public static readonly DependencyProperty UseFractionalTicksProperty = WPFHelper.create_dp<bool, ExecutionStrategyEditor>(
|
||||
nameof(UseFractionalTicks), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, true);
|
||||
|
||||
public bool UseFractionalTicks {
|
||||
get => (bool)GetValue(UseFractionalTicksProperty);
|
||||
set => SetValue(UseFractionalTicksProperty, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IntegerTickSize
|
||||
public static readonly DependencyProperty IntegerTickSizeProperty = WPFHelper.create_dp<int, ExecutionStrategyEditor>(
|
||||
nameof(IntegerTickSize), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, 1);
|
||||
|
||||
public int IntegerTickSize {
|
||||
get => (int)GetValue(IntegerTickSizeProperty);
|
||||
set => SetValue(IntegerTickSizeProperty, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IsNew
|
||||
public static readonly DependencyProperty IsNewProperty =
|
||||
DependencyProperty.Register(
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
ContractPickerModel="{Binding contract_picker_model}"
|
||||
HedgePricing="{Binding hedge_pricing}"
|
||||
HedgePricingItemsSource="{Binding hedge_pricing_options}"
|
||||
UseFractionalTicks="{Binding use_fractional_ticks}"
|
||||
IntegerTickSize="{Binding integer_tick_size}"
|
||||
/>
|
||||
<c:DialogSkirtOKCancel Grid.Row="1" OKCommand="{Binding commit}" CloseOnOK="False"/>
|
||||
</Grid>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using bts.collections;
|
||||
using bts.shell;
|
||||
using bts.spark;
|
||||
using bts.utils;
|
||||
using mbts.ui;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.spark;
|
||||
@@ -30,8 +29,16 @@ namespace mbts.spark {
|
||||
readonly Property<bool> _has_working_orders, _can_add_leg;
|
||||
|
||||
Security _synthetic;
|
||||
bool _set_name_automatically, _set_ticks_automatically, _set_quantities_automatically, _set_price_mults_automatically, _is_setting_quantities, _is_setting_price_mults;
|
||||
bool
|
||||
_set_name_automatically,
|
||||
_set_ticks_automatically,
|
||||
_set_quantities_automatically,
|
||||
_set_price_mults_automatically,
|
||||
_is_setting_quantities,
|
||||
_is_setting_price_mults,
|
||||
_use_fractional_ticks = true;
|
||||
TickFactors _tick_factors;
|
||||
int _integer_tick_size = 1;
|
||||
ExecutionStrategyImmutable _strategy;
|
||||
HedgePricing _hedge_pricing;
|
||||
|
||||
@@ -44,6 +51,10 @@ namespace mbts.spark {
|
||||
: this(synthetic, strategy, false) {
|
||||
ExceptionAssert.InvalidOperation.That(synthetic.Id != 0, "This constructor may only be used for already-existing synthetic securities (id must be non-zero).");
|
||||
_tick_factors = TickUtils.get_regional_ticks(synthetic.ContractSpec).low_tick;
|
||||
if (TickUtils.is_integer_tick(synthetic.ContractSpec)) {
|
||||
_use_fractional_ticks = false;
|
||||
_integer_tick_size = DoubleHelper.to_optional_int32(synthetic.ContractSpec.LowTick) ?? 0;
|
||||
}
|
||||
title = $"Edit '{synthetic.Synthetic.Name}'";
|
||||
icon = Icons.ModifySynthetic;
|
||||
_has_working_orders = backing(nameof(has_working_orders), security_has_working_orders.OnDispatcher());
|
||||
@@ -131,14 +142,14 @@ namespace mbts.spark {
|
||||
flash_error_msg("Name already taken", SparkUtils.UI.MessageFlashDuration, nameof(name)).ignore();
|
||||
valid = false;
|
||||
}
|
||||
if (_tick_factors == null || !_tick_factors.is_valid()) {
|
||||
flash_error_msg("Please select ticks", SparkUtils.UI.MessageFlashDuration, nameof(tick_factors)).ignore();
|
||||
if (use_fractional_ticks ? (_tick_factors == null || !_tick_factors.is_valid()) : integer_tick_size == 0) {
|
||||
flash_error_msg("Please select ticks", SparkUtils.UI.MessageFlashDuration, use_fractional_ticks ? nameof(tick_factors) : nameof(integer_tick_size)).ignore();
|
||||
valid = false;
|
||||
}
|
||||
if (valid) {
|
||||
_synthetic.Synthetic.Legs.SetItems(leg_tuples.Select(l => l.leg));
|
||||
_synthetic.Symbol = _deduce_symbol(_synthetic);
|
||||
_synthetic.ContractSpec = _tick_factors.to_spec();
|
||||
_synthetic.ContractSpec = use_fractional_ticks ? _tick_factors.to_spec() : TickUtils.create_integer_tick_spec(integer_tick_size);
|
||||
uint? id = await model.create_synthetic(new SecurityImmutable(_synthetic));
|
||||
if (id.HasValue && id != 0) {
|
||||
if (await model.save_strategy(id.Value, get_strategy())) {
|
||||
@@ -295,6 +306,20 @@ namespace mbts.spark {
|
||||
public bool has_working_orders => _has_working_orders.Value;
|
||||
public bool is_new { get; }
|
||||
public bool is_new_leg_popup_open { get; set; }
|
||||
public bool use_fractional_ticks {
|
||||
get => _use_fractional_ticks;
|
||||
set {
|
||||
if (Set(ref _use_fractional_ticks, value))
|
||||
_set_ticks_automatically = false;
|
||||
}
|
||||
}
|
||||
public int integer_tick_size {
|
||||
get => _integer_tick_size;
|
||||
set {
|
||||
if (Set(ref _integer_tick_size, value))
|
||||
_set_ticks_automatically = false;
|
||||
}
|
||||
}
|
||||
public bool can_add_leg => _can_add_leg.Value;
|
||||
public SyntheticContract.Types.PriceCalc price_calc { get => _synthetic.Synthetic.PriceCalc; set => _synthetic.Synthetic.PriceCalc = value; }
|
||||
public ObservableCollection<LegSpreaderParamsTuple> leg_tuples { get; } = new ObservableCollection<LegSpreaderParamsTuple>();
|
||||
@@ -323,6 +348,16 @@ namespace mbts.spark {
|
||||
_strategy = strategy;
|
||||
hedge_pricing = strategy.HedgePricing;
|
||||
leg_tuples.SetItems(_get_legs(_synthetic, strategy));
|
||||
if (synthetic.HasContractSpec) {
|
||||
/// assign the fields <see cref="_use_fractional_ticks"/> and <see cref="_integer_tick_size"/>,
|
||||
/// rather than the properties <see cref="use_fractional_ticks"/> and <see cref="integer_tick_size"/>
|
||||
/// because the setters of the former flip <see cref="_set_ticks_automatically"/> to false if the value changes.
|
||||
/// This behavior causes the ticks to be automatically deduced as legs are added/removed,
|
||||
/// until the user explicitly enters a different value (as the properties are bound to tick input controls in the view).
|
||||
Set(ref _use_fractional_ticks, !TickUtils.is_integer_tick(synthetic.ContractSpec), nameof(use_fractional_ticks));
|
||||
if (!use_fractional_ticks)
|
||||
Set(ref _integer_tick_size, DoubleHelper.to_optional_int32(synthetic.ContractSpec.LowTick) ?? 0, nameof(integer_tick_size));
|
||||
}
|
||||
RaisePropertyChanged(nameof(name), nameof(tick_factors));
|
||||
}
|
||||
|
||||
|
||||
@@ -534,13 +534,44 @@ namespace mbts.spark {
|
||||
_size_from_row(row, _price_list, _asks, _vm.security.ContractSpec);
|
||||
|
||||
uint _volume_from_row(int row) {
|
||||
if (_price_list.SafeTryGetAt(row, out var price)) {
|
||||
var vapls = _volume_container.read_new_value();
|
||||
if (vapls != null) {
|
||||
return vapls.SelectFirstOrDefault(v => MathUtils.epsilon_equals(v.Price, price), v => v.Volume);
|
||||
}
|
||||
const int max_tries = 3;
|
||||
var errors = new List<string>(0);
|
||||
int num_tries = 0;
|
||||
for (; num_tries < max_tries; num_tries++) {
|
||||
try {
|
||||
var rv = impl();
|
||||
if (num_tries > 0) {
|
||||
log_errors(true);
|
||||
}
|
||||
return rv;
|
||||
} catch (Exception ex) {
|
||||
errors.Add(ex.ToString());
|
||||
}
|
||||
}
|
||||
log_errors(false);
|
||||
return 0;
|
||||
|
||||
void log_errors(bool succeeded) {
|
||||
// Only log distinct errors to avoid useless noise.
|
||||
// It's likely that the exception will always be the same (IndexOutOfRange),
|
||||
// however, this bug is not fully understood, so assume nothing.
|
||||
var error_msg = string.Join("; ", errors.Distinct());
|
||||
if (succeeded) {
|
||||
Log.Ui.error($"Ladder '{security}' got volume for row at index '{row}' after {num_tries + 1} attempts (price_list array length is {_price_list.Length}). The following exceptions were observed: {error_msg}");
|
||||
} else {
|
||||
Log.Ui.error($"Ladder '{security}' failed to get volume for row at index '{row}' after {max_tries} attempts (price_list array length is {_price_list.Length}): {error_msg}");
|
||||
}
|
||||
}
|
||||
|
||||
uint impl() {
|
||||
if (_price_list.SafeTryGetAt(row, out var price)) {
|
||||
var vapls = _volume_container.read_new_value();
|
||||
if (vapls != null) {
|
||||
return vapls.SelectFirstOrDefault(v => MathUtils.epsilon_equals(v.Price, price), v => v.Volume);
|
||||
}
|
||||
}
|
||||
return 0u;
|
||||
}
|
||||
return 0u;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace mbts.spark {
|
||||
readonly OrderParamsAggregator _selected_params_mon;
|
||||
readonly CommonValueMonitor<SecurityImmutable?> _selected_security_mon = new CommonValueMonitor<SecurityImmutable?>();
|
||||
readonly RightPanelModel _right_panel = new RightPanelModel();
|
||||
readonly CustomStateSynchronizer _custom_state_sync;
|
||||
OrderBookFillsGridSettings _cached_fills_settings = OrderBookStartupData.DefaultFillsGrid;
|
||||
double
|
||||
_raw_right_panel_width = OrderBookStartupData.Default.right_panel_width,
|
||||
@@ -124,6 +125,8 @@ namespace mbts.spark {
|
||||
_row_collection.CollectionChanged += _row_collection_CollectionChanged;
|
||||
_current_row = backing<OrderBookRowVM>(nameof(current_row));
|
||||
_columns.filter_changed += _on_filter_changed;
|
||||
_custom_state_sync = new CustomStateSynchronizer(this);
|
||||
// commands
|
||||
collapse_all_rows_command = new DelegateCommand(_row_collection.collapse_all);
|
||||
expand_all_rows_command = new DelegateCommand(_row_collection.expand_all);
|
||||
var modify_selected_orders_async_cmd = new AsyncCommand(_modify_selected_orders_async, () => _selected_params_mon.all_active && order_mod_vm.is_dirty);
|
||||
@@ -188,56 +191,7 @@ namespace mbts.spark {
|
||||
security_plurality = p;
|
||||
RaisePropertyChanged(nameof(security_plurality));
|
||||
}),
|
||||
Observable.Create<OrderBookRowVM>(o => {
|
||||
OrderBookRowVM last_fired = null;
|
||||
selected_order_changed += on_selected_order_changed;
|
||||
var sub = _current_row.Subscribe(ch => notify());
|
||||
return Disposable.Create(dispose);
|
||||
// local methods
|
||||
void on_selected_order_changed(OrderRecordImmutable? _) =>
|
||||
notify();
|
||||
|
||||
void notify() {
|
||||
var cr = current_row_if_distinct_root_selected();
|
||||
if (!cr.safe_equals(last_fired))
|
||||
o.OnNext(last_fired = cr);
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
Disposable.dispose(ref sub);
|
||||
selected_order_changed -= on_selected_order_changed;
|
||||
}
|
||||
})
|
||||
.SubscribeEach(r => {
|
||||
if (r == null) {
|
||||
current_algo_custom_state.Clear();
|
||||
return Disposable.empty;
|
||||
}
|
||||
r.updated += on_updated;
|
||||
refresh_custom_state();
|
||||
return Disposable.Create(() => r.updated -= on_updated);
|
||||
void on_updated((OrderSecurityRootPair oldval, OrderSecurityRootPair newval) _) =>
|
||||
refresh_custom_state();
|
||||
|
||||
void refresh_custom_state() {
|
||||
current_algo_custom_state.Clear();
|
||||
var dcs = r.order.dynamic_custom_state();
|
||||
// while dcs is not expected to be null, best to play it safe and double check.
|
||||
if (dcs.is_null_or_empty()) {
|
||||
var child_rows = _row_collection.get_descendent_rows(r.order_key);
|
||||
if (_row_collection.filter != null) {
|
||||
child_rows = child_rows.Where(cr => _row_collection.filter(cr.order_tuple));
|
||||
}
|
||||
foreach (var dr in child_rows) {
|
||||
dcs = dr.order.dynamic_custom_state();
|
||||
if (!dcs.is_null_or_empty())
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (var p in dcs.empty_if_null().OrderBy(kv => kv.Key))
|
||||
current_algo_custom_state.Add(new NamedValueVM(p.Key, DynamicOrderHelper.fmt_param(p.Value)));
|
||||
}
|
||||
}),
|
||||
_current_row.Subscribe(_ => _custom_state_sync.sync()),
|
||||
orders_source.OnDispatcher().Subscribe(t => {
|
||||
if (_selected_rows.Count == 0) {
|
||||
_cached_orders = t.state;
|
||||
@@ -257,6 +211,8 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
}
|
||||
_custom_state_sync.sync(true);
|
||||
orders_changed?.Invoke();
|
||||
}),
|
||||
model.on_orders_can_attach.OnDispatcher().Subscribe(table => {
|
||||
_cached_attachable = new MappedDictionary<uint, KeyValuePair<uint, bool>, bool>(table.state, kv => kv.Value);
|
||||
@@ -402,15 +358,6 @@ namespace mbts.spark {
|
||||
}
|
||||
void on_end_attaching() => Disposable.dispose(ref attach_vm_hooks);
|
||||
|
||||
// the output grid (custom state) in the right panel
|
||||
// will only display info for the 'current_row'
|
||||
// if all selected rows are of the same root order.
|
||||
OrderBookRowVM current_row_if_distinct_root_selected() =>
|
||||
current_row != null &&
|
||||
selected_rows.Select(r => r.order_tuple.root.order.Key).Distinct().TryGetSingle(out uint droot) &&
|
||||
current_row.order_tuple.root.order.Key == droot ?
|
||||
current_row : null;
|
||||
|
||||
IDisposable connect_order_mod_vm() =>
|
||||
Disposable.Create(
|
||||
_selected_params_mon.subscribe_algos().OnDispatcher().Subscribe(order_mod_vm.algo_vm.load_many),
|
||||
@@ -434,7 +381,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
public event Action<OrderRecordImmutable?> selected_order_changed;
|
||||
public event Action begin_attaching, end_attaching;
|
||||
public event Action begin_attaching, end_attaching, orders_changed;
|
||||
public event Action<(IEnumerable, bool)> request_selection;
|
||||
|
||||
public ObservableAppendCollection<DIYGrid.ColumnBase> columns { get; }
|
||||
@@ -534,6 +481,28 @@ namespace mbts.spark {
|
||||
public IObservable<bool> subscribe_show_fills() => _show_fills.observe_current(true);
|
||||
public IObservable<bool> subscribe_show_ladder() => _show_ladder.observe_current(true);
|
||||
public IObservable<bool> subscribe_show_order_params() => _show_order_params.observe_current(true);
|
||||
public IObservable<OrderSecurityAlgo?> subscribe_single_selected_order() =>
|
||||
Observable.Create<OrderSecurityAlgo?>(o => {
|
||||
OrderSecurityAlgo? last_fired = null;
|
||||
orders_changed += notify;
|
||||
_current_row.Changed += on_current_row_changed;
|
||||
notify();
|
||||
return Disposable.Create(dispose);
|
||||
// local methods
|
||||
void notify() {
|
||||
var next = current_row == null ? (OrderSecurityAlgo?)null : current_row.order_tuple.order;
|
||||
if (next != last_fired)
|
||||
o.OnNext(last_fired = next);
|
||||
}
|
||||
|
||||
void on_current_row_changed(OrderBookRowVM oldval, OrderBookRowVM newval) =>
|
||||
notify();
|
||||
|
||||
void dispose() {
|
||||
orders_changed -= notify;
|
||||
_current_row.Changed -= on_current_row_changed;
|
||||
}
|
||||
});
|
||||
|
||||
public void row_selection_changed(SelectionChangedEventArgs e) {
|
||||
try {
|
||||
@@ -563,6 +532,7 @@ namespace mbts.spark {
|
||||
_can_attach_selected_orders.refresh();
|
||||
_can_detach_selected_orders.refresh();
|
||||
selected_order_changed?.Invoke(current_order);
|
||||
_custom_state_sync.sync();
|
||||
} catch (Exception ex) {
|
||||
// [John]I observed a strange null-reference exception in this callback when the launcher was shutting down (see https://bluetradesys.atlassian.net/browse/SPARK-2089)
|
||||
Log.Ui.error($"[{nameof(OrderBookVM)}] Error handling selection change: {ex}");
|
||||
@@ -783,6 +753,45 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
|
||||
class CustomStateSynchronizer {
|
||||
readonly OrderBookVM _vm;
|
||||
OrderBookRowVM _synced_row;
|
||||
|
||||
public CustomStateSynchronizer(OrderBookVM vm) =>
|
||||
_vm = vm;
|
||||
|
||||
public void sync(bool force_refresh = false) {
|
||||
var row = _vm.current_row != null &&
|
||||
_vm.selected_rows.Select(r => r.order_tuple.root.order.Key).Distinct().TryGetSingle(out uint droot) &&
|
||||
_vm.current_row.order_tuple.root.order.Key == droot ?
|
||||
_vm.current_row : null;
|
||||
if (force_refresh || row != _synced_row) {
|
||||
_synced_row = row;
|
||||
_refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void _refresh() {
|
||||
_vm.current_algo_custom_state.Clear();
|
||||
if (_synced_row == null)
|
||||
return;
|
||||
var dcs = _synced_row.order.dynamic_custom_state();
|
||||
// while dcs is not expected to be null, best to play it safe and double check.
|
||||
if (dcs.is_null_or_empty()) {
|
||||
var descendent_rows = _vm._row_collection.get_descendent_rows(_synced_row.order_key);
|
||||
if (_vm._row_collection.filter != null)
|
||||
descendent_rows = descendent_rows.Where(child => _vm._row_collection.filter(child.order_tuple));
|
||||
foreach (var dr in descendent_rows) {
|
||||
dcs = dr.order.dynamic_custom_state();
|
||||
if (!dcs.is_null_or_empty())
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (var p in dcs.empty_if_null().OrderBy(kv => kv.Key))
|
||||
_vm.current_algo_custom_state.Add(new NamedValueVM(p.Key, DynamicOrderHelper.fmt_param(p.Value)));
|
||||
}
|
||||
}
|
||||
|
||||
public class OrderParamsVM : DisposableViewModelBase {
|
||||
readonly SelectorProperty<AccountTuple, AccountTuple?> _accounts;
|
||||
readonly OrderBookVM _owner;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.api.orderman;
|
||||
using bts.shell;
|
||||
using bts.shell.fills;
|
||||
@@ -6,9 +7,11 @@ using bts.shell.orderbook;
|
||||
using bts.spark;
|
||||
using bts.view;
|
||||
using mbts.persist;
|
||||
using mbts.spark.utilities;
|
||||
using mbts.ui;
|
||||
using mbts.ui.extensions;
|
||||
using mbts.ui.spark;
|
||||
using mbts.ui.utilities;
|
||||
using mbts.ui.utility;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
@@ -24,7 +27,10 @@ namespace mbts.spark {
|
||||
const string _window_type = "OrderBook", _default_title = "Order Book";
|
||||
readonly INotificationService _notification_service;
|
||||
readonly IWindowSettingsManager<OrderBookGridSettings> _settings_manager;
|
||||
readonly bool _can_edit_specific_algo_params;
|
||||
IDisposable _attachment_exit_sub;
|
||||
// initialized in thread_init
|
||||
List<IDisposable> _thread_init_resources;
|
||||
OrderBookStartupData _state;
|
||||
OrdersModel _model;
|
||||
OrderBookVM _vm;
|
||||
@@ -34,13 +40,14 @@ namespace mbts.spark {
|
||||
SparkCommand[] _commands;
|
||||
|
||||
public OrderBookWindow(OrdersModel model, OrderBookWindowFactory factory, IBus bus, INotificationService notification_service,
|
||||
OrderBookStartupData state, ImageSource icon, IWindowSettingsManager<OrderBookGridSettings> settings_manager)
|
||||
OrderBookStartupData state, ImageSource icon, IWindowSettingsManager<OrderBookGridSettings> settings_manager, bool can_edit_specific_algo_params)
|
||||
: base(_default_title, bus, factory, SparkCommands.ShowOrders.icon) {
|
||||
_model = model;
|
||||
_factory = factory;
|
||||
_notification_service = notification_service;
|
||||
_state = state;
|
||||
_settings_manager = settings_manager;
|
||||
_can_edit_specific_algo_params = can_edit_specific_algo_params;
|
||||
thread_id = config.Configuration.get<bts.config.MultiThreadedWindows>().order_book ? "OrderBook" : null;
|
||||
}
|
||||
|
||||
@@ -64,12 +71,14 @@ namespace mbts.spark {
|
||||
public string thread_id { get; }
|
||||
|
||||
public override void Dispose() {
|
||||
_commands.OfType<IDisposable>().DisposeAll();
|
||||
Disposable.dispose(_thread_init_resources);
|
||||
Disposable.dispose(ref _attachment_exit_sub);
|
||||
Disposable.dispose(ref _vm);
|
||||
}
|
||||
|
||||
public void thread_init() {
|
||||
Log.assert(_thread_init_resources == null, $"{nameof(_thread_init_resources)} must be initialized in thread_init.");
|
||||
_thread_init_resources = new List<IDisposable>();
|
||||
_menu_display_vm = new SparkMenuDisplayVM();
|
||||
if (_state != null)
|
||||
_menu_display_vm.load_from(_state.menu_display);
|
||||
@@ -147,6 +156,15 @@ namespace mbts.spark {
|
||||
can_execute: () => _vm.selected_orders.Any(x => passes_recreate_search_criteria(x))
|
||||
);
|
||||
recreate_selected_orders_command.group = CommandGroups.Modify;
|
||||
ICommand edit_algo_params_cmd;
|
||||
if (_can_edit_specific_algo_params) {
|
||||
_thread_init_resources.Add(CommandHelper.bind_param_source(
|
||||
new DialogCommand<OrderSecurityAlgo?, Window>(mk_algo_params_dialog, has_algo_params),
|
||||
_vm.subscribe_single_selected_order(),
|
||||
out edit_algo_params_cmd, true));
|
||||
} else {
|
||||
edit_algo_params_cmd = DelegateCommand.empty;
|
||||
}
|
||||
|
||||
var attach_selected_orders_command = new SparkCommandCommand(
|
||||
"Attach To Selected",
|
||||
@@ -194,14 +212,22 @@ namespace mbts.spark {
|
||||
show_grid_settings_command.group = CommandGroups.Auxiliary;
|
||||
|
||||
_commands = new SparkCommand[] {
|
||||
// modify commands
|
||||
toggle_show_right_panel_command,
|
||||
attach_selected_orders_command,
|
||||
detach_selected_orders_command,
|
||||
recreate_selected_orders_command,
|
||||
new SparkCommandCommand("Algo Params...", Icons.Algo, edit_algo_params_cmd) {
|
||||
group = CommandGroups.Modify,
|
||||
show_in_toolbar = false,
|
||||
show_in_context_menu = _can_edit_specific_algo_params
|
||||
},
|
||||
// cancel commands
|
||||
cancel_selected_orders_command,
|
||||
cancel_buy_orders_command,
|
||||
cancel_sell_orders_command,
|
||||
cancel_all_orders_command,
|
||||
|
||||
toggle_collapse_all_command,
|
||||
toggle_expand_all_command,
|
||||
show_grid_settings_command,
|
||||
@@ -210,9 +236,12 @@ namespace mbts.spark {
|
||||
hidden_cmd(new SparkCommandCommand(OrderBookView.CommandDescriptions.RevertOrders, null, _vm.revert_selected_orders_cmd, OrderBookView.KeyboardShortcuts.RevertOrders)),
|
||||
_menu_display_vm.spark_cmd
|
||||
};
|
||||
_vm.as_demuxer().subscribe<bool>(nameof(OrderBookVM.show_right_panel))
|
||||
.Subscribe(_ => toggle_show_right_panel_command.title = get_toggle_show_right_panel_cmd_title());
|
||||
_thread_init_resources.AddRange(_commands.OfType<IDisposable>());
|
||||
_thread_init_resources.Add(_vm.as_demuxer()
|
||||
.subscribe<bool>(nameof(OrderBookVM.show_right_panel))
|
||||
.Subscribe(_ => toggle_show_right_panel_command.title = get_toggle_show_right_panel_cmd_title()));
|
||||
_vm.selected_order_changed += vm_selected_order_changed;
|
||||
_thread_init_resources.Add(Disposable.Create(() => _vm.selected_order_changed -= vm_selected_order_changed));
|
||||
// local methods
|
||||
string get_toggle_show_right_panel_cmd_title() =>
|
||||
_vm.show_right_panel ? OrderBookView.CommandDescriptions.HideRightPanel : OrderBookView.CommandDescriptions.ShowRightPanel;
|
||||
@@ -234,6 +263,36 @@ namespace mbts.spark {
|
||||
attach_selected_orders_command.raiseCanExecuteChanged();
|
||||
detach_selected_orders_command.raiseCanExecuteChanged();
|
||||
}
|
||||
|
||||
bool has_algo_params(OrderSecurityAlgo? order) =>
|
||||
order.HasValue && !OrderDataHelper.get_metadata(order.Value.algo.value.CustomCase).NoProps;
|
||||
|
||||
Window mk_algo_params_dialog(OrderSecurityAlgo? order) {
|
||||
if (!has_algo_params(order))
|
||||
return null;
|
||||
var algo_def = AlgoDefinitionVM.create(_model, order.Value.algo, editing_permissions: AlgoEditingPermissions.AllowEditValues);
|
||||
var algo_params_vm = new OrderBookAlgoParamsVM(algo_def, order.Value.order.is_non_terminal());
|
||||
var dialog = new OrderBookAlgoParamsDialog {
|
||||
Content = algo_params_vm
|
||||
};
|
||||
ui.WindowStyle.SetTitleContent(dialog, algo_def);
|
||||
dialog.Closed += (s, e) => {
|
||||
Disposable.dispose(ref algo_params_vm);
|
||||
dialog = null;
|
||||
};
|
||||
algo_params_vm.RequestCommit += commit;
|
||||
algo_params_vm.RequestClose += (s, e) => close_dialog();
|
||||
return dialog;
|
||||
|
||||
void close_dialog() {
|
||||
dialog?.Close();
|
||||
dialog = null;
|
||||
}
|
||||
void commit(CustomOrderDefinitionImmutable value) {
|
||||
_model.update_order(order.Value.order, new_algo: value).ignore();
|
||||
close_dialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnParentViewCreated(SparkWindowView parent_view) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using bts.api;
|
||||
using bts.shell.orderbook;
|
||||
using bts.spark;
|
||||
using mbts.config;
|
||||
using mbts.persist;
|
||||
using mbts.spark;
|
||||
using mbts.ui;
|
||||
@@ -15,8 +16,11 @@ namespace bts.shell {
|
||||
readonly INotificationServiceDataCache _notification_service_data_cache;
|
||||
readonly OrdersModel _model;
|
||||
readonly UserSettingsHub _settings_hub;
|
||||
readonly OrderBookConfig _config;
|
||||
|
||||
public OrderBookWindowFactory(IShellModule owner, IBus bus, INotificationService notification_service, INotificationServiceDataCache notification_service_data_cache, OrdersModel model, UserSettingsHub settings_hub) : base(owner, "SparkOrderBookWindow") {
|
||||
var raw_config = Configuration.get<bts.config.OrderBookOptions>();
|
||||
_config = new OrderBookConfig(raw_config.can_edit_specific_algo_params);
|
||||
_bus = bus;
|
||||
_notification_service = notification_service;
|
||||
_notification_service_data_cache = notification_service_data_cache;
|
||||
@@ -29,7 +33,8 @@ namespace bts.shell {
|
||||
var settings_manager = new WindowSettingsManager<OrderBookGridSettings>(_settings_hub, state.grid_settings_wrapper(),
|
||||
us => us.order_book_grid ?? OrderBookStartupData.DefaultGrid,
|
||||
(us, s) => us.with(order_book_grid: s));
|
||||
var w = new OrderBookWindow(_model, this, _bus, _notification_service, state, SparkCommands.ShowOrders.icon, settings_manager.as_non_shared());
|
||||
var w = new OrderBookWindow(_model, this, _bus, _notification_service, state,
|
||||
SparkCommands.ShowOrders.icon, settings_manager.as_non_shared(), _config.can_edit_specific_algo_params);
|
||||
return Task.FromResult<IShellWindow>(w);
|
||||
}
|
||||
|
||||
@@ -37,5 +42,12 @@ namespace bts.shell {
|
||||
var w = await load(startup_data);
|
||||
_bus.post(SparkTags.ShowWindow, w);
|
||||
}
|
||||
|
||||
readonly struct OrderBookConfig {
|
||||
public readonly bool can_edit_specific_algo_params;
|
||||
|
||||
public OrderBookConfig(bool can_edit_specific_algo_params) =>
|
||||
this.can_edit_specific_algo_params = can_edit_specific_algo_params;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<Window
|
||||
x:Class="bts.shell.orderbook.OrderBookAlgoParamsDialog"
|
||||
x:ClassModifier="internal"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sp="clr-namespace:mbts.spark"
|
||||
xmlns:ob="clr-namespace:bts.shell.orderbook"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
u:WindowStyle.SizeToContent="WidthAndHeight"
|
||||
Margin="0"
|
||||
Padding="0"
|
||||
Style="{StaticResource BTSWindowTitleTemplate}"
|
||||
>
|
||||
<u:WindowStyle.TitleContentTemplate>
|
||||
<DataTemplate DataType="{x:Type sp:AlgoDefinitionVM}">
|
||||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
|
||||
<usp:OrderTypeItem Margin="4,0" DisplayName="{Binding name, StringFormat='{}{0} Params'}" BadgeFill="{Binding badge_fill}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</u:WindowStyle.TitleContentTemplate>
|
||||
<Window.ContentTemplate>
|
||||
<DataTemplate DataType="{x:Type ob:OrderBookAlgoParamsVM}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<usp:AlgoEditorGridView
|
||||
Width="390"
|
||||
Margin="5"
|
||||
AlgoParamRows="{Binding param_rows}"
|
||||
CanUserChangeAlgoRoot="False"
|
||||
/>
|
||||
<c:DialogSkirt Grid.Row="1" RightItems="{Binding dialog_skirt}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Window.ContentTemplate>
|
||||
</Window>
|
||||
@@ -0,0 +1,49 @@
|
||||
using bts.api.orderman;
|
||||
using bts.collections;
|
||||
using mbts.spark;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.shell;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
namespace bts.shell.orderbook {
|
||||
/// <summary>
|
||||
/// Interaction logic for OrderBookAlgoParamsDialog.xaml
|
||||
/// </summary>
|
||||
partial class OrderBookAlgoParamsDialog : Window {
|
||||
public OrderBookAlgoParamsDialog() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
class OrderBookAlgoParamsVM : DisposableViewModelBase, IRequestViewClose {
|
||||
readonly ObservableAggregateCollection<AlgoParamRowVM> _param_rows = new ObservableAggregateCollection<AlgoParamRowVM>();
|
||||
readonly DialogSkirtItem _commit, _cancel;
|
||||
|
||||
public OrderBookAlgoParamsVM(AlgoDefinitionVM algo_definition, bool can_user_edit) {
|
||||
this.algo_definition = algo_definition;
|
||||
_dispose = AlgoParamRowsHelper.connect(algo_definition, _param_rows, false);
|
||||
_commit = new DialogSkirtItem("OK", new DelegateCommand(commit, () => can_user_edit)) { is_default = true };
|
||||
_cancel = new DialogSkirtItem("Cancel", new DelegateCommand(close)) { is_cancel = true };
|
||||
// local methods
|
||||
void commit() {
|
||||
RequestCommit?.Invoke(new CustomOrderDefinitionImmutable(algo_definition.algo_root.created_assigned()));
|
||||
close();
|
||||
}
|
||||
void close() => RequestClose?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public event EventHandler RequestClose;
|
||||
public event Action<CustomOrderDefinitionImmutable> RequestCommit;
|
||||
|
||||
public AlgoDefinitionVM algo_definition { get; }
|
||||
public IReadOnlyObservableCollection<AlgoParamRowVM> param_rows => _param_rows;
|
||||
public IEnumerable<DialogSkirtItem> dialog_skirt {
|
||||
get {
|
||||
yield return _commit;
|
||||
yield return _cancel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ namespace bts.shell.pnl {
|
||||
security_type_cell = _cell_map.add(ColumnKeys.SecurityType, d => d.security?.ContractCase ?? Security.ContractOneofCase.None);
|
||||
exchange_cell = _cell_map.add(ColumnKeys.Exchange, d => d.security?.Exchange ?? Venue.Unset);
|
||||
symbol_cell = _cell_map.add(ColumnKeys.Symbol, d => d.security?.Symbol ?? string.Empty);
|
||||
security_cell = _cell_map.add(ColumnKeys.Security, d => (d.security), null, EqualityComparer<SecurityImmutable?>.Default, Comparer<SecurityImmutable>.Default.to_nullable());
|
||||
security_cell = _cell_map.add(ColumnKeys.Security, d => d.security, null, EqualityComparer<SecurityImmutable?>.Default, Comparer<SecurityImmutable>.Default.to_nullable());
|
||||
security_key = _cell_map.add(ColumnKeys.SecurityKey, d => d.key.security_id);
|
||||
cpp = _cell_map.add(ColumnKeys.CPP, d => d.cpp);
|
||||
// sod
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace mbts.spark
|
||||
{
|
||||
return;
|
||||
}
|
||||
var ev = fd.EnumType.Values.First(x => x.Name == value)?.Number;
|
||||
var ev = fd.EnumType.Values.FirstOrDefault(x => x.Name == value)?.Number;
|
||||
if(ev.HasValue)
|
||||
fd.Accessor.SetValue(message, ev.Value);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using bts.api;
|
||||
using bts.api.orderman;
|
||||
using bts.collections;
|
||||
using bts.spark;
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.Reflection;
|
||||
using mbts.collections;
|
||||
@@ -15,21 +14,19 @@ using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reflection;
|
||||
using AlgoType = bts.api.orderman.CustomOrderDefinition.CustomOneofCase;
|
||||
|
||||
namespace mbts.spark {
|
||||
static partial class OrderTypeVMFactory
|
||||
{
|
||||
internal class GenericOrderFactory
|
||||
{
|
||||
static public IAlgoVM create_vm(AlgoKey key, AlgoType algo_type, string display_name, AlgoEditingPermissions editing_permissions)
|
||||
{
|
||||
static partial class OrderTypeVMFactory {
|
||||
internal class GenericOrderFactory {
|
||||
static public IAlgoVM create_vm(AlgoKey key, AlgoType algo_type, string display_name, AlgoEditingPermissions editing_permissions) {
|
||||
var prop = typeof(CustomOrderDefinition).GetProperty(algo_type.ToString(),
|
||||
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
|
||||
BindingFlags.Instance | BindingFlags.Public);
|
||||
var rt = prop.PropertyType;
|
||||
|
||||
var propi = typeof(CustomOrderDefinitionImmutable).GetProperty(algo_type.ToString(),
|
||||
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
|
||||
BindingFlags.Instance | BindingFlags.Public);
|
||||
var rti = propi.PropertyType;
|
||||
|
||||
var vmt = typeof(GenericOrderVM<,>);
|
||||
@@ -38,38 +35,33 @@ namespace mbts.spark {
|
||||
object vm = Activator.CreateInstance(makevm, key, algo_type, display_name, editing_permissions);
|
||||
return (IAlgoVM)vm;
|
||||
}
|
||||
static public void setup_generic_custom_order(CustomOrderDefinition custom, CustomOrderDefinition.CustomOneofCase type)
|
||||
{
|
||||
static public void setup_generic_custom_order(CustomOrderDefinition custom, CustomOrderDefinition.CustomOneofCase type) {
|
||||
var prop = typeof(CustomOrderDefinition).GetProperty(type.ToString(),
|
||||
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
|
||||
BindingFlags.Instance | BindingFlags.Public);
|
||||
var rt = prop.PropertyType;
|
||||
var rtt = Activator.CreateInstance(rt);
|
||||
|
||||
|
||||
var ci = rt.GetProperties().Where(x => x.PropertyType == typeof(CustomOrderDefinition));
|
||||
foreach(var cid in ci)
|
||||
foreach (var cid in ci)
|
||||
cid.SetValue(rtt, new CustomOrderDefinition { Limit = new LimitOrderDefinition() });
|
||||
prop.SetValue(custom, rtt);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class GenericOrderVM<TMutable, TImmutable> : OrderTypeVMBase<TMutable, TImmutable>
|
||||
where TMutable : class, IMessage, new() where TImmutable : struct, IImmutableMessage
|
||||
{
|
||||
where TMutable : class, IMessage, new() where TImmutable : struct, IImmutableMessage {
|
||||
readonly ObservableKeyedCollection<GenericOrderParamVM<TMutable>, string> _parameters =
|
||||
new ObservableKeyedCollection<GenericOrderParamVM<TMutable>, string>(vm => vm.descriptor.Name);
|
||||
readonly AlgoType _algo_type;
|
||||
|
||||
public GenericOrderVM(AlgoKey key, AlgoType algo_type, string display_name, AlgoEditingPermissions editing_permissions)
|
||||
: base(key, display_name, editing_permissions)
|
||||
{
|
||||
: base(key, display_name, editing_permissions) {
|
||||
_algo_type = algo_type;
|
||||
_parameters = new ObservableKeyedCollection<GenericOrderParamVM<TMutable>, string>(vm => vm.descriptor.Name);
|
||||
_resources.AddRange(
|
||||
ObservableAutoWrapper.connect_item_hooks(_parameters, p =>
|
||||
{
|
||||
ObservableAutoWrapper.connect_item_hooks(_parameters, p => {
|
||||
p.PropertyChanged += on_param_prop_changed;
|
||||
return Disposable.Create(() =>
|
||||
{
|
||||
return Disposable.Create(() => {
|
||||
p.PropertyChanged -= on_param_prop_changed;
|
||||
remove_property(p.descriptor.Name);
|
||||
p.Dispose();
|
||||
@@ -80,84 +72,74 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
public string algo_type => _algo_type.ToString();
|
||||
public override string abbreviation =>
|
||||
public override string abbreviation =>
|
||||
model == null ? display_name : model.factory.abbreviate_algo(new OneOf<CustomOrderDefinition.CustomOneofCase, string>(_algo_type));
|
||||
public override AlgoDisplayGroup group => AlgoDisplayGroup.API;
|
||||
public ObservableCollection<GenericOrderParamVM<TMutable>> parameters => _parameters;
|
||||
|
||||
protected override void on_model_internal()
|
||||
{
|
||||
protected override void on_model_internal() =>
|
||||
_sync_generic_params();
|
||||
}
|
||||
|
||||
void _sync_generic_params()
|
||||
{
|
||||
if (model != null)
|
||||
{
|
||||
Google.Protobuf.Reflection.MessageDescriptor desc = new TMutable().Descriptor;
|
||||
void _sync_generic_params() {
|
||||
if (model != null) {
|
||||
MessageDescriptor desc = new TMutable().Descriptor;
|
||||
_parameters.SyncWithDictionary(
|
||||
desc.Fields.InDeclarationOrder().Where(_is_value_param_desc).ToDictionary(p => p.Name), _mk_param_vm);
|
||||
}
|
||||
}
|
||||
static bool _is_value_param_desc(FieldDescriptor desc)
|
||||
{
|
||||
return (desc.FieldType != Google.Protobuf.Reflection.FieldType.Message ||
|
||||
|
||||
static bool _is_value_param_desc(FieldDescriptor desc) =>
|
||||
(desc.FieldType != FieldType.Message ||
|
||||
_is_quantity_measure_desc(desc));
|
||||
}
|
||||
|
||||
static bool _is_quantity_measure_desc(FieldDescriptor desc)
|
||||
{
|
||||
return desc.FieldType == Google.Protobuf.Reflection.FieldType.Message &&
|
||||
static bool _is_quantity_measure_desc(FieldDescriptor desc) =>
|
||||
desc.FieldType == FieldType.Message &&
|
||||
desc.MessageType.FullName == typeof(bts.spark.QuantityMeasure).FullName;
|
||||
}
|
||||
|
||||
protected override IEnumerable<ChildAlgoData> get_selector_data()
|
||||
{
|
||||
var v = OrderDataHelper.get_child_algo_data(_algo_type);
|
||||
return v;
|
||||
}
|
||||
protected override IEnumerable<ChildAlgoData> get_selector_data() =>
|
||||
OrderDataHelper.get_child_algo_data(_algo_type);
|
||||
|
||||
GenericOrderParamVM<TMutable> _mk_param_vm(FieldDescriptor descriptor)
|
||||
{
|
||||
GenericOrderParamVM<TMutable> _mk_param_vm(FieldDescriptor descriptor) {
|
||||
ExceptionAssert.Argument.NotNull(descriptor, nameof(descriptor));
|
||||
|
||||
if (descriptor.FieldType == FieldType.Message &&
|
||||
descriptor.MessageType.FullName == typeof(bts.spark.QuantityMeasure).FullName)
|
||||
{
|
||||
if (descriptor.FieldType == FieldType.Message &&
|
||||
descriptor.MessageType.FullName == typeof(bts.spark.QuantityMeasure).FullName) {
|
||||
var qm = new GenericOrderQuantityVM<TMutable>(descriptor);
|
||||
return attached(qm, GenericOrderHelper.get_quantity_value, GenericOrderHelper.set_quantity_value);
|
||||
}
|
||||
else if(descriptor.FieldType == FieldType.Enum)
|
||||
{
|
||||
var pvm = new GenericOrderEnumeratedVM<TMutable>(descriptor);
|
||||
attached(pvm, GenericOrderHelper.get_enumerated_value, GenericOrderHelper.set_enumerated_value);
|
||||
return pvm;
|
||||
}
|
||||
else if (descriptor.FieldType == FieldType.Bool)
|
||||
} else if (descriptor.FieldType == FieldType.Enum) {
|
||||
return EnumParamFactory.create(this, descriptor);
|
||||
} else if (descriptor.FieldType == FieldType.Bool) {
|
||||
return mk<bool?, bool>(descriptor, v => v, v => v.GetValueOrDefault());
|
||||
else if (descriptor.FieldType == FieldType.Double || descriptor.FieldType == FieldType.Float)
|
||||
} else if (descriptor.FieldType == FieldType.Double || descriptor.FieldType == FieldType.Float) {
|
||||
return mk<double, double>(descriptor, v => v, v => v, double.NaN);
|
||||
else if (descriptor.FieldType == FieldType.Int32)
|
||||
} else if (descriptor.FieldType == FieldType.Int32) {
|
||||
return mk<int?, int>(descriptor, v => v, v => v.GetValueOrDefault());
|
||||
else if (descriptor.FieldType == FieldType.UInt32)
|
||||
} else if (descriptor.FieldType == FieldType.UInt32) {
|
||||
return mk<uint?, uint>(descriptor, v => v, v => v.GetValueOrDefault());
|
||||
else if (descriptor.FieldType == FieldType.String)
|
||||
} else if (descriptor.FieldType == FieldType.String) {
|
||||
return mk<string, string>(descriptor, v => v, v => v);
|
||||
else
|
||||
return null;
|
||||
} else return null;
|
||||
}
|
||||
GenericOrderParamVM<TMutable, TView, TModel> mk<TView, TModel>(FieldDescriptor fdesc, Func<TModel, TView> convert, Func<TView, TModel> convert_back, TView default_value = default)
|
||||
{
|
||||
var pvm = new GenericOrderParamVM<TMutable, TView, TModel>(fdesc, convert, convert_back);
|
||||
return attached<TView, GenericOrderParamVM<TMutable, TView, TModel>>(pvm, get_from_param, assign_to_param, default_value);
|
||||
|
||||
GenericOrderParamVM<TMutable, TView, TModel> mk<TView, TModel>(
|
||||
FieldDescriptor fdesc,
|
||||
Func<TModel, TView> convert,
|
||||
Func<TView, TModel> convert_back,
|
||||
TView default_value = default) {
|
||||
//
|
||||
var pvm = new GenericOrderParamVM<TMutable, TView, TModel>(fdesc, convert, convert_back);
|
||||
return attached(pvm, get_from_param, assign_to_param, default_value);
|
||||
TView get_from_param(IMessage param, FieldDescriptor fd) => convert(ConvertUtils.try_convert<TModel>(fdesc.Accessor.GetValue(param)));
|
||||
void assign_to_param(IMessage param, FieldDescriptor fd, TView value) => fdesc.Accessor.SetValue(param, convert_back(value));
|
||||
}
|
||||
|
||||
TParam attached<T, TParam>(TParam pvm, Func<IMessage, FieldDescriptor, T> selector, Action<IMessage, FieldDescriptor, T> assign_to_param, T default_value = default) where TParam : GenericOrderParamVM<TMutable>, IGenericOrderParamVM<T>
|
||||
{
|
||||
add_property<T>(
|
||||
TParam attached<T, TParam>(
|
||||
TParam pvm,
|
||||
Func<IMessage, FieldDescriptor, T>
|
||||
selector, Action<IMessage, FieldDescriptor, T> assign_to_param,
|
||||
T default_value = default)
|
||||
where TParam : GenericOrderParamVM<TMutable>, IGenericOrderParamVM<T> {
|
||||
//
|
||||
add_property(
|
||||
pvm.descriptor.Name,
|
||||
mdef => mdef != null ? selector(mdef, pvm.descriptor) : default_value,
|
||||
(mdef, v) => assign_to_param(mdef, pvm.descriptor, v),
|
||||
@@ -166,7 +148,37 @@ namespace mbts.spark {
|
||||
pvm.subscribe_value(),
|
||||
default_value);
|
||||
return pvm;
|
||||
}
|
||||
}
|
||||
|
||||
static class EnumParamFactory {
|
||||
[ThreadStatic]
|
||||
static Dictionary<Type, IFactory> _factories_backing;
|
||||
static Dictionary<Type, IFactory> _factories =>
|
||||
_factories_backing ?? (_factories_backing = new Dictionary<Type, IFactory>());
|
||||
|
||||
public static GenericOrderParamVM<TMutable> create(GenericOrderVM<TMutable, TImmutable> owner, FieldDescriptor descriptor) {
|
||||
if (descriptor.FieldType != FieldType.Enum)
|
||||
throw ExceptionBuilder.Argument.unexpected_case(descriptor.FieldType, $"{nameof(descriptor)}.{nameof(FieldDescriptor.FieldType)}");
|
||||
if (!_factories.TryGetValue(descriptor.EnumType.ClrType, out var f)) {
|
||||
// Impl<T> is a nested type, so parent class's generic type args must be included.
|
||||
_factories[descriptor.EnumType.ClrType] = f = (IFactory)Activator.CreateInstance(typeof(Impl<>)
|
||||
.MakeGenericType(typeof(TMutable), typeof(TImmutable), descriptor.EnumType.ClrType));
|
||||
}
|
||||
return f.create(owner, descriptor);
|
||||
}
|
||||
|
||||
interface IFactory {
|
||||
GenericOrderParamVM<TMutable> create(GenericOrderVM<TMutable, TImmutable> owner, FieldDescriptor descriptor);
|
||||
}
|
||||
|
||||
class Impl<T> : IFactory where T : struct {
|
||||
static readonly Func<T, T?> _convert = v => v;
|
||||
static readonly Func<T?, T> _convert_back = v => v ?? default;
|
||||
|
||||
public GenericOrderParamVM<TMutable> create(GenericOrderVM<TMutable, TImmutable> owner, FieldDescriptor descriptor) =>
|
||||
owner.mk(descriptor, _convert, _convert_back, default);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<LanguageTargets>$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets</LanguageTargets>
|
||||
<LanguageTargets Condition="'$(VisualStudioVersion)'=='16.0'">$(MSBuildToolsPath)\Microsoft.CSharp.targets</LanguageTargets>
|
||||
<ApplicationIcon>logo.ico</ApplicationIcon>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<StartupObject>mbts.ui.shell.App</StartupObject>
|
||||
|
||||
@@ -63,5 +63,20 @@ namespace mbts {
|
||||
|
||||
public static double? nan_nullable(double value) =>
|
||||
double.IsNaN(value) ? (double?)null : value;
|
||||
|
||||
public static int? to_optional_int32(double value) {
|
||||
if (double.IsNaN(value) || double.IsInfinity(value))
|
||||
return null;
|
||||
if (value > 0) {
|
||||
value = Math.Floor(value);
|
||||
if (value <= int.MaxValue)
|
||||
return (int)value;
|
||||
} else if (value < 0) {
|
||||
value = Math.Ceiling(value);
|
||||
if (value >= int.MinValue)
|
||||
return (int)value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +1,39 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace mbts.spark.filters {
|
||||
static class RegexFilterUtils {
|
||||
public static Regex build_regex(string str) {
|
||||
if (str == null)
|
||||
return null;
|
||||
str = str.Trim();
|
||||
if (str == string.Empty)
|
||||
return null;
|
||||
return new Regex(str, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
||||
}
|
||||
}
|
||||
class RegexFilterVM<TRow> : FilterVMBase<TRow, string, string> {
|
||||
string _text = string.Empty;
|
||||
Regex _regex;
|
||||
|
||||
public RegexFilterVM(Func<TRow, string> get_row_val, string prop_name = null) : base(get_row_val, prop_name) { }
|
||||
|
||||
public string text {
|
||||
get => _text;
|
||||
set => _regex = RegexFilterUtils.build_regex(_text = (value ?? string.Empty));
|
||||
}
|
||||
|
||||
public override string get_state() => _text ?? string.Empty;
|
||||
|
||||
protected override bool _get_active() => _regex != null;
|
||||
protected override bool _filter(string value) =>
|
||||
_regex != null && (
|
||||
_regex.IsMatch(value) ||
|
||||
(!string.IsNullOrEmpty(value) && _regex.IsMatch(value.Replace(" ", ""))));
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
protected override void _load_state_internal(string state) => text = state;
|
||||
protected override void _clear() {
|
||||
_close();
|
||||
_text = string.Empty;
|
||||
_regex = null;
|
||||
RaisePropertyChanged(nameof(text));
|
||||
_raise_filter_changed();
|
||||
}
|
||||
}
|
||||
namespace mbts.spark.filters {
|
||||
static class RegexFilterUtils {
|
||||
public static Regex build_regex(string str) {
|
||||
if (str == null)
|
||||
return null;
|
||||
str = str.Trim();
|
||||
if (str == string.Empty)
|
||||
return null;
|
||||
return new Regex(str, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
||||
}
|
||||
}
|
||||
class RegexFilterVM<TRow> : FilterVMBase<TRow, string, string> {
|
||||
string _text = string.Empty;
|
||||
Regex _regex;
|
||||
|
||||
public RegexFilterVM(Func<TRow, string> get_row_val, string prop_name = null) : base(get_row_val, prop_name) { }
|
||||
|
||||
public string text {
|
||||
get => _text;
|
||||
set => _regex = RegexFilterUtils.build_regex(_text = (value ?? string.Empty));
|
||||
}
|
||||
|
||||
public override string get_state() => _text ?? string.Empty;
|
||||
|
||||
protected override bool _get_active() => _regex != null;
|
||||
protected override bool _filter(string value) => _regex != null && _regex.IsMatch(value);
|
||||
protected override void _load_state_internal(string state) => text = state;
|
||||
protected override void _clear() {
|
||||
_close();
|
||||
_text = string.Empty;
|
||||
_regex = null;
|
||||
RaisePropertyChanged(nameof(text));
|
||||
_raise_filter_changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1005,6 +1005,8 @@
|
||||
ContractPickerModel="{Binding contract_picker_model}"
|
||||
HedgePricing="{Binding hedge_pricing}"
|
||||
HedgePricingItemsSource="{Binding hedge_pricing_options}"
|
||||
UseFractionalTicks="{Binding use_fractional_ticks}"
|
||||
IntegerTickSize="{Binding integer_tick_size}"
|
||||
/>
|
||||
<c:DialogSkirt Grid.Row="1" Margin="-4" VerticalAlignment="Top" RightItems="{Binding skirt_items}"/>
|
||||
</Grid>
|
||||
|
||||
@@ -12,6 +12,9 @@ namespace mbts.ui.converters
|
||||
public Visibility VisibilityForFalse { get { return _visfalse; } set { _visfalse = value; } }
|
||||
|
||||
public static BooleanToVisibilityConverter Instance => new BooleanToVisibilityConverter();
|
||||
public static BooleanToVisibilityConverter HiddenInstance => new BooleanToVisibilityConverter {
|
||||
VisibilityForFalse = Visibility.Hidden
|
||||
};
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
|
||||
bool flag = false;
|
||||
|
||||
@@ -49,6 +49,28 @@ namespace mbts.spark {
|
||||
public static double parse(this ContractSpecificationImmutable? spec, string text, double display_multiplier, string nan_text) =>
|
||||
spec.spec_or_default().parse(text, display_multiplier, nan_text);
|
||||
|
||||
public static bool is_integer_tick(ContractSpecificationImmutable spec) =>
|
||||
spec.MainFraction == 0 &&
|
||||
spec.PriceDisplayFormat == 0 &&
|
||||
spec.LowTick > 0 &&
|
||||
MathUtils.is_int(spec.LowTick) &&
|
||||
spec.HighTick > 0 &&
|
||||
MathUtils.is_int(spec.HighTick);
|
||||
|
||||
public static ContractSpecification create_integer_tick_spec(int low_tick) =>
|
||||
create_integer_tick_spec(low_tick, low_tick);
|
||||
|
||||
public static ContractSpecification create_integer_tick_spec(int low_tick, int high_tick) {
|
||||
var rv = SecurityDataHelper.Defaults.ContractSpecification;
|
||||
rv.MainFraction = 0;
|
||||
rv.SubFraction = 0;
|
||||
rv.PriceDisplayFormat = 0;
|
||||
rv.PriceBreak = 0;
|
||||
rv.LowTick = low_tick;
|
||||
rv.HighTick = high_tick;
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static double low_tick(NativePriceSize[] bids, NativePriceSize[] asks) {
|
||||
double low = bids[bids.Length - 1].price;
|
||||
if (double.IsNaN(low))
|
||||
@@ -326,7 +348,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
static bool _check_tick_size(double tick_size) =>
|
||||
(tick_size > 0 && tick_size <= 0.5) || tick_size == 1;
|
||||
tick_size > 0 && (tick_size <= 0.5 || MathUtils.is_int(tick_size));
|
||||
|
||||
struct SpecKey : IEquatable<SpecKey> {
|
||||
public readonly uint denominator, display_digits;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using mbts.ui.converters;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
@@ -12,6 +14,31 @@ namespace mbts.ui.utilities {
|
||||
public static string fmt(string title, KeyGesture key_gesture) =>
|
||||
key_gesture == null ? title : $"{title} ({key_gesture.GetDisplayStringForCulture(CultureInfo.CurrentCulture)})";
|
||||
|
||||
public static IDisposable bind_param_source<T>(ICommand command, IObservable<T> param_source, out ICommand bound_cmd, bool dispose_command_on_dispose = false) {
|
||||
bool initialized = false;
|
||||
bool can_execute = false;
|
||||
T param = default;
|
||||
var bcmd = new DelegateCommand(() => command.Execute(param), () => can_execute);
|
||||
bound_cmd = bcmd;
|
||||
var sub = param_source.Subscribe(p => {
|
||||
param = p;
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
can_execute = command.CanExecute(p);
|
||||
bcmd.RaiseCanExecuteChanged();
|
||||
} else if (can_execute != command.CanExecute(p)) {
|
||||
can_execute = !can_execute;
|
||||
bcmd.RaiseCanExecuteChanged();
|
||||
}
|
||||
});
|
||||
return dispose_command_on_dispose ?
|
||||
Disposable.Create(() => {
|
||||
Disposable.dispose(ref sub);
|
||||
(command as IDisposable)?.Dispose();
|
||||
command = null;
|
||||
}) : sub;
|
||||
}
|
||||
|
||||
#region Paraphrased from https://referencesource.microsoft.com/#PresentationFramework/src/Framework/MS/Internal/Commands/CommandHelpers.cs
|
||||
|
||||
public static bool CanExecuteCommandSource(ICommandSource commandSource) {
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace bts {
|
||||
Plugin,
|
||||
Sdk,
|
||||
Http,
|
||||
iLink3
|
||||
// Please keep this list in sync with logging.h/logging.cpp
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
Session ID Access ID Secret Key Creation Date Expiration Date Environment
|
||||
|
||||
M4D lLtjH74y1Kh5XUJTLyH2 f1K_tROQp2lTIplVp34WxKa7xDUgfFnIteolfik061o 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC1 VEMlkDuLz74OVHSuacQB IuHyYT3b-9KUo3WsuXykt-fXsjzp7L-JOrdCSQZLNl0 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC5 77lzSUwPLlM9obaXh2mK z6aA9qfASDKfZkYTVKFqJd-78i0HZ2Q9ec3CKCYIqHg 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC7 RphzI3rn71oGUEiYnX9e y6OvvPPyoyj2S8YAnE1gFduXT8v29HIMjO5EngYxSNg 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC8 PYBIm2TI9gFPIxmHbuYl 6o-ZolGH2DdeQOlGtJ5Zqoh_kg7VdbxkmjeOHmigKwU 2019-09-03 2020-09-03 CERT
|
||||
|
||||
Session ID Access ID Secret Key Creation Date Expiration Date Environment
|
||||
|
||||
M4D lLtjH74y1Kh5XUJTLyH2 f1K_tROQp2lTIplVp34WxKa7xDUgfFnIteolfik061o 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC1 VEMlkDuLz74OVHSuacQB IuHyYT3b-9KUo3WsuXykt-fXsjzp7L-JOrdCSQZLNl0 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC5 77lzSUwPLlM9obaXh2mK z6aA9qfASDKfZkYTVKFqJd-78i0HZ2Q9ec3CKCYIqHg 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC7 RphzI3rn71oGUEiYnX9e y6OvvPPyoyj2S8YAnE1gFduXT8v29HIMjO5EngYxSNg 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC8 PYBIm2TI9gFPIxmHbuYl 6o-ZolGH2DdeQOlGtJ5Zqoh_kg7VdbxkmjeOHmigKwU 2019-09-03 2020-09-03 CERT
|
||||
|
||||
NGG RYcigz3bSLIIBBF2A2Hq qB1dm9VkTKeXcdQpFzla8B3_jwTgya_-Fk5iyEJvr2E 2020-06-15 2021-06-15 NEWRELEASE
|
||||
|
||||
NGF o4OTmmTLQ7Lv4g6bCm26 HbD3FneMyb9Fu-FkCDLscCczHqFcFE2PyWv978RXGyA 2019-12-20 2020-12-20 NEWRELEASE
|
||||
|
||||
UZE EeFdZ1FPepk6U4k3xBZA 2LjEtdLvBLLB1QuDJ4KiJW6M4dF6IHWd_UKmo7p3_Us 2020-06-24 2021-06-24 NEWRELEASE
|
||||
|
||||
VAE Y8iqatTewuoHX16gghw8 FNcCB3Ks1qleS56quYzH4V7zAu78YY2bCdLRi9tmU9E 2020-06-24 2021-06-24 NEWRELEASE
|
||||
@@ -15,7 +15,7 @@
|
||||
<server name="default">
|
||||
<ip>63.247.113.163</ip>
|
||||
<port>3000</port>
|
||||
<userName>katas2f-ps</userName>
|
||||
<userName>bluetrd-ps</userName>
|
||||
<password>Starts123</password>
|
||||
<getStripInfoMessages>N</getStripInfoMessages>
|
||||
<strategyPreference>New</strategyPreference>
|
||||
@@ -24,8 +24,8 @@
|
||||
<server name="endex">
|
||||
<ip>63.247.113.77</ip>
|
||||
<port>3000</port>
|
||||
<userName>katas2f-ps</userName>
|
||||
<password>Starts123</password>
|
||||
<userName>Value from ICE Support</userName>
|
||||
<password>Value from ICE Support</password>
|
||||
<getStripInfoMessages>N</getStripInfoMessages>
|
||||
<strategyPreference>New</strategyPreference>
|
||||
<localNetworkInterface></localNetworkInterface>
|
||||
|
||||
@@ -1 +1 @@
|
||||
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MarketDataService.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/keycode.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/position_cfg.conf;config/defaults/span.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spreader.proto;config/protos/subprocess.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/sod.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MBOProcessor.cpp;md/MBOServiceServer.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/Product.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityMapper.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ice/ICEUtils.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/service/MarketDataServiceServer.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/mbo_tests.cpp;md/test/md2_tests.cpp;md/test/md_test_utils.cpp;md/test/synthetic_book_merge_tests.cpp;md/vendor/OnixsUtils.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metricsLine truncated
|
||||
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MarketDataService.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/keycode.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/position_cfg.conf;config/defaults/span.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spreader.proto;config/protos/subprocess.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/sod.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MBOProcessor.cpp;md/MBOServiceServer.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/Product.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityMapper.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ice/ICEUtils.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/service/MarketDataServiceServer.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/mbo_tests.cpp;md/test/md2_tests.cpp;md/test/md_test_utils.cpp;md/test/synthetic_book_merge_tests.cpp;md/vendor/OnixsUtils.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metricsLine truncated
|
||||
@@ -580,7 +580,9 @@ bts::api::orderman::RoutingRecord AdminServiceUtils::get_routing_record(const bt
|
||||
rv.set_session(conn_ptr->name());
|
||||
rv.set_operator_id(cme_user_data->operator_id());
|
||||
rv.set_location(cme_user_data->location());
|
||||
|
||||
rv.set_smp_id(cme_user_data->smp_id());
|
||||
|
||||
if (cme_user_data->smp_instruction()== "O")
|
||||
rv.set_smp_instruction(api::orderman::SelfMatchPreventionInstruction::SELF_MATCH_PREVENTION_INSTRUCTION_CANCEL_RESTING);
|
||||
else if (cme_user_data->smp_instruction()== "N")
|
||||
|
||||
@@ -104,6 +104,7 @@ message CustomOrderDefinition
|
||||
SplitterOrderDefinition splitter = 29;
|
||||
ScratchOrderDefinition scratch = 31;
|
||||
ProRataOrderDefinition prorata = 32;
|
||||
DeleteAndCoverDefinition delete_and_cover = 34;
|
||||
|
||||
DynamicOrderDefinition dynamic = 1000;
|
||||
}
|
||||
@@ -144,6 +145,13 @@ message TickOrderDefinition {
|
||||
bool detach_on_toward = 5;
|
||||
CustomOrderDefinition child = 6;
|
||||
}
|
||||
enum LeanOnToward
|
||||
{
|
||||
NO_CHANGE = 0; //continue to lean on initial inside market
|
||||
CANCEL = 1; //cancel algo and order
|
||||
DETACH = 2; //cancel algo but leave order working
|
||||
REPRICE = 3; //lean on new inside market
|
||||
}
|
||||
message LeanOrderDefinition {
|
||||
spark.QuantityMeasure cross_threshold = 1;
|
||||
uint32 max_chase_ticks = 2;
|
||||
@@ -179,6 +187,21 @@ message CoverOrderDefinition {
|
||||
CustomOrderDefinition child = 3;
|
||||
bool cancel_on_external_hedge_cancel = 4;
|
||||
bool cancel_hedges_on_cancel = 5;
|
||||
bool detach_hedges = 6;
|
||||
}
|
||||
message DeleteAndCoverDefinition{
|
||||
// cover
|
||||
uint32 hedge_ticks = 1;
|
||||
bool cancel_on_external_hedge_cancel = 2;
|
||||
bool cancel_hedges_on_cancel = 3;
|
||||
bool detach_hedges = 4;
|
||||
// main child = top
|
||||
spark.QuantityMeasure top_threshold = 10;
|
||||
uint32 ticks_off = 11;
|
||||
// hedge child = Lean
|
||||
spark.QuantityMeasure cross_threshold = 20;
|
||||
uint32 max_chase_ticks = 21;
|
||||
LeanOnToward trade_toward_behavior = 22;
|
||||
}
|
||||
message OffsetOrderDefinition {
|
||||
uint32 tick_offset_on_deploy = 1;
|
||||
@@ -360,7 +383,9 @@ message NativeOrderState {
|
||||
RoutingRecord routing_record = 5;
|
||||
NativeOrderType native_type = 6;
|
||||
string last_transact_time = 7;
|
||||
uint64 last_transact_time_unix_ns = 9;
|
||||
double stop_px = 8;
|
||||
uint64 exchange_order_id64 = 10;
|
||||
}
|
||||
|
||||
// Custom order states
|
||||
@@ -429,7 +454,8 @@ enum TimeInForce {
|
||||
TIME_IN_FORCE_UNDEFINED = 0;
|
||||
TIME_IN_FORCE_DAY = 48;
|
||||
TIME_IN_FORCE_GTC = 49;
|
||||
TIME_IN_FORCE_IOC = 51;
|
||||
TIME_IN_FORCE_IOC = 51; // FAK
|
||||
TIME_IN_FORCE_DATE = 52;
|
||||
}
|
||||
|
||||
enum ManualOrderIndicator {
|
||||
|
||||
@@ -1,130 +1,137 @@
|
||||
#
|
||||
# Common Market data options
|
||||
#
|
||||
|
||||
MarketDataConfig {
|
||||
rule: "DeploymentType.type == 'PROD'"
|
||||
value {
|
||||
use_sim: false
|
||||
}
|
||||
}
|
||||
|
||||
PublisherOptions {
|
||||
rule: "DeploymentType.type == 'dev'"
|
||||
value {
|
||||
disable_heartbeat: true
|
||||
}
|
||||
}
|
||||
|
||||
PlatformMap {
|
||||
value {
|
||||
glbx_platform: "PLATFORM_MDP3ONIXS"
|
||||
ice_platform: "PLATFORM_ICEONIXS"
|
||||
}
|
||||
}
|
||||
|
||||
PublisherNamespace {
|
||||
value {
|
||||
shared_memory_namespace: @System.os_user
|
||||
}
|
||||
}
|
||||
|
||||
CMEOptions {
|
||||
value {
|
||||
feed_engine {
|
||||
name: "mdp3feed"
|
||||
# udp_socket_buffer_size: 425984
|
||||
# channels_per_thread: 1
|
||||
spin_time: 0
|
||||
}
|
||||
channel {
|
||||
id: "*"
|
||||
feed_engine: "mdp3feed"
|
||||
use_tcp_replay: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#to make this work in dev clone the operations repo
|
||||
#go here: c:\\code\\bts\\operations\\ice\\ICE_iMpactMulticastFeed_GettingStarted-1_1_36\\bin\\easyTunnel>
|
||||
#modify the easyTunnelProxy.properties file to replace
|
||||
#tunnel.multicast.interface=10.96.18.37 with your local ip
|
||||
#run easyTunnelProxy.bat BRENT-FI for Brent Full implied
|
||||
#you should see ice data
|
||||
|
||||
ICEOptions {
|
||||
value {
|
||||
channel {
|
||||
name: "oil" #these names are arbitrary and are for debugging
|
||||
market_type: 3
|
||||
uds_market_type: 3
|
||||
market_type: 4 #ICE IPE Gas Oil Futures
|
||||
uds_market_type: 4
|
||||
market_type: 5 #ICE Futures Brent, IPE Brent Futures
|
||||
uds_market_type: 5
|
||||
market_type: 9 #ICE Futures WTI, ICE WTI Crude Futures
|
||||
uds_market_type: 9
|
||||
market_type: 13 #ICE Heating Oil Futures
|
||||
uds_market_type: 13
|
||||
market_type: 15 #ICE NYH (RBOB) Gasoline Futures
|
||||
uds_market_type: 15
|
||||
##market_type: 21 #ICE Futures US Agricultures, Coffee C
|
||||
##uds_market_type: 21
|
||||
##market_type: 23 #ICE Futures US Agricultures, FCOJ A
|
||||
##uds_market_type: 23
|
||||
|
||||
##market_type: 26 #ICE Futures US Financials DX
|
||||
##uds_market_type: 26
|
||||
|
||||
uds_market_type: 11 #ICE WTI-Brent spreads
|
||||
uds_market_type: 14 #ICE Heating Oil/WTI Futures Crack
|
||||
uds_market_type: 16 #ICE NYH (RBOB) Gasoline/WTI Futures Crack
|
||||
uds_market_type: 58 #ICE Futures UI Heating Oil / Brent
|
||||
uds_market_type: 59 #ICE NYH (RBOB) Gasoline/Brent Futures Crack
|
||||
uds_market_type: 66 #ICE NYH (RBOB) Gasoline/Heating Oil Spread
|
||||
uds_market_type: 70 #ICE Heating Oil/LS Gasoil Futures Spread
|
||||
uds_market_type: 71 #ICE LS Gasoil/Brent Futures Crack
|
||||
uds_market_type: 72 #ICE NYH (RBOB) Gasoline/LS Gasoil Futures Spread
|
||||
|
||||
#onixs_log_mode: Debug
|
||||
}
|
||||
# channel {
|
||||
# name: "juice"
|
||||
# market_type: 26 #ICE Futures US Agricultures, FCOJ A
|
||||
# }
|
||||
ice_config_file: "ConnectivityConfiguration.APITest.xml"
|
||||
#ice_config_file: "ConnectivityConfiguration.PerfTest.xml"
|
||||
}
|
||||
}
|
||||
|
||||
MDBootDelayWindow {
|
||||
rule: "DeploymentType.type == 'dev'"
|
||||
value {
|
||||
delay_seconds: 0
|
||||
}
|
||||
}
|
||||
|
||||
MDBootDelayWindow {
|
||||
value {
|
||||
delay_seconds: 120
|
||||
standard {
|
||||
start: "16:30"
|
||||
end: "16:40"
|
||||
}
|
||||
sunday {
|
||||
start: "14:00"
|
||||
end: "14:10"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DisplayFactorOverride {
|
||||
value {
|
||||
override {
|
||||
symbol: "SOM"
|
||||
exchange: "GLBX"
|
||||
type: "SPREAD"
|
||||
price_multiplier: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
#
|
||||
# Common Market data options
|
||||
#
|
||||
|
||||
MarketDataConfig {
|
||||
rule: "DeploymentType.type == 'PROD'"
|
||||
value {
|
||||
use_sim: false
|
||||
}
|
||||
}
|
||||
|
||||
PublisherOptions {
|
||||
rule: "DeploymentType.type == 'dev'"
|
||||
value {
|
||||
disable_heartbeat: true
|
||||
}
|
||||
}
|
||||
|
||||
PlatformMap {
|
||||
value {
|
||||
glbx_platform: "PLATFORM_MDP3ONIXS"
|
||||
ice_platform: "PLATFORM_ICEONIXS"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PublisherNamespace {
|
||||
value {
|
||||
shared_memory_namespace: @System.os_user
|
||||
}
|
||||
}
|
||||
|
||||
CMEOptions {
|
||||
value {
|
||||
feed_engine {
|
||||
name: "mdp3feed"
|
||||
# udp_socket_buffer_size: 425984
|
||||
# channels_per_thread: 1
|
||||
spin_time: 0
|
||||
}
|
||||
channel {
|
||||
id: "*"
|
||||
feed_engine: "mdp3feed"
|
||||
use_tcp_replay: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ICEPublisherOptions {
|
||||
value {
|
||||
network_interface: "eth1"
|
||||
}
|
||||
}
|
||||
|
||||
#to make this work in dev clone the operations repo
|
||||
#go here: c:\\code\\bts\\operations\\ice\\ICE_iMpactMulticastFeed_GettingStarted-1_1_36\\bin\\easyTunnel>
|
||||
#modify the easyTunnelProxy.properties file to replace
|
||||
#tunnel.multicast.interface=10.96.18.37 with your local ip
|
||||
#run easyTunnelProxy.bat BRENT-FI for Brent Full implied
|
||||
#you should see ice data
|
||||
|
||||
ICEOptions {
|
||||
value {
|
||||
channel {
|
||||
name: "oil" #these names are arbitrary and are for debugging
|
||||
market_type: 3
|
||||
uds_market_type: 3
|
||||
market_type: 4 #ICE IPE Gas Oil Futures
|
||||
uds_market_type: 4
|
||||
market_type: 5 #ICE Futures Brent, IPE Brent Futures
|
||||
uds_market_type: 5
|
||||
market_type: 9 #ICE Futures WTI, ICE WTI Crude Futures
|
||||
uds_market_type: 9
|
||||
market_type: 13 #ICE Heating Oil Futures
|
||||
uds_market_type: 13
|
||||
market_type: 15 #ICE NYH (RBOB) Gasoline Futures
|
||||
uds_market_type: 15
|
||||
##market_type: 21 #ICE Futures US Agricultures, Coffee C
|
||||
##uds_market_type: 21
|
||||
##market_type: 23 #ICE Futures US Agricultures, FCOJ A
|
||||
##uds_market_type: 23
|
||||
|
||||
##market_type: 26 #ICE Futures US Financials DX
|
||||
##uds_market_type: 26
|
||||
|
||||
uds_market_type: 11 #ICE WTI-Brent spreads
|
||||
uds_market_type: 14 #ICE Heating Oil/WTI Futures Crack
|
||||
uds_market_type: 16 #ICE NYH (RBOB) Gasoline/WTI Futures Crack
|
||||
uds_market_type: 58 #ICE Futures UI Heating Oil / Brent
|
||||
uds_market_type: 59 #ICE NYH (RBOB) Gasoline/Brent Futures Crack
|
||||
uds_market_type: 66 #ICE NYH (RBOB) Gasoline/Heating Oil Spread
|
||||
uds_market_type: 70 #ICE Heating Oil/LS Gasoil Futures Spread
|
||||
uds_market_type: 71 #ICE LS Gasoil/Brent Futures Crack
|
||||
uds_market_type: 72 #ICE NYH (RBOB) Gasoline/LS Gasoil Futures Spread
|
||||
|
||||
#onixs_log_mode: Debug
|
||||
}
|
||||
# channel {
|
||||
# name: "juice"
|
||||
# market_type: 26 #ICE Futures US Agricultures, FCOJ A
|
||||
# }
|
||||
ice_config_file: "ConnectivityConfiguration.APITest.xml"
|
||||
#ice_config_file: "ConnectivityConfiguration.PerfTest.xml"
|
||||
}
|
||||
}
|
||||
|
||||
MDBootDelayWindow {
|
||||
rule: "DeploymentType.type == 'dev'"
|
||||
value {
|
||||
delay_seconds: 0
|
||||
}
|
||||
}
|
||||
|
||||
MDBootDelayWindow {
|
||||
value {
|
||||
delay_seconds: 120
|
||||
standard {
|
||||
start: "16:30"
|
||||
end: "16:40"
|
||||
}
|
||||
sunday {
|
||||
start: "14:00"
|
||||
end: "14:10"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DisplayFactorOverride {
|
||||
value {
|
||||
override {
|
||||
symbol: "SOM"
|
||||
exchange: "GLBX"
|
||||
type: "SPREAD"
|
||||
price_multiplier: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ JetFIXSimConnection {
|
||||
end_time: "02:00:00"
|
||||
start_time: "02:05:00"
|
||||
raw_data: "1JE9X"
|
||||
use_cme_secure_logon: false
|
||||
use_cme_secure_logon: false
|
||||
seconds_to_pause : 1
|
||||
max_connection_attempts: 9999999
|
||||
}
|
||||
@@ -31,9 +31,9 @@ JetFIXSimConnection {
|
||||
end_time: "02:00:00"
|
||||
start_time: "02:05:00"
|
||||
raw_data: "1JE9X"
|
||||
use_cme_secure_logon: false
|
||||
use_cme_secure_logon: false
|
||||
seconds_to_pause : 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ JetFIX {
|
||||
socket_connect_host_ip: "63.247.113.154"
|
||||
socket_connect_port: 80
|
||||
sender_compid: "51251"
|
||||
target_compid: "ICE"
|
||||
target_compid: "ICE"
|
||||
start_time: "22:55:00"
|
||||
end_time: "22:05:00"
|
||||
sender_subid: "BTS"
|
||||
@@ -57,12 +57,12 @@ JetFIX {
|
||||
raw_data: "Starts123"
|
||||
max_order_msgs_per_window: 300
|
||||
auto_fix_seq_num: true
|
||||
|
||||
|
||||
seconds_to_replay: 6000
|
||||
}
|
||||
connection: @JetFIXSimConnection.sim
|
||||
#connection: @JetFIXSimConnection.sim_ice
|
||||
|
||||
|
||||
connection {
|
||||
name: "cme_mc5_99"
|
||||
platform: GLBX
|
||||
@@ -181,9 +181,9 @@ JetFIX {
|
||||
sender_subid: "BTS"
|
||||
raw_data: "S4PMA"
|
||||
auto_fix_seq_num: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JetFIX {
|
||||
rule: "CannedCertSession.name='gt_cert'"
|
||||
@@ -196,7 +196,7 @@ JetFIX {
|
||||
socket_connect_host_ip: "63.247.113.154"
|
||||
socket_connect_port: 80
|
||||
sender_compid: "51251"
|
||||
target_compid: "ICE"
|
||||
target_compid: "ICE"
|
||||
start_time: "22:55:00"
|
||||
end_time: "22:05:00"
|
||||
sender_subid: "BTS"
|
||||
@@ -204,7 +204,7 @@ JetFIX {
|
||||
raw_data: "Starts123"
|
||||
max_order_msgs_per_window: 300
|
||||
auto_fix_seq_num: true
|
||||
|
||||
|
||||
seconds_to_replay: 6000
|
||||
}
|
||||
connection: @JetFIXSimConnection.sim
|
||||
@@ -515,7 +515,7 @@ JetFIX {
|
||||
auto_fix_seq_num: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
JetFIX {
|
||||
@@ -2391,9 +2391,91 @@ JetFIX {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# NrCert gateways
|
||||
# 69.50.112.184,12,OESGW
|
||||
# 69.50.112.202,50,CME Eurodollar Options
|
||||
# 69.50.112.181,52,CME Globex FX Options II
|
||||
# 69.50.112.191,54,CME Equity Options
|
||||
# 69.50.112.174,56,NYMEX and COMEX Options
|
||||
# 69.50.112.172,58,CBOT Treasury Options
|
||||
# 69.50.112.195,60,CBOT Commodity and Equity Options
|
||||
# 69.50.112.177,64,CME E-mini S&P 500 Futures
|
||||
# 69.50.112.168,68,CME Equity Futures excluding E-mini S&P
|
||||
# 69.50.112.183,70,CME Commodity Futures
|
||||
# 69.50.112.189,72,CBOT Commodity Futures
|
||||
# 69.50.112.197,74,KRX Futures; BMD Futures and Options
|
||||
# 69.50.112.204,76,NYMEX and COMEX Metals and Alternative Market Futures
|
||||
# 69.50.112.167,78,NYMEX Non-Crude Energy Futures
|
||||
# 69.50.112.187,80,NYMEX Crude Energy Futures
|
||||
# 69.50.112.179,82,CME Eurodollar Futures
|
||||
# 69.50.112.198,84,CBOT Treasury Futures
|
||||
# 69.50.112.169,88,CME Globex FX Futures and Options
|
||||
# 69.50.112.199,99,AutoCert Segment
|
||||
|
||||
macro {
|
||||
name: "canned_004"
|
||||
expression: "[CannedCertSession.name, '004']"
|
||||
}
|
||||
|
||||
JetFIX {
|
||||
rule: "CannedCertSession.name in ['NGG', 'NGF', 'UZE', 'VAE']"
|
||||
value {
|
||||
# ES
|
||||
connection {
|
||||
name: "cme_canned_64"
|
||||
platform: GLBX
|
||||
socket_connect_host_ip: "69.50.112.177"
|
||||
socket_connect_port: 64530
|
||||
sender_compid: $canned_004
|
||||
target_compid: "CME"
|
||||
target_subid: "64"
|
||||
cme_market_segment_id: 64
|
||||
start_time: "00:30:00"
|
||||
end_time: "23:30:00"
|
||||
start_day: "sunday"
|
||||
end_day: "friday"
|
||||
sender_subid: "BTS"
|
||||
use_ilink3: true
|
||||
}
|
||||
# CL
|
||||
connection {
|
||||
name: "cme_canned_80"
|
||||
platform: GLBX
|
||||
socket_connect_host_ip: "69.50.112.187"
|
||||
socket_connect_port: 64530
|
||||
sender_compid: $canned_004
|
||||
target_compid: "CME"
|
||||
target_subid: "80"
|
||||
cme_market_segment_id: 80
|
||||
start_time: "00:30:00"
|
||||
end_time: "23:30:00"
|
||||
start_day: "sunday"
|
||||
end_day: "friday"
|
||||
sender_subid: "BTS"
|
||||
use_ilink3: true
|
||||
}
|
||||
connection {
|
||||
name: "cme_canned_99"
|
||||
platform: GLBX
|
||||
socket_connect_host_ip: "69.50.112.199"
|
||||
socket_connect_port: 64530
|
||||
sender_compid: $canned_004
|
||||
target_compid: "CME"
|
||||
target_subid: "99"
|
||||
cme_market_segment_id: 99
|
||||
start_time: "00:30:00"
|
||||
end_time: "23:30:00"
|
||||
start_day: "sunday"
|
||||
end_day: "friday"
|
||||
sender_subid: "BTS"
|
||||
use_ilink3: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#If no canned cert specified we fallback to just sim
|
||||
CannedCertSession { value { name: "" }}
|
||||
JetFIX {value {connection: @JetFIXSimConnection.sim}}
|
||||
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ message LadderKnobs {
|
||||
message OrderBookOptions {
|
||||
optional bool animate_child_order_rows = 1 [default = false];
|
||||
optional double status_color_opacity_when_selected = 2 [default = 0.35];
|
||||
optional bool can_edit_specific_algo_params = 3 [default = false];
|
||||
}
|
||||
|
||||
message OrderTicketOptions {
|
||||
|
||||
@@ -9,9 +9,9 @@ message JetFIX {
|
||||
enum JetFIXPlatform {
|
||||
GLBX = 1;
|
||||
CBOE = 6;
|
||||
SIM = 2;
|
||||
ICE = 3;
|
||||
SIMICE = 4;
|
||||
SIM = 2;
|
||||
ICE = 3;
|
||||
SIMICE = 4;
|
||||
}
|
||||
optional JetFIXPlatform platform = 15 [default = GLBX];
|
||||
|
||||
@@ -87,6 +87,7 @@ message JetFIX {
|
||||
|
||||
optional uint32 max_connection_attempts = 346 [default=10];
|
||||
optional bool auto_fix_seq_num = 347 [default=false];
|
||||
optional bool use_ilink3 = 348 [default=false] ;
|
||||
}
|
||||
|
||||
repeated Connection connection = 10;
|
||||
@@ -116,4 +117,4 @@ message CMECannedSecureLogon {
|
||||
"MC8 AbEEtBn63WIAuItPDz1c n3ndjYb03Hx6wBO3me35HoONyDgO5TZKWk0tDSaX9KA 2018-04-05 2019-04-05 CERT \n"
|
||||
"T39 UWggBgHWAe07aqW3ps2I tbb3it0rUQSSTa0TC9QcRwkrHEMDLWhaJH4VQ0FqGB4 2018-04-05 2019-04-05 NEWRELEASE \n"
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -68,4 +68,5 @@ message DynamicAlgos{
|
||||
optional bool enable_pyramid = 2 [default = false];
|
||||
optional bool enable_tas = 3 [default = false];
|
||||
optional bool enable_tascounter = 4 [default = false];
|
||||
optional bool enable_limit_cover = 5 [default = false];
|
||||
}
|
||||
@@ -41,16 +41,16 @@ inline api::Side other_side(api::Side side) {
|
||||
}
|
||||
}
|
||||
|
||||
inline double market_epislon() { return 1e-10; }
|
||||
inline double market_epsilon() { return 1e-10; }
|
||||
|
||||
// better == p1 more aggressive than p1 ie for a buy order p1 is higher
|
||||
// than p2, and for a sell order p1 is lower than p2
|
||||
inline bool is_better(api::Side side, Price p1, Price p2) {
|
||||
switch (side) {
|
||||
case api::SIDE_BUY:
|
||||
return p1.value() - p2.value() > market_epislon();
|
||||
return p1.value() - p2.value() > market_epsilon();
|
||||
case api::SIDE_SELL:
|
||||
return p2.value() - p1.value() > market_epislon();
|
||||
return p2.value() - p1.value() > market_epsilon();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ inline Price worsen_price(api::Side side, Price p, Price offset) {
|
||||
}
|
||||
|
||||
inline bool is_same(Price p1, Price p2) {
|
||||
return std::abs(p1.value() - p2.value()) < market_epislon();
|
||||
return std::abs(p1.value() - p2.value()) < market_epsilon();
|
||||
}
|
||||
|
||||
inline bool is_equal_or_better(api::Side side, Price p1, Price p2) {
|
||||
@@ -212,5 +212,5 @@ inline bool gr_than(double p1, double p2, double tick_size) {
|
||||
!test_price_equality(p1, p2, tick_size);
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
} // namespace securities
|
||||
} // namespace bts
|
||||
@@ -52,7 +52,7 @@ class FIXEncodingStream {
|
||||
auto msg_offset = _buffer.size();
|
||||
|
||||
_current_msg = FIXFragment(_buffer);
|
||||
_begin_string_bm = _current_msg.add<fix::BeginString>("FIX.4.2");
|
||||
_begin_string_bm = _current_msg.add<fix::BeginString>(std::string_view {"FIX.4.2"});
|
||||
_body_length_bm = _current_msg.add<fix::BodyLength>(0, 6);
|
||||
|
||||
char mt_encoding[4];
|
||||
|
||||
@@ -85,6 +85,7 @@ typedef StringField<307> UnderlyingSecurityDesc;
|
||||
typedef StringField<336> TradingSessionID;
|
||||
typedef StringField<35> MsgType;
|
||||
typedef StringField<37> OrderID;
|
||||
typedef BigIntField<37> OrderIDu64;
|
||||
typedef StringField<41> OrigClOrdID;
|
||||
typedef StringField<440> ClearingAccount;
|
||||
typedef StringField<48> SecurityID;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <memory>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <string_view>
|
||||
|
||||
#include "lib/jetfix/codec/ReaderCursor.h"
|
||||
#include "lib/utils/meta_programming.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
@@ -203,6 +205,13 @@ public:
|
||||
static std::pair<uint32_t,uint32_t> write (char*buffer,std::string const &str)
|
||||
{return write (buffer,str.data (),str.size ());}
|
||||
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
static uint32_t max_value_size (std::string_view const&str) {return str.size ();}
|
||||
static std::pair<uint32_t,uint32_t> write (char*buffer,std::string_view const &str)
|
||||
{return write (buffer,str.data (),str.size ());}
|
||||
#endif
|
||||
|
||||
static std::pair<uint32_t,uint32_t> write (char*buffer,const char*str,uint32_t sz)
|
||||
{
|
||||
memcpy (buffer,str,sz);
|
||||
|
||||
@@ -23,9 +23,9 @@ SocketConnection::SocketConnection(bts::config::JetFIX::Connection const &cfg,
|
||||
: _fd(-1), _cfg(cfg), _log(cfg.log_fix_stream()), _in_log(), _out_log(),
|
||||
_perf_log(perf_log) {
|
||||
if (_log) {
|
||||
_in_log.open(std::string("/tmp/fix_raw_read_log_") + session_name(cfg),
|
||||
_in_log.open(std::string("/tmp/fix_raw_read_log_") + session_name(cfg).as_string,
|
||||
std::ios_base::app);
|
||||
_out_log.open(std::string("/tmp/fix_raw_write_log_") + session_name(cfg),
|
||||
_out_log.open(std::string("/tmp/fix_raw_write_log_") + session_name(cfg).as_string,
|
||||
std::ios_base::app);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -783,32 +783,32 @@ OutFIXPtr make_logon(uint32_t seq_num, uint32_t last_seq_num_processed,
|
||||
const char *application = "O2";
|
||||
#endif
|
||||
|
||||
if(session_cfg.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_ICE ||
|
||||
session_cfg.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_SIMICE)
|
||||
{
|
||||
buffer.add<ICEApplicationSystemName>(application);
|
||||
buffer.add<ICEApplicationSystemVersion>("1.0");
|
||||
buffer.add<ICEApplicationSystemVendor>("BTS");
|
||||
|
||||
buffer.add<UserName>(session_cfg.user_name());
|
||||
if (session_cfg.platform() ==
|
||||
bts::config::JetFIX_Connection_JetFIXPlatform_ICE ||
|
||||
session_cfg.platform() ==
|
||||
bts::config::JetFIX_Connection_JetFIXPlatform_SIMICE) {
|
||||
buffer.add<ICEApplicationSystemName>(std::string_view{application});
|
||||
buffer.add<ICEApplicationSystemVersion>(std::string_view{"1.0"});
|
||||
buffer.add<ICEApplicationSystemVendor>(std::string_view{"BTS"});
|
||||
|
||||
buffer.add<UserName>(session_cfg.user_name());
|
||||
buffer.add<RawDataLength>(session_cfg.raw_data().size());
|
||||
buffer.add<RawData>(session_cfg.raw_data());
|
||||
buffer.add<RawData>(session_cfg.raw_data());
|
||||
buffer.add<EncryptMethod>(0);
|
||||
buffer.add<ICEStrategyPreference>(1);
|
||||
buffer.add<ICETimeStampPreference>(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.add<ApplicationSystemName>(application);
|
||||
buffer.add<ApplicationSystemVersion>("1.0");
|
||||
buffer.add<ApplicationSystemVendor>("BTS");
|
||||
} else {
|
||||
buffer.add<ApplicationSystemName>(std::string_view{application});
|
||||
buffer.add<ApplicationSystemVersion>(std::string_view{"1.0"});
|
||||
buffer.add<ApplicationSystemVendor>(std::string_view{"BTS"});
|
||||
|
||||
if (session_cfg.has_trading_session_id()) {
|
||||
buffer.add<fix::NoTradingSessions>(1);
|
||||
buffer.add<fix::TradingSessionID>(session_cfg.trading_session_id());
|
||||
}
|
||||
if (session_cfg.has_udf_support_indicator())
|
||||
buffer.add<fix::UDFSupportIndicator>(session_cfg.udf_support_indicator());
|
||||
buffer.add<fix::UDFSupportIndicator>(
|
||||
session_cfg.udf_support_indicator());
|
||||
|
||||
if (session_cfg.use_cme_secure_logon()) {
|
||||
bts_assert(session_cfg.sender_compid().size() >= 3);
|
||||
@@ -819,25 +819,24 @@ OutFIXPtr make_logon(uint32_t seq_num, uint32_t last_seq_num_processed,
|
||||
std::string last_seq_num_str(9, ' ');
|
||||
i32_toa(last_seq_num_processed, &last_seq_num_str[0], 9);
|
||||
auto ld = glbx::calculate_hmac(
|
||||
session_id, seq_num_str, session_cfg.sender_compid(),
|
||||
session_cfg.sender_subid(), time_str, session_cfg.target_subid(),
|
||||
std::to_string(session_cfg.seconds_between_hbs()),
|
||||
session_cfg.sender_locationid(), last_seq_num_str, application, "1.0",
|
||||
"BTS");
|
||||
#ifndef BTS_EDGE
|
||||
LOG(Jetfix, Info, "Canonical string for secure logon: {}", ld.canonical);
|
||||
#endif
|
||||
session_id, seq_num_str, session_cfg.sender_compid(),
|
||||
session_cfg.sender_subid(), time_str, session_cfg.target_subid(),
|
||||
std::to_string(session_cfg.seconds_between_hbs()),
|
||||
session_cfg.sender_locationid(), last_seq_num_str, application,
|
||||
"1.0", "BTS");
|
||||
#ifndef BTS_EDGE
|
||||
LOG(Jetfix, Info, "Canonical string for secure logon: {}",
|
||||
ld.canonical);
|
||||
#endif
|
||||
buffer.add<EncodedTextLen>(ld.access_key.size());
|
||||
buffer.add<EncodedText>(ld.access_key);
|
||||
buffer.add<EncryptedPasswordMethod>("CME-1-SHA-256");
|
||||
buffer.add<EncryptedPasswordMethod>(std::string_view{"CME-1-SHA-256"});
|
||||
buffer.add<EncryptedPasswordLen>(ld.signature.size());
|
||||
buffer.add<EncryptedPassword>(ld.signature);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
buffer.add<RawDataLength>(session_cfg.raw_data().size());
|
||||
buffer.add<RawData>(session_cfg.raw_data());
|
||||
if(session_cfg.user_name() != "")
|
||||
if (session_cfg.user_name() != "")
|
||||
buffer.add<UserName>(session_cfg.user_name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ void load_seq_nums(std::string const &path, uint32_t *last_seq_num,
|
||||
FIXFileStore::FIXFileStore(config::JetFIX::Connection const &cfg,
|
||||
std::string base_path)
|
||||
: me(new PImpl(cfg)) {
|
||||
auto sn = session_name(cfg);
|
||||
auto sn = session_name(cfg).as_string;
|
||||
me->active = sn.size() > 0;
|
||||
if (me->active) {
|
||||
|
||||
|
||||
@@ -75,49 +75,55 @@ bool in_session (datetime::PTime const &ref_date,
|
||||
return closest_earlier_end<closest_earlier_start;
|
||||
}
|
||||
|
||||
std::string session_name_from_ptime (datetime::PTime t,
|
||||
SessionName session_name_from_ptime (datetime::PTime t,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end)
|
||||
{
|
||||
std::string result (10,' ');
|
||||
SessionName result;
|
||||
result.as_string = std::string(10,' ');
|
||||
auto start_of_session = t;
|
||||
|
||||
if (time_of_day_start > time_of_day_end &&
|
||||
start_of_session.time_of_day () <= time_of_day_end)
|
||||
start_of_session -= boost::gregorian::date_duration (1);
|
||||
|
||||
sprintf (&result[0], "%04d-%02d-%02d",
|
||||
|
||||
using namespace boost::posix_time;
|
||||
ptime epoch(boost::gregorian::date(1970,1,1));
|
||||
ptime session_start_date(start_of_session.date());
|
||||
result.as_uint64_t = (session_start_date - epoch).total_milliseconds();
|
||||
|
||||
sprintf (&(result.as_string[0]), "%04d-%02d-%02d",
|
||||
(unsigned short) start_of_session.date ().year (),
|
||||
start_of_session.date ().month ().as_number (),
|
||||
start_of_session.date ().day ().as_number ());
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string session_name (datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday_start,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::gregorian::greg_weekday weekday_end,
|
||||
boost::posix_time::time_duration time_of_day_end)
|
||||
SessionName session_name (datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday_start,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::gregorian::greg_weekday weekday_end,
|
||||
boost::posix_time::time_duration time_of_day_end)
|
||||
{
|
||||
if (in_session (ref_date,weekday_start,time_of_day_start,weekday_end,time_of_day_end))
|
||||
return session_name_from_ptime (closest_before (ref_date,weekday_start,time_of_day_start),
|
||||
boost::posix_time::time_duration(0, 0, 0),
|
||||
boost::posix_time::time_duration(0, 0, 1));
|
||||
else
|
||||
return std::string ();
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string session_name (datetime::PTime const &ref_date,
|
||||
SessionName session_name (datetime::PTime const &ref_date,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end)
|
||||
{
|
||||
if (in_session (ref_date,time_of_day_start,time_of_day_end))
|
||||
return session_name_from_ptime (ref_date, time_of_day_start, time_of_day_end);
|
||||
else
|
||||
return "";
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string session_name (config::JetFIX::Connection const &session_cfg)
|
||||
SessionName session_name (config::JetFIX::Connection const &session_cfg)
|
||||
{
|
||||
auto now = datetime::local_now ();
|
||||
|
||||
@@ -134,7 +140,6 @@ std::string session_name (config::JetFIX::Connection const &session_cfg)
|
||||
parse_time (session_cfg.end_time ()));
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/config/protos/jetfix.pb.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/config/protos/jetfix.pb.h"
|
||||
|
||||
namespace boost {
|
||||
namespace gregorian {
|
||||
@@ -11,39 +11,45 @@ class greg_weekday;
|
||||
}
|
||||
namespace posix_time {
|
||||
class time_duration;
|
||||
}}
|
||||
|
||||
}
|
||||
} // namespace boost
|
||||
|
||||
namespace bts {
|
||||
namespace jetfix {
|
||||
|
||||
boost::gregorian::greg_weekday parse_weekday (std::string weekday_str);
|
||||
bool parse_time (std::string const &time_str,boost::posix_time::time_duration *out);
|
||||
boost::gregorian::greg_weekday parse_weekday(std::string weekday_str);
|
||||
bool parse_time(std::string const &time_str,
|
||||
boost::posix_time::time_duration *out);
|
||||
|
||||
datetime::PTime closest_before (datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday,
|
||||
boost::posix_time::time_duration time_of_day);
|
||||
datetime::PTime closest_before(datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday,
|
||||
boost::posix_time::time_duration time_of_day);
|
||||
|
||||
bool in_session (datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday_start,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::gregorian::greg_weekday weekday_end,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
bool in_session(datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday_start,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::gregorian::greg_weekday weekday_end,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
|
||||
bool in_session (datetime::PTime const &ref_date,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
bool in_session(datetime::PTime const &ref_date,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
|
||||
std::string session_name (datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday_start,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::gregorian::greg_weekday weekday_end,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
struct SessionName {
|
||||
std::string as_string;
|
||||
uint64_t as_uint64_t;
|
||||
bool empty() const {return as_string.empty();};
|
||||
};
|
||||
|
||||
std::string session_name (datetime::PTime const &ref_date,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
SessionName session_name(datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday_start,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::gregorian::greg_weekday weekday_end,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
SessionName session_name(datetime::PTime const &ref_date,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
SessionName session_name(config::JetFIX::Connection const &session_cfg);
|
||||
|
||||
std::string session_name (config::JetFIX::Connection const &session_cfg);
|
||||
|
||||
}}
|
||||
} // namespace jetfix
|
||||
} // namespace bts
|
||||
@@ -81,9 +81,9 @@ TEST_CASE ("JetFIX Field2Tests", "[jetfix]")
|
||||
std::string out (20, ' ');
|
||||
typedef StringField<123> Field;
|
||||
|
||||
REQUIRE(Field::max_value_size ("hello")==5);
|
||||
REQUIRE(Field::max_value_size (std::string_view{"hello"})==5);
|
||||
|
||||
auto result = Field::write (&out[0],"hello");
|
||||
auto result = Field::write (&out[0],std::string_view{"hello"});
|
||||
REQUIRE (result.first==5);
|
||||
REQUIRE (result.second=='h'+'e'+'l'+'l'+'o');
|
||||
REQUIRE (out.compare (0,5,"hello") == 0);
|
||||
@@ -112,7 +112,7 @@ TEST_CASE ("JetFIX FIXFragmentTests" , "[jetfix]")
|
||||
FIXFragment g (0);
|
||||
g.add<CharField<1>> ('a');
|
||||
g.add<FloatField<2>> (1.2,-1,6);
|
||||
g.add<StringField<3>> ("hello");
|
||||
g.add<StringField<3>> (std::string_view{"hello"});
|
||||
g.add<IntField<4>> (123,3);
|
||||
const char*t_s = "20150427-19:05:18.922";
|
||||
g.add<TimeField<5>> (datetime::parse_FIX_timestamp (t_s));
|
||||
@@ -141,14 +141,14 @@ TEST_CASE ("JetFIX FIXFragmentTests" , "[jetfix]")
|
||||
FIXFragment g;
|
||||
auto c_bm = g.add<CharField<1>> ('a');
|
||||
auto f_bm = g.add<FloatField<2>> (1.2,-1,6);
|
||||
auto s_bm = g.add<StringField<3>> ("hello");
|
||||
auto s_bm = g.add<StringField<3>> (std::string_view{"hello"});
|
||||
auto i_bm = g.add<IntField<4>> (123,3);
|
||||
auto t_bm = g.add<TimeField<5>> (datetime::parse_FIX_timestamp (t_s1));
|
||||
auto b_bm = g.add<BoolField<6>> (true);
|
||||
|
||||
g.overwrite (c_bm,'b');
|
||||
g.overwrite (f_bm,1.3,-1,6);
|
||||
g.overwrite (s_bm,"olleh");
|
||||
g.overwrite (s_bm,std::string_view {"olleh"});
|
||||
g.overwrite (i_bm,321,3);
|
||||
g.overwrite (t_bm,(datetime::parse_FIX_timestamp (t_s2)));
|
||||
g.overwrite (b_bm,false);
|
||||
@@ -172,11 +172,11 @@ TEST_CASE ("JetFIX FIXFragmentTests" , "[jetfix]")
|
||||
FIXFragment g1;;
|
||||
g1.add<CharField<1>> ('a');
|
||||
g1.add<FloatField<2>> (1.2,-1,6);
|
||||
g1.add<StringField<3>> ("hello");
|
||||
g1.add<StringField<3>> (std::string_view{"hello"});
|
||||
auto chk1 = g1.checksum ();
|
||||
|
||||
FIXFragment g2;
|
||||
g2.add<StringField<4>> ("goodbye");
|
||||
g2.add<StringField<4>> (std::string_view{"goodbye"});
|
||||
g2.add<IntField<5>> (321,3);
|
||||
auto chk2 = g2.checksum ();
|
||||
|
||||
|
||||
@@ -6,279 +6,270 @@
|
||||
#include "lib/jetfix/common/OutFIXPtr.h"
|
||||
#include "lib/jetfix/store/FIXFileStore.h"
|
||||
#include "lib/jetfix/store/session_name.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/utils/TempDir.h"
|
||||
#include "lib/utils/TimeStamp.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/logging/logging.h"
|
||||
|
||||
#include <boost/date_time.hpp>
|
||||
#include <boost/date_time/gregorian/gregorian.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/date_time.hpp>
|
||||
|
||||
namespace bts {
|
||||
namespace jetfix {
|
||||
|
||||
TEST_CASE ("JetFIX SessionNameTests", "[jetfix]")
|
||||
{
|
||||
SECTION("greg_weekday_works")
|
||||
{
|
||||
const char*days [] = {"sun","Monday","tuesday","Wedn","Thursday","Friday","sat"};
|
||||
TEST_CASE("JetFIX SessionNameTests", "[jetfix]") {
|
||||
SECTION("greg_weekday_works") {
|
||||
const char *days[] = {"sun", "Monday", "tuesday", "Wedn",
|
||||
"Thursday", "Friday", "sat"};
|
||||
|
||||
int i =0;
|
||||
int i = 0;
|
||||
for (auto d : days)
|
||||
REQUIRE (parse_weekday (d)==boost::gregorian::greg_weekday (i++));
|
||||
}
|
||||
|
||||
SECTION("closest_before_works")
|
||||
{
|
||||
auto same_day_before = closest_before (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(16, 59, 59));
|
||||
REQUIRE (datetime::FIX_date_time_string (same_day_before)=="20150717-16:59:59");
|
||||
|
||||
auto same_day_after = closest_before (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(17,0,1));
|
||||
REQUIRE (datetime::FIX_date_time_string (same_day_after)=="20150710-17:00:01");
|
||||
|
||||
auto another_day_same_week = closest_before (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Thursday,
|
||||
boost::posix_time::time_duration(16, 59, 59));
|
||||
REQUIRE (datetime::FIX_date_time_string (another_day_same_week)=="20150716-16:59:59");
|
||||
|
||||
auto another_day_previous_week = closest_before (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Saturday,
|
||||
boost::posix_time::time_duration(16, 59, 59));
|
||||
REQUIRE (datetime::FIX_date_time_string (another_day_previous_week)=="20150711-16:59:59");
|
||||
|
||||
REQUIRE(parse_weekday(d) == boost::gregorian::greg_weekday(i++));
|
||||
}
|
||||
|
||||
SECTION("in_session_works")
|
||||
{
|
||||
REQUIRE (in_session (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(17, 0, 1)));
|
||||
SECTION("closest_before_works") {
|
||||
auto same_day_before =
|
||||
closest_before(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(16, 59, 59));
|
||||
REQUIRE(datetime::FIX_date_time_string(same_day_before) ==
|
||||
"20150717-16:59:59");
|
||||
|
||||
REQUIRE (!in_session (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(16, 59, 59)));
|
||||
auto same_day_after = closest_before(
|
||||
datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Friday, boost::posix_time::time_duration(17, 0, 1));
|
||||
REQUIRE(datetime::FIX_date_time_string(same_day_after) ==
|
||||
"20150710-17:00:01");
|
||||
|
||||
REQUIRE (in_session (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
boost::posix_time::time_duration(17, 59, 59)));
|
||||
auto another_day_same_week =
|
||||
closest_before(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Thursday,
|
||||
boost::posix_time::time_duration(16, 59, 59));
|
||||
REQUIRE(datetime::FIX_date_time_string(another_day_same_week) ==
|
||||
"20150716-16:59:59");
|
||||
|
||||
REQUIRE (!in_session (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::posix_time::time_duration(0,0,0),
|
||||
boost::posix_time::time_duration(16, 0,0)));
|
||||
|
||||
REQUIRE (in_session (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)));
|
||||
|
||||
REQUIRE (!in_session (datetime::make_ptime (2015,7,17,17,47,0,0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)));
|
||||
auto another_day_previous_week =
|
||||
closest_before(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Saturday,
|
||||
boost::posix_time::time_duration(16, 59, 59));
|
||||
REQUIRE(datetime::FIX_date_time_string(another_day_previous_week) ==
|
||||
"20150711-16:59:59");
|
||||
}
|
||||
|
||||
SECTION("session_name_works")
|
||||
{
|
||||
REQUIRE (session_name (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(17, 0, 1)) ==
|
||||
"2015-07-12");
|
||||
SECTION("in_session_works") {
|
||||
REQUIRE(in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(17, 0, 1)));
|
||||
|
||||
REQUIRE (session_name (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(16, 59, 59)) == "");
|
||||
REQUIRE(!in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
REQUIRE (session_name (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
boost::posix_time::time_duration(17, 59, 59)) ==
|
||||
"2015-07-17");
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(16, 59, 59)));
|
||||
|
||||
REQUIRE (session_name (datetime::make_ptime (2015,7,17,18,0,0,0),
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
boost::posix_time::time_duration(17, 59, 59)) ==
|
||||
"");
|
||||
REQUIRE(in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
boost::posix_time::time_duration(17, 59, 59)));
|
||||
|
||||
REQUIRE (session_name (datetime::make_ptime (2015,7,17,17,0,0,0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)) ==
|
||||
"2015-07-16");
|
||||
REQUIRE(!in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::posix_time::time_duration(0, 0, 0),
|
||||
boost::posix_time::time_duration(16, 0, 0)));
|
||||
|
||||
REQUIRE (session_name (datetime::make_ptime (2015,7,17,17,51,0,0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)) ==
|
||||
"2015-07-17");
|
||||
|
||||
REQUIRE (session_name (datetime::make_ptime (2015,7,17,17,47,0,0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)) ==
|
||||
"");
|
||||
REQUIRE(in_session(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)));
|
||||
|
||||
REQUIRE(!in_session(datetime::make_ptime(2015, 7, 17, 17, 47, 0, 0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)));
|
||||
}
|
||||
|
||||
SECTION("session_name_works") {
|
||||
REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(17, 0, 1)).as_string ==
|
||||
"2015-07-12");
|
||||
|
||||
REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::gregorian::Sunday,
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
|
||||
boost::gregorian::Friday,
|
||||
boost::posix_time::time_duration(16, 59, 59)).as_string == "");
|
||||
|
||||
REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
boost::posix_time::time_duration(17, 59, 59)).as_string ==
|
||||
"2015-07-17");
|
||||
|
||||
REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 18, 0, 0, 0),
|
||||
boost::posix_time::time_duration(16, 59, 59),
|
||||
boost::posix_time::time_duration(17, 59, 59)).as_string == "");
|
||||
|
||||
REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 0, 0, 0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)).as_string ==
|
||||
"2015-07-16");
|
||||
|
||||
REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 51, 0, 0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)).as_string ==
|
||||
"2015-07-17");
|
||||
|
||||
REQUIRE(session_name(datetime::make_ptime(2015, 7, 17, 17, 47, 0, 0),
|
||||
boost::posix_time::time_duration(17, 50, 59),
|
||||
boost::posix_time::time_duration(17, 45, 59)).as_string == "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE ("JetFIX FileStoreTests", "[jetfix]")
|
||||
{
|
||||
SECTION("empty_store_works")
|
||||
{
|
||||
TEST_CASE("JetFIX FileStoreTests", "[jetfix]") {
|
||||
SECTION("empty_store_works") {
|
||||
config::JetFIX::Connection c;
|
||||
c.set_name ("test");
|
||||
c.set_sender_compid ("CME");
|
||||
c.set_sender_subid ("G");
|
||||
c.set_target_compid ("1U7001N");
|
||||
c.set_target_subid ("BLUESTREAM");
|
||||
c.set_name("test");
|
||||
c.set_sender_compid("CME");
|
||||
c.set_sender_subid("G");
|
||||
c.set_target_compid("1U7001N");
|
||||
c.set_target_subid("BLUESTREAM");
|
||||
|
||||
c.set_start_time ("00:00:00");
|
||||
c.set_end_time ("23:59:59");
|
||||
c.set_start_time("00:00:00");
|
||||
c.set_end_time("23:59:59");
|
||||
|
||||
utils::TempDir td;
|
||||
|
||||
FIXFileStore fs (c,td.name ());
|
||||
REQUIRE (fs.session_active ());
|
||||
REQUIRE (fs.replay ().size ()==0);
|
||||
REQUIRE (fs.last_seq_num ()==0);
|
||||
REQUIRE (fs.last_seq_num_processed ()==0);
|
||||
|
||||
FIXFileStore fs(c, td.name());
|
||||
REQUIRE(fs.session_active());
|
||||
REQUIRE(fs.replay().size() == 0);
|
||||
REQUIRE(fs.last_seq_num() == 0);
|
||||
REQUIRE(fs.last_seq_num_processed() == 0);
|
||||
}
|
||||
|
||||
SECTION("in_msg_is_stored")
|
||||
{
|
||||
auto td = std::make_shared<utils::TempDir> ();
|
||||
SECTION("in_msg_is_stored") {
|
||||
auto td = std::make_shared<utils::TempDir>();
|
||||
config::JetFIX::Connection c;
|
||||
c.set_name ("test");
|
||||
c.set_sender_compid ("CME");
|
||||
c.set_sender_subid ("G");
|
||||
c.set_target_compid ("1U7001N");
|
||||
c.set_target_subid ("BLUESTREAM");
|
||||
c.set_name("test");
|
||||
c.set_sender_compid("CME");
|
||||
c.set_sender_subid("G");
|
||||
c.set_target_compid("1U7001N");
|
||||
c.set_target_subid("BLUESTREAM");
|
||||
|
||||
c.set_start_time ("00:00:00");
|
||||
c.set_end_time ("23:59:59");
|
||||
c.set_start_time("00:00:00");
|
||||
c.set_end_time("23:59:59");
|
||||
|
||||
FIXEncodingStream stream (c);
|
||||
auto &buf = stream.new_msg (MessageTypes::Logon);
|
||||
buf.add<fix::TargetLocationID> ("US,NC");
|
||||
buf.add<fix::EncryptMethod> (0);
|
||||
FIXEncodingStream stream(c);
|
||||
auto &buf = stream.new_msg(MessageTypes::Logon);
|
||||
buf.add<fix::TargetLocationID>(std::string_view{"US,NC"});
|
||||
buf.add<fix::EncryptMethod>(0);
|
||||
buf.add<fix::HeartBtInt>(30);
|
||||
buf.add<fix::ApplicationSystemName> ("O2");
|
||||
buf.add<fix::ApplicationSystemVersion> ("1.0");
|
||||
buf.add<fix::ApplicationSystemVendor> ("BTS");
|
||||
stream.close ();
|
||||
stream.stamp (2,3,datetime::FIX_timestamp (datetime::now ()));
|
||||
auto fix = stream.to_str ();
|
||||
|
||||
buf.add<fix::ApplicationSystemName>(std::string_view{"O2"});
|
||||
buf.add<fix::ApplicationSystemVersion>(std::string_view{"1.0"});
|
||||
buf.add<fix::ApplicationSystemVendor>(std::string_view{"BTS"});
|
||||
stream.close();
|
||||
stream.stamp(2, 3, datetime::FIX_timestamp(datetime::now()));
|
||||
auto fix = stream.to_str();
|
||||
|
||||
{
|
||||
FIXFileStore fs (c,td->name ());
|
||||
fs.store (InMsgBuffer (fix));
|
||||
fs.set_last_msg_processed (3);
|
||||
FIXFileStore fs(c, td->name());
|
||||
fs.store(InMsgBuffer(fix));
|
||||
fs.set_last_msg_processed(3);
|
||||
}
|
||||
|
||||
FIXFileStore fs (c,td->name ());
|
||||
auto replay = fs.replay ();
|
||||
REQUIRE (replay.size ()==1);
|
||||
REQUIRE (replay[0].type ()==MessageTypes::Logon);
|
||||
REQUIRE (replay[0].to_str ()==fix);
|
||||
REQUIRE (fs.last_seq_num ()==0);
|
||||
REQUIRE (fs.last_seq_num_processed ()==3);
|
||||
FIXFileStore fs(c, td->name());
|
||||
auto replay = fs.replay();
|
||||
REQUIRE(replay.size() == 1);
|
||||
REQUIRE(replay[0].type() == MessageTypes::Logon);
|
||||
REQUIRE(replay[0].to_str() == fix);
|
||||
REQUIRE(fs.last_seq_num() == 0);
|
||||
REQUIRE(fs.last_seq_num_processed() == 3);
|
||||
}
|
||||
|
||||
SECTION("out_msg_is_stored")
|
||||
{
|
||||
auto td = std::make_shared<utils::TempDir> ();
|
||||
SECTION("out_msg_is_stored") {
|
||||
auto td = std::make_shared<utils::TempDir>();
|
||||
config::JetFIX::Connection c;
|
||||
c.set_name ("test");
|
||||
c.set_sender_compid ("CME");
|
||||
c.set_sender_subid ("G");
|
||||
c.set_target_compid ("1U7001N");
|
||||
c.set_target_subid ("BLUESTREAM");
|
||||
c.set_name("test");
|
||||
c.set_sender_compid("CME");
|
||||
c.set_sender_subid("G");
|
||||
c.set_target_compid("1U7001N");
|
||||
c.set_target_subid("BLUESTREAM");
|
||||
|
||||
c.set_start_time ("00:00:00");
|
||||
c.set_end_time ("23:59:59");
|
||||
c.set_start_time("00:00:00");
|
||||
c.set_end_time("23:59:59");
|
||||
|
||||
auto msg_vec = std::make_shared<OutFIX>(c);
|
||||
auto &stream = msg_vec->fix.back ();
|
||||
auto &buf = stream.new_msg (MessageTypes::Logon);
|
||||
buf.add<fix::TargetLocationID> ("US,NC");
|
||||
buf.add<fix::EncryptMethod> (0);
|
||||
auto &stream = msg_vec->fix.back();
|
||||
auto &buf = stream.new_msg(MessageTypes::Logon);
|
||||
buf.add<fix::TargetLocationID>(std::string_view{"US,NC"});
|
||||
buf.add<fix::EncryptMethod>(0);
|
||||
buf.add<fix::HeartBtInt>(30);
|
||||
buf.add<fix::ApplicationSystemName> ("O2");
|
||||
buf.add<fix::ApplicationSystemVersion> ("1.0");
|
||||
buf.add<fix::ApplicationSystemVendor> ("BTS");
|
||||
stream.close ();
|
||||
stream.stamp (2,3,datetime::FIX_timestamp (datetime::now ()));
|
||||
|
||||
buf.add<fix::ApplicationSystemName>(std::string_view{"O2"});
|
||||
buf.add<fix::ApplicationSystemVersion>(std::string_view{"1.0"});
|
||||
buf.add<fix::ApplicationSystemVendor>(std::string_view{"BTS"});
|
||||
stream.close();
|
||||
stream.stamp(2, 3, datetime::FIX_timestamp(datetime::now()));
|
||||
|
||||
{
|
||||
FIXFileStore fs (c,td->name ());
|
||||
fs.store (msg_vec);
|
||||
FIXFileStore fs(c, td->name());
|
||||
fs.store(msg_vec);
|
||||
}
|
||||
|
||||
FIXFileStore fs (c,td->name ());
|
||||
auto replay = fs.replay ();
|
||||
REQUIRE (replay.size ()==0);
|
||||
REQUIRE (fs.last_seq_num ()==3);
|
||||
REQUIRE (fs.last_seq_num_processed ()==0);
|
||||
FIXFileStore fs(c, td->name());
|
||||
auto replay = fs.replay();
|
||||
REQUIRE(replay.size() == 0);
|
||||
REQUIRE(fs.last_seq_num() == 3);
|
||||
REQUIRE(fs.last_seq_num_processed() == 0);
|
||||
}
|
||||
|
||||
SECTION("test_performance")
|
||||
{
|
||||
auto td = std::make_shared<utils::TempDir> ();
|
||||
SECTION("test_performance") {
|
||||
auto td = std::make_shared<utils::TempDir>();
|
||||
config::JetFIX::Connection c;
|
||||
c.set_name ("test");
|
||||
c.set_sender_compid ("CME");
|
||||
c.set_sender_subid ("G");
|
||||
c.set_target_compid ("1U7001N");
|
||||
c.set_target_subid ("BLUESTREAM");
|
||||
c.set_name("test");
|
||||
c.set_sender_compid("CME");
|
||||
c.set_sender_subid("G");
|
||||
c.set_target_compid("1U7001N");
|
||||
c.set_target_subid("BLUESTREAM");
|
||||
|
||||
c.set_start_time ("00:00:00");
|
||||
c.set_end_time ("23:59:59");
|
||||
c.set_start_time("00:00:00");
|
||||
c.set_end_time("23:59:59");
|
||||
|
||||
auto start = utils::TimeStamp::now ();
|
||||
auto start = utils::TimeStamp::now();
|
||||
{
|
||||
FIXFileStore fs (c,td->name ());
|
||||
for (int i = 0; i < 10000;i++) {
|
||||
FIXFileStore fs(c, td->name());
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
auto msg_vec = std::make_shared<std::vector<FIXEncodingStream>>();
|
||||
msg_vec->emplace_back (c);
|
||||
auto &stream = msg_vec->back ();
|
||||
auto &buf = stream.new_msg (MessageTypes::Logon);
|
||||
buf.add<fix::TargetLocationID> ("US,NC");
|
||||
buf.add<fix::EncryptMethod> (0);
|
||||
msg_vec->emplace_back(c);
|
||||
auto &stream = msg_vec->back();
|
||||
auto &buf = stream.new_msg(MessageTypes::Logon);
|
||||
buf.add<fix::TargetLocationID>(std::string_view{"US,NC"});
|
||||
buf.add<fix::EncryptMethod>(0);
|
||||
buf.add<fix::HeartBtInt>(30);
|
||||
buf.add<fix::ApplicationSystemName> ("O2");
|
||||
buf.add<fix::ApplicationSystemVersion> ("1.0");
|
||||
buf.add<fix::ApplicationSystemVendor> ("BTS");
|
||||
stream.close ();
|
||||
stream.stamp (i,3,datetime::FIX_timestamp (datetime::now () - boost::gregorian::days (1)));
|
||||
fs.store (InMsgBuffer (stream.to_str ()));
|
||||
buf.add<fix::ApplicationSystemName>(std::string_view{"O2"});
|
||||
buf.add<fix::ApplicationSystemVersion>(std::string_view{"1.0"});
|
||||
buf.add<fix::ApplicationSystemVendor>(std::string_view{"BTS"});
|
||||
stream.close();
|
||||
stream.stamp(i, 3,
|
||||
datetime::FIX_timestamp(datetime::now() -
|
||||
boost::gregorian::days(1)));
|
||||
fs.store(InMsgBuffer(stream.to_str()));
|
||||
}
|
||||
}
|
||||
auto stop = utils::TimeStamp::now ();
|
||||
LOG(Testing,Info,"jetfix store gen: {} ms", (stop-start).milliseconds () );
|
||||
|
||||
start = utils::TimeStamp::now ();
|
||||
FIXFileStore fs (c,td->name ());
|
||||
stop = utils::TimeStamp::now ();
|
||||
LOG(Testing,Info,"jetfix store load: {} ms", (stop-start).milliseconds () );
|
||||
auto stop = utils::TimeStamp::now();
|
||||
LOG(Testing, Info, "jetfix store gen: {} ms",
|
||||
(stop - start).milliseconds());
|
||||
|
||||
start = utils::TimeStamp::now();
|
||||
FIXFileStore fs(c, td->name());
|
||||
stop = utils::TimeStamp::now();
|
||||
LOG(Testing, Info, "jetfix store load: {} ms",
|
||||
(stop - start).milliseconds());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace jetfix
|
||||
} // namespace bts
|
||||
@@ -120,6 +120,7 @@ void configure_logging(bts::config::Logging const&cfg, bts::config::ThreadGroupC
|
||||
{log::Plugin,"Plugin"},
|
||||
{log::Sdk,"Sdk"},
|
||||
{log::Http,"Http"},
|
||||
{log::iLink3,"ilink3"},
|
||||
};
|
||||
|
||||
real_cfg.sinks["console"] =
|
||||
|
||||
@@ -46,6 +46,7 @@ constexpr log::Subsystem DataFlow {Latency.ordinal+1 };
|
||||
constexpr log::Subsystem Plugin {DataFlow.ordinal+1 };
|
||||
constexpr log::Subsystem Sdk {Plugin.ordinal+1 };
|
||||
constexpr log::Subsystem Http {Sdk.ordinal+1 };
|
||||
constexpr log::Subsystem iLink3 {Http.ordinal+1 };
|
||||
|
||||
struct LoggerHandle {
|
||||
LoggerHandle(LoggerHandle const&) = delete;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
#include "lib/utils/ValueWrapper.h"
|
||||
namespace bts {
|
||||
using ExchangeSecurityKey = utils::ValueWrapper<struct ExchangeSecurityKeyTag,uint64_t>;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ MDConsumer& MDClient::current_consumer() const {
|
||||
return _self->_consumer;
|
||||
}
|
||||
SecurityOracle MDClient::oracle() const {
|
||||
return SecurityOracle(*this);
|
||||
return SecurityOracle(_self->_cache);
|
||||
}
|
||||
std::set<UserSymbol> MDClient::symbols() const {
|
||||
return _self->_symbols;
|
||||
|
||||
@@ -897,7 +897,7 @@ public:
|
||||
scan_securities(resolve_legs);
|
||||
}
|
||||
|
||||
SecurityPtr get_security(SecurityKey key) const {
|
||||
const Security* get_security(SecurityKey key) const {
|
||||
return _cache.get_security(key);
|
||||
}
|
||||
|
||||
@@ -979,7 +979,7 @@ size_t MDConsumer::walk_security_list(SecurityCallback cb, const string& symbol,
|
||||
|
||||
size_t MDConsumer::scan_securities(bool resolve_legs) { return _pimpl->scan_securities(resolve_legs); }
|
||||
void MDConsumer::on_security(SecurityCallback cb, bool resolve_legs) { _pimpl->on_security(cb, resolve_legs); }
|
||||
const api::Security* MDConsumer::get_security(SecurityKey key) const { return _pimpl->get_security(key).get(); }
|
||||
const api::Security* MDConsumer::get_security(SecurityKey key) const { return _pimpl->get_security(key); }
|
||||
std::vector<api::Security const*> MDConsumer::get_securities() const {return _pimpl->get_securities();}
|
||||
|
||||
MDConsumerChannel MDConsumer::get_channel(const std::string& symbol, SecurityType type, Venue exchange) const {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "SecurityCache.h"
|
||||
#include "SecurityDB.h"
|
||||
#include "lib/utils/Dispatcher.h"
|
||||
#include "lib/utils/LockBox.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <google/btree/btree_map.h>
|
||||
#include <tbb/concurrent_queue.h>
|
||||
#include <mutex>
|
||||
|
||||
@@ -10,8 +12,8 @@ namespace bts {
|
||||
namespace md {
|
||||
|
||||
struct SecurityCacheImpl {
|
||||
std::mutex cache_mutex;
|
||||
std::unordered_map<SecurityKey, SecurityPtr> cache;
|
||||
utils::LockBox<btree::btree_map<SecurityKey, SecurityPtr>> cache;
|
||||
utils::LockBox<btree::btree_map<ExchangeSecurityKey, SecurityPtr>> ex_cache;
|
||||
tbb::concurrent_queue<SecurityPtr> update_queue;
|
||||
void enqueue_update_db(const SecurityPtr&);
|
||||
void flush();
|
||||
@@ -42,61 +44,83 @@ void SecurityCacheImpl::flush() {
|
||||
SecurityCache::SecurityCache() : _me(std::make_shared<SecurityCacheImpl>()) {}
|
||||
SecurityCache::~SecurityCache() {}
|
||||
|
||||
SecurityPtr SecurityCache::try_get_security(SecurityKey key) const {
|
||||
std::lock_guard<std::mutex> lock(_me->cache_mutex);
|
||||
auto iter = _me->cache.find(key);
|
||||
if (iter != _me->cache.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
return nullptr;
|
||||
const Security* SecurityCache::try_get_security(SecurityKey key) const {
|
||||
return _me->cache.lock([key](btree::btree_map<SecurityKey, SecurityPtr>& t) {
|
||||
auto iter = t.find(key);
|
||||
if (iter != t.end()) {
|
||||
return iter->second.get();
|
||||
}
|
||||
return (const api::Security*)nullptr;
|
||||
});
|
||||
}
|
||||
const Security* SecurityCache::try_get_security(ExchangeSecurityKey key) const {
|
||||
return _me->ex_cache.lock([key](btree::btree_map<ExchangeSecurityKey,SecurityPtr>& t) {
|
||||
auto iter = t.find(key);
|
||||
if (iter != t.end()) {
|
||||
return iter->second.get();
|
||||
}
|
||||
return (const api::Security*)nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
SecurityPtr SecurityCache::get_security(SecurityKey key) {
|
||||
std::unique_lock<std::mutex> lock(_me->cache_mutex);
|
||||
auto iter = _me->cache.find(key);
|
||||
if (iter != _me->cache.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
else {
|
||||
// unlock for db read
|
||||
lock.unlock();
|
||||
|
||||
const Security* SecurityCache::get_security(SecurityKey key) {
|
||||
const Security* result = try_get_security(key);
|
||||
if (result == nullptr) {
|
||||
// outside lock
|
||||
auto security = db::find_security(key);
|
||||
if (security) {
|
||||
LOG(md,Info, "Loaded security from database: {} {}", security->symbol(), security->id());
|
||||
return add_db_security(security);
|
||||
}
|
||||
return security;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<api::Security const*> SecurityCache::get_securities()
|
||||
{
|
||||
std::vector<api::Security const*> result;
|
||||
result.reserve(100000);
|
||||
|
||||
std::unique_lock<std::mutex> lock(_me->cache_mutex);
|
||||
for (auto const&p : _me->cache)
|
||||
result.push_back(p.second.get());
|
||||
return result;
|
||||
}
|
||||
|
||||
SecurityPtr SecurityCache::add_db_security(const SecurityPtr& security) {
|
||||
std::vector<api::Security const*> SecurityCache::get_securities() {
|
||||
std::vector<api::Security const*> result;
|
||||
result.reserve(100000);
|
||||
|
||||
_me->cache.lock([&result](auto& cache) {
|
||||
for (auto const&p : cache) {
|
||||
result.push_back(p.second.get());
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
const Security* SecurityCache::add_db_security(const SecurityPtr& security) {
|
||||
bts_assert(security);
|
||||
std::lock_guard<std::mutex> lock(_me->cache_mutex);
|
||||
SecurityKey key(security->id());
|
||||
auto result = _me->cache.insert(std::make_pair(SecurityKey(security->id()), security));
|
||||
// If result was inserted result.first->second is equal to security
|
||||
// If the value was already present it must be a recently inserted 'live' security and we should use it
|
||||
return result.first->second;
|
||||
if (security->has_glbx()) {
|
||||
_me->ex_cache.lock([&security](auto& cache) {
|
||||
ExchangeSecurityKey key(security->id());
|
||||
cache.insert(std::make_pair(key, security));
|
||||
});
|
||||
}
|
||||
return _me->cache.lock([&security](auto& cache) {
|
||||
SecurityKey key(security->id());
|
||||
auto result = cache.insert(std::make_pair(key, security));
|
||||
// If result was inserted result.first->second is equal to security
|
||||
// If the value was already present it must be a recently inserted 'live' security and we should use it
|
||||
return result.first->second.get();
|
||||
});
|
||||
}
|
||||
bool SecurityCache::add_live_security(const SecurityPtr& security) {
|
||||
bts_assert(security);
|
||||
std::lock_guard<std::mutex> lock(_me->cache_mutex);
|
||||
SecurityKey key(security->id());
|
||||
// Insert but don't overwrite existing
|
||||
auto result = _me->cache.insert(std::make_pair(SecurityKey(security->id()), security));
|
||||
_me->enqueue_update_db(security);
|
||||
return result.second;
|
||||
if (security->has_glbx()) {
|
||||
_me->ex_cache.lock([&security](auto& cache) {
|
||||
ExchangeSecurityKey key(security->id());
|
||||
cache.insert(std::make_pair(key, security));
|
||||
});
|
||||
}
|
||||
return _me->cache.lock([&](auto& cache) {
|
||||
SecurityKey key(security->id());
|
||||
// Insert but don't overwrite existing
|
||||
auto result = cache.insert(std::make_pair(SecurityKey(security->id()), security));
|
||||
_me->enqueue_update_db(security);
|
||||
return result.second;
|
||||
});
|
||||
}
|
||||
|
||||
void SecurityCache::flush_to_disk() { _me->flush(); }
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "lib/domain_model/Security.pb.h"
|
||||
#include "MDConsumerHandle.h"
|
||||
#include "lib/domain_model/SecurityKey.h"
|
||||
#include "lib/md/ExchangeSecurityKey.h"
|
||||
#include "SecurityPtr.h"
|
||||
#include <memory>
|
||||
|
||||
@@ -20,17 +21,18 @@ public:
|
||||
~SecurityCache();
|
||||
|
||||
//Load security from cache with fallback to database
|
||||
SecurityPtr get_security(SecurityKey key);
|
||||
const Security* get_security(SecurityKey key);
|
||||
|
||||
// Load all securities from cache, no fallback to database
|
||||
std::vector<api::Security const*> get_securities();
|
||||
|
||||
// Get the security if it's in the cache otherwise return nullptr. Does not query security database.
|
||||
SecurityPtr try_get_security(SecurityKey key) const;
|
||||
const Security* try_get_security(SecurityKey key) const;
|
||||
const Security* try_get_security(ExchangeSecurityKey key) const;
|
||||
|
||||
// returns true if the cache was updated
|
||||
bool add_live_security(const SecurityPtr& security);
|
||||
SecurityPtr add_db_security(const SecurityPtr& security);
|
||||
const Security* add_db_security(const SecurityPtr& security);
|
||||
|
||||
void flush_to_disk();
|
||||
|
||||
|
||||
@@ -4,14 +4,18 @@
|
||||
namespace bts {
|
||||
namespace md {
|
||||
|
||||
SecurityOracle::SecurityOracle(const MDClient& client): _client(client) {}
|
||||
SecurityOracle::SecurityOracle(SecurityCache& cache): _cache(cache) {}
|
||||
SecurityOracle::~SecurityOracle() { }
|
||||
const api::Security* SecurityOracle::get_security(SecurityKey key) const {
|
||||
return _client.current_consumer().get_security(key);
|
||||
return _cache.get_security(key);
|
||||
}
|
||||
|
||||
const api::Security* SecurityOracle::get_security(ExchangeSecurityKey key) const {
|
||||
return _cache.try_get_security(key);
|
||||
}
|
||||
|
||||
std::vector<api::Security const*> SecurityOracle::get_securities() const {
|
||||
return _client.current_consumer().get_securities();
|
||||
return _cache.get_securities();
|
||||
}
|
||||
|
||||
}}//namespace
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/domain_model/SecurityKey.h"
|
||||
#include "lib/md/ExchangeSecurityKey.h"
|
||||
#include "lib/md/SecurityCache.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@@ -9,11 +11,12 @@ namespace api {class Security;}
|
||||
namespace md {
|
||||
class MDClient;
|
||||
class SecurityOracle {
|
||||
const MDClient& _client;
|
||||
SecurityCache& _cache;
|
||||
public:
|
||||
SecurityOracle(const MDClient&);
|
||||
SecurityOracle(SecurityCache&);
|
||||
~SecurityOracle();
|
||||
const api::Security* get_security(SecurityKey key) const;
|
||||
const api::Security* get_security(ExchangeSecurityKey key) const;
|
||||
std::vector<api::Security const*> get_securities() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "lib/persistence/SqliteStore.h"
|
||||
#include "lib/utils/PBUtils.h"
|
||||
#include "lib/orderman/actors/SODPosition.h"
|
||||
#include "lib/utils/overloaded.h"
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <sys/time.h>
|
||||
@@ -119,8 +120,21 @@ void FillStore::on_execution_report(
|
||||
fill.set_fill_status(api::orderman::Fill::FILL_STATUS_CORRECTED);
|
||||
fill.set_fill_key(fk);
|
||||
|
||||
auto exchange_ts = utils::pb::to_timestamp(
|
||||
datetime::parse_FIX_timestamp(to_str(er.transact_time)));
|
||||
auto exchange_ts =
|
||||
std::visit(overloaded {
|
||||
[](const orderman::ExchangeTimeStampStr& ts) {
|
||||
return utils::pb::to_timestamp(
|
||||
datetime::parse_FIX_timestamp(to_str(ts)));
|
||||
},
|
||||
[](ExchangeTimeStamp64 ts) {
|
||||
google::protobuf::Timestamp gts;
|
||||
auto seconds = ts.value() / 1E9;
|
||||
gts.set_seconds(seconds);
|
||||
gts.set_nanos(ts.value() - (seconds * 1E9));
|
||||
return gts;
|
||||
}
|
||||
}, er.transact_time);
|
||||
|
||||
*fill.mutable_timestamp() = exchange_ts;
|
||||
|
||||
auto it = me->known_orders.find(er.order_key);
|
||||
|
||||
@@ -222,7 +222,9 @@ void GLBXExecutionGateway::on_exe_report(
|
||||
msg.get<fix::ManualOrderIndicator>()
|
||||
? api::orderman::MANUAL_ORDER_INDICATOR_YES
|
||||
: api::orderman::MANUAL_ORDER_INDICATOR_YES;
|
||||
str_to(msg.get<fix::OrderID>(), &data->exchange_order_id);
|
||||
str_to(msg.get<fix::OrderID>(),
|
||||
& std::get<ExchangeOrderID>(
|
||||
data->exchange_order_id));
|
||||
|
||||
if (msg.has<fix::Price>())
|
||||
data->price = securities::decode_exchange_price(
|
||||
@@ -261,7 +263,9 @@ void GLBXExecutionGateway::on_exe_report(
|
||||
: Price(0);
|
||||
if (msg.has<fix::ExecID>())
|
||||
str_to(msg.get<fix::ExecID>(), &data->exchange_fill_id);
|
||||
str_to(msg.get<fix::TransactTimeStr>(), &data->transact_time);
|
||||
orderman::ExchangeTimeStampStr t;
|
||||
str_to(msg.get<fix::TransactTimeStr>(), &t);
|
||||
data->transact_time = t;
|
||||
|
||||
if (msg.has<fix::CustOrderHandlingInst>())
|
||||
data->cust_order_handling_inst = msg.get<fix::CustOrderHandlingInst>();
|
||||
|
||||
@@ -18,6 +18,7 @@ class GLBXExecutionGateway : public IExecutionGateway {
|
||||
void on_securities(const mercury::Update<NewSecuritiesEvent> &) override;
|
||||
void on_admin_data(const mercury::Update<NewAdminDataEvent> &) override;
|
||||
void send_fix(jetfix::OutFIXPtr const &fix, trace::CorID trace) override;
|
||||
void send_msgs(std::vector<OrderMsg> const&, trace::CorID) override {bts_assert(false);}
|
||||
|
||||
OnExeReport& on_exe_report() override;
|
||||
OnGwStatusChange& on_gw_status_change() override;
|
||||
|
||||
@@ -0,0 +1,284 @@
|
||||
#include "lib/orderman/actors/GLBXiLink3ExecutionGateway.h"
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/config/protos/orderman_cfg.pb.h"
|
||||
#include "lib/domain_model/Security.h"
|
||||
#include "lib/jetfix/common/OutFIX.h"
|
||||
#include "lib/jetfix/store/session_name.h"
|
||||
#include "lib/orderman/actors/GLBXExecutionGateway.h"
|
||||
#include "lib/orderman/actors/ilink3/IL3Reactor.h"
|
||||
#include "lib/orderman/actors/ilink3/ILinkGW.h"
|
||||
#include "lib/orderman/actors/ilink3/SessionStore.h"
|
||||
#include "lib/orderman/events/NewSecuritiesEvent.h"
|
||||
#include "lib/orderman/orderman_utils/fix_order_codec.h"
|
||||
#include "lib/orderman/actors/ilink3/IL3MessageFramer.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
enum class GLBXiLink3ExecutionGateway::State {
|
||||
|
||||
WAITING_FOR_SECURITIES,
|
||||
PAUSED,
|
||||
CONNECTING,
|
||||
READY
|
||||
};
|
||||
|
||||
struct GLBXiLink3ExecutionGateway::PImpl {
|
||||
PImpl(config::JetFIX::Connection const &cfg, trace::PerfLog &log,
|
||||
md::SecurityOracle o)
|
||||
: state(), cfg(cfg), reactor(), start_of_pause(), on_exe_report(),
|
||||
on_gw_status_change(), on_cancel_reject(), perf_log(log),
|
||||
sec_oracle(o), securities(), securities_by_descriptor(),
|
||||
gw_name(cfg.name()), session_store(), gw(), connection(nullptr),
|
||||
connection_failures(0) {
|
||||
TCPEndpoint endpoint{cfg.socket_connect_host_ip(),
|
||||
(ushort)cfg.socket_connect_port()};
|
||||
connection = &reactor.register_connection({endpoint});
|
||||
}
|
||||
|
||||
State state;
|
||||
config::JetFIX::Connection const cfg;
|
||||
IL3Reactor reactor;
|
||||
IL3MessageFramer framer;
|
||||
TimeStamp start_of_pause;
|
||||
|
||||
OnExeReport on_exe_report;
|
||||
OnGwStatusChange on_gw_status_change;
|
||||
orderman::OnCancelReject on_cancel_reject;
|
||||
trace::PerfLog &perf_log;
|
||||
md::SecurityOracle sec_oracle;
|
||||
std::unordered_map<SecurityKey::Value, api::Security const *> securities;
|
||||
std::unordered_map<std::string, api::Security const *>
|
||||
securities_by_descriptor;
|
||||
GatewayName gw_name;
|
||||
std::optional<SessionStore> session_store;
|
||||
std::optional<ILinkGW> gw;
|
||||
IL3Connection *connection;
|
||||
size_t connection_failures;
|
||||
};
|
||||
|
||||
GLBXiLink3ExecutionGateway::GLBXiLink3ExecutionGateway(
|
||||
config::JetFIX::Connection const &cfg, trace::PerfLog &log,
|
||||
md::SecurityOracle o)
|
||||
: me(new PImpl(cfg, log, o)) {
|
||||
me->state = State::WAITING_FOR_SECURITIES;
|
||||
}
|
||||
|
||||
GLBXiLink3ExecutionGateway::~GLBXiLink3ExecutionGateway() {}
|
||||
|
||||
void GLBXiLink3ExecutionGateway::start() {}
|
||||
|
||||
void GLBXiLink3ExecutionGateway::dispatch_incoming_fix_messages() {
|
||||
switch (me->state) {
|
||||
case State::WAITING_FOR_SECURITIES:
|
||||
break;
|
||||
case State::PAUSED:
|
||||
on_time();
|
||||
break;
|
||||
case State::READY:
|
||||
case State::CONNECTING:
|
||||
me->reactor.do_work();
|
||||
me->gw->on_time();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void GLBXiLink3ExecutionGateway::on_time() {
|
||||
bts_assert(me->state == State::PAUSED);
|
||||
|
||||
// If we are still paused bail early, this avoids logging too much
|
||||
// or spending too much CPU
|
||||
if (pause_in_effect())
|
||||
return;
|
||||
|
||||
me->start_of_pause = Timer::now();
|
||||
|
||||
// If we alread exceed the maximum number of failures per run
|
||||
// bail. This is a safety measure to avoid overwhelming the
|
||||
// exchange in the event of a bug or operational problem that
|
||||
// results in repeated connection failures.
|
||||
if (max_failures_reached()) {
|
||||
LOG(iLink3, Warn,
|
||||
"Maximum number of connection failures reached for {}. Reboot to try "
|
||||
"again",
|
||||
me->gw_name.value());
|
||||
return;
|
||||
}
|
||||
|
||||
// If we reach this point we are no longer in the pause window and
|
||||
// we have not exceed our connection failure limit. The only thing
|
||||
// to check now is wheter we are inside the exchange's active
|
||||
// hours.
|
||||
auto current_session = jetfix::session_name(me->cfg);
|
||||
if (current_session.empty()) {
|
||||
LOG(iLink3, Info, "Outside of session in ", me->gw_name.value());
|
||||
return;
|
||||
}
|
||||
// Yep, the stars are all aligned, lets try to connect
|
||||
connect(current_session);
|
||||
}
|
||||
|
||||
void GLBXiLink3ExecutionGateway::connect(jetfix::SessionName const &sn) {
|
||||
bts_assert(me->state == State::PAUSED);
|
||||
transition(State::CONNECTING);
|
||||
Config c;
|
||||
c.cme_session = me->cfg.sender_compid().substr(0, 3);
|
||||
c.firm = me->cfg.sender_compid().substr(3);
|
||||
c.failover_on_disconnect = false;
|
||||
|
||||
me->session_store.emplace(me->sec_oracle, sn, me->cfg);
|
||||
c.raw_message_logger =
|
||||
[store = &me->session_store.value()](auto d, auto const &msg) {
|
||||
store->async_store_raw_msg(d, msg);
|
||||
};
|
||||
|
||||
me->gw.emplace(*me->connection, me->framer, &me->sec_oracle, me->session_store->starting_session_descriptor(), c, me->cfg);
|
||||
|
||||
me->gw->subscribe_cancel_reject([this](auto k, auto const &msg) {
|
||||
bts_assert(me->state == State::READY || me->state == State::CONNECTING);
|
||||
me->on_cancel_reject(k, msg);
|
||||
});
|
||||
|
||||
me->gw->subscribe_execution_reports([this](auto er) {
|
||||
bts_assert(me->state == State::READY || me->state == State::CONNECTING);
|
||||
me->on_exe_report(*er, {});
|
||||
});
|
||||
|
||||
me->gw->subscribe_session([this](auto const &s) {
|
||||
me->session_store->async_update_session(s);
|
||||
});
|
||||
|
||||
me->gw->subscribe_state([this](auto gw_state) {
|
||||
LOG(iLink3, Info, "Internal gateway state change in {}. State is now {}",
|
||||
me->gw_name.value(),
|
||||
log::CharPtrWrapper{ilink3::state_string(gw_state)});
|
||||
switch (me->state) {
|
||||
case State::CONNECTING:
|
||||
if (gw_state == ilink3::State::READY) {
|
||||
transition(State::READY);
|
||||
me->on_gw_status_change(true);
|
||||
} else if (gw_state == ilink3::State::ERROR) {
|
||||
me->connection_failures++;
|
||||
pause();
|
||||
}
|
||||
break;
|
||||
case State::READY:
|
||||
if (gw_state == ilink3::State::ERROR) {
|
||||
me->connection_failures++;
|
||||
pause();
|
||||
me->on_gw_status_change(false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
bts_assert(false);
|
||||
break;
|
||||
}
|
||||
});
|
||||
me->gw->connect();
|
||||
}
|
||||
|
||||
void GLBXiLink3ExecutionGateway::pause() {
|
||||
me->start_of_pause = Timer::now();
|
||||
me->gw.reset();
|
||||
transition(State::PAUSED);
|
||||
}
|
||||
|
||||
bool GLBXiLink3ExecutionGateway::pause_in_effect() const {
|
||||
return sec_diff(Timer::now(), me->start_of_pause) <=
|
||||
me->cfg.seconds_to_pause();
|
||||
}
|
||||
|
||||
bool GLBXiLink3ExecutionGateway::max_failures_reached() const {
|
||||
return me->connection_failures > me->cfg.max_connection_attempts();
|
||||
}
|
||||
|
||||
void GLBXiLink3ExecutionGateway::on_securities(
|
||||
const mercury::Update<NewSecuritiesEvent> &update) {
|
||||
if (update.events) {
|
||||
|
||||
for (auto const &ev : *(update.events)) {
|
||||
auto sec_ptr = ev.security;
|
||||
me->securities[sec_ptr->id()] = sec_ptr;
|
||||
me->securities_by_descriptor[securities::descriptor(*sec_ptr)] =
|
||||
sec_ptr;
|
||||
}
|
||||
|
||||
if (me->state == State::WAITING_FOR_SECURITIES) {
|
||||
LOG(iLink3, Warn,
|
||||
"Received first set of {} securities. Proceeding "
|
||||
"with initialization of execution gateway {}",
|
||||
update.events->size(), me->gw_name.value());
|
||||
// got our security synopsis, ready to start the GW
|
||||
transition(State::PAUSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GLBXiLink3ExecutionGateway::on_admin_data(
|
||||
const mercury::Update<NewAdminDataEvent> &) {}
|
||||
|
||||
void GLBXiLink3ExecutionGateway::send_msgs(std::vector<OrderMsg> const &msgs,
|
||||
trace::CorID) {
|
||||
|
||||
if (me->state == State::READY) {
|
||||
for (auto &m : msgs) {
|
||||
// NewOrderSingle
|
||||
auto create_ptr = std::get_if<CreateOrderMsg>(&m);
|
||||
if (create_ptr) {
|
||||
me->gw->send_order(*create_ptr);
|
||||
break;
|
||||
}
|
||||
// CancelReplace
|
||||
auto cancel_replace_ptr = std::get_if<CancelReplaceOrderMsg>(&m);
|
||||
if (cancel_replace_ptr) {
|
||||
me->gw->send_cancel_replace(*cancel_replace_ptr);
|
||||
break;
|
||||
}
|
||||
// Cancel
|
||||
auto cancel_ptr = std::get_if<CancelOrderMsg>(&m);
|
||||
if (cancel_ptr) {
|
||||
me->gw->send_cancel(*cancel_ptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
me->gw->flush();
|
||||
}
|
||||
}
|
||||
|
||||
OnExeReport &GLBXiLink3ExecutionGateway::on_exe_report() {
|
||||
return me->on_exe_report;
|
||||
}
|
||||
|
||||
OnGwStatusChange &GLBXiLink3ExecutionGateway::on_gw_status_change() {
|
||||
return me->on_gw_status_change;
|
||||
}
|
||||
|
||||
orderman::OnCancelReject &GLBXiLink3ExecutionGateway::on_cancel_reject() {
|
||||
return me->on_cancel_reject;
|
||||
}
|
||||
|
||||
log::CharPtrWrapper GLBXiLink3ExecutionGateway::state_name(State st) {
|
||||
switch (st) {
|
||||
case State::WAITING_FOR_SECURITIES:
|
||||
return {"WAITING_FOR_SECURITIES"};
|
||||
case State::PAUSED:
|
||||
return {"PAUSED"};
|
||||
case State::CONNECTING:
|
||||
return {"CONNECTING"};
|
||||
case State::READY:
|
||||
return {"READY"};
|
||||
}
|
||||
bts_assert(false);
|
||||
return {""};
|
||||
}
|
||||
|
||||
void GLBXiLink3ExecutionGateway::transition(State new_state) {
|
||||
LOG(iLink3, Info, "Transitioning {} from {} to {}", me->gw_name.value(),
|
||||
state_name(me->state), state_name(new_state));
|
||||
me->state = new_state;
|
||||
}
|
||||
|
||||
} // namespace ilink3
|
||||
} // namespace orderman
|
||||
} // namespace bts
|
||||
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include "IExecutionGateway.h"
|
||||
#include "lib/logging/logging.h"
|
||||
|
||||
namespace bts {
|
||||
namespace jetfix {struct SessionName;}
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
struct Session;
|
||||
|
||||
class GLBXiLink3ExecutionGateway : public IExecutionGateway {
|
||||
public:
|
||||
GLBXiLink3ExecutionGateway(config::JetFIX::Connection const &, trace::PerfLog &,
|
||||
md::SecurityOracle);
|
||||
virtual ~GLBXiLink3ExecutionGateway();
|
||||
|
||||
void start() override;
|
||||
void dispatch_incoming_fix_messages() override;
|
||||
void on_securities(const mercury::Update<NewSecuritiesEvent> &) override;
|
||||
void on_admin_data(const mercury::Update<NewAdminDataEvent> &) override;
|
||||
void send_fix(jetfix::OutFIXPtr const &, trace::CorID ) override {bts_assert(false);}
|
||||
void send_msgs(std::vector<OrderMsg> const&, trace::CorID) override;
|
||||
|
||||
OnExeReport& on_exe_report() override;
|
||||
OnGwStatusChange& on_gw_status_change() override;
|
||||
OnCancelReject &on_cancel_reject() override;
|
||||
|
||||
private:
|
||||
enum class State;
|
||||
struct PImpl;
|
||||
std::unique_ptr<PImpl> me;
|
||||
|
||||
// Time passing
|
||||
void on_time();
|
||||
bool pause_in_effect() const;
|
||||
bool max_failures_reached()const;
|
||||
static log::CharPtrWrapper state_name(State);
|
||||
void transition(State);
|
||||
|
||||
void pause();
|
||||
void connect(jetfix::SessionName const&);
|
||||
};
|
||||
|
||||
} // namespace orderman
|
||||
} // namespace bts
|
||||
}
|
||||
@@ -390,7 +390,9 @@ void ICEExecutionGateway::on_exe_report(const jetfix::fix::ICEExecutionReportMsg
|
||||
data->manual_order_indicator = api::orderman::MANUAL_ORDER_INDICATOR_NO;
|
||||
|
||||
std::string oid_string = get_ice_order_id_string(msg);
|
||||
str_to(oid_string, &data->exchange_order_id);
|
||||
str_to(oid_string,
|
||||
& std::get<ExchangeOrderID>(
|
||||
data->exchange_order_id));
|
||||
data->ice_cl_ord_id = 0;
|
||||
if(msg.has<fix::Int_ClOrdID>())
|
||||
data->ice_cl_ord_id = msg.get<fix::Int_ClOrdID>();
|
||||
@@ -438,8 +440,10 @@ void ICEExecutionGateway::on_exe_report(const jetfix::fix::ICEExecutionReportMsg
|
||||
if (msg.has<fix::TransactTimeStr>())
|
||||
{
|
||||
std::string stamp = msg.get<fix::TransactTimeStr>();
|
||||
stamp.resize(sizeof(mercury::TimeStampStr));
|
||||
str_to(stamp, &data->transact_time);
|
||||
stamp.resize(sizeof(orderman::ExchangeTimeStampStr));
|
||||
orderman::ExchangeTimeStampStr t;
|
||||
str_to(stamp, &t);
|
||||
data->transact_time = t;
|
||||
}
|
||||
data->cfg = &me->cfg;
|
||||
data->msg = text_msg;
|
||||
|
||||
@@ -17,6 +17,7 @@ class ICEExecutionGateway : public IExecutionGateway {
|
||||
void on_securities(const mercury::Update<NewSecuritiesEvent> &) override;
|
||||
void on_admin_data(const mercury::Update<NewAdminDataEvent> &) override;
|
||||
void send_fix(const jetfix::OutFIXPtr& fix, trace::CorID trace) override;
|
||||
void send_msgs(std::vector<OrderMsg> const&, trace::CorID) override {bts_assert(false);}
|
||||
|
||||
OnExeReport& on_exe_report() override;
|
||||
OnGwStatusChange& on_gw_status_change() override;
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
|
||||
#include "IExecutionGateway.h"
|
||||
#include "ICEExecutionGateway.h"
|
||||
#include "GLBXExecutionGateway.h"
|
||||
#include "ICEExecutionGateway.h"
|
||||
#include "lib/utils/ValueWrapper.h"
|
||||
#include "lib/orderman/actors/GLBXiLink3ExecutionGateway.h"
|
||||
|
||||
#include <variant>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
std::unique_ptr<IExecutionGateway>
|
||||
ExecutionGatewayFactory::create_gateway(const config::JetFIX::Connection& conn, trace::PerfLog& pl, md::SecurityOracle o)
|
||||
{
|
||||
if(conn.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_ICE ||
|
||||
conn.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_SIMICE)
|
||||
ExecutionGatewayFactory::create_gateway(const config::JetFIX::Connection &conn,
|
||||
trace::PerfLog &pl,
|
||||
md::SecurityOracle o) {
|
||||
if (conn.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_ICE ||
|
||||
conn.platform() == bts::config::JetFIX_Connection_JetFIXPlatform_SIMICE)
|
||||
return std::make_unique<ICEExecutionGateway>(conn, pl, o);
|
||||
else if (conn.use_ilink3())
|
||||
return std::make_unique<ilink3::GLBXiLink3ExecutionGateway>(conn, pl, o);
|
||||
else
|
||||
return std::make_unique<GLBXExecutionGateway>(conn, pl, o);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "lib/utils/bts_no_copy.h"
|
||||
|
||||
#include <memory>
|
||||
#include <variant>
|
||||
|
||||
namespace bts {
|
||||
namespace trace {struct CorID;class PerfLog;}
|
||||
@@ -18,6 +19,37 @@ class NewAdminDataEvent;
|
||||
class ExecutionReport;
|
||||
|
||||
|
||||
struct CreateOrderMsg {
|
||||
OrderKey key;
|
||||
Price price;
|
||||
Quantity quantity;
|
||||
api::Security const *security;
|
||||
api::Side side;
|
||||
Price stop_px;
|
||||
Quantity display_quantity;
|
||||
api::orderman::NativeOrderType order_type;
|
||||
api::orderman::TimeInForce time_in_force;
|
||||
api::orderman::ManualOrderIndicator manual_order_indicator;
|
||||
api::orderman::RoutingRecord const *routing_record;
|
||||
};
|
||||
|
||||
struct CancelReplaceOrderMsg {
|
||||
CreateOrderMsg create_fields;
|
||||
ExchangeOrderID64 exchange_order_id;
|
||||
};
|
||||
|
||||
struct CancelOrderMsg {
|
||||
OrderKey key;
|
||||
ExchangeOrderID64 exchange_order_id;
|
||||
api::orderman::ManualOrderIndicator manual_order_indicator;
|
||||
api::Security const *security;
|
||||
api::orderman::RoutingRecord const *routing_record;
|
||||
api::Side side;
|
||||
};
|
||||
|
||||
using OrderMsg =
|
||||
std::variant<CreateOrderMsg, CancelReplaceOrderMsg, CancelOrderMsg>;
|
||||
|
||||
using OnGwStatusChange = std::function<void(bool)>;
|
||||
using OnExeReport = std::function<void(ExecutionReport const &, trace::CorID const &)>;
|
||||
using OnCancelReject = std::function<void(OrderKey, std::string const &)>;
|
||||
@@ -33,7 +65,7 @@ class IExecutionGateway {
|
||||
virtual void on_securities(const mercury::Update<NewSecuritiesEvent> &) = 0;
|
||||
virtual void on_admin_data(const mercury::Update<NewAdminDataEvent> &) = 0;
|
||||
virtual void send_fix(const jetfix::OutFIXPtr&, trace::CorID) = 0;
|
||||
|
||||
virtual void send_msgs(std::vector<OrderMsg> const&, trace::CorID) = 0;
|
||||
virtual OnExeReport& on_exe_report() = 0;
|
||||
virtual OnGwStatusChange& on_gw_status_change() = 0;
|
||||
virtual OnCancelReject &on_cancel_reject() = 0;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "IL3ConnectionHandler.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
struct IL3Connection {
|
||||
virtual ~IL3Connection() = default;
|
||||
virtual void connect(IL3ConnectionHandler&) = 0;
|
||||
virtual void disconnect() = 0;
|
||||
// Switch connection but do not connect()
|
||||
virtual void failover() = 0;
|
||||
virtual void send(const std::string_view) = 0;
|
||||
virtual void send(const std::vector<std::string_view>&) = 0;
|
||||
};
|
||||
|
||||
}}}//namespace
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "IL3ConnectionHandler.h"
|
||||
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
IL3ConnectionHandler::~IL3ConnectionHandler() = default;
|
||||
|
||||
}}}
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
struct IL3ConnectionHandler {
|
||||
virtual ~IL3ConnectionHandler() ;
|
||||
virtual void on_connect_success() = 0;
|
||||
virtual void on_disconnect() = 0;
|
||||
// Send available data and length. Handler will return what it consumed
|
||||
virtual size_t on_data(const std::string_view&) = 0;
|
||||
};
|
||||
|
||||
}}}//namespace
|
||||
@@ -0,0 +1,135 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include "IL3GeneratedFull.h"
|
||||
#include "IL3MessageFramer.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
template <class Handler, class T>
|
||||
void handle(Handler& h, const char* data, uint16_t len) {
|
||||
T t {
|
||||
const_cast<char*>(data),
|
||||
sizeof(FramingHeader) + iLinkBinary::MessageHeader::encodedLength(),
|
||||
len,
|
||||
T::sbeBlockLength(),
|
||||
T::sbeSchemaVersion() };
|
||||
h.handle(t);
|
||||
}
|
||||
|
||||
|
||||
template <class H>
|
||||
void dispatch_message(H& handler, const FramingHeader* header, const char* data) {
|
||||
using namespace iLinkBinary;
|
||||
bts_assert_d(header->encoding_type == 0XCAFE);
|
||||
MessageHeader mheader {
|
||||
(char*)data, sizeof(FramingHeader), header->message_size,
|
||||
MessageHeader::sbeSchemaVersion() };
|
||||
|
||||
switch(mheader.templateId()) {
|
||||
case 501: handle<H, NegotiationResponse501>(handler, data, header->message_size); break;
|
||||
case 502: handle<H, NegotiationReject502>(handler, data, header->message_size); break;
|
||||
case 504: handle<H, EstablishmentAck504>(handler, data, header->message_size); break;
|
||||
case 505: handle<H, EstablishmentReject505>(handler, data, header->message_size); break;
|
||||
case 506: handle<H, Sequence506>(handler, data, header->message_size); break;
|
||||
case 507: handle<H, Terminate507>(handler, data, header->message_size); break;
|
||||
case 509: handle<H, Retransmission509>(handler, data, header->message_size); break;
|
||||
case 510: handle<H, RetransmitReject510>(handler, data, header->message_size); break;
|
||||
case 513: handle<H, NotApplied513>(handler, data, header->message_size); break;
|
||||
case 519: handle<H, PartyDetailsDefinitionRequestAck519>(handler, data, header->message_size); break;
|
||||
case 521: handle<H, BusinessReject521>(handler, data, header->message_size); break;
|
||||
case 522: handle<H, ExecutionReportNew522>(handler, data, header->message_size); break;
|
||||
case 523: handle<H, ExecutionReportReject523>(handler, data, header->message_size); break;
|
||||
case 524: handle<H, ExecutionReportElimination524>(handler, data, header->message_size); break;
|
||||
case 525: handle<H, ExecutionReportTradeOutright525>(handler, data, header->message_size); break;
|
||||
case 526: handle<H, ExecutionReportTradeSpread526>(handler, data, header->message_size); break;
|
||||
case 527: handle<H, ExecutionReportTradeSpreadLeg527>(handler, data, header->message_size); break;
|
||||
case 531: handle<H, ExecutionReportModify531>(handler, data, header->message_size); break;
|
||||
case 532: handle<H, ExecutionReportStatus532>(handler, data, header->message_size); break;
|
||||
case 534: handle<H, ExecutionReportCancel534>(handler, data, header->message_size); break;
|
||||
case 535: handle<H, OrderCancelReject535>(handler, data, header->message_size); break;
|
||||
case 536: handle<H, OrderCancelReplaceReject536>(handler, data, header->message_size); break;
|
||||
// case 538: handle<H, PartyDetailsListReport538>(handler, data, header->message_size); break;
|
||||
// The Execution Acknowledgment message notifies CME that a given fill has either been accepted or rejected by a counterparty for EU bilateral trades.
|
||||
// case 539: handle<H, ExecutionAck539>(handler, data, header->message_size); break;
|
||||
// case 544: handle<H, NewOrderCross544>(handler, data, header->message_size); break;
|
||||
// case 545: handle<H, MassQuoteAck545>(handler, data, header->message_size); break;
|
||||
// case 546: handle<H, RequestForQuoteAck546>(handler, data, header->message_size); break;
|
||||
// case 547: handle<H, QuoteCancelAck547>(handler, data, header->message_size); break;
|
||||
case 548: handle<H, ExecutionReportTradeAddendumOutright548>(handler, data, header->message_size); break;
|
||||
case 549: handle<H, ExecutionReportTradeAddendumSpread549>(handler, data, header->message_size); break;
|
||||
case 550: handle<H, ExecutionReportTradeAddendumSpreadLeg550>(handler, data, header->message_size); break;
|
||||
// case 558: handle<H, iLinkBinary::OrderMassActionReport558>(handler, data, header->message_size); break;
|
||||
// case 561: handle<H, iLinkBinary::SecurityDefinitionResponse561>(handler, data, header->message_size); break;
|
||||
}
|
||||
}
|
||||
|
||||
template <class H>
|
||||
void dispatch_execution_reports(H& handler, const FramingHeader* header, const char* data) {
|
||||
using namespace iLinkBinary;
|
||||
bts_assert_d(header->encoding_type == 0XCAFE);
|
||||
MessageHeader mheader {
|
||||
(char*)data, sizeof(FramingHeader), header->message_size,
|
||||
MessageHeader::sbeSchemaVersion() };
|
||||
|
||||
switch(mheader.templateId()) {
|
||||
case 522: handle<H, ExecutionReportNew522>(handler, data, header->message_size); break;
|
||||
case 523: handle<H, ExecutionReportReject523>(handler, data, header->message_size); break;
|
||||
case 524: handle<H, ExecutionReportElimination524>(handler, data, header->message_size); break;
|
||||
case 525: handle<H, ExecutionReportTradeOutright525>(handler, data, header->message_size); break;
|
||||
case 526: handle<H, ExecutionReportTradeSpread526>(handler, data, header->message_size); break;
|
||||
case 527: handle<H, ExecutionReportTradeSpreadLeg527>(handler, data, header->message_size); break;
|
||||
case 531: handle<H, ExecutionReportModify531>(handler, data, header->message_size); break;
|
||||
case 532: handle<H, ExecutionReportStatus532>(handler, data, header->message_size); break;
|
||||
case 534: handle<H, ExecutionReportCancel534>(handler, data, header->message_size); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This handler handles exchange messages for testing
|
||||
template <class H>
|
||||
void dispatch_exchange_message(H& handler, const FramingHeader* header, const char* data) {
|
||||
using namespace iLinkBinary;
|
||||
bts_assert_d(header->encoding_type == 0XCAFE);
|
||||
MessageHeader mheader {
|
||||
(char*)data, sizeof(FramingHeader), header->message_size,
|
||||
MessageHeader::sbeSchemaVersion() };
|
||||
// Rather than trying to be exhaustive like the client
|
||||
// we will only add handlers for the messages we use for testing
|
||||
switch(mheader.templateId()) {
|
||||
case 500: handle<H, Negotiate500>(handler, data, header->message_size); break;
|
||||
case 503: handle<H, Establish503>(handler, data, header->message_size); break;
|
||||
case 506: handle<H, Sequence506>(handler, data, header->message_size); break;
|
||||
case 508: handle<H, RetransmitRequest508>(handler, data, header->message_size); break;
|
||||
case 518: handle<H, PartyDetailsDefinitionRequest518>(handler, data, header->message_size); break;
|
||||
case 514: handle<H, NewOrderSingle514>(handler, data, header->message_size); break;
|
||||
case 515: handle<H, OrderCancelReplaceRequest515>(handler, data, header->message_size); break;
|
||||
case 516: handle<H, OrderCancelRequest516>(handler, data, header->message_size); break;
|
||||
}
|
||||
}
|
||||
|
||||
template <class Handler, class Dispatcher>
|
||||
size_t consume_messages(
|
||||
Handler& handler, const char* data, size_t len, Dispatcher dispatch) {
|
||||
// void(*dispatch)(Handler&, const FramingHeader*, const char*)) {
|
||||
size_t read = 0;
|
||||
while(len > sizeof(FramingHeader)) {
|
||||
// read the FramingHeader
|
||||
const FramingHeader* header = reinterpret_cast<const FramingHeader*>(data);
|
||||
// Check if we can consume the message
|
||||
auto msize = header->message_size;
|
||||
if (msize <= len) {
|
||||
read += msize;
|
||||
dispatch(handler, header, data);
|
||||
data += msize;
|
||||
len -= msize;
|
||||
}
|
||||
else {
|
||||
return read;
|
||||
}
|
||||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
}}}//namespace
|
||||
@@ -0,0 +1,162 @@
|
||||
#include "IL3ExecutionReportParser.h"
|
||||
#include "IL3GeneratedFull.h"
|
||||
#include "ILink3Utils.h"
|
||||
#include "IL3Dispatcher.h"
|
||||
#include "lib/md/IntPrice.h"
|
||||
#include "lib/orderman/orderman_utils/fix_order_codec.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
IL3ExecutionReportParser::IL3ExecutionReportParser(config::JetFIX::Connection const &cfg, md::SecurityOracle* o):
|
||||
oracle(o),
|
||||
most_recent_account(),
|
||||
cfg(cfg)
|
||||
{}
|
||||
|
||||
void IL3ExecutionReportParser::cache(const api::Security* security) {
|
||||
auto id = SecurityKey { security->id() };
|
||||
if (security_cache.find(id) == security_cache.end()) {
|
||||
security_cache.insert(std::make_pair(id, security));
|
||||
}
|
||||
}
|
||||
|
||||
const api::Security* IL3ExecutionReportParser::get_security(SecurityKey id) {
|
||||
auto iter = security_cache.find(id);
|
||||
if (iter == security_cache.end()) {
|
||||
if (oracle) {
|
||||
return oracle->get_security(id);
|
||||
}
|
||||
else return nullptr;
|
||||
}
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void IL3ExecutionReportParser::common(const T& msg, ExecutionReport* data) {
|
||||
data->account_name = most_recent_account;
|
||||
|
||||
static_assert(sizeof(OperatorID) == T::senderIDLength());
|
||||
memcpy(&data->operator_id.value(), msg.senderID(), msg.senderIDLength());
|
||||
auto& price = const_cast<T&>(msg).price();
|
||||
data->exchange = api::VENUE_GLBX;
|
||||
data->exchange_order_id = ExchangeOrderID64 { msg.orderID() };
|
||||
data->leg_security = nullptr;
|
||||
data->manual_order_indicator = map_manual_order_indicator(msg.manualOrderIndicator());
|
||||
data->msg_seq_num = msg.seqNum();
|
||||
SecurityKey sk;
|
||||
decode_clorid(msg.clOrdID(),&data->order_key,&sk);
|
||||
auto sec = get_security(sk);
|
||||
bts_assert(sec);
|
||||
data->security = sec;
|
||||
//data->security = get_security(ExchangeSecurityKey { (uint64_t) msg.securityID() });
|
||||
data->order_type = map_order_type(msg.ordType());
|
||||
data->price = Price { price.mantissa() * md::pow10(price.exponent()) };
|
||||
data->quantity = Quantity { msg.orderQty() };
|
||||
data->side = map_side(msg.side());
|
||||
data->stop_price = Price { 0.0 };
|
||||
data->time_in_force = map_time_in_force(msg.timeInForce());
|
||||
data->transact_time = ExchangeTimeStamp64 { msg.transactTime() };
|
||||
|
||||
data->ice_cl_ord_id = 0;
|
||||
data->ice_company_id = 0;
|
||||
data->cfg = &cfg;
|
||||
}
|
||||
|
||||
bool IL3ExecutionReportParser::parse(const iLinkBinary::ExecutionReportNew522& msg, ExecutionReport* data) {
|
||||
common(msg, data);
|
||||
data->avg_price = Price { 0.0 };
|
||||
data->cust_order_handling_inst = "";
|
||||
data->exchange_fill_id = ExchangeFillID { };
|
||||
data->exec_type = api::orderman::EXEC_TYPE_NEW;
|
||||
data->filled_quantity = Quantity { 0 };
|
||||
data->last_price = Price { 0.0 };
|
||||
data->last_shares = Quantity { 0 };
|
||||
data->max_show = Quantity { 0 };
|
||||
data->memo = "";
|
||||
data->msg = "";
|
||||
|
||||
data->order_status = api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_NEW;
|
||||
|
||||
return true;
|
||||
}
|
||||
bool IL3ExecutionReportParser::parse(const iLinkBinary::ExecutionReportReject523& msg, ExecutionReport* data) {
|
||||
common(msg, data);
|
||||
data->order_status = api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_REJECTED;
|
||||
return true;
|
||||
}
|
||||
bool IL3ExecutionReportParser::parse(const iLinkBinary::ExecutionReportElimination524& msg, ExecutionReport* data) {
|
||||
common(msg, data);
|
||||
return true;
|
||||
}
|
||||
bool IL3ExecutionReportParser::parse(const iLinkBinary::ExecutionReportTradeOutright525& msg, ExecutionReport* data) {
|
||||
common(msg, data);
|
||||
switch(msg.ordStatus()) {
|
||||
case iLinkBinary::OrdStatusTrd::Filled:
|
||||
data->order_status = api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_FILLED;
|
||||
break;
|
||||
case iLinkBinary::OrdStatusTrd::PartiallyFilled:
|
||||
data->order_status = api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_PARTIALLY_FILLED;
|
||||
break;
|
||||
default:
|
||||
data->order_status = api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_UNDEFINED;
|
||||
}
|
||||
data->last_shares = Quantity { msg.lastQty() };
|
||||
data->filled_quantity = Quantity { msg.cumQty() };
|
||||
return true;
|
||||
}
|
||||
bool IL3ExecutionReportParser::parse(const iLinkBinary::ExecutionReportTradeSpread526& msg, ExecutionReport* data) {
|
||||
common(msg, data);
|
||||
return true;
|
||||
}
|
||||
bool IL3ExecutionReportParser::parse(const iLinkBinary::ExecutionReportTradeSpreadLeg527& msg, ExecutionReport* data) {
|
||||
// determine spread security from order key?
|
||||
(void)msg;
|
||||
(void)data;
|
||||
return false;
|
||||
}
|
||||
bool IL3ExecutionReportParser::parse(const iLinkBinary::ExecutionReportModify531& msg, ExecutionReport* data) {
|
||||
common(msg, data);
|
||||
return true;
|
||||
}
|
||||
bool IL3ExecutionReportParser::parse(const iLinkBinary::ExecutionReportStatus532& msg, ExecutionReport* data) {
|
||||
common(msg, data);
|
||||
// data->order_status = msg.
|
||||
return true;
|
||||
}
|
||||
bool IL3ExecutionReportParser::parse(const iLinkBinary::ExecutionReportCancel534& msg, ExecutionReport* data) {
|
||||
common(msg, data);
|
||||
data->order_status = api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_CANCELED;
|
||||
return true;
|
||||
}
|
||||
void IL3ExecutionReportParser::set_account(const iLinkBinary::PartyDetailsDefinitionRequestAck519& msg) {
|
||||
// When using on-demand format the PartyDetailsDefinitionRequestAck519
|
||||
// is sent back immediately preceding the execution report on the wire.
|
||||
auto details =const_cast<iLinkBinary::PartyDetailsDefinitionRequestAck519&> (msg).noPartyDetails();
|
||||
while(details.hasNext()) {
|
||||
details.next();
|
||||
if (details.partyDetailRole() == iLinkBinary::PartyDetailRole::CustomerAccount) {
|
||||
const char* p_account = details.partyDetailID();
|
||||
strncpy(most_recent_account.value().data(), p_account, most_recent_account.value().size());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ParseHandler {
|
||||
IL3ExecutionReportParser& parser;
|
||||
ExecutionReport* result;
|
||||
bool success = false;
|
||||
template<class T>
|
||||
void handle(const T& t) { success = parser.parse(t, result); }
|
||||
void handle(iLinkBinary::PartyDetailsDefinitionRequestAck519& t) { parser.set_account(t); }
|
||||
};
|
||||
|
||||
bool parse_report(const std::string& data, IL3ExecutionReportParser& parser, ExecutionReport* result) {
|
||||
ParseHandler handler { parser, result };
|
||||
consume_messages(handler, data.c_str(), data.size(), dispatch_execution_reports<ParseHandler>);
|
||||
return handler.success;
|
||||
}
|
||||
|
||||
}}}//namespace
|
||||
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/orderman/orderman_utils/ExecutionReport.h"
|
||||
#include "IL3GeneratedFwd.h"
|
||||
#include "lib/md/SecurityOracle.h"
|
||||
#include "lib/md/ExchangeSecurityKey.h"
|
||||
#include <boost/pool/object_pool.hpp>
|
||||
#include <google/btree/btree_map.h>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
class IL3ExecutionReportParser {
|
||||
btree::btree_map<SecurityKey, const api::Security*> security_cache;
|
||||
md::SecurityOracle* oracle;
|
||||
AccountName most_recent_account;
|
||||
config::JetFIX::Connection const cfg;
|
||||
|
||||
const api::Security* get_security(SecurityKey);
|
||||
|
||||
public:
|
||||
IL3ExecutionReportParser(config::JetFIX::Connection const &, md::SecurityOracle*);
|
||||
void cache(const api::Security*);
|
||||
|
||||
bool parse(const iLinkBinary::ExecutionReportNew522&, ExecutionReport*);
|
||||
bool parse(const iLinkBinary::ExecutionReportReject523&, ExecutionReport*);
|
||||
bool parse(const iLinkBinary::ExecutionReportElimination524&, ExecutionReport*);
|
||||
bool parse(const iLinkBinary::ExecutionReportTradeOutright525&, ExecutionReport*);
|
||||
bool parse(const iLinkBinary::ExecutionReportTradeSpread526&, ExecutionReport*);
|
||||
bool parse(const iLinkBinary::ExecutionReportTradeSpreadLeg527&, ExecutionReport*);
|
||||
bool parse(const iLinkBinary::ExecutionReportModify531&, ExecutionReport*);
|
||||
bool parse(const iLinkBinary::ExecutionReportStatus532&, ExecutionReport*);
|
||||
bool parse(const iLinkBinary::ExecutionReportCancel534&, ExecutionReport*);
|
||||
void set_account(const iLinkBinary::PartyDetailsDefinitionRequestAck519&);
|
||||
|
||||
template <class T> void common(const T&, ExecutionReport*);
|
||||
};
|
||||
|
||||
bool parse_report(const std::string&, IL3ExecutionReportParser&, ExecutionReport*);
|
||||
|
||||
}}}//namespace
|
||||
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
//
|
||||
// Message templates
|
||||
|
||||
// BTS -> CME
|
||||
#include "generated/Negotiate500.h"
|
||||
#include "generated/Establish503.h"
|
||||
#include "generated/RetransmitRequest508.h"
|
||||
#include "generated/NewOrderSingle514.h"
|
||||
#include "generated/OrderCancelReplaceRequest515.h"
|
||||
#include "generated/OrderCancelRequest516.h"
|
||||
// #include "generated/MassQuote517.h"
|
||||
#include "generated/PartyDetailsDefinitionRequest518.h"
|
||||
// #include "generated/QuoteCancel528.h"
|
||||
// #include "generated/OrderMassActionRequest529.h"
|
||||
// #include "generated/OrderMassStatusRequest530.h"
|
||||
// #include "generated/OrderStatusRequest533.h"
|
||||
// #include "generated/PartyDetailsListRequest537.h"
|
||||
// #include "generated/RequestForQuote543.h"
|
||||
// #include "generated/SecurityDefinitionRequest560.h"
|
||||
|
||||
// CME -> BTS
|
||||
#include "generated/NegotiationResponse501.h"
|
||||
#include "generated/NegotiationReject502.h"
|
||||
#include "generated/EstablishmentAck504.h"
|
||||
#include "generated/EstablishmentReject505.h"
|
||||
#include "generated/Sequence506.h"
|
||||
#include "generated/Terminate507.h"
|
||||
#include "generated/Retransmission509.h"
|
||||
#include "generated/RetransmitReject510.h"
|
||||
#include "generated/NotApplied513.h"
|
||||
#include "generated/PartyDetailsDefinitionRequestAck519.h"
|
||||
#include "generated/BusinessReject521.h"
|
||||
#include "generated/ExecutionReportNew522.h"
|
||||
#include "generated/ExecutionReportReject523.h"
|
||||
#include "generated/ExecutionReportElimination524.h"
|
||||
#include "generated/ExecutionReportTradeOutright525.h"
|
||||
#include "generated/ExecutionReportTradeSpread526.h"
|
||||
#include "generated/ExecutionReportTradeSpreadLeg527.h"
|
||||
#include "generated/ExecutionReportModify531.h"
|
||||
#include "generated/ExecutionReportStatus532.h"
|
||||
#include "generated/ExecutionReportCancel534.h"
|
||||
#include "generated/OrderCancelReject535.h"
|
||||
#include "generated/OrderCancelReplaceReject536.h"
|
||||
// #include "generated/PartyDetailsListReport538.h"
|
||||
#include "generated/ExecutionAck539.h"
|
||||
// #include "generated/NewOrderCross544.h"
|
||||
// #include "generated/MassQuoteAck545.h"
|
||||
// #include "generated/RequestForQuoteAck546.h"
|
||||
// #include "generated/QuoteCancelAck547.h"
|
||||
#include "generated/ExecutionReportTradeAddendumOutright548.h"
|
||||
#include "generated/ExecutionReportTradeAddendumSpread549.h"
|
||||
#include "generated/ExecutionReportTradeAddendumSpreadLeg550.h"
|
||||
// #include "generated/OrderMassActionReport558.h"
|
||||
// #include "generated/SecurityDefinitionResponse561.h"
|
||||
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
namespace iLinkBinary {
|
||||
class Negotiate500;
|
||||
class Establish503;
|
||||
class RetransmitRequest508;
|
||||
class NewOrderSingle514;
|
||||
class OrderCancelReplaceRequest515;
|
||||
class OrderCancelRequest516;
|
||||
class PartyDetailsDefinitionRequest518;
|
||||
class NegotiationResponse501;
|
||||
class NegotiationReject502;
|
||||
class EstablishmentAck504;
|
||||
class EstablishmentReject505;
|
||||
class Sequence506;
|
||||
class Terminate507;
|
||||
class Retransmission509;
|
||||
class RetransmitReject510;
|
||||
class NotApplied513;
|
||||
class PartyDetailsDefinitionRequestAck519;
|
||||
class BusinessReject521;
|
||||
class ExecutionReportNew522;
|
||||
class ExecutionReportReject523;
|
||||
class ExecutionReportElimination524;
|
||||
class ExecutionReportTradeOutright525;
|
||||
class ExecutionReportTradeSpread526;
|
||||
class ExecutionReportTradeSpreadLeg527;
|
||||
class ExecutionReportModify531;
|
||||
class ExecutionReportStatus532;
|
||||
class ExecutionReportCancel534;
|
||||
class OrderCancelReject535;
|
||||
class OrderCancelReplaceReject536;
|
||||
class ExecutionAck539;
|
||||
class ExecutionReportTradeAddendumOutright548;
|
||||
class ExecutionReportTradeAddendumSpread549;
|
||||
class ExecutionReportTradeAddendumSpreadLeg550;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
#include "IL3Connection.h"
|
||||
#include "IL3ReceiveBuffer.h"
|
||||
|
||||
#include "generated/MessageHeader.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
struct FramingHeader {
|
||||
uint16_t message_size;
|
||||
uint16_t encoding_type;
|
||||
};
|
||||
|
||||
class IL3MessageFramer {
|
||||
std::vector<std::string_view> _buffer_ptrs;
|
||||
IL3ReceiveBuffer _memory;
|
||||
|
||||
public:
|
||||
IL3MessageFramer():
|
||||
_buffer_ptrs(), _memory()
|
||||
{
|
||||
_buffer_ptrs.reserve(512);
|
||||
}
|
||||
~IL3MessageFramer() = default;
|
||||
|
||||
//
|
||||
// Framing
|
||||
template <class Msg>
|
||||
Msg frame(size_t extra=0) {
|
||||
auto size =
|
||||
sizeof(FramingHeader) +
|
||||
iLinkBinary::MessageHeader::encodedLength() +
|
||||
Msg::sbeBlockLength() +
|
||||
extra;
|
||||
auto buffer = _memory.allocate(size);
|
||||
_memory.advance(size);
|
||||
FramingHeader* fhead = (FramingHeader*)(buffer.data());
|
||||
fhead->message_size = size;
|
||||
fhead->encoding_type = 0xCAFE;
|
||||
Msg msg;
|
||||
msg.wrapAndApplyHeader(const_cast<char*>(buffer.data()), sizeof(FramingHeader), size+sizeof(FramingHeader));
|
||||
_buffer_ptrs.push_back(buffer);
|
||||
return msg;
|
||||
}
|
||||
|
||||
void flush(IL3Connection& connection) {
|
||||
if (!_buffer_ptrs.empty()) {
|
||||
connection.send(_buffer_ptrs);
|
||||
_buffer_ptrs.clear();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}}} //namespace
|
||||
@@ -0,0 +1,221 @@
|
||||
#include "IL3Reactor.h"
|
||||
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include "IL3ReceiveBuffer.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
#include <fstream>
|
||||
#include <netinet/tcp.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
#include <array>
|
||||
#include <queue>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
struct IL3Reactor::Connection : public IL3Connection {
|
||||
int epoll_fd;
|
||||
int fd;
|
||||
bool is_connected;
|
||||
IL3ConnectionHandler* handler;
|
||||
std::queue<TCPEndpoint> end_points;
|
||||
IL3ReceiveBuffer rc_buffer;
|
||||
|
||||
Connection(int epoll_fd, const std::vector<TCPEndpoint>& end_points):
|
||||
epoll_fd(epoll_fd), fd(0), is_connected(false), handler(nullptr),
|
||||
end_points(std::deque<TCPEndpoint> { end_points.begin(), end_points.end() }),
|
||||
rc_buffer()
|
||||
{ }
|
||||
~Connection() {
|
||||
if (is_connected) disconnect();
|
||||
}
|
||||
|
||||
void connect(IL3ConnectionHandler& h) override {
|
||||
bts_assert(!is_connected);
|
||||
handler = &h;
|
||||
|
||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
int flag = 1;
|
||||
auto result = ::setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(int));
|
||||
bts_assert(result == 0);
|
||||
bts_assert(fd >= 0);
|
||||
|
||||
struct sockaddr_in serv_addr;
|
||||
memset(&serv_addr, '0', sizeof(serv_addr));
|
||||
|
||||
auto end_point = current_end_point();
|
||||
auto& host = end_point.host;
|
||||
auto port = end_point.port;
|
||||
|
||||
serv_addr.sin_family = AF_INET;
|
||||
serv_addr.sin_port = htons(port);
|
||||
result = inet_pton(AF_INET, host.c_str(), &serv_addr.sin_addr);
|
||||
bts_assert(result > 0);
|
||||
|
||||
result = ::connect(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
|
||||
if (result < 0) {
|
||||
auto er = errno;
|
||||
char msg[256];
|
||||
LOG(iLink3, Error, "Failed to connect: {} {}:{}",
|
||||
std::string(strerror_r(er, msg, sizeof(msg))),host,port);
|
||||
disconnect();
|
||||
}
|
||||
else {
|
||||
int flag = 1;
|
||||
result = ::setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag,
|
||||
sizeof(int));
|
||||
bts_assert(result == 0);
|
||||
|
||||
epoll_event ev;
|
||||
ev.events = EPOLLIN | EPOLLHUP | EPOLLERR | EPOLLRDHUP;
|
||||
ev.data.ptr = this;
|
||||
auto result = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev);
|
||||
bts_assert_msg(result == 0, "epoll");
|
||||
is_connected = true;
|
||||
handler->on_connect_success();
|
||||
}
|
||||
}
|
||||
|
||||
void disconnect() override {
|
||||
if (fd) close(fd);
|
||||
fd = 0;
|
||||
is_connected = false;
|
||||
handler->on_disconnect();
|
||||
}
|
||||
|
||||
void send(const std::string_view data) override {
|
||||
if (!is_connected) {
|
||||
LOG(iLink3, Error, "Attempted to send on closed connection. {}:{}", current_end_point().host, current_end_point().port);
|
||||
return;
|
||||
}
|
||||
auto result = write(fd, data.data(), data.size());
|
||||
if (result < 0) {
|
||||
auto er = errno;
|
||||
char msg[256];
|
||||
auto host = current_end_point().host;
|
||||
auto port = current_end_point().port;
|
||||
LOG(iLink3, Warn, "Could not write to reactor connection. {}:{}",
|
||||
std::string(strerror_r(er, msg, sizeof(msg))),host,port);
|
||||
disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void send(const std::vector<std::string_view>& dt) override {
|
||||
if (!is_connected) {
|
||||
LOG(iLink3, Error, "Attempted to send on closed connection. {}:{}", current_end_point().host, current_end_point().port);
|
||||
return;
|
||||
}
|
||||
|
||||
iovec *iv = (iovec*)alloca(sizeof(iovec)*dt.size());
|
||||
for (size_t i = 0; i < dt.size();i++) {
|
||||
iv[i].iov_base = (void*)dt[i].data();
|
||||
iv[i].iov_len = dt[i].size();
|
||||
}
|
||||
auto result = ::writev(fd,iv,dt.size());
|
||||
if (result < 0) {
|
||||
auto er = errno;
|
||||
char msg[256];
|
||||
auto host = current_end_point().host;
|
||||
auto port = current_end_point().port;
|
||||
LOG(iLink3, Warn, "Could not write to reactor connection. {}:{}",
|
||||
std::string(strerror_r(er, msg, sizeof(msg))),host,port);
|
||||
disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void on_data(const std::string_view data) {
|
||||
bts_assert_d(is_connected);
|
||||
// Copy input data into a permanent buffer
|
||||
rc_buffer.append(data);
|
||||
bts_assert_d(rc_buffer.unread() > 0);
|
||||
auto read = handler->on_data(rc_buffer.data());
|
||||
rc_buffer.advance(read);
|
||||
}
|
||||
|
||||
void failover() override {
|
||||
bts_assert(!is_connected);
|
||||
next_end_point();
|
||||
}
|
||||
|
||||
TCPEndpoint current_end_point() {
|
||||
return end_points.front();
|
||||
}
|
||||
|
||||
void next_end_point() {
|
||||
auto next = end_points.front();
|
||||
end_points.pop();
|
||||
end_points.push(next);
|
||||
}
|
||||
};
|
||||
|
||||
struct IL3Reactor::PImpl {
|
||||
int epoll_fd = -1;
|
||||
std::vector<std::unique_ptr<Connection>> connections;
|
||||
};
|
||||
|
||||
IL3Reactor::IL3Reactor() : me(new PImpl()) {
|
||||
me->epoll_fd = epoll_create(100);
|
||||
bts_assert(me->epoll_fd >= 0);
|
||||
}
|
||||
IL3Reactor::~IL3Reactor() {
|
||||
me->connections.clear();
|
||||
close(me->epoll_fd);
|
||||
me->epoll_fd = -1;
|
||||
}
|
||||
|
||||
IL3Connection& IL3Reactor::register_connection(const std::vector<TCPEndpoint>& end_points) {
|
||||
me->connections.emplace_back(
|
||||
std::make_unique<Connection>(me->epoll_fd, end_points));
|
||||
return *me->connections.back();
|
||||
}
|
||||
|
||||
[[gnu::noinline]]
|
||||
void non_inline_assert() {
|
||||
bts_assert(false);
|
||||
}
|
||||
|
||||
constexpr bool has_error(int events) {
|
||||
return events & (EPOLLHUP | EPOLLERR | EPOLLRDHUP);
|
||||
}
|
||||
|
||||
void IL3Reactor::do_work() {
|
||||
std::array<epoll_event, 100> ev_list;
|
||||
auto ready = epoll_wait(me->epoll_fd, ev_list.data(), ev_list.size(), 0);
|
||||
if (ready == -1) {
|
||||
if (errno == EINTR) return;
|
||||
else non_inline_assert();
|
||||
}
|
||||
|
||||
for (int i = 0; i < ready; ++i) {
|
||||
auto& ev = ev_list[i];
|
||||
auto handler = (Connection*)(ev.data.ptr);
|
||||
if (ev.events & EPOLLIN) {
|
||||
char buffer[4096];
|
||||
auto sz = read(handler->fd, buffer, sizeof(buffer));
|
||||
if (sz > 0) {
|
||||
bts_assert_d(handler->is_connected);
|
||||
handler->on_data(std::string_view(buffer, sz));
|
||||
}
|
||||
else if (has_error(ev.events)) {
|
||||
handler->disconnect();
|
||||
}
|
||||
}
|
||||
else if (has_error(ev.events)) {
|
||||
// if EPOLLIN was set along with
|
||||
// EPOLLHUP/EPOLLERR/EPOLLRDHUP, we pretend it is a normal
|
||||
// read so that we drain the bytes in the socket. The error
|
||||
// or hup condition would remain and we would catch in the
|
||||
// next iteration.
|
||||
handler->disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}}} //namespace
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "IL3Connection.h"
|
||||
#include "IL3ConnectionHandler.h"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
struct TCPEndpoint {
|
||||
std::string host;
|
||||
uint16_t port;
|
||||
};
|
||||
|
||||
class IL3Reactor {
|
||||
struct PImpl;
|
||||
struct Connection;
|
||||
|
||||
std::unique_ptr<PImpl> me;
|
||||
|
||||
public:
|
||||
IL3Reactor();
|
||||
~IL3Reactor();
|
||||
|
||||
IL3Connection& register_connection(const std::vector<TCPEndpoint>&);
|
||||
|
||||
void do_work();
|
||||
};
|
||||
|
||||
}}} //namespace
|
||||
@@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
class IL3ReceiveBuffer {
|
||||
std::list<std::vector<char>> buffers;
|
||||
size_t read_pos, write_pos;
|
||||
size_t buffer_size;
|
||||
|
||||
public:
|
||||
IL3ReceiveBuffer(size_t size = 1024*1024) : buffers(), read_pos(0), write_pos(0), buffer_size(size) {
|
||||
add_buffer(size);
|
||||
}
|
||||
|
||||
void append(const std::string_view& data) {
|
||||
auto dest = allocate(data.size());
|
||||
memcpy(const_cast<char*>(dest.data()), data.data(), data.size());
|
||||
}
|
||||
|
||||
std::string_view allocate(size_t size) {
|
||||
// If we have enough space append the data
|
||||
if (size <= available_write_space()) {
|
||||
char* write_ptr = buffers.back().data() + write_pos;
|
||||
write_pos += size;
|
||||
return std::string_view(write_ptr, size);
|
||||
}
|
||||
else {
|
||||
// If we don't have enough space...
|
||||
// Compute the minimum size of the new buffer
|
||||
auto min_size = unread() + size;
|
||||
// allocate a new buffer
|
||||
const auto& prev_buffer = buffers.back();
|
||||
auto prev_read = read_pos;
|
||||
auto prev_write = write_pos;
|
||||
add_buffer(std::max(buffer_size, min_size));
|
||||
// copy unread portion of old buffer + the new data into the new buffer
|
||||
auto unread_sz = prev_write - prev_read;
|
||||
memcpy(buffers.back().data(), prev_buffer.data()+prev_read, unread_sz);
|
||||
write_pos = unread_sz;
|
||||
bts_assert_d(size <= available_write_space());
|
||||
return allocate(size);
|
||||
}
|
||||
}
|
||||
|
||||
void advance(size_t consumed) {
|
||||
read_pos += consumed;
|
||||
bts_assert_d(read_pos <= write_pos);
|
||||
}
|
||||
|
||||
size_t unread() const {
|
||||
return write_pos - read_pos;
|
||||
}
|
||||
|
||||
const std::string_view data() const {
|
||||
return std::string_view(buffers.back().data()+read_pos, unread());
|
||||
}
|
||||
|
||||
private:
|
||||
size_t available_write_space() const {
|
||||
return buffers.back().size() - write_pos;
|
||||
}
|
||||
|
||||
void add_buffer(size_t size) {
|
||||
buffers.emplace_back(std::vector<char>());
|
||||
buffers.back().resize(size);
|
||||
read_pos = write_pos = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}}} //namespace
|
||||
@@ -0,0 +1,528 @@
|
||||
#include "ILink3Utils.h"
|
||||
#include "lib/orderman/orderman_utils/fix_order_codec.h"
|
||||
#include "lib/utils/base62.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
iLinkBinary::SideReq::Value map_side(api::Side side) {
|
||||
switch (side) {
|
||||
case api::Side::SIDE_BUY:
|
||||
return iLinkBinary::SideReq::Buy;
|
||||
case api::Side::SIDE_SELL:
|
||||
return iLinkBinary::SideReq::Sell;
|
||||
default:
|
||||
return iLinkBinary::SideReq::NULL_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
api::Side map_side(iLinkBinary::SideReq::Value side) {
|
||||
switch (side) {
|
||||
case iLinkBinary::SideReq::Buy:
|
||||
return api::Side::SIDE_BUY;
|
||||
case iLinkBinary::SideReq::Sell:
|
||||
return api::Side::SIDE_SELL;
|
||||
default:
|
||||
return api::Side::SIDE_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
iLinkBinary::OrderTypeReq::Value
|
||||
map_order_type(api::orderman::NativeOrderType ot) {
|
||||
using namespace api::orderman;
|
||||
using namespace iLinkBinary;
|
||||
switch (ot) {
|
||||
case NativeOrderType::NATIVE_ORDER_TYPE_MARKET:
|
||||
return OrderTypeReq::MarketwithProtection;
|
||||
case NativeOrderType::NATIVE_ORDER_TYPE_LIMIT:
|
||||
return OrderTypeReq::Limit;
|
||||
case NativeOrderType::NATIVE_ORDER_TYPE_STOP:
|
||||
return OrderTypeReq::StopwithProtection;
|
||||
case NativeOrderType::NATIVE_ORDER_TYPE_STOP_LIMIT:
|
||||
return OrderTypeReq::StopLimit;
|
||||
case NativeOrderType::NATIVE_ORDER_TYPE_MARKET_LIMIT:
|
||||
return OrderTypeReq::MarketWithLeftoverAsLimit;
|
||||
default:
|
||||
return iLinkBinary::OrderTypeReq::NULL_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
api::orderman::NativeOrderType
|
||||
map_order_type(iLinkBinary::OrderType::Value ot) {
|
||||
using namespace api::orderman;
|
||||
using namespace iLinkBinary;
|
||||
switch (ot) {
|
||||
case OrderType::MarketWithProtection:
|
||||
return NativeOrderType::NATIVE_ORDER_TYPE_MARKET;
|
||||
case OrderType::Limit:
|
||||
return NativeOrderType::NATIVE_ORDER_TYPE_LIMIT;
|
||||
case OrderType::StopLimit:
|
||||
return NativeOrderType::NATIVE_ORDER_TYPE_STOP_LIMIT;
|
||||
case OrderType::MarketWithLeftoverAsLimit:
|
||||
return NativeOrderType::NATIVE_ORDER_TYPE_MARKET_LIMIT;
|
||||
case OrderType::NULL_VALUE:
|
||||
return NativeOrderType::NATIVE_ORDER_TYPE_UNDEFINED;
|
||||
}
|
||||
return NativeOrderType::NATIVE_ORDER_TYPE_UNDEFINED;
|
||||
}
|
||||
|
||||
iLinkBinary::TimeInForce::Value
|
||||
map_time_in_force(api::orderman::TimeInForce tif) {
|
||||
using namespace api::orderman;
|
||||
switch (tif) {
|
||||
case TimeInForce::TIME_IN_FORCE_DATE:
|
||||
return iLinkBinary::TimeInForce::GoodTillDate;
|
||||
case TimeInForce::TIME_IN_FORCE_DAY:
|
||||
return iLinkBinary::TimeInForce::Day;
|
||||
case TimeInForce::TIME_IN_FORCE_GTC:
|
||||
return iLinkBinary::TimeInForce::GoodTillCancel;
|
||||
case TimeInForce::TIME_IN_FORCE_IOC:
|
||||
return iLinkBinary::TimeInForce::FillAndKill;
|
||||
default:
|
||||
return iLinkBinary::TimeInForce::NULL_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
api::orderman::TimeInForce
|
||||
map_time_in_force(iLinkBinary::TimeInForce::Value tif) {
|
||||
using namespace api::orderman;
|
||||
switch (tif) {
|
||||
case iLinkBinary::TimeInForce::Day:
|
||||
return TimeInForce::TIME_IN_FORCE_DAY;
|
||||
case iLinkBinary::TimeInForce::GoodTillCancel:
|
||||
return TimeInForce::TIME_IN_FORCE_GTC;
|
||||
case iLinkBinary::TimeInForce::FillOrKill:
|
||||
return TimeInForce::TIME_IN_FORCE_IOC;
|
||||
default:
|
||||
return TimeInForce::TIME_IN_FORCE_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
iLinkBinary::ManualOrdIndReq::Value
|
||||
map_manual_order_indicator(api::orderman::ManualOrderIndicator moi) {
|
||||
using namespace api::orderman;
|
||||
using namespace iLinkBinary;
|
||||
switch (moi) {
|
||||
case ManualOrderIndicator::MANUAL_ORDER_INDICATOR_NO:
|
||||
return ManualOrdIndReq::Automated;
|
||||
case ManualOrderIndicator::MANUAL_ORDER_INDICATOR_YES:
|
||||
return ManualOrdIndReq::Manual;
|
||||
default:
|
||||
return ManualOrdIndReq::NULL_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
api::orderman::ManualOrderIndicator
|
||||
map_manual_order_indicator(iLinkBinary::ManualOrdIndReq::Value moi) {
|
||||
using namespace api::orderman;
|
||||
using namespace iLinkBinary;
|
||||
switch (moi) {
|
||||
case ManualOrdIndReq::Automated:
|
||||
return ManualOrderIndicator::MANUAL_ORDER_INDICATOR_NO;
|
||||
case ManualOrdIndReq::Manual:
|
||||
return ManualOrderIndicator::MANUAL_ORDER_INDICATOR_YES;
|
||||
default:
|
||||
return ManualOrderIndicator::MANUAL_ORDER_INDICATOR_NO;
|
||||
}
|
||||
}
|
||||
|
||||
iLinkBinary::ClearingAcctType::Value
|
||||
map_customer_or_firm(api::orderman::CustomerOrFirm c) {
|
||||
using namespace api::orderman;
|
||||
using namespace iLinkBinary;
|
||||
switch (c) {
|
||||
case CustomerOrFirm::CUSTOMER_OR_FIRM_CUSTOMER:
|
||||
return ClearingAcctType::Customer;
|
||||
case CustomerOrFirm::CUSTOMER_OR_FIRM_FIRM:
|
||||
return ClearingAcctType::Firm;
|
||||
default:
|
||||
return ClearingAcctType::NULL_VALUE;
|
||||
}
|
||||
}
|
||||
iLinkBinary::SMPI::Value
|
||||
map_smp_instruction(api::orderman::SelfMatchPreventionInstruction smpi) {
|
||||
using namespace api::orderman;
|
||||
using namespace iLinkBinary;
|
||||
switch (smpi) {
|
||||
case SELF_MATCH_PREVENTION_INSTRUCTION_CANCEL_RESTING:
|
||||
return SMPI::CancelOldest;
|
||||
case SELF_MATCH_PREVENTION_INSTRUCTION_CANCEL_AGRESSING:
|
||||
return SMPI::CancelNewest;
|
||||
default:
|
||||
return SMPI::NULL_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
iLinkBinary::CustOrderCapacity::Value
|
||||
map_cust_cti(api::orderman::CTICode code) {
|
||||
using namespace api::orderman;
|
||||
using namespace iLinkBinary;
|
||||
switch (code) {
|
||||
case CTI_CODE_CTI_CODE1:
|
||||
return CustOrderCapacity::Membertradingfortheirownaccount;
|
||||
case CTI_CODE_CTI_CODE2:
|
||||
return CustOrderCapacity::Clearingfirmtradingforitsproprietaryaccount;
|
||||
case CTI_CODE_CTI_CODE3:
|
||||
return CustOrderCapacity::Membertradingforanothermember;
|
||||
case CTI_CODE_CTI_CODE4:
|
||||
return CustOrderCapacity::Allother;
|
||||
default:
|
||||
case CTI_CODE_UNDEFINED:
|
||||
return CustOrderCapacity::NULL_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
const char *translate_business_reject_reason(int reason) {
|
||||
switch (reason) {
|
||||
case 0:
|
||||
return "Other";
|
||||
case 1:
|
||||
return "Unknown ID (unknown PartyDetailsListReqID being referenced in "
|
||||
"business message)";
|
||||
case 2:
|
||||
return "Unknown Security";
|
||||
case 3:
|
||||
return "Unsupported Message Type (for example using messages specific to "
|
||||
"cash markets for futures)";
|
||||
case 5:
|
||||
return "Required Field Missing";
|
||||
case 6:
|
||||
return "Not Authorized";
|
||||
case 8:
|
||||
return "Throttle Limit Exceeded (volume controls)";
|
||||
case 100:
|
||||
return "Value is incorrect (out of range) for this tag (for example "
|
||||
"using a value outside defined range of integer) ";
|
||||
case 101:
|
||||
return "Incorrect data format for value (for example using ASCII "
|
||||
"character outside 32-126 in string field)";
|
||||
case 102:
|
||||
return "Rejected due to Kill Switch";
|
||||
case 103:
|
||||
return "Rejected due to Risk Management API";
|
||||
case 104:
|
||||
return "Rejected due to Globex Credit Controls";
|
||||
case 105:
|
||||
return "Not Authorized to trade Deliverable Swap Futures";
|
||||
case 106:
|
||||
return "Not Authorized to trade Interest Rate Swap Futures";
|
||||
case 107:
|
||||
return "Rejected due to Inline Credit Controls";
|
||||
case 108:
|
||||
return "Invalid PartyDetailsListReqID (reusing already existing "
|
||||
"PartyDetailsListReqID while creating Party Details Definition "
|
||||
"Request)";
|
||||
case 109:
|
||||
return "Incoming message could not be decoded. (Check schema version)";
|
||||
case 110:
|
||||
return "Same repeating group entry appears more than once";
|
||||
case 111:
|
||||
return "Exceeded maximum number of allowable Party Details Definition "
|
||||
"Requests";
|
||||
case 112:
|
||||
return "Technical Error in Registering Party Details";
|
||||
case 113:
|
||||
return "Rejected due to Cross Venue Risk";
|
||||
case 114:
|
||||
return "Order Status Not Available";
|
||||
case 115:
|
||||
return "Enum Not Supported";
|
||||
case 116:
|
||||
return "Order Status Not Found";
|
||||
case 117:
|
||||
return "Mass Order Status Cannot be Completed";
|
||||
case 118:
|
||||
return "Exceeded Maximum Number of Allowable RequestingPartyID's in "
|
||||
"Party Details List Request";
|
||||
case 119:
|
||||
return "Duplicate Order Threshold Exceeded";
|
||||
case 120:
|
||||
return "On-Demand Message Rejected Due to Preceding Party Details "
|
||||
"Definition Request Being Rejected";
|
||||
case 121:
|
||||
return "Message Rejected Since PartyDetailsListReqID Does Not Match with "
|
||||
"Immediately Preceding Party Details Definition Request sent to "
|
||||
"MSGW when using On-demand administrative information";
|
||||
case 122:
|
||||
return "Party Details Definition Request sent to MSGW Being Rejected Due "
|
||||
"to Corresponding Business Message Being Rejected";
|
||||
case 123:
|
||||
return "Another Message Sent in Between Party Details Definition Request "
|
||||
"and Business Message when using On-demand administrative "
|
||||
"information";
|
||||
case 124:
|
||||
return "Cannot Have More Than One In-Flight Mass Order Status Request in "
|
||||
"Progress";
|
||||
case 125:
|
||||
return "Exceeded Maximum Number of In-Flight Order Status Requests";
|
||||
case 126:
|
||||
return "Cannot Have More Than One In-Flight Party Details List Request "
|
||||
"in Progress";
|
||||
case 127:
|
||||
return "Party Details List Request is Missing Requesting Party ID and "
|
||||
"Party ID";
|
||||
case 128:
|
||||
return "Party Details List Request cannot contain both RequestingPartyID "
|
||||
"and PartyID";
|
||||
case 129:
|
||||
return "Party Details Definition Request Being Rejected Since Another "
|
||||
"Message was sent in Between On-Demand Message";
|
||||
case 130:
|
||||
return "Buy Side Firm ID Does Not Match Sell Side Firm ID in New Order "
|
||||
"Cross";
|
||||
case 131:
|
||||
return "Message Type Not Supported on Backup Instance";
|
||||
case 132:
|
||||
return "New Order Cross Does Not Contain Buy Side Followed by Sell Side";
|
||||
}
|
||||
return "Unknown or invalid business reject reason.";
|
||||
}
|
||||
|
||||
const char *translate_negotiation_reject(int reason) {
|
||||
// https://www.cmegroup.com/confluence/display/EPICSANDBOX/Negotiation+Reject
|
||||
// 01/13/2020
|
||||
switch (reason) {
|
||||
case 0:
|
||||
return "HMACNotAuthenticated: failed authentication because identity is "
|
||||
"not recognized";
|
||||
case 1:
|
||||
return "HMACNotAvailable: HMAC component is not responding (5sec)";
|
||||
case 2:
|
||||
return "InvalidUUID: UUID is not greater than the one last used or value "
|
||||
"sent by the client is out of acceptable range (MIN, MAX)";
|
||||
case 3:
|
||||
return "InvalidTimestamp: Timestamp is not greater than the one last "
|
||||
"used or value sent by the client is out of acceptable range "
|
||||
"(MIN, MAX)";
|
||||
case 4:
|
||||
return "RequiredHMACSignatureMissing: empty bytes in HMACSignature field";
|
||||
case 5:
|
||||
return "RequiredAccessKeyIDMissing: empty bytes in AccessKeyID field";
|
||||
case 6:
|
||||
return "RequiredSessionMissing: empty bytes in Session field";
|
||||
case 7:
|
||||
return "RequiredFirmMissing: empty bytes in Firm field";
|
||||
case 8:
|
||||
return "RequiredUUIDMisssing: null value in UUID field";
|
||||
case 9:
|
||||
return "RequiredRequestTimestampMissing: null value in RequestTimestamp "
|
||||
"field";
|
||||
case 10:
|
||||
return "SessionBlocked: session and firm are not authorized for this "
|
||||
"port";
|
||||
case 12:
|
||||
return "InvalidAccessKeyID: contains non-printable ASCII character";
|
||||
case 13:
|
||||
return "InvalidSession: contains non-printable ASCII character";
|
||||
case 14:
|
||||
return "InvalidFirm: contains non-printable ASCII character";
|
||||
case 15:
|
||||
return "Volume Controls - exceeding TPS limit as defined for volume "
|
||||
"controls (reject action)";
|
||||
case 16:
|
||||
return "SplitMessageRejected - Messages queued due to split message "
|
||||
"penalty being rejected because of logout or disconnect";
|
||||
case 17:
|
||||
return "SplitMessageQueue - Reached threshold of messages queued due to "
|
||||
"split message penalty";
|
||||
case 27:
|
||||
return "DesignatedBackup - Using Designated backup before designated "
|
||||
"primary not allowed";
|
||||
}
|
||||
return "Unknown or invalid Negotiate reject reason.";
|
||||
}
|
||||
|
||||
const char *translate_establish_reject(int reason) {
|
||||
switch (reason) {
|
||||
case 0:
|
||||
return "HMACNotAuthenticated: failed authentication because identity is "
|
||||
"not recognized";
|
||||
case 1:
|
||||
return "HMACNotAvailable: HMAC component is not responding (5sec)";
|
||||
case 2:
|
||||
return "InvalidUUID: UUID is not greater than the one last used or value "
|
||||
"sent by the client is out of acceptable range (MIN, MAX)";
|
||||
case 3:
|
||||
return "InvalidTimestamp: Timestamp is not greater than the one last "
|
||||
"used or value sent by the client is out of acceptable range "
|
||||
"(MIN, MAX)";
|
||||
case 4:
|
||||
return "RequiredHMACSignatureMissing: empty bytes in HMACSignature field";
|
||||
case 5:
|
||||
return "RequiredAccessKeyIDMissing: empty bytes in AccessKeyID field";
|
||||
case 6:
|
||||
return "RequiredSessionMissing: empty bytes in Session field";
|
||||
case 7:
|
||||
return "RequiredFirmMissing: empty bytes in Firm field";
|
||||
case 8:
|
||||
return "RequiredUUIDMisssing: null value in UUID field";
|
||||
case 9:
|
||||
return "RequiredRequestTimestampMissing: null value in RequestTimestamp "
|
||||
"field";
|
||||
case 10:
|
||||
return "SessionBlocked: session and firm are not authorized for this "
|
||||
"port";
|
||||
case 11:
|
||||
return "InvalidKeepAliveInterval: value is out of acceptable range (MIN, "
|
||||
"MAX)";
|
||||
case 12:
|
||||
return "InvalidAccessKeyID: contains non-printable ASCII character";
|
||||
case 13:
|
||||
return "InvalidSession: contains non-printable ASCII character";
|
||||
case 14:
|
||||
return "InvalidFirm: contains non-printable ASCII character";
|
||||
case 15:
|
||||
return "Volume Controls - exceeding TPS limit as defined for volume "
|
||||
"controls (reject action)";
|
||||
case 16:
|
||||
return "SplitMessageRejected - Messages queued due to split message "
|
||||
"penalty being rejected because of logout or disconnect";
|
||||
case 17:
|
||||
return "SplitMessageQueue - Reached threshold of messages queued due to "
|
||||
"split message penalty";
|
||||
case 18:
|
||||
return "RequiredTradingSystemNameMissing: empty bytes in "
|
||||
"TradingSystemName";
|
||||
case 19:
|
||||
return "RequiredTradingSystemVersionMissing: empty bytes in "
|
||||
"TradingSystemVersion";
|
||||
case 20:
|
||||
return "RequiredTradingSystemVendorMissing: empty bytes in "
|
||||
"TradingSystemVendor";
|
||||
case 21:
|
||||
return "RequiredKeepAliveIntervalMissing: null value in "
|
||||
"KeepAliveInterval field";
|
||||
case 22:
|
||||
return "RequiredNextSeqNoMissing: empty bytes in NextSeqNo field";
|
||||
case 23:
|
||||
return "InvalidTradingSystemName: contains non-prinatable ASCII "
|
||||
"character";
|
||||
case 24:
|
||||
return "InvalidTradingSystemVersion: contains non-prinatable ASCII "
|
||||
"character";
|
||||
case 25:
|
||||
return "InvalidTradingSystemVendor: contains non-prinatable ASCII "
|
||||
"character";
|
||||
case 26:
|
||||
return "DesignatedBackup - Using Designated backup before designated "
|
||||
"primary not allowed";
|
||||
case 27:
|
||||
return "DesignatedBackup - Using Designated backup before designated "
|
||||
"primary not allowed";
|
||||
}
|
||||
return "Unknown or invalid Establish reject reason.";
|
||||
}
|
||||
|
||||
const char *translate_terminate(int reason) {
|
||||
switch (reason) {
|
||||
case 0:
|
||||
return "Finished: session is being terminated without finalization";
|
||||
|
||||
case 2:
|
||||
return "Unnegotiated: Sending any message when session has not been "
|
||||
"Negotiated ";
|
||||
|
||||
case 3:
|
||||
return "NotEstablished: Sending any message (except Negotiate) when "
|
||||
"session has not been established";
|
||||
|
||||
case 4:
|
||||
return "AlreadyNegotiated: NegotiationResponse was already sent; "
|
||||
"Negotiate was redundant";
|
||||
|
||||
case 5:
|
||||
return "NegotiationInProgress: Previous Negotiate still being processed; "
|
||||
"Wait for NegotiationResponse or timeout";
|
||||
|
||||
case 6:
|
||||
return "AlreadyEstablished: EstablishmentAck was already sent; Establish "
|
||||
"was redundant";
|
||||
|
||||
case 7:
|
||||
return "EstablishInProgress: Previous Establish still being processed; "
|
||||
"Wait for EstablishmentAck or timeout";
|
||||
|
||||
case 8:
|
||||
return "CMEAdministeredPortClosure: due to invalid number of "
|
||||
"Negotiate/Establish attempts being exceeded";
|
||||
|
||||
case 9:
|
||||
return "Volume Controls - exceeding TPS limit as defined for volume "
|
||||
"controls (logout action)";
|
||||
|
||||
case 10:
|
||||
return "InvalidNextSeqNo - value is not greater than the one last used "
|
||||
"for same UUID or value sent by the client is out of acceptable "
|
||||
"range (MIN, MAX)";
|
||||
|
||||
case 11:
|
||||
return "InvalidMsgSeqNo - value is lower than the last one used for the "
|
||||
"same UUID or value is not initialized to 1 at the beginning of "
|
||||
"the week or value sent by the client is out of acceptable range "
|
||||
"(MIN, MAX)";
|
||||
|
||||
case 12:
|
||||
return "InvalidLastSeqNo - value is lower than the last one used for the "
|
||||
"same UUID or value sent by the client is out of acceptable range "
|
||||
"(MIN, MAX)";
|
||||
|
||||
case 13:
|
||||
return "InvalidUUID: UUID value does not match current UUID or value "
|
||||
"sent by the client is out of acceptable range (MIN, MAX)";
|
||||
|
||||
case 14:
|
||||
return "InvalidTimestamp: Timestamp value does not match with "
|
||||
"RequestTimestamp sent by CME or value sent by the client is out "
|
||||
"of acceptable range (MIN, MAX)";
|
||||
|
||||
case 15:
|
||||
return "RequiredUUIDMisssing: null value in UUID field";
|
||||
|
||||
case 16:
|
||||
return "RequiredRequestTimestampMissing: null value in RequestTimestamp "
|
||||
"field";
|
||||
|
||||
case 17:
|
||||
return "RequiredCodeMisssing: null value in Code field";
|
||||
|
||||
case 18:
|
||||
return "InvalidSOFH: Invalid message length or invalid encoding type "
|
||||
"specified";
|
||||
|
||||
case 19:
|
||||
return "DecodingError: Incoming message could not be decoded";
|
||||
|
||||
case 20:
|
||||
return "KeepAliveIntervalLapsed: KeepAliveInterval has lapsed without "
|
||||
"any response so terminating session";
|
||||
|
||||
case 21:
|
||||
return "RequiredNextSeqNoMissing: null value in NextSeqNo field";
|
||||
|
||||
case 22:
|
||||
return "RequiredKeepAliveIntervalLapsedMissing: null value in "
|
||||
"KeepAliveIntervalLapsed field";
|
||||
|
||||
case 23:
|
||||
return "Non-Negotiate/Establish message received when not "
|
||||
"Negotiated/Established";
|
||||
|
||||
case 24:
|
||||
return "TerminateInProgress: Previous Terminate still being processed; "
|
||||
"Wait for Terminate or timeout";
|
||||
|
||||
case 25:
|
||||
return "Other: any other error condition not mentioned above";
|
||||
|
||||
case 26:
|
||||
return "DisconnectFromPrimary: Backup session will be terminated as "
|
||||
"well}";
|
||||
default:
|
||||
return "Unknown error";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ilink3
|
||||
} // namespace orderman
|
||||
} // namespace bts
|
||||
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/domain_model/common.h"
|
||||
#include "lib/domain_model/Security.pb.h"
|
||||
#include "lib/api/services/OrderService.pb.h"
|
||||
#include "lib/orderman/orderman_utils/orderman_common.h"
|
||||
|
||||
#include "generated/SideReq.h"
|
||||
#include "generated/OrderTypeReq.h"
|
||||
#include "generated/OrderType.h"
|
||||
#include "generated/TimeInForce.h"
|
||||
#include "generated/ManualOrdInd.h"
|
||||
#include "generated/ManualOrdIndReq.h"
|
||||
#include "generated/ClearingAcctType.h"
|
||||
#include "generated/SMPI.h"
|
||||
#include "generated/CustOrderCapacity.h"
|
||||
|
||||
#include <tuple>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
iLinkBinary::SideReq::Value map_side(api::Side side);
|
||||
api::Side map_side(iLinkBinary::SideReq::Value side);
|
||||
|
||||
inline int64_t to_price9(Price p) {
|
||||
return p.value() * 1E9;
|
||||
}
|
||||
|
||||
iLinkBinary::OrderTypeReq::Value map_order_type(api::orderman::NativeOrderType ot);
|
||||
api::orderman::NativeOrderType map_order_type(iLinkBinary::OrderType::Value);
|
||||
|
||||
iLinkBinary::TimeInForce::Value map_time_in_force(api::orderman::TimeInForce);
|
||||
api::orderman::TimeInForce map_time_in_force(iLinkBinary::TimeInForce::Value);
|
||||
|
||||
iLinkBinary::ManualOrdIndReq::Value map_manual_order_indicator(api::orderman::ManualOrderIndicator moi);
|
||||
api::orderman::ManualOrderIndicator map_manual_order_indicator(iLinkBinary::ManualOrdIndReq::Value moi);
|
||||
|
||||
iLinkBinary::ClearingAcctType::Value map_customer_or_firm(api::orderman::CustomerOrFirm c);
|
||||
|
||||
iLinkBinary::SMPI::Value map_smp_instruction(api::orderman::SelfMatchPreventionInstruction smpi);
|
||||
iLinkBinary::CustOrderCapacity::Value map_cust_cti(api::orderman::CTICode code);
|
||||
|
||||
const char* translate_business_reject_reason(int reason) ;
|
||||
const char* translate_negotiation_reject(int reason) ;
|
||||
const char* translate_establish_reject(int reason) ;
|
||||
const char* translate_terminate(int reason) ;
|
||||
|
||||
|
||||
}}}//namespace
|
||||
@@ -0,0 +1,645 @@
|
||||
#include "ILinkGW.h"
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include "lib/utils/SecureLogon.h"
|
||||
#include "ILink3Utils.h"
|
||||
#include "IL3GeneratedFull.h"
|
||||
#include "IL3Dispatcher.h"
|
||||
#include "IL3MessageFramer.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/orderman/orderman_utils/fix_order_codec.h"
|
||||
|
||||
/*
|
||||
# Some notes about session binding and initialization: #
|
||||
|
||||
## Official documentation:
|
||||
https://www.cmegroup.com/confluence/display/EPICSANDBOX/iLink+3+Binary+Order+Entry+-+Session+Layer#iLink3BinaryOrderEntry-SessionLayer-WeeklyReset
|
||||
|
||||
## Begining of week (new session?)
|
||||
- config.session = X
|
||||
- config.outgoing_sequence = 1
|
||||
-> Negotiate session=X
|
||||
<- NegotiateResponse session=X, oldsession=Y, oldSeq=N
|
||||
if oldSeq > 0 -> ReplayRequest
|
||||
-> Establish seq=1
|
||||
<- EstablishAck oldsession=Y, oldSeq=N
|
||||
|
||||
## Middle of week (same session)
|
||||
- config.session = X
|
||||
- config.outgoing_sequence > 1
|
||||
-> Establish seq=N
|
||||
*/
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
log::CharPtrWrapper wrap(const char* str) { return log::CharPtrWrapper{ str }; }
|
||||
|
||||
ILinkGW::ILinkGW(
|
||||
IL3Connection& con,
|
||||
IL3MessageFramer& buffer,
|
||||
md::SecurityOracle* oracle,
|
||||
const Session& session,
|
||||
const Config& conf,
|
||||
config::JetFIX::Connection const & cfg) :
|
||||
_config(conf),
|
||||
_x_state(State::INIT),
|
||||
_buffer(buffer),
|
||||
_on_state_change([](auto){}),
|
||||
_on_exe_report([](auto*){}),
|
||||
_on_session_change([](auto){}),
|
||||
_connection(con),
|
||||
_session(session),
|
||||
_msg_count(0),
|
||||
_time(),
|
||||
_pool(),
|
||||
_exe_parser(cfg,oracle),
|
||||
_retransmit()
|
||||
{
|
||||
_clorid_buffer.resize(clordid_sz());
|
||||
}
|
||||
|
||||
void ILinkGW::connect() {
|
||||
bts_assert(state() == State::INIT || state() == State::ERROR);
|
||||
set_state(State::CONNECTING);
|
||||
_connection.connect(*this); // -> on_connect_success
|
||||
}
|
||||
|
||||
// This determines the session uuid
|
||||
void ILinkGW::send_negotiate() {
|
||||
// add 2 bytes for the empty 'credentials' (39008) length which must be present
|
||||
auto msg = _buffer.frame<iLinkBinary::Negotiate500>(
|
||||
iLinkBinary::Negotiate500::credentialsHeaderLength());
|
||||
msg.uUID(_session.uuid);
|
||||
msg.requestTimestamp(_time.now());
|
||||
msg.putSession(_config.cme_session);
|
||||
// We need this call to set the length of the credential block to 0
|
||||
// This behavior is specific to "data" in the xml template
|
||||
msg.putCredentials("", 0);
|
||||
msg.putFirm(_config.firm);
|
||||
|
||||
const auto ld = glbx::calculate_hmac(
|
||||
_config.cme_session,
|
||||
std::to_string(msg.requestTimestamp()),
|
||||
std::to_string(msg.uUID()),
|
||||
_config.cme_session,
|
||||
_config.firm
|
||||
);
|
||||
msg.putAccessKeyID(ld.access_key);
|
||||
msg.putHMACSignature(ld.hmac);
|
||||
|
||||
std::string temp = ld.canonical;
|
||||
for (size_t x = 0; x < temp.size(); ++x) { if (temp[x] == '\n') temp[x] = '$'; }
|
||||
|
||||
flush(false);
|
||||
// clear HMAC for json logging
|
||||
msg.putHMACSignature(std::string_view { nullptr, 0 });
|
||||
log_out(msg);
|
||||
// expect -> NegotiationResponse501 or NegotiationReject502
|
||||
}
|
||||
|
||||
void ILinkGW::send_establish() {
|
||||
// add 2 bytes for the empty 'credentials' (39008) length which must be present
|
||||
auto msg = _buffer.frame<iLinkBinary::Establish503>(2);
|
||||
msg.uUID(_session.uuid);
|
||||
msg.requestTimestamp(_time.now());
|
||||
msg.putSession(_config.cme_session);
|
||||
msg.putCredentials("", 0);
|
||||
msg.putFirm(_config.firm);
|
||||
|
||||
msg.putTradingSystemName(std::string_view("SPARK"));
|
||||
msg.putTradingSystemVersion(std::string_view("1"));
|
||||
msg.putTradingSystemVendor(std::string_view("BTS"));
|
||||
// On primary connection, the expected message sequence number of the next business message from customer to CME
|
||||
msg.nextSeqNo(_session.to_cme);
|
||||
msg.keepAliveInterval(30000);
|
||||
|
||||
const auto ld = glbx::calculate_hmac(
|
||||
_config.cme_session,
|
||||
// RequestTimestamp
|
||||
std::to_string(msg.requestTimestamp()),
|
||||
std::to_string(msg.uUID()),
|
||||
_config.cme_session,
|
||||
// Firm ID
|
||||
_config.firm,
|
||||
// TradingSystemName
|
||||
msg.getTradingSystemNameAsString(),
|
||||
// TradingSystemVersion
|
||||
msg.getTradingSystemVersionAsString(),
|
||||
// TradingSystemVendor
|
||||
msg.getTradingSystemVendorAsString(),
|
||||
// NextSeqNo
|
||||
std::to_string(msg.nextSeqNo()),
|
||||
// KeepAliveInterval
|
||||
std::to_string(msg.keepAliveInterval())
|
||||
);
|
||||
|
||||
msg.putAccessKeyID(ld.access_key);
|
||||
msg.putHMACSignature(ld.hmac);
|
||||
|
||||
flush(false);
|
||||
// clear HMAC for json logging
|
||||
msg.putHMACSignature(std::string_view { nullptr, 0 });
|
||||
log_out(msg);
|
||||
// expect -> EstablishmentAck504 or EstablishmentReject505
|
||||
}
|
||||
|
||||
void ILinkGW::send_sequence(bool lapsed) {
|
||||
auto msg = _buffer.frame<iLinkBinary::Sequence506>();
|
||||
msg.uUID(_session.uuid);
|
||||
msg.nextSeqNo(_session.to_cme);
|
||||
msg.faultToleranceIndicator(iLinkBinary::FTI::NULL_VALUE);
|
||||
msg.keepAliveIntervalLapsed(
|
||||
lapsed ?
|
||||
iLinkBinary::KeepAliveLapsed::Lapsed :
|
||||
iLinkBinary::KeepAliveLapsed::NotLapsed);
|
||||
log_out(msg);
|
||||
}
|
||||
|
||||
void ILinkGW::send_retransmit_request(uint64_t uuid, uint32_t from, size_t count) {
|
||||
bts_assert(from > 0);
|
||||
using namespace iLinkBinary;
|
||||
auto msg = _buffer.frame<RetransmitRequest508>();
|
||||
msg.uUID(_session.uuid);
|
||||
msg.lastUUID(uuid);
|
||||
msg.requestTimestamp(_time.now());
|
||||
msg.fromSeqNo(from);
|
||||
msg.msgCount(count);
|
||||
log_out(msg);
|
||||
}
|
||||
|
||||
uint64_t ILinkGW::send_party_details(const api::orderman::RoutingRecord& route) {
|
||||
using namespace iLinkBinary;
|
||||
|
||||
auto msg = _buffer.frame<PartyDetailsDefinitionRequest518>(
|
||||
// 2 repeating group header.
|
||||
// 1 for party details and 1 for trade reg
|
||||
// This seems unsafe but the api doesn't seem to want you to know how to size buffers ahead of time
|
||||
2 * PartyDetailsDefinitionRequest518::NoPartyDetails::sbeHeaderSize() +
|
||||
// N * size of each block
|
||||
3 * PartyDetailsDefinitionRequest518::NoPartyDetails::sbeBlockLength() +
|
||||
0 * PartyDetailsDefinitionRequest518::NoTrdRegPublications::sbeBlockLength()
|
||||
);
|
||||
msg.partyDetailsListReqID(0);
|
||||
msg.sendingTimeEpoch(_time.now());
|
||||
msg.listUpdateAction(ListUpdAct::Add);
|
||||
msg.seqNum(next_seq());
|
||||
// msg.putMemo("") -- not supported
|
||||
if (route.smp_id().empty()) {
|
||||
msg.selfMatchPreventionID(
|
||||
PartyDetailsDefinitionRequest518::selfMatchPreventionIDNullValue());
|
||||
}
|
||||
else {
|
||||
// CME needs the SMP_ID to be 12 characters or less
|
||||
// after they to_string() the uint64
|
||||
bts_assert_d(route.smp_id().size() == 8);
|
||||
const uint64_t* psmp_id = reinterpret_cast<const uint64_t*>(&route.smp_id());
|
||||
uint64_t smp_id = (*psmp_id) % (2UL<<39);
|
||||
msg.selfMatchPreventionID(smp_id);
|
||||
}
|
||||
msg.cmtaGiveupCD(CmtaGiveUpCD::NULL_VALUE);
|
||||
msg.custOrderCapacity(map_cust_cti(route.cti_code()));
|
||||
msg.clearingAccountType(map_customer_or_firm(route.customer_or_firm()));
|
||||
msg.selfMatchPreventionInstruction(map_smp_instruction(route.smp_instruction()));
|
||||
msg.avgPxIndicator(AvgPxInd::NULL_VALUE);
|
||||
msg.clearingTradePriceType(SLEDS::NULL_VALUE);
|
||||
msg.custOrderHandlingInst(
|
||||
static_cast<iLinkBinary::CustOrdHandlInst::Value>(
|
||||
route.cust_order_handing_inst()[0]));
|
||||
msg.executor(PartyDetailsDefinitionRequest518::executorNullValue());
|
||||
msg.iDMShortCode(PartyDetailsDefinitionRequest518::iDMShortCodeNullValue());
|
||||
|
||||
auto details = msg.noPartyDetailsCount(3);
|
||||
details.next();
|
||||
details.partyDetailRole(PartyDetailRole::CustomerAccount);
|
||||
details.putPartyDetailID(route.account());
|
||||
details.next();
|
||||
details.partyDetailRole(PartyDetailRole::ExecutingFirm);
|
||||
// 004 in cert
|
||||
details.putPartyDetailID(
|
||||
std::string_view(route.sender_compid().c_str()+3, 3));
|
||||
details.next();
|
||||
details.partyDetailRole(PartyDetailRole::Operator);
|
||||
details.putPartyDetailID(
|
||||
std::string_view(route.sender_compid().c_str(), 3));
|
||||
msg.noTrdRegPublicationsCount(0);
|
||||
// In the future we may check for existing party details definitions and return that id
|
||||
log_out(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool needs_stop_px(api::orderman::NativeOrderType order_type) {
|
||||
return order_type == api::orderman::NativeOrderType::NATIVE_ORDER_TYPE_STOP ||
|
||||
order_type == api::orderman::NativeOrderType::NATIVE_ORDER_TYPE_STOP_LIMIT;
|
||||
}
|
||||
bool need_px(api::orderman::NativeOrderType order_type) {
|
||||
return order_type != api::orderman::NativeOrderType::NATIVE_ORDER_TYPE_MARKET &&
|
||||
order_type != api::orderman::NativeOrderType::NATIVE_ORDER_TYPE_MARKET_LIMIT &&
|
||||
order_type != api::orderman::NativeOrderType::NATIVE_ORDER_TYPE_STOP;
|
||||
}
|
||||
|
||||
void ILinkGW::send_order(const CreateOrderMsg& create) {
|
||||
bts_assert_d(create.routing_record);
|
||||
bts_assert_d(create.security);
|
||||
bts_assert_d(create.security->has_glbx());
|
||||
|
||||
auto party = send_party_details(*create.routing_record);
|
||||
auto msg = _buffer.frame<iLinkBinary::NewOrderSingle514>();
|
||||
|
||||
if (need_px(create.order_type)) { msg.price().mantissa(to_price9(create.price)); }
|
||||
else { msg.price().mantissa(iLinkBinary::PRICENULL9::mantissaNullValue()); }
|
||||
msg.orderQty(create.quantity.value());
|
||||
msg.securityID(create.security->glbx().exchange_id());
|
||||
msg.side(map_side(create.side));
|
||||
msg.seqNum(next_seq());
|
||||
msg.putSenderID(create.routing_record->operator_id());
|
||||
encode_clorid(create.key, SecurityKey(create.security->id()), &_clorid_buffer);
|
||||
msg.putClOrdID(_clorid_buffer);
|
||||
msg.partyDetailsListReqID(party);
|
||||
msg.orderRequestID(++_msg_count);
|
||||
msg.sendingTimeEpoch(_time.now());
|
||||
if (needs_stop_px(create.order_type)) { msg.stopPx().mantissa(to_price9(create.stop_px)); }
|
||||
else { msg.stopPx().mantissa(iLinkBinary::PRICENULL9::mantissaNullValue()); }
|
||||
msg.putLocation(create.routing_record->location());
|
||||
msg.minQty(iLinkBinary::NewOrderSingle514::minQtyNullValue());
|
||||
if (create.time_in_force != api::orderman::TimeInForce::TIME_IN_FORCE_IOC) {
|
||||
msg.displayQty(create.display_quantity.value());
|
||||
}
|
||||
else { msg.displayQty(iLinkBinary::NewOrderSingle514::displayQtyNullValue()); }
|
||||
if (create.time_in_force == api::orderman::TimeInForce::TIME_IN_FORCE_DATE) {
|
||||
//TODO: # of days since jan 1 1970
|
||||
msg.expireDate(18424);
|
||||
}
|
||||
else {
|
||||
msg.expireDate(iLinkBinary::NewOrderSingle514::expireDateNullValue());
|
||||
}
|
||||
msg.ordType(map_order_type(create.order_type));
|
||||
msg.timeInForce(map_time_in_force(create.time_in_force));
|
||||
msg.manualOrderIndicator(map_manual_order_indicator(create.manual_order_indicator));
|
||||
msg.execInst().clear();
|
||||
msg.executionMode(iLinkBinary::ExecMode::NULL_VALUE);
|
||||
msg.liquidityFlag(iLinkBinary::BooleanNULL::NULL_VALUE);
|
||||
msg.managedOrder(iLinkBinary::BooleanNULL::NULL_VALUE);
|
||||
msg.shortSaleType(iLinkBinary::ShortSaleType::NULL_VALUE);
|
||||
|
||||
_exe_parser.cache(create.security);
|
||||
log_out(msg);
|
||||
}
|
||||
|
||||
void ILinkGW::send_cancel_replace(const CancelReplaceOrderMsg& replace) {
|
||||
const auto& create = replace.create_fields;
|
||||
bts_assert_d(create.routing_record);
|
||||
bts_assert_d(create.security);
|
||||
bts_assert_d(create.security->has_glbx());
|
||||
|
||||
auto party = send_party_details(*create.routing_record);
|
||||
auto msg = _buffer.frame<iLinkBinary::OrderCancelReplaceRequest515>();
|
||||
|
||||
msg.orderID(replace.exchange_order_id.value());
|
||||
|
||||
if (need_px(create.order_type)) { msg.price().mantissa(to_price9(create.price)); }
|
||||
else { msg.price().mantissa(iLinkBinary::PRICENULL9::mantissaNullValue()); }
|
||||
msg.orderQty(create.quantity.value());
|
||||
msg.securityID(create.security->glbx().exchange_id());
|
||||
msg.side(map_side(create.side));
|
||||
msg.seqNum(next_seq());
|
||||
msg.putSenderID(create.routing_record->operator_id());
|
||||
encode_clorid(create.key, SecurityKey(create.security->id()), &_clorid_buffer);
|
||||
msg.putClOrdID(_clorid_buffer);
|
||||
msg.partyDetailsListReqID(party);
|
||||
msg.orderRequestID(++_msg_count);
|
||||
msg.sendingTimeEpoch(_time.now());
|
||||
if (needs_stop_px(create.order_type)) { msg.stopPx().mantissa(to_price9(create.stop_px)); }
|
||||
else { msg.stopPx().mantissa(iLinkBinary::PRICENULL9::mantissaNullValue()); }
|
||||
msg.putLocation(create.routing_record->location());
|
||||
msg.minQty(iLinkBinary::NewOrderSingle514::minQtyNullValue());
|
||||
msg.displayQty(create.display_quantity.value());
|
||||
msg.expireDate(iLinkBinary::NewOrderSingle514::expireDateNullValue());
|
||||
msg.ordType(map_order_type(create.order_type));
|
||||
msg.timeInForce(map_time_in_force(create.time_in_force));
|
||||
msg.manualOrderIndicator(map_manual_order_indicator(create.manual_order_indicator));
|
||||
msg.oFMOverride(iLinkBinary::OFMOverrideReq::Enabled);
|
||||
msg.execInst().clear();
|
||||
msg.executionMode(iLinkBinary::ExecMode::NULL_VALUE);
|
||||
msg.liquidityFlag(iLinkBinary::BooleanNULL::NULL_VALUE);
|
||||
msg.managedOrder(iLinkBinary::BooleanNULL::NULL_VALUE);
|
||||
msg.shortSaleType(iLinkBinary::ShortSaleType::NULL_VALUE);
|
||||
log_out(msg);
|
||||
}
|
||||
|
||||
void ILinkGW::send_cancel(const CancelOrderMsg& cancel) {
|
||||
bts_assert_d(cancel.routing_record);
|
||||
bts_assert_d(cancel.security);
|
||||
bts_assert_d(cancel.security->has_glbx());
|
||||
|
||||
auto party = send_party_details(*cancel.routing_record);
|
||||
auto msg = _buffer.frame<iLinkBinary::OrderCancelRequest516>();
|
||||
|
||||
msg.orderID(cancel.exchange_order_id.value());
|
||||
msg.partyDetailsListReqID(party);
|
||||
msg.manualOrderIndicator(map_manual_order_indicator(cancel.manual_order_indicator));
|
||||
msg.seqNum(next_seq());
|
||||
msg.putSenderID(cancel.routing_record->operator_id());
|
||||
encode_clorid(cancel.key, SecurityKey(cancel.security->id()), &_clorid_buffer);
|
||||
msg.putClOrdID(_clorid_buffer);
|
||||
msg.orderRequestID(++_msg_count);
|
||||
msg.sendingTimeEpoch(_time.now());
|
||||
msg.putLocation(cancel.routing_record->location());
|
||||
msg.securityID(cancel.security->glbx().exchange_id());
|
||||
msg.side(map_side(cancel.side));
|
||||
msg.liquidityFlag(iLinkBinary::BooleanNULL::NULL_VALUE);
|
||||
log_out(msg);
|
||||
}
|
||||
|
||||
void ILinkGW::send_terminate(uint16_t code) {
|
||||
LOG(iLink3, Info, "Terminate");
|
||||
auto msg = _buffer.frame<iLinkBinary::Terminate507>();
|
||||
msg.uUID(_session.uuid);
|
||||
msg.requestTimestamp(_time.now());
|
||||
msg.errorCodes(code);
|
||||
log_out(msg);
|
||||
}
|
||||
|
||||
void ILinkGW::flush(bool publish) {
|
||||
_buffer.flush(_connection);
|
||||
if (publish) publish_session_update();
|
||||
}
|
||||
|
||||
const char* state_string(State s) {
|
||||
switch(s) {
|
||||
case State::INIT: return "INIT";
|
||||
case State::CONNECTING: return "CONNECTING";
|
||||
case State::NEGOTATING: return "NEGOTATING";
|
||||
case State::ESTABLISHING: return "ESTABLISHING";
|
||||
case State::RETRANSMITTING: return "RETRANSMITTING";
|
||||
case State::READY: return "READY";
|
||||
case State::ERROR: return "ERROR";
|
||||
}
|
||||
return "UNKNOWN";
|
||||
}
|
||||
log::CharPtrWrapper wstate_string(State s) { return wrap(state_string(s)); }
|
||||
|
||||
void ILinkGW::set_state(State s) {
|
||||
if (s != _x_state) {
|
||||
LOG(iLink3, Info, "ILinkGW {}: {}->{}",
|
||||
_session.uuid, wstate_string(_x_state), wstate_string(s));
|
||||
_x_state = s;
|
||||
if (_on_state_change) _on_state_change(s);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// IConnectionHandler
|
||||
|
||||
void ILinkGW::on_connect_success() {
|
||||
if (!_session) {
|
||||
// If we have a 0 cme_seq this is a new session and we need to negotiate it
|
||||
LOG(iLink3, Info, "Negotiating new iLink session. {}", _session.uuid);
|
||||
set_state(State::NEGOTATING);
|
||||
send_negotiate();
|
||||
}
|
||||
else {
|
||||
// We only need to establish the current sequence number
|
||||
LOG(iLink3, Info, "re-establishing existing iLink session. {}", _session.uuid);
|
||||
_session.to_cme = std::max(_session.to_cme, 1u);
|
||||
set_state(State::ESTABLISHING);
|
||||
send_establish();
|
||||
}
|
||||
}
|
||||
|
||||
void ILinkGW::on_disconnect() {
|
||||
LOG(iLink3, Error, "Disconnected.");
|
||||
if (_config.failover_on_disconnect) {
|
||||
LOG(iLink3, Error, "Attempting failover");
|
||||
_connection.failover();
|
||||
connect();
|
||||
}
|
||||
else {
|
||||
set_state(State::ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
void ILinkGW::enqueue_retransmit(uint32_t from, uint32_t to, uint64_t uuid) {
|
||||
LOG(iLink3,Warn, "Prepare retransmit from: {} to: {}", from, to);
|
||||
bts_assert(to >= from);
|
||||
do {
|
||||
// +1 because to/from are using an inclusive range
|
||||
auto count = std::min(to - from + 1, Retransmit::MAX_RECOVERY);
|
||||
_retransmit.push(Retransmit {
|
||||
uuid,
|
||||
from,
|
||||
from + count - 1
|
||||
});
|
||||
from += count;
|
||||
} while(from < to);
|
||||
}
|
||||
|
||||
void ILinkGW::begin_retransmit() {
|
||||
if (_retransmit.empty()) return;
|
||||
auto& working = _retransmit.front();
|
||||
// Don't pop the queue because we need to know when we're done
|
||||
auto count = working.to - working.from + 1;
|
||||
LOG(iLink3,Warn, "Sending retransmit for missing packets: from: {} to: {} count: {}", working.from, working.to, count);
|
||||
bts_assert_d(count < Retransmit::MAX_RECOVERY);
|
||||
send_retransmit_request(working.uuid, working.from, count);
|
||||
}
|
||||
|
||||
void ILinkGW::on_retransmit_complete() {
|
||||
// Replay is complete. Advance to go. Collect $200
|
||||
_retransmit.pop();
|
||||
LOG(iLink3,Warn,"Retransmit complete");
|
||||
if (!_retransmit.empty()) {
|
||||
// More replay to do...
|
||||
begin_retransmit();
|
||||
flush();
|
||||
}
|
||||
else {
|
||||
// Replay is finished, transition to ready state.
|
||||
// Since we're already established we dont' need to send anything
|
||||
set_state(State::READY);
|
||||
}
|
||||
}
|
||||
|
||||
size_t ILinkGW::on_data(const std::string_view& data) {
|
||||
return consume_messages(*this, data.data(), data.size(), dispatch_message<ILinkGW>);
|
||||
}
|
||||
|
||||
void ILinkGW::handle(const iLinkBinary::NegotiationResponse501& msg) {
|
||||
// If we're receiving a NegotiateResponse we just created a session
|
||||
log_in(msg);
|
||||
|
||||
// NegotiationResponse indicates the session was created. CME sequence will be 1
|
||||
_session.from_cme = 1;
|
||||
publish_session_update();
|
||||
|
||||
// Even though the CME sends a previous uuid+sequence we can't act on
|
||||
// that data right now since we aren't established. We don't have to remember it,
|
||||
// though, because exactly the same data comes on the EstablishmentAck
|
||||
// msg.previousUUID(), msg.previousSeqNo();
|
||||
|
||||
set_state(State::ESTABLISHING);
|
||||
send_establish();
|
||||
}
|
||||
|
||||
void ILinkGW::handle(const iLinkBinary::NegotiationReject502& msg) {
|
||||
LOG(iLink3, Error, "Negotiate Reject: {} '{}'.",
|
||||
msg.errorCodes(),
|
||||
std::string(translate_negotiation_reject(msg.errorCodes())));
|
||||
log_in(msg);
|
||||
_connection.disconnect();
|
||||
set_state(State::ERROR);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::EstablishmentAck504& msg) {
|
||||
// previous uuid+sequence
|
||||
auto cme_prev_uuid = msg.previousUUID();
|
||||
auto cme_prev_seq = msg.previousSeqNo();
|
||||
if (cme_prev_seq != 0 && cme_prev_uuid != _session.uuid) {
|
||||
// There was a previous session and we need to replay messages from it
|
||||
|
||||
// We *intend* to only have a single session each week except
|
||||
// in the case of catastrophic failure. So If we log in and
|
||||
// there is a previous UUID we can just replay it entirely.
|
||||
// The other possibility is a session was created automatically
|
||||
// to handle a fill from a GTC order from the previous week
|
||||
enqueue_retransmit(1, cme_prev_seq, cme_prev_uuid);
|
||||
}
|
||||
|
||||
// next sequence number from the current session may also be ahead
|
||||
auto cme_current_seq = msg.nextSeqNo() - 1;
|
||||
if (_session.from_cme < cme_current_seq) {
|
||||
// If we're behind it indicates we missed messages while disconnected
|
||||
enqueue_retransmit(_session.from_cme+1, cme_current_seq, msg.uUID());
|
||||
}
|
||||
|
||||
_session.from_cme = cme_current_seq;
|
||||
log_in(msg);
|
||||
|
||||
if (!_retransmit.empty()) {
|
||||
send_sequence();
|
||||
begin_retransmit();
|
||||
flush();
|
||||
set_state(State::RETRANSMITTING);
|
||||
}
|
||||
else {
|
||||
send_sequence();
|
||||
flush();
|
||||
set_state(State::READY);
|
||||
}
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::EstablishmentReject505& msg) {
|
||||
LOG(iLink3, Error, "Establishment Reject: {} '{}'. NextSeq: {}.",
|
||||
msg.errorCodes(),
|
||||
std::string(translate_establish_reject(msg.errorCodes())),
|
||||
msg.nextSeqNo());
|
||||
_connection.disconnect();
|
||||
log_in(msg);
|
||||
set_state(State::ERROR);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::Sequence506& msg) {
|
||||
log_in(msg);
|
||||
_session.from_cme = msg.nextSeqNo() - 1;
|
||||
publish_session_update();
|
||||
send_sequence();
|
||||
flush();
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::Terminate507 &msg) {
|
||||
// https://www.cmegroup.com/confluence/display/EPICSANDBOX/Terminate
|
||||
LOG(iLink3, Error, "Terminated by exchange. Code: {} Reason: {} Text: {}",
|
||||
msg.errorCodes(), wrap(msg.reason()),
|
||||
wrap(translate_terminate(msg.errorCodes())));
|
||||
if (msg.errorCodes() == 11 || msg.errorCodes() == 10) {
|
||||
// This indicates our sequence number is too low. We will jump
|
||||
// forward one at a time. That should eventually fix it.
|
||||
LOG(iLink3, Error, "Will attempt to recover by advancing our sequence number");
|
||||
_session.to_cme ++;
|
||||
publish_session_update();
|
||||
}
|
||||
log_in(msg);
|
||||
_connection.disconnect();
|
||||
set_state(State::ERROR);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::Retransmission509& msg) {
|
||||
// Accepted Retransmit
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::RetransmitReject510& msg) {
|
||||
LOG(iLink3, Error, "Retransmit requeste rejected. {}", msg.getReasonAsString());
|
||||
log_in(msg);
|
||||
set_state(State::ERROR);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::NotApplied513& msg) {
|
||||
log_in(msg);
|
||||
send_sequence();
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::PartyDetailsDefinitionRequestAck519& msg) {
|
||||
_exe_parser.set_account(msg);
|
||||
handle_common(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::BusinessReject521& msg) {
|
||||
LOG(iLink3, Error, "Business Reject: {} '{}'.",
|
||||
msg.businessRejectReason(),
|
||||
wrap(translate_business_reject_reason(msg.businessRejectReason())));
|
||||
handle_common(msg);
|
||||
// A business reject can de-sync the sequence number because it rejects
|
||||
// the sequence number of the rejected message. Send a sequence message
|
||||
// to tell the cme to advance.
|
||||
send_sequence();
|
||||
flush();
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportNew522& msg) {
|
||||
handle_exe_report(msg);
|
||||
handle_common(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportReject523& msg) {
|
||||
LOG(iLink3, Error, "Execution report reject: {}", wrap(msg.text()));
|
||||
handle_exe_report(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportElimination524& msg) {
|
||||
handle_exe_report(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeOutright525& msg) {
|
||||
handle_exe_report(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeSpread526& msg) {
|
||||
handle_exe_report(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeSpreadLeg527& msg) {
|
||||
handle_exe_report(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportModify531& msg) {
|
||||
handle_exe_report(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportStatus532& msg) {
|
||||
handle_exe_report(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportCancel534& msg) {
|
||||
handle_exe_report(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::OrderCancelReject535& msg) {
|
||||
handle_common(msg);
|
||||
// TODO: log
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::OrderCancelReplaceReject536& msg) {
|
||||
handle_common(msg);
|
||||
// TODO: log
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionAck539&) {
|
||||
// handle_common(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeAddendumOutright548& msg) {
|
||||
// Ignore trade correction/addendum messages for now.
|
||||
// See GLBXExecutionGateway.cpp:139 for further details
|
||||
handle_common(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeAddendumSpread549& msg) {
|
||||
// Ignore trade correction/addendum messages for now.
|
||||
// See GLBXExecutionGateway.cpp:139 for further details
|
||||
handle_common(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeAddendumSpreadLeg550& msg) {
|
||||
// Ignore trade correction/addendum messages for now.
|
||||
// See GLBXExecutionGateway.cpp:139 for further details
|
||||
handle_common(msg);
|
||||
}
|
||||
|
||||
}}} //namespace
|
||||
@@ -0,0 +1,232 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
|
||||
#include "../IExecutionGateway.h"
|
||||
#include "TimeKeeper.h"
|
||||
#include "IL3Connection.h"
|
||||
#include "IL3ConnectionHandler.h"
|
||||
|
||||
#include "generated/MessageHeader.h"
|
||||
#include "IL3GeneratedFwd.h"
|
||||
#include "IL3ExecutionReportParser.h"
|
||||
#include "lib/orderman/actors/ilink3/RawMsg.h"
|
||||
#include "lib/config/protos/jetfix.pb.h"
|
||||
|
||||
#define MID_SESSION_REPLAY
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
class ExecutionReport;
|
||||
namespace ilink3 {
|
||||
|
||||
struct Session {
|
||||
uint64_t uuid;
|
||||
// bts->cme
|
||||
uint32_t to_cme;
|
||||
// cme->bts
|
||||
uint32_t from_cme;
|
||||
|
||||
operator bool const() { return from_cme; }
|
||||
};
|
||||
|
||||
struct Config {
|
||||
std::string cme_session; // NGG
|
||||
std::string firm; // 004
|
||||
bool failover_on_disconnect;
|
||||
std::function<void(RawMessageDirection, RawMsg const&)> raw_message_logger;
|
||||
};
|
||||
|
||||
enum class State {
|
||||
INIT,
|
||||
CONNECTING,
|
||||
NEGOTATING,
|
||||
ESTABLISHING,
|
||||
RETRANSMITTING,
|
||||
READY,
|
||||
ERROR
|
||||
};
|
||||
const char* state_string(State s);
|
||||
typedef std::function<void(State)> OnStateChange;
|
||||
typedef std::function<void(const ExecutionReport*)> OnExecutionReport;
|
||||
typedef std::function<void(const Session& s)> OnSessionChange;
|
||||
typedef std::function<void(OrderKey,std::string const&)> OnCancelReject;
|
||||
|
||||
struct Retransmit {
|
||||
static constexpr uint32_t MAX_RECOVERY = 2500;
|
||||
uint64_t uuid;
|
||||
uint32_t from;
|
||||
uint32_t to;
|
||||
};
|
||||
|
||||
class IL3MessageFramer;
|
||||
|
||||
// Does not allow re-entrance
|
||||
class ILinkGW : IL3ConnectionHandler {
|
||||
const Config _config;
|
||||
State _x_state;
|
||||
IL3MessageFramer& _buffer;
|
||||
OnStateChange _on_state_change;
|
||||
OnExecutionReport _on_exe_report;
|
||||
OnSessionChange _on_session_change;
|
||||
IL3Connection& _connection;
|
||||
Session _session;
|
||||
std::string _clorid_buffer;
|
||||
uint32_t _msg_count;
|
||||
TimeKeeper _time;
|
||||
boost::object_pool<ExecutionReport> _pool;
|
||||
IL3ExecutionReportParser _exe_parser;
|
||||
std::queue<Retransmit> _retransmit;
|
||||
|
||||
public:
|
||||
ILinkGW(
|
||||
IL3Connection&,
|
||||
IL3MessageFramer&,
|
||||
md::SecurityOracle*,
|
||||
const Session&,
|
||||
const Config&,
|
||||
config::JetFIX::Connection const &);
|
||||
|
||||
void connect();
|
||||
void send_order(const CreateOrderMsg&);
|
||||
void send_cancel_replace(const CancelReplaceOrderMsg&);
|
||||
void send_cancel(const CancelOrderMsg&);
|
||||
void send_terminate(uint16_t code=0);
|
||||
void flush(bool publish=true);
|
||||
void on_time() {
|
||||
// Currently we just reply to a heartbeat with another heartbeat
|
||||
// Probably better to track time and send them on demand
|
||||
};
|
||||
|
||||
// state change
|
||||
State state() { return _x_state; }
|
||||
void subscribe_state(OnStateChange o) { _on_state_change = o; }
|
||||
void subscribe_execution_reports(OnExecutionReport sub) {
|
||||
_on_exe_report = sub;
|
||||
}
|
||||
void subscribe_session(OnSessionChange cb) { _on_session_change = cb; }
|
||||
void subscribe_cancel_reject(OnCancelReject) {}
|
||||
// Only used for certification
|
||||
void send_sequence(bool lapsed=false);
|
||||
|
||||
private:
|
||||
void send_negotiate();
|
||||
void send_establish();
|
||||
void send_retransmit_request(uint64_t uuid, uint32_t from, size_t count);
|
||||
uint64_t send_party_details(const api::orderman::RoutingRecord&);
|
||||
|
||||
private:
|
||||
void set_state(State);
|
||||
uint32_t next_seq() {
|
||||
_session.to_cme += 1;
|
||||
return _session.to_cme-1;
|
||||
}
|
||||
void publish_session_update() { _on_session_change(_session); }
|
||||
void on_connect_success() override;
|
||||
void on_disconnect() override;
|
||||
void enqueue_retransmit(uint32_t from, uint32_t to, uint64_t uuid);
|
||||
void begin_retransmit();
|
||||
void on_retransmit_complete();
|
||||
|
||||
template <class T>
|
||||
static auto serialize(const T& msg) -> auto {
|
||||
return [=]() -> auto {
|
||||
RawMessageData result;
|
||||
std::stringstream buffer;
|
||||
buffer << msg;
|
||||
result.json = buffer.str();
|
||||
result.binary = std::string(msg.buffer() + msg.offset(), msg.decodeLength());
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void log_in(const T& msg) {
|
||||
_config.raw_message_logger(RawMessageDirection::INCOMING, serialize(msg));
|
||||
}
|
||||
template <class T>
|
||||
void log_out(const T& msg) {
|
||||
_config.raw_message_logger(RawMessageDirection::OUTGOING, serialize(msg));
|
||||
}
|
||||
|
||||
//
|
||||
// Message handlers
|
||||
|
||||
size_t on_data(const std::string_view&) override;
|
||||
|
||||
template <class T>
|
||||
void handle_common(const T& msg) {
|
||||
auto uuid = msg.uUID();
|
||||
auto seq = msg.seqNum();
|
||||
log_in(msg);
|
||||
// Test if replay is copmlete
|
||||
if (!_retransmit.empty() && _retransmit.front().to == seq) {
|
||||
on_retransmit_complete();
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle non-replay packet
|
||||
if (uuid == _session.uuid) {
|
||||
#ifdef MID_SESSION_REPLAY
|
||||
// Gap detected during normal operation
|
||||
auto expected = _session.from_cme + 1;
|
||||
if (seq > expected) {
|
||||
bool busy = !_retransmit.empty();
|
||||
enqueue_retransmit(expected, seq-1, _session.uuid);
|
||||
if (!busy) begin_retransmit();
|
||||
flush();
|
||||
}
|
||||
#endif
|
||||
// msg may be a replay message with a lower sequence number
|
||||
if (msg.seqNum() > _session.from_cme) {
|
||||
_session.from_cme = msg.seqNum();
|
||||
publish_session_update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void handle_exe_report(const T& msg) {
|
||||
auto* report = _pool.construct();
|
||||
bool result = _exe_parser.parse(msg, report);
|
||||
if (result) {
|
||||
_on_exe_report(report);
|
||||
}
|
||||
else { LOG(iLink3, Error, "Failed to parse error report."); }
|
||||
handle_common(msg);
|
||||
}
|
||||
|
||||
public:
|
||||
void handle(const iLinkBinary::NegotiationResponse501&);
|
||||
void handle(const iLinkBinary::NegotiationReject502&);
|
||||
void handle(const iLinkBinary::EstablishmentAck504&);
|
||||
void handle(const iLinkBinary::EstablishmentReject505&);
|
||||
void handle(const iLinkBinary::Sequence506&);
|
||||
void handle(const iLinkBinary::Terminate507&);
|
||||
void handle(const iLinkBinary::Retransmission509&);
|
||||
void handle(const iLinkBinary::RetransmitReject510&);
|
||||
void handle(const iLinkBinary::NotApplied513&);
|
||||
void handle(const iLinkBinary::PartyDetailsDefinitionRequestAck519&);
|
||||
void handle(const iLinkBinary::BusinessReject521&);
|
||||
void handle(const iLinkBinary::ExecutionReportNew522&);
|
||||
void handle(const iLinkBinary::ExecutionReportReject523&);
|
||||
void handle(const iLinkBinary::ExecutionReportElimination524&);
|
||||
void handle(const iLinkBinary::ExecutionReportTradeOutright525&);
|
||||
void handle(const iLinkBinary::ExecutionReportTradeSpread526&);
|
||||
void handle(const iLinkBinary::ExecutionReportTradeSpreadLeg527&);
|
||||
void handle(const iLinkBinary::ExecutionReportModify531&);
|
||||
void handle(const iLinkBinary::ExecutionReportStatus532&);
|
||||
void handle(const iLinkBinary::ExecutionReportCancel534&);
|
||||
void handle(const iLinkBinary::OrderCancelReject535&);
|
||||
void handle(const iLinkBinary::OrderCancelReplaceReject536&);
|
||||
void handle(const iLinkBinary::ExecutionAck539&);
|
||||
void handle(const iLinkBinary::ExecutionReportTradeAddendumOutright548&);
|
||||
void handle(const iLinkBinary::ExecutionReportTradeAddendumSpread549&);
|
||||
void handle(const iLinkBinary::ExecutionReportTradeAddendumSpreadLeg550&);
|
||||
|
||||
};
|
||||
|
||||
}}} //namespace
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
enum class RawMessageDirection {INCOMING, OUTGOING};
|
||||
struct RawMessageData {
|
||||
std::string json;
|
||||
std::string binary;
|
||||
};
|
||||
using RawMsg = std::function<RawMessageData(void)>;
|
||||
}}}
|
||||
@@ -0,0 +1,180 @@
|
||||
#include "SessionStore.h"
|
||||
#include "lib/jetfix/store/session_name.h"
|
||||
#include "lib/orderman/actors/ilink3/ILinkGW.h"
|
||||
#include "lib/orderman/orderman_utils/ExecutionReport.h"
|
||||
#include "lib/utils/base64.hpp"
|
||||
#include "lib/utils/bts_chrono.h"
|
||||
#include "lib/utils/file_utils.h"
|
||||
#include "lib/utils/thread_manager.h"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <tbb/concurrent_queue.h>
|
||||
#include <thread>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
using Action = std::function<void()>;
|
||||
|
||||
static std::string base_store_path(std::string base_path,
|
||||
std::string const &connection_name,
|
||||
std::string const &session_name) {
|
||||
if (base_path.empty())
|
||||
base_path = os::bts_data_path();
|
||||
boost::filesystem::path result = utils::normalize_data_path(base_path);
|
||||
result /= "ilink3";
|
||||
result /= connection_name;
|
||||
result /= session_name;
|
||||
if (!boost::filesystem::exists(result))
|
||||
bts_assert(boost::filesystem::create_directories(result));
|
||||
return result.string();
|
||||
}
|
||||
|
||||
static std::string raw_msg_log_path(std::string const &store_path) {
|
||||
boost::filesystem::path result = store_path;
|
||||
result /= "raw_msgs";
|
||||
return result.string();
|
||||
}
|
||||
|
||||
static std::string session_path(std::string const &store_path) {
|
||||
boost::filesystem::path result = store_path;
|
||||
result /= "session";
|
||||
return result.string();
|
||||
}
|
||||
|
||||
static std::vector<ExecutionReport>
|
||||
load_replay(md::SecurityOracle &, config::JetFIX::Connection const &cfg,
|
||||
std::string const &path) {
|
||||
std::vector<ExecutionReport> result;
|
||||
|
||||
if (boost::filesystem::exists(path)) {
|
||||
|
||||
std::ifstream f(path);
|
||||
nlohmann::json j;
|
||||
for (;;) {
|
||||
while (!f.eof() && f.get() != '{')
|
||||
;
|
||||
if (f.eof())
|
||||
break;
|
||||
else {
|
||||
f.unget();
|
||||
f >> j;
|
||||
if (j["direction"] == "<") {
|
||||
auto ts = datetime::parse_FIX_timestamp(j["time"]);
|
||||
if (!datetime::is_at_least_secs_old(ts,
|
||||
cfg.seconds_to_replay())) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void save_raw_msg(std::ofstream &out, RawMessageDirection d,
|
||||
RawMessageData const &msg) {
|
||||
nlohmann::json j;
|
||||
j["direction"] = d == RawMessageDirection::INCOMING ? "<" : ">";
|
||||
j["time"] = datetime::FIX_timestamp(datetime::now());
|
||||
j["msg_sbe"] = websocketpp::base64_encode(msg.binary);
|
||||
try {
|
||||
j["msg_json"] = nlohmann::json::parse(msg.json);
|
||||
}
|
||||
catch (...) {
|
||||
LOG(iLink3, Error, "Skipping troublesome json encoded message: {}", msg.json);
|
||||
j["msg_json"] = nlohmann::json {};
|
||||
}
|
||||
out << j << std::endl;
|
||||
out.flush();
|
||||
}
|
||||
|
||||
void save_session(std::string const &path, Session const &session) {
|
||||
std::ofstream f(path);
|
||||
f << session.uuid << " " << session.to_cme << " " << session.from_cme
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
Session load_session(jetfix::SessionName const &sn, std::string const &path) {
|
||||
auto result = Session{sn.as_uint64_t, 1, 0};
|
||||
if (boost::filesystem::exists(path)) {
|
||||
std::ifstream f(path);
|
||||
uint64_t dummy;
|
||||
f >> dummy >> result.to_cme >> result.from_cme;
|
||||
}
|
||||
else
|
||||
save_session(path, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
struct SessionStore::PImpl {
|
||||
PImpl(md::SecurityOracle &oracle, jetfix::SessionName const &session_name,
|
||||
config::JetFIX::Connection const &cfg, std::string const &base_path)
|
||||
: cfg(cfg), store_path(base_store_path(base_path, cfg.name(),
|
||||
session_name.as_string)),
|
||||
replay_messages(
|
||||
load_replay(oracle, cfg, raw_msg_log_path(store_path))),
|
||||
starting_session_descriptor(
|
||||
load_session(session_name, session_path(store_path))),
|
||||
raw_msg_store() {
|
||||
raw_msg_store.open(raw_msg_log_path(store_path), std::ofstream::app);
|
||||
}
|
||||
|
||||
const config::JetFIX::Connection cfg;
|
||||
const std::string store_path;
|
||||
const std::vector<ExecutionReport> replay_messages;
|
||||
const Session starting_session_descriptor;
|
||||
std::atomic<bool> done = false;
|
||||
tbb::concurrent_queue<Action> event_queue;
|
||||
std::thread storage_thread;
|
||||
std::ofstream raw_msg_store;
|
||||
};
|
||||
|
||||
SessionStore::SessionStore(md::SecurityOracle &oracle,
|
||||
jetfix::SessionName const &session_name,
|
||||
config::JetFIX::Connection const &cfg,
|
||||
std::string base_path)
|
||||
: me(new PImpl(oracle, session_name, cfg, base_path)) {
|
||||
me->storage_thread = threading::make_thread_from_function(
|
||||
"il3_store", [this]() { do_work(); });
|
||||
}
|
||||
|
||||
std::vector<ExecutionReport> const &SessionStore::replay() const {
|
||||
return me->replay_messages;
|
||||
}
|
||||
|
||||
Session SessionStore::starting_session_descriptor() const {
|
||||
return me->starting_session_descriptor;
|
||||
}
|
||||
|
||||
void SessionStore::async_update_session(Session const &s) {
|
||||
me->event_queue.push(
|
||||
Action{[this, s]() { save_session(session_path(me->store_path), s); }});
|
||||
}
|
||||
|
||||
void SessionStore::async_store_raw_msg(RawMessageDirection d,
|
||||
RawMsg const &ms) {
|
||||
me->event_queue.push(
|
||||
Action{[this, d, ms]() { save_raw_msg(me->raw_msg_store, d, ms()); }});
|
||||
}
|
||||
|
||||
void SessionStore::do_work() {
|
||||
while (!me->done) {
|
||||
Action a;
|
||||
if (me->event_queue.try_pop(a))
|
||||
a();
|
||||
else
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
}
|
||||
|
||||
SessionStore::~SessionStore() {
|
||||
me->done = true;
|
||||
me->storage_thread.join();
|
||||
}
|
||||
|
||||
} // namespace ilink3
|
||||
} // namespace orderman
|
||||
} // namespace bts
|
||||
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include "lib/config/protos/jetfix.pb.h"
|
||||
#include "RawMsg.h"
|
||||
|
||||
// fwds
|
||||
namespace bts {
|
||||
namespace jetfix {struct SessionName;}
|
||||
namespace md { class SecurityOracle;}
|
||||
namespace orderman {class ExecutionReport;}
|
||||
}
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
struct Session;
|
||||
class SessionStore {
|
||||
public:
|
||||
SessionStore(md::SecurityOracle &,
|
||||
jetfix::SessionName const&session_name,
|
||||
config::JetFIX::Connection const&,
|
||||
std::string base_path="");
|
||||
~SessionStore() ;
|
||||
|
||||
Session starting_session_descriptor() const;
|
||||
std::vector<ExecutionReport> const &replay() const;
|
||||
|
||||
void async_update_session(Session const&) ;
|
||||
void async_store_raw_msg(RawMessageDirection, RawMsg const&);
|
||||
private:
|
||||
void do_work();
|
||||
struct PImpl;
|
||||
std::unique_ptr<PImpl> me;
|
||||
};
|
||||
|
||||
}}}
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/utils/TimeStamp.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
struct TimeKeeper {
|
||||
uint64_t unix_time;
|
||||
utils::TimeStamp start;
|
||||
|
||||
TimeKeeper() :
|
||||
unix_time(datetime::unix_nano_now()),
|
||||
start(utils::TimeStamp::now())
|
||||
{}
|
||||
|
||||
uint64_t now() const {
|
||||
auto now = utils::TimeStamp::now();
|
||||
auto delta = now - start;
|
||||
return unix_time + delta.microseconds();
|
||||
}
|
||||
};
|
||||
|
||||
}}} //namespace
|
||||
@@ -0,0 +1,144 @@
|
||||
/* Generated SBE (Simple Binary Encoding) message codec */
|
||||
#ifndef _ILINKBINARY_AVGPXIND_H_
|
||||
#define _ILINKBINARY_AVGPXIND_H_
|
||||
|
||||
#if defined(SBE_HAVE_CMATH)
|
||||
/* cmath needed for std::numeric_limits<double>::quiet_NaN() */
|
||||
# include <cmath>
|
||||
# define SBE_FLOAT_NAN std::numeric_limits<float>::quiet_NaN()
|
||||
# define SBE_DOUBLE_NAN std::numeric_limits<double>::quiet_NaN()
|
||||
#else
|
||||
/* math.h needed for NAN */
|
||||
# include <math.h>
|
||||
# define SBE_FLOAT_NAN NAN
|
||||
# define SBE_DOUBLE_NAN NAN
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define SBE_CONSTEXPR constexpr
|
||||
# define SBE_NOEXCEPT noexcept
|
||||
#else
|
||||
# define SBE_CONSTEXPR
|
||||
# define SBE_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201402L
|
||||
# define SBE_CONSTEXPR_14 constexpr
|
||||
#else
|
||||
# define SBE_CONSTEXPR_14
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
# include <string_view>
|
||||
# define SBE_NODISCARD [[nodiscard]]
|
||||
#else
|
||||
# define SBE_NODISCARD
|
||||
#endif
|
||||
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
# define __STDC_LIMIT_MACROS 1
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) _byteswap_ushort(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) _byteswap_ulong(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) _byteswap_uint64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) (v)
|
||||
#else
|
||||
# error "Byte Ordering of platform not determined. Set __BYTE_ORDER__ manually before including this file."
|
||||
#endif
|
||||
|
||||
#if defined(SBE_NO_BOUNDS_CHECK)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (false)
|
||||
#elif defined(_MSC_VER)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (exp)
|
||||
#else
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (__builtin_expect(exp,c))
|
||||
#endif
|
||||
|
||||
#define SBE_NULLVALUE_INT8 (std::numeric_limits<std::int8_t>::min)()
|
||||
#define SBE_NULLVALUE_INT16 (std::numeric_limits<std::int16_t>::min)()
|
||||
#define SBE_NULLVALUE_INT32 (std::numeric_limits<std::int32_t>::min)()
|
||||
#define SBE_NULLVALUE_INT64 (std::numeric_limits<std::int64_t>::min)()
|
||||
#define SBE_NULLVALUE_UINT8 (std::numeric_limits<std::uint8_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT16 (std::numeric_limits<std::uint16_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT32 (std::numeric_limits<std::uint32_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT64 (std::numeric_limits<std::uint64_t>::max)()
|
||||
|
||||
|
||||
namespace iLinkBinary {
|
||||
|
||||
class AvgPxInd
|
||||
{
|
||||
public:
|
||||
enum Value
|
||||
{
|
||||
NoAveragePricing = (std::uint8_t)0,
|
||||
TradeispartofanAveragePriceGroupIdentifiedbytheAvgPxGrpID = (std::uint8_t)1,
|
||||
TradeispartofaNotionalValueAveragePriceGroup = (std::uint8_t)3,
|
||||
NULL_VALUE = (std::uint8_t)255
|
||||
};
|
||||
|
||||
static AvgPxInd::Value get(const std::uint8_t value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 0: return NoAveragePricing;
|
||||
case 1: return TradeispartofanAveragePriceGroupIdentifiedbytheAvgPxGrpID;
|
||||
case 3: return TradeispartofaNotionalValueAveragePriceGroup;
|
||||
case 255: return NULL_VALUE;
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum AvgPxInd [E103]");
|
||||
}
|
||||
|
||||
static const char* c_str(const AvgPxInd::Value value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case NoAveragePricing: return "NoAveragePricing";
|
||||
case TradeispartofanAveragePriceGroupIdentifiedbytheAvgPxGrpID: return "TradeispartofanAveragePriceGroupIdentifiedbytheAvgPxGrpID";
|
||||
case TradeispartofaNotionalValueAveragePriceGroup: return "TradeispartofaNotionalValueAveragePriceGroup";
|
||||
case NULL_VALUE: return "NULL_VALUE";
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum AvgPxInd [E103]:");
|
||||
}
|
||||
|
||||
template<typename CharT, typename Traits>
|
||||
friend std::basic_ostream<CharT, Traits>& operator << (
|
||||
std::basic_ostream<CharT, Traits>& os, AvgPxInd::Value m)
|
||||
{
|
||||
return os << AvgPxInd::c_str(m);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,141 @@
|
||||
/* Generated SBE (Simple Binary Encoding) message codec */
|
||||
#ifndef _ILINKBINARY_BOOLEANFLAG_H_
|
||||
#define _ILINKBINARY_BOOLEANFLAG_H_
|
||||
|
||||
#if defined(SBE_HAVE_CMATH)
|
||||
/* cmath needed for std::numeric_limits<double>::quiet_NaN() */
|
||||
# include <cmath>
|
||||
# define SBE_FLOAT_NAN std::numeric_limits<float>::quiet_NaN()
|
||||
# define SBE_DOUBLE_NAN std::numeric_limits<double>::quiet_NaN()
|
||||
#else
|
||||
/* math.h needed for NAN */
|
||||
# include <math.h>
|
||||
# define SBE_FLOAT_NAN NAN
|
||||
# define SBE_DOUBLE_NAN NAN
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define SBE_CONSTEXPR constexpr
|
||||
# define SBE_NOEXCEPT noexcept
|
||||
#else
|
||||
# define SBE_CONSTEXPR
|
||||
# define SBE_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201402L
|
||||
# define SBE_CONSTEXPR_14 constexpr
|
||||
#else
|
||||
# define SBE_CONSTEXPR_14
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
# include <string_view>
|
||||
# define SBE_NODISCARD [[nodiscard]]
|
||||
#else
|
||||
# define SBE_NODISCARD
|
||||
#endif
|
||||
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
# define __STDC_LIMIT_MACROS 1
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) _byteswap_ushort(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) _byteswap_ulong(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) _byteswap_uint64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) (v)
|
||||
#else
|
||||
# error "Byte Ordering of platform not determined. Set __BYTE_ORDER__ manually before including this file."
|
||||
#endif
|
||||
|
||||
#if defined(SBE_NO_BOUNDS_CHECK)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (false)
|
||||
#elif defined(_MSC_VER)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (exp)
|
||||
#else
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (__builtin_expect(exp,c))
|
||||
#endif
|
||||
|
||||
#define SBE_NULLVALUE_INT8 (std::numeric_limits<std::int8_t>::min)()
|
||||
#define SBE_NULLVALUE_INT16 (std::numeric_limits<std::int16_t>::min)()
|
||||
#define SBE_NULLVALUE_INT32 (std::numeric_limits<std::int32_t>::min)()
|
||||
#define SBE_NULLVALUE_INT64 (std::numeric_limits<std::int64_t>::min)()
|
||||
#define SBE_NULLVALUE_UINT8 (std::numeric_limits<std::uint8_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT16 (std::numeric_limits<std::uint16_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT32 (std::numeric_limits<std::uint32_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT64 (std::numeric_limits<std::uint64_t>::max)()
|
||||
|
||||
|
||||
namespace iLinkBinary {
|
||||
|
||||
class BooleanFlag
|
||||
{
|
||||
public:
|
||||
enum Value
|
||||
{
|
||||
False = (std::uint8_t)0,
|
||||
True = (std::uint8_t)1,
|
||||
NULL_VALUE = (std::uint8_t)255
|
||||
};
|
||||
|
||||
static BooleanFlag::Value get(const std::uint8_t value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 0: return False;
|
||||
case 1: return True;
|
||||
case 255: return NULL_VALUE;
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum BooleanFlag [E103]");
|
||||
}
|
||||
|
||||
static const char* c_str(const BooleanFlag::Value value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case False: return "False";
|
||||
case True: return "True";
|
||||
case NULL_VALUE: return "NULL_VALUE";
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum BooleanFlag [E103]:");
|
||||
}
|
||||
|
||||
template<typename CharT, typename Traits>
|
||||
friend std::basic_ostream<CharT, Traits>& operator << (
|
||||
std::basic_ostream<CharT, Traits>& os, BooleanFlag::Value m)
|
||||
{
|
||||
return os << BooleanFlag::c_str(m);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,141 @@
|
||||
/* Generated SBE (Simple Binary Encoding) message codec */
|
||||
#ifndef _ILINKBINARY_BOOLEANNULL_H_
|
||||
#define _ILINKBINARY_BOOLEANNULL_H_
|
||||
|
||||
#if defined(SBE_HAVE_CMATH)
|
||||
/* cmath needed for std::numeric_limits<double>::quiet_NaN() */
|
||||
# include <cmath>
|
||||
# define SBE_FLOAT_NAN std::numeric_limits<float>::quiet_NaN()
|
||||
# define SBE_DOUBLE_NAN std::numeric_limits<double>::quiet_NaN()
|
||||
#else
|
||||
/* math.h needed for NAN */
|
||||
# include <math.h>
|
||||
# define SBE_FLOAT_NAN NAN
|
||||
# define SBE_DOUBLE_NAN NAN
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define SBE_CONSTEXPR constexpr
|
||||
# define SBE_NOEXCEPT noexcept
|
||||
#else
|
||||
# define SBE_CONSTEXPR
|
||||
# define SBE_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201402L
|
||||
# define SBE_CONSTEXPR_14 constexpr
|
||||
#else
|
||||
# define SBE_CONSTEXPR_14
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
# include <string_view>
|
||||
# define SBE_NODISCARD [[nodiscard]]
|
||||
#else
|
||||
# define SBE_NODISCARD
|
||||
#endif
|
||||
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
# define __STDC_LIMIT_MACROS 1
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) _byteswap_ushort(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) _byteswap_ulong(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) _byteswap_uint64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) (v)
|
||||
#else
|
||||
# error "Byte Ordering of platform not determined. Set __BYTE_ORDER__ manually before including this file."
|
||||
#endif
|
||||
|
||||
#if defined(SBE_NO_BOUNDS_CHECK)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (false)
|
||||
#elif defined(_MSC_VER)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (exp)
|
||||
#else
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (__builtin_expect(exp,c))
|
||||
#endif
|
||||
|
||||
#define SBE_NULLVALUE_INT8 (std::numeric_limits<std::int8_t>::min)()
|
||||
#define SBE_NULLVALUE_INT16 (std::numeric_limits<std::int16_t>::min)()
|
||||
#define SBE_NULLVALUE_INT32 (std::numeric_limits<std::int32_t>::min)()
|
||||
#define SBE_NULLVALUE_INT64 (std::numeric_limits<std::int64_t>::min)()
|
||||
#define SBE_NULLVALUE_UINT8 (std::numeric_limits<std::uint8_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT16 (std::numeric_limits<std::uint16_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT32 (std::numeric_limits<std::uint32_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT64 (std::numeric_limits<std::uint64_t>::max)()
|
||||
|
||||
|
||||
namespace iLinkBinary {
|
||||
|
||||
class BooleanNULL
|
||||
{
|
||||
public:
|
||||
enum Value
|
||||
{
|
||||
False = (std::uint8_t)0,
|
||||
True = (std::uint8_t)1,
|
||||
NULL_VALUE = (std::uint8_t)255
|
||||
};
|
||||
|
||||
static BooleanNULL::Value get(const std::uint8_t value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 0: return False;
|
||||
case 1: return True;
|
||||
case 255: return NULL_VALUE;
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum BooleanNULL [E103]");
|
||||
}
|
||||
|
||||
static const char* c_str(const BooleanNULL::Value value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case False: return "False";
|
||||
case True: return "True";
|
||||
case NULL_VALUE: return "NULL_VALUE";
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum BooleanNULL [E103]:");
|
||||
}
|
||||
|
||||
template<typename CharT, typename Traits>
|
||||
friend std::basic_ostream<CharT, Traits>& operator << (
|
||||
std::basic_ostream<CharT, Traits>& os, BooleanNULL::Value m)
|
||||
{
|
||||
return os << BooleanNULL::c_str(m);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,141 @@
|
||||
/* Generated SBE (Simple Binary Encoding) message codec */
|
||||
#ifndef _ILINKBINARY_CLEARINGACCTTYPE_H_
|
||||
#define _ILINKBINARY_CLEARINGACCTTYPE_H_
|
||||
|
||||
#if defined(SBE_HAVE_CMATH)
|
||||
/* cmath needed for std::numeric_limits<double>::quiet_NaN() */
|
||||
# include <cmath>
|
||||
# define SBE_FLOAT_NAN std::numeric_limits<float>::quiet_NaN()
|
||||
# define SBE_DOUBLE_NAN std::numeric_limits<double>::quiet_NaN()
|
||||
#else
|
||||
/* math.h needed for NAN */
|
||||
# include <math.h>
|
||||
# define SBE_FLOAT_NAN NAN
|
||||
# define SBE_DOUBLE_NAN NAN
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define SBE_CONSTEXPR constexpr
|
||||
# define SBE_NOEXCEPT noexcept
|
||||
#else
|
||||
# define SBE_CONSTEXPR
|
||||
# define SBE_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201402L
|
||||
# define SBE_CONSTEXPR_14 constexpr
|
||||
#else
|
||||
# define SBE_CONSTEXPR_14
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
# include <string_view>
|
||||
# define SBE_NODISCARD [[nodiscard]]
|
||||
#else
|
||||
# define SBE_NODISCARD
|
||||
#endif
|
||||
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
# define __STDC_LIMIT_MACROS 1
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) _byteswap_ushort(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) _byteswap_ulong(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) _byteswap_uint64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) (v)
|
||||
#else
|
||||
# error "Byte Ordering of platform not determined. Set __BYTE_ORDER__ manually before including this file."
|
||||
#endif
|
||||
|
||||
#if defined(SBE_NO_BOUNDS_CHECK)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (false)
|
||||
#elif defined(_MSC_VER)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (exp)
|
||||
#else
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (__builtin_expect(exp,c))
|
||||
#endif
|
||||
|
||||
#define SBE_NULLVALUE_INT8 (std::numeric_limits<std::int8_t>::min)()
|
||||
#define SBE_NULLVALUE_INT16 (std::numeric_limits<std::int16_t>::min)()
|
||||
#define SBE_NULLVALUE_INT32 (std::numeric_limits<std::int32_t>::min)()
|
||||
#define SBE_NULLVALUE_INT64 (std::numeric_limits<std::int64_t>::min)()
|
||||
#define SBE_NULLVALUE_UINT8 (std::numeric_limits<std::uint8_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT16 (std::numeric_limits<std::uint16_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT32 (std::numeric_limits<std::uint32_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT64 (std::numeric_limits<std::uint64_t>::max)()
|
||||
|
||||
|
||||
namespace iLinkBinary {
|
||||
|
||||
class ClearingAcctType
|
||||
{
|
||||
public:
|
||||
enum Value
|
||||
{
|
||||
Customer = (std::uint8_t)0,
|
||||
Firm = (std::uint8_t)1,
|
||||
NULL_VALUE = (std::uint8_t)255
|
||||
};
|
||||
|
||||
static ClearingAcctType::Value get(const std::uint8_t value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 0: return Customer;
|
||||
case 1: return Firm;
|
||||
case 255: return NULL_VALUE;
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum ClearingAcctType [E103]");
|
||||
}
|
||||
|
||||
static const char* c_str(const ClearingAcctType::Value value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case Customer: return "Customer";
|
||||
case Firm: return "Firm";
|
||||
case NULL_VALUE: return "NULL_VALUE";
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum ClearingAcctType [E103]:");
|
||||
}
|
||||
|
||||
template<typename CharT, typename Traits>
|
||||
friend std::basic_ostream<CharT, Traits>& operator << (
|
||||
std::basic_ostream<CharT, Traits>& os, ClearingAcctType::Value m)
|
||||
{
|
||||
return os << ClearingAcctType::c_str(m);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,141 @@
|
||||
/* Generated SBE (Simple Binary Encoding) message codec */
|
||||
#ifndef _ILINKBINARY_CMTAGIVEUPCD_H_
|
||||
#define _ILINKBINARY_CMTAGIVEUPCD_H_
|
||||
|
||||
#if defined(SBE_HAVE_CMATH)
|
||||
/* cmath needed for std::numeric_limits<double>::quiet_NaN() */
|
||||
# include <cmath>
|
||||
# define SBE_FLOAT_NAN std::numeric_limits<float>::quiet_NaN()
|
||||
# define SBE_DOUBLE_NAN std::numeric_limits<double>::quiet_NaN()
|
||||
#else
|
||||
/* math.h needed for NAN */
|
||||
# include <math.h>
|
||||
# define SBE_FLOAT_NAN NAN
|
||||
# define SBE_DOUBLE_NAN NAN
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define SBE_CONSTEXPR constexpr
|
||||
# define SBE_NOEXCEPT noexcept
|
||||
#else
|
||||
# define SBE_CONSTEXPR
|
||||
# define SBE_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201402L
|
||||
# define SBE_CONSTEXPR_14 constexpr
|
||||
#else
|
||||
# define SBE_CONSTEXPR_14
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
# include <string_view>
|
||||
# define SBE_NODISCARD [[nodiscard]]
|
||||
#else
|
||||
# define SBE_NODISCARD
|
||||
#endif
|
||||
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
# define __STDC_LIMIT_MACROS 1
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) _byteswap_ushort(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) _byteswap_ulong(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) _byteswap_uint64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) (v)
|
||||
#else
|
||||
# error "Byte Ordering of platform not determined. Set __BYTE_ORDER__ manually before including this file."
|
||||
#endif
|
||||
|
||||
#if defined(SBE_NO_BOUNDS_CHECK)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (false)
|
||||
#elif defined(_MSC_VER)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (exp)
|
||||
#else
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (__builtin_expect(exp,c))
|
||||
#endif
|
||||
|
||||
#define SBE_NULLVALUE_INT8 (std::numeric_limits<std::int8_t>::min)()
|
||||
#define SBE_NULLVALUE_INT16 (std::numeric_limits<std::int16_t>::min)()
|
||||
#define SBE_NULLVALUE_INT32 (std::numeric_limits<std::int32_t>::min)()
|
||||
#define SBE_NULLVALUE_INT64 (std::numeric_limits<std::int64_t>::min)()
|
||||
#define SBE_NULLVALUE_UINT8 (std::numeric_limits<std::uint8_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT16 (std::numeric_limits<std::uint16_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT32 (std::numeric_limits<std::uint32_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT64 (std::numeric_limits<std::uint64_t>::max)()
|
||||
|
||||
|
||||
namespace iLinkBinary {
|
||||
|
||||
class CmtaGiveUpCD
|
||||
{
|
||||
public:
|
||||
enum Value
|
||||
{
|
||||
GiveUp = (char)71,
|
||||
SGXoffset = (char)83,
|
||||
NULL_VALUE = (char)0
|
||||
};
|
||||
|
||||
static CmtaGiveUpCD::Value get(const char value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 71: return GiveUp;
|
||||
case 83: return SGXoffset;
|
||||
case 0: return NULL_VALUE;
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum CmtaGiveUpCD [E103]");
|
||||
}
|
||||
|
||||
static const char* c_str(const CmtaGiveUpCD::Value value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case GiveUp: return "GiveUp";
|
||||
case SGXoffset: return "SGXoffset";
|
||||
case NULL_VALUE: return "NULL_VALUE";
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum CmtaGiveUpCD [E103]:");
|
||||
}
|
||||
|
||||
template<typename CharT, typename Traits>
|
||||
friend std::basic_ostream<CharT, Traits>& operator << (
|
||||
std::basic_ostream<CharT, Traits>& os, CmtaGiveUpCD::Value m)
|
||||
{
|
||||
return os << CmtaGiveUpCD::c_str(m);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,153 @@
|
||||
/* Generated SBE (Simple Binary Encoding) message codec */
|
||||
#ifndef _ILINKBINARY_CUSTORDHANDLINST_H_
|
||||
#define _ILINKBINARY_CUSTORDHANDLINST_H_
|
||||
|
||||
#if defined(SBE_HAVE_CMATH)
|
||||
/* cmath needed for std::numeric_limits<double>::quiet_NaN() */
|
||||
# include <cmath>
|
||||
# define SBE_FLOAT_NAN std::numeric_limits<float>::quiet_NaN()
|
||||
# define SBE_DOUBLE_NAN std::numeric_limits<double>::quiet_NaN()
|
||||
#else
|
||||
/* math.h needed for NAN */
|
||||
# include <math.h>
|
||||
# define SBE_FLOAT_NAN NAN
|
||||
# define SBE_DOUBLE_NAN NAN
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define SBE_CONSTEXPR constexpr
|
||||
# define SBE_NOEXCEPT noexcept
|
||||
#else
|
||||
# define SBE_CONSTEXPR
|
||||
# define SBE_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201402L
|
||||
# define SBE_CONSTEXPR_14 constexpr
|
||||
#else
|
||||
# define SBE_CONSTEXPR_14
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
# include <string_view>
|
||||
# define SBE_NODISCARD [[nodiscard]]
|
||||
#else
|
||||
# define SBE_NODISCARD
|
||||
#endif
|
||||
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
# define __STDC_LIMIT_MACROS 1
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) _byteswap_ushort(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) _byteswap_ulong(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) _byteswap_uint64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) (v)
|
||||
#else
|
||||
# error "Byte Ordering of platform not determined. Set __BYTE_ORDER__ manually before including this file."
|
||||
#endif
|
||||
|
||||
#if defined(SBE_NO_BOUNDS_CHECK)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (false)
|
||||
#elif defined(_MSC_VER)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (exp)
|
||||
#else
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (__builtin_expect(exp,c))
|
||||
#endif
|
||||
|
||||
#define SBE_NULLVALUE_INT8 (std::numeric_limits<std::int8_t>::min)()
|
||||
#define SBE_NULLVALUE_INT16 (std::numeric_limits<std::int16_t>::min)()
|
||||
#define SBE_NULLVALUE_INT32 (std::numeric_limits<std::int32_t>::min)()
|
||||
#define SBE_NULLVALUE_INT64 (std::numeric_limits<std::int64_t>::min)()
|
||||
#define SBE_NULLVALUE_UINT8 (std::numeric_limits<std::uint8_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT16 (std::numeric_limits<std::uint16_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT32 (std::numeric_limits<std::uint32_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT64 (std::numeric_limits<std::uint64_t>::max)()
|
||||
|
||||
|
||||
namespace iLinkBinary {
|
||||
|
||||
class CustOrdHandlInst
|
||||
{
|
||||
public:
|
||||
enum Value
|
||||
{
|
||||
FCMprovidedscreen = (char)67,
|
||||
Otherprovidedscreen = (char)68,
|
||||
FCMAPIorFIX = (char)71,
|
||||
AlgoEngine = (char)72,
|
||||
DeskElectronic = (char)87,
|
||||
ClientElectronic = (char)89,
|
||||
NULL_VALUE = (char)0
|
||||
};
|
||||
|
||||
static CustOrdHandlInst::Value get(const char value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 67: return FCMprovidedscreen;
|
||||
case 68: return Otherprovidedscreen;
|
||||
case 71: return FCMAPIorFIX;
|
||||
case 72: return AlgoEngine;
|
||||
case 87: return DeskElectronic;
|
||||
case 89: return ClientElectronic;
|
||||
case 0: return NULL_VALUE;
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum CustOrdHandlInst [E103]");
|
||||
}
|
||||
|
||||
static const char* c_str(const CustOrdHandlInst::Value value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case FCMprovidedscreen: return "FCMprovidedscreen";
|
||||
case Otherprovidedscreen: return "Otherprovidedscreen";
|
||||
case FCMAPIorFIX: return "FCMAPIorFIX";
|
||||
case AlgoEngine: return "AlgoEngine";
|
||||
case DeskElectronic: return "DeskElectronic";
|
||||
case ClientElectronic: return "ClientElectronic";
|
||||
case NULL_VALUE: return "NULL_VALUE";
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum CustOrdHandlInst [E103]:");
|
||||
}
|
||||
|
||||
template<typename CharT, typename Traits>
|
||||
friend std::basic_ostream<CharT, Traits>& operator << (
|
||||
std::basic_ostream<CharT, Traits>& os, CustOrdHandlInst::Value m)
|
||||
{
|
||||
return os << CustOrdHandlInst::c_str(m);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,147 @@
|
||||
/* Generated SBE (Simple Binary Encoding) message codec */
|
||||
#ifndef _ILINKBINARY_CUSTORDERCAPACITY_H_
|
||||
#define _ILINKBINARY_CUSTORDERCAPACITY_H_
|
||||
|
||||
#if defined(SBE_HAVE_CMATH)
|
||||
/* cmath needed for std::numeric_limits<double>::quiet_NaN() */
|
||||
# include <cmath>
|
||||
# define SBE_FLOAT_NAN std::numeric_limits<float>::quiet_NaN()
|
||||
# define SBE_DOUBLE_NAN std::numeric_limits<double>::quiet_NaN()
|
||||
#else
|
||||
/* math.h needed for NAN */
|
||||
# include <math.h>
|
||||
# define SBE_FLOAT_NAN NAN
|
||||
# define SBE_DOUBLE_NAN NAN
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define SBE_CONSTEXPR constexpr
|
||||
# define SBE_NOEXCEPT noexcept
|
||||
#else
|
||||
# define SBE_CONSTEXPR
|
||||
# define SBE_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201402L
|
||||
# define SBE_CONSTEXPR_14 constexpr
|
||||
#else
|
||||
# define SBE_CONSTEXPR_14
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
# include <string_view>
|
||||
# define SBE_NODISCARD [[nodiscard]]
|
||||
#else
|
||||
# define SBE_NODISCARD
|
||||
#endif
|
||||
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
# define __STDC_LIMIT_MACROS 1
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) _byteswap_ushort(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) _byteswap_ulong(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) _byteswap_uint64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) (v)
|
||||
#else
|
||||
# error "Byte Ordering of platform not determined. Set __BYTE_ORDER__ manually before including this file."
|
||||
#endif
|
||||
|
||||
#if defined(SBE_NO_BOUNDS_CHECK)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (false)
|
||||
#elif defined(_MSC_VER)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (exp)
|
||||
#else
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (__builtin_expect(exp,c))
|
||||
#endif
|
||||
|
||||
#define SBE_NULLVALUE_INT8 (std::numeric_limits<std::int8_t>::min)()
|
||||
#define SBE_NULLVALUE_INT16 (std::numeric_limits<std::int16_t>::min)()
|
||||
#define SBE_NULLVALUE_INT32 (std::numeric_limits<std::int32_t>::min)()
|
||||
#define SBE_NULLVALUE_INT64 (std::numeric_limits<std::int64_t>::min)()
|
||||
#define SBE_NULLVALUE_UINT8 (std::numeric_limits<std::uint8_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT16 (std::numeric_limits<std::uint16_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT32 (std::numeric_limits<std::uint32_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT64 (std::numeric_limits<std::uint64_t>::max)()
|
||||
|
||||
|
||||
namespace iLinkBinary {
|
||||
|
||||
class CustOrderCapacity
|
||||
{
|
||||
public:
|
||||
enum Value
|
||||
{
|
||||
Membertradingfortheirownaccount = (std::uint8_t)1,
|
||||
Clearingfirmtradingforitsproprietaryaccount = (std::uint8_t)2,
|
||||
Membertradingforanothermember = (std::uint8_t)3,
|
||||
Allother = (std::uint8_t)4,
|
||||
NULL_VALUE = (std::uint8_t)255
|
||||
};
|
||||
|
||||
static CustOrderCapacity::Value get(const std::uint8_t value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 1: return Membertradingfortheirownaccount;
|
||||
case 2: return Clearingfirmtradingforitsproprietaryaccount;
|
||||
case 3: return Membertradingforanothermember;
|
||||
case 4: return Allother;
|
||||
case 255: return NULL_VALUE;
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum CustOrderCapacity [E103]");
|
||||
}
|
||||
|
||||
static const char* c_str(const CustOrderCapacity::Value value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case Membertradingfortheirownaccount: return "Membertradingfortheirownaccount";
|
||||
case Clearingfirmtradingforitsproprietaryaccount: return "Clearingfirmtradingforitsproprietaryaccount";
|
||||
case Membertradingforanothermember: return "Membertradingforanothermember";
|
||||
case Allother: return "Allother";
|
||||
case NULL_VALUE: return "NULL_VALUE";
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum CustOrderCapacity [E103]:");
|
||||
}
|
||||
|
||||
template<typename CharT, typename Traits>
|
||||
friend std::basic_ostream<CharT, Traits>& operator << (
|
||||
std::basic_ostream<CharT, Traits>& os, CustOrderCapacity::Value m)
|
||||
{
|
||||
return os << CustOrderCapacity::c_str(m);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,348 @@
|
||||
/* Generated SBE (Simple Binary Encoding) message codec */
|
||||
#ifndef _ILINKBINARY_DATA_H_
|
||||
#define _ILINKBINARY_DATA_H_
|
||||
|
||||
#if defined(SBE_HAVE_CMATH)
|
||||
/* cmath needed for std::numeric_limits<double>::quiet_NaN() */
|
||||
# include <cmath>
|
||||
# define SBE_FLOAT_NAN std::numeric_limits<float>::quiet_NaN()
|
||||
# define SBE_DOUBLE_NAN std::numeric_limits<double>::quiet_NaN()
|
||||
#else
|
||||
/* math.h needed for NAN */
|
||||
# include <math.h>
|
||||
# define SBE_FLOAT_NAN NAN
|
||||
# define SBE_DOUBLE_NAN NAN
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define SBE_CONSTEXPR constexpr
|
||||
# define SBE_NOEXCEPT noexcept
|
||||
#else
|
||||
# define SBE_CONSTEXPR
|
||||
# define SBE_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201402L
|
||||
# define SBE_CONSTEXPR_14 constexpr
|
||||
#else
|
||||
# define SBE_CONSTEXPR_14
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
# include <string_view>
|
||||
# define SBE_NODISCARD [[nodiscard]]
|
||||
#else
|
||||
# define SBE_NODISCARD
|
||||
#endif
|
||||
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
# define __STDC_LIMIT_MACROS 1
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) _byteswap_ushort(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) _byteswap_ulong(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) _byteswap_uint64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) (v)
|
||||
#else
|
||||
# error "Byte Ordering of platform not determined. Set __BYTE_ORDER__ manually before including this file."
|
||||
#endif
|
||||
|
||||
#if defined(SBE_NO_BOUNDS_CHECK)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (false)
|
||||
#elif defined(_MSC_VER)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (exp)
|
||||
#else
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (__builtin_expect(exp,c))
|
||||
#endif
|
||||
|
||||
#define SBE_NULLVALUE_INT8 (std::numeric_limits<std::int8_t>::min)()
|
||||
#define SBE_NULLVALUE_INT16 (std::numeric_limits<std::int16_t>::min)()
|
||||
#define SBE_NULLVALUE_INT32 (std::numeric_limits<std::int32_t>::min)()
|
||||
#define SBE_NULLVALUE_INT64 (std::numeric_limits<std::int64_t>::min)()
|
||||
#define SBE_NULLVALUE_UINT8 (std::numeric_limits<std::uint8_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT16 (std::numeric_limits<std::uint16_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT32 (std::numeric_limits<std::uint32_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT64 (std::numeric_limits<std::uint64_t>::max)()
|
||||
|
||||
|
||||
namespace iLinkBinary {
|
||||
|
||||
class DATA
|
||||
{
|
||||
private:
|
||||
char *m_buffer = nullptr;
|
||||
std::uint64_t m_bufferLength = 0;
|
||||
std::uint64_t m_offset = 0;
|
||||
std::uint64_t m_actingVersion = 0;
|
||||
|
||||
public:
|
||||
enum MetaAttribute
|
||||
{
|
||||
EPOCH, TIME_UNIT, SEMANTIC_TYPE, PRESENCE
|
||||
};
|
||||
|
||||
union sbe_float_as_uint_u
|
||||
{
|
||||
float fp_value;
|
||||
std::uint32_t uint_value;
|
||||
};
|
||||
|
||||
union sbe_double_as_uint_u
|
||||
{
|
||||
double fp_value;
|
||||
std::uint64_t uint_value;
|
||||
};
|
||||
|
||||
DATA() = default;
|
||||
|
||||
DATA(
|
||||
char *buffer,
|
||||
const std::uint64_t offset,
|
||||
const std::uint64_t bufferLength,
|
||||
const std::uint64_t actingVersion) :
|
||||
m_buffer(buffer),
|
||||
m_bufferLength(bufferLength),
|
||||
m_offset(offset),
|
||||
m_actingVersion(actingVersion)
|
||||
{
|
||||
if (SBE_BOUNDS_CHECK_EXPECT(((m_offset + -1) > m_bufferLength), false))
|
||||
{
|
||||
throw std::runtime_error("buffer too short for flyweight [E107]");
|
||||
}
|
||||
}
|
||||
|
||||
DATA(
|
||||
char *buffer,
|
||||
const std::uint64_t bufferLength,
|
||||
const std::uint64_t actingVersion) :
|
||||
DATA(buffer, 0, bufferLength, actingVersion)
|
||||
{
|
||||
}
|
||||
|
||||
DATA(
|
||||
char *buffer,
|
||||
const std::uint64_t bufferLength) :
|
||||
DATA(buffer, 0, bufferLength, sbeSchemaVersion())
|
||||
{
|
||||
}
|
||||
|
||||
DATA &wrap(
|
||||
char *buffer,
|
||||
const std::uint64_t offset,
|
||||
const std::uint64_t actingVersion,
|
||||
const std::uint64_t bufferLength)
|
||||
{
|
||||
return *this = DATA(buffer, offset, bufferLength, actingVersion);
|
||||
}
|
||||
|
||||
SBE_NODISCARD static SBE_CONSTEXPR std::uint64_t encodedLength() SBE_NOEXCEPT
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
SBE_NODISCARD std::uint64_t offset() const SBE_NOEXCEPT
|
||||
{
|
||||
return m_offset;
|
||||
}
|
||||
|
||||
SBE_NODISCARD const char * buffer() const SBE_NOEXCEPT
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
SBE_NODISCARD char * buffer() SBE_NOEXCEPT
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
SBE_NODISCARD std::uint64_t bufferLength() const SBE_NOEXCEPT
|
||||
{
|
||||
return m_bufferLength;
|
||||
}
|
||||
|
||||
SBE_NODISCARD std::uint64_t actingVersion() const SBE_NOEXCEPT
|
||||
{
|
||||
return m_actingVersion;
|
||||
}
|
||||
|
||||
SBE_NODISCARD static SBE_CONSTEXPR std::uint16_t sbeSchemaId() SBE_NOEXCEPT
|
||||
{
|
||||
return (std::uint16_t)8;
|
||||
}
|
||||
|
||||
SBE_NODISCARD static SBE_CONSTEXPR std::uint16_t sbeSchemaVersion() SBE_NOEXCEPT
|
||||
{
|
||||
return (std::uint16_t)5;
|
||||
}
|
||||
|
||||
SBE_NODISCARD static const char * lengthMetaAttribute(const MetaAttribute metaAttribute) SBE_NOEXCEPT
|
||||
{
|
||||
switch (metaAttribute)
|
||||
{
|
||||
case MetaAttribute::PRESENCE: return "required";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::uint16_t lengthId() SBE_NOEXCEPT
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
SBE_NODISCARD static SBE_CONSTEXPR std::uint64_t lengthSinceVersion() SBE_NOEXCEPT
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SBE_NODISCARD bool lengthInActingVersion() SBE_NOEXCEPT
|
||||
{
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wtautological-compare"
|
||||
#endif
|
||||
return m_actingVersion >= lengthSinceVersion();
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
SBE_NODISCARD static SBE_CONSTEXPR std::size_t lengthEncodingOffset() SBE_NOEXCEPT
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::uint16_t lengthNullValue() SBE_NOEXCEPT
|
||||
{
|
||||
return SBE_NULLVALUE_UINT16;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::uint16_t lengthMinValue() SBE_NOEXCEPT
|
||||
{
|
||||
return (std::uint16_t)0;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::uint16_t lengthMaxValue() SBE_NOEXCEPT
|
||||
{
|
||||
return (std::uint16_t)65534;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::size_t lengthEncodingLength() SBE_NOEXCEPT
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
SBE_NODISCARD std::uint16_t length() const SBE_NOEXCEPT
|
||||
{
|
||||
std::uint16_t val;
|
||||
std::memcpy(&val, m_buffer + m_offset + 0, sizeof(std::uint16_t));
|
||||
return SBE_LITTLE_ENDIAN_ENCODE_16(val);
|
||||
}
|
||||
|
||||
DATA &length(const std::uint16_t value) SBE_NOEXCEPT
|
||||
{
|
||||
std::uint16_t val = SBE_LITTLE_ENDIAN_ENCODE_16(value);
|
||||
std::memcpy(m_buffer + m_offset + 0, &val, sizeof(std::uint16_t));
|
||||
return *this;
|
||||
}
|
||||
|
||||
SBE_NODISCARD static const char * varDataMetaAttribute(const MetaAttribute metaAttribute) SBE_NOEXCEPT
|
||||
{
|
||||
switch (metaAttribute)
|
||||
{
|
||||
case MetaAttribute::PRESENCE: return "required";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::uint16_t varDataId() SBE_NOEXCEPT
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
SBE_NODISCARD static SBE_CONSTEXPR std::uint64_t varDataSinceVersion() SBE_NOEXCEPT
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SBE_NODISCARD bool varDataInActingVersion() SBE_NOEXCEPT
|
||||
{
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wtautological-compare"
|
||||
#endif
|
||||
return m_actingVersion >= varDataSinceVersion();
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
SBE_NODISCARD static SBE_CONSTEXPR std::size_t varDataEncodingOffset() SBE_NOEXCEPT
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR char varDataNullValue() SBE_NOEXCEPT
|
||||
{
|
||||
return (char)0;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR char varDataMinValue() SBE_NOEXCEPT
|
||||
{
|
||||
return (char)32;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR char varDataMaxValue() SBE_NOEXCEPT
|
||||
{
|
||||
return (char)126;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::size_t varDataEncodingLength() SBE_NOEXCEPT
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
template<typename CharT, typename Traits>
|
||||
friend std::basic_ostream<CharT, Traits>& operator << (
|
||||
std::basic_ostream<CharT, Traits>& builder, DATA writer)
|
||||
{
|
||||
builder << '{';
|
||||
builder << R"("length": )";
|
||||
builder << +writer.length();
|
||||
|
||||
builder << '}';
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,159 @@
|
||||
/* Generated SBE (Simple Binary Encoding) message codec */
|
||||
#ifndef _ILINKBINARY_DKREASON_H_
|
||||
#define _ILINKBINARY_DKREASON_H_
|
||||
|
||||
#if defined(SBE_HAVE_CMATH)
|
||||
/* cmath needed for std::numeric_limits<double>::quiet_NaN() */
|
||||
# include <cmath>
|
||||
# define SBE_FLOAT_NAN std::numeric_limits<float>::quiet_NaN()
|
||||
# define SBE_DOUBLE_NAN std::numeric_limits<double>::quiet_NaN()
|
||||
#else
|
||||
/* math.h needed for NAN */
|
||||
# include <math.h>
|
||||
# define SBE_FLOAT_NAN NAN
|
||||
# define SBE_DOUBLE_NAN NAN
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define SBE_CONSTEXPR constexpr
|
||||
# define SBE_NOEXCEPT noexcept
|
||||
#else
|
||||
# define SBE_CONSTEXPR
|
||||
# define SBE_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201402L
|
||||
# define SBE_CONSTEXPR_14 constexpr
|
||||
#else
|
||||
# define SBE_CONSTEXPR_14
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
# include <string_view>
|
||||
# define SBE_NODISCARD [[nodiscard]]
|
||||
#else
|
||||
# define SBE_NODISCARD
|
||||
#endif
|
||||
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
# define __STDC_LIMIT_MACROS 1
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) _byteswap_ushort(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) _byteswap_ulong(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) _byteswap_uint64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) (v)
|
||||
#else
|
||||
# error "Byte Ordering of platform not determined. Set __BYTE_ORDER__ manually before including this file."
|
||||
#endif
|
||||
|
||||
#if defined(SBE_NO_BOUNDS_CHECK)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (false)
|
||||
#elif defined(_MSC_VER)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (exp)
|
||||
#else
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (__builtin_expect(exp,c))
|
||||
#endif
|
||||
|
||||
#define SBE_NULLVALUE_INT8 (std::numeric_limits<std::int8_t>::min)()
|
||||
#define SBE_NULLVALUE_INT16 (std::numeric_limits<std::int16_t>::min)()
|
||||
#define SBE_NULLVALUE_INT32 (std::numeric_limits<std::int32_t>::min)()
|
||||
#define SBE_NULLVALUE_INT64 (std::numeric_limits<std::int64_t>::min)()
|
||||
#define SBE_NULLVALUE_UINT8 (std::numeric_limits<std::uint8_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT16 (std::numeric_limits<std::uint16_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT32 (std::numeric_limits<std::uint32_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT64 (std::numeric_limits<std::uint64_t>::max)()
|
||||
|
||||
|
||||
namespace iLinkBinary {
|
||||
|
||||
class DKReason
|
||||
{
|
||||
public:
|
||||
enum Value
|
||||
{
|
||||
UnknownSecurity = (char)65,
|
||||
WrongSide = (char)66,
|
||||
QuantityExceedsOrder = (char)67,
|
||||
NoMatchingOrder = (char)68,
|
||||
PriceExceedsLimit = (char)69,
|
||||
CalculationDifference = (char)70,
|
||||
NoMatchingExecutionReport = (char)71,
|
||||
Other = (char)90,
|
||||
NULL_VALUE = (char)0
|
||||
};
|
||||
|
||||
static DKReason::Value get(const char value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 65: return UnknownSecurity;
|
||||
case 66: return WrongSide;
|
||||
case 67: return QuantityExceedsOrder;
|
||||
case 68: return NoMatchingOrder;
|
||||
case 69: return PriceExceedsLimit;
|
||||
case 70: return CalculationDifference;
|
||||
case 71: return NoMatchingExecutionReport;
|
||||
case 90: return Other;
|
||||
case 0: return NULL_VALUE;
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum DKReason [E103]");
|
||||
}
|
||||
|
||||
static const char* c_str(const DKReason::Value value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case UnknownSecurity: return "UnknownSecurity";
|
||||
case WrongSide: return "WrongSide";
|
||||
case QuantityExceedsOrder: return "QuantityExceedsOrder";
|
||||
case NoMatchingOrder: return "NoMatchingOrder";
|
||||
case PriceExceedsLimit: return "PriceExceedsLimit";
|
||||
case CalculationDifference: return "CalculationDifference";
|
||||
case NoMatchingExecutionReport: return "NoMatchingExecutionReport";
|
||||
case Other: return "Other";
|
||||
case NULL_VALUE: return "NULL_VALUE";
|
||||
}
|
||||
|
||||
throw std::runtime_error("unknown value for enum DKReason [E103]:");
|
||||
}
|
||||
|
||||
template<typename CharT, typename Traits>
|
||||
friend std::basic_ostream<CharT, Traits>& operator << (
|
||||
std::basic_ostream<CharT, Traits>& os, DKReason::Value m)
|
||||
{
|
||||
return os << DKReason::c_str(m);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,366 @@
|
||||
/* Generated SBE (Simple Binary Encoding) message codec */
|
||||
#ifndef _ILINKBINARY_DECIMAL32NULL_H_
|
||||
#define _ILINKBINARY_DECIMAL32NULL_H_
|
||||
|
||||
#if defined(SBE_HAVE_CMATH)
|
||||
/* cmath needed for std::numeric_limits<double>::quiet_NaN() */
|
||||
# include <cmath>
|
||||
# define SBE_FLOAT_NAN std::numeric_limits<float>::quiet_NaN()
|
||||
# define SBE_DOUBLE_NAN std::numeric_limits<double>::quiet_NaN()
|
||||
#else
|
||||
/* math.h needed for NAN */
|
||||
# include <math.h>
|
||||
# define SBE_FLOAT_NAN NAN
|
||||
# define SBE_DOUBLE_NAN NAN
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define SBE_CONSTEXPR constexpr
|
||||
# define SBE_NOEXCEPT noexcept
|
||||
#else
|
||||
# define SBE_CONSTEXPR
|
||||
# define SBE_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201402L
|
||||
# define SBE_CONSTEXPR_14 constexpr
|
||||
#else
|
||||
# define SBE_CONSTEXPR_14
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
# include <string_view>
|
||||
# define SBE_NODISCARD [[nodiscard]]
|
||||
#else
|
||||
# define SBE_NODISCARD
|
||||
#endif
|
||||
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
# define __STDC_LIMIT_MACROS 1
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) _byteswap_ushort(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) _byteswap_ulong(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) _byteswap_uint64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
|
||||
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_16(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_32(v) (v)
|
||||
# define SBE_BIG_ENDIAN_ENCODE_64(v) (v)
|
||||
#else
|
||||
# error "Byte Ordering of platform not determined. Set __BYTE_ORDER__ manually before including this file."
|
||||
#endif
|
||||
|
||||
#if defined(SBE_NO_BOUNDS_CHECK)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (false)
|
||||
#elif defined(_MSC_VER)
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (exp)
|
||||
#else
|
||||
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (__builtin_expect(exp,c))
|
||||
#endif
|
||||
|
||||
#define SBE_NULLVALUE_INT8 (std::numeric_limits<std::int8_t>::min)()
|
||||
#define SBE_NULLVALUE_INT16 (std::numeric_limits<std::int16_t>::min)()
|
||||
#define SBE_NULLVALUE_INT32 (std::numeric_limits<std::int32_t>::min)()
|
||||
#define SBE_NULLVALUE_INT64 (std::numeric_limits<std::int64_t>::min)()
|
||||
#define SBE_NULLVALUE_UINT8 (std::numeric_limits<std::uint8_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT16 (std::numeric_limits<std::uint16_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT32 (std::numeric_limits<std::uint32_t>::max)()
|
||||
#define SBE_NULLVALUE_UINT64 (std::numeric_limits<std::uint64_t>::max)()
|
||||
|
||||
|
||||
namespace iLinkBinary {
|
||||
|
||||
class Decimal32NULL
|
||||
{
|
||||
private:
|
||||
char *m_buffer = nullptr;
|
||||
std::uint64_t m_bufferLength = 0;
|
||||
std::uint64_t m_offset = 0;
|
||||
std::uint64_t m_actingVersion = 0;
|
||||
|
||||
public:
|
||||
enum MetaAttribute
|
||||
{
|
||||
EPOCH, TIME_UNIT, SEMANTIC_TYPE, PRESENCE
|
||||
};
|
||||
|
||||
union sbe_float_as_uint_u
|
||||
{
|
||||
float fp_value;
|
||||
std::uint32_t uint_value;
|
||||
};
|
||||
|
||||
union sbe_double_as_uint_u
|
||||
{
|
||||
double fp_value;
|
||||
std::uint64_t uint_value;
|
||||
};
|
||||
|
||||
Decimal32NULL() = default;
|
||||
|
||||
Decimal32NULL(
|
||||
char *buffer,
|
||||
const std::uint64_t offset,
|
||||
const std::uint64_t bufferLength,
|
||||
const std::uint64_t actingVersion) :
|
||||
m_buffer(buffer),
|
||||
m_bufferLength(bufferLength),
|
||||
m_offset(offset),
|
||||
m_actingVersion(actingVersion)
|
||||
{
|
||||
if (SBE_BOUNDS_CHECK_EXPECT(((m_offset + 5) > m_bufferLength), false))
|
||||
{
|
||||
throw std::runtime_error("buffer too short for flyweight [E107]");
|
||||
}
|
||||
}
|
||||
|
||||
Decimal32NULL(
|
||||
char *buffer,
|
||||
const std::uint64_t bufferLength,
|
||||
const std::uint64_t actingVersion) :
|
||||
Decimal32NULL(buffer, 0, bufferLength, actingVersion)
|
||||
{
|
||||
}
|
||||
|
||||
Decimal32NULL(
|
||||
char *buffer,
|
||||
const std::uint64_t bufferLength) :
|
||||
Decimal32NULL(buffer, 0, bufferLength, sbeSchemaVersion())
|
||||
{
|
||||
}
|
||||
|
||||
Decimal32NULL &wrap(
|
||||
char *buffer,
|
||||
const std::uint64_t offset,
|
||||
const std::uint64_t actingVersion,
|
||||
const std::uint64_t bufferLength)
|
||||
{
|
||||
return *this = Decimal32NULL(buffer, offset, bufferLength, actingVersion);
|
||||
}
|
||||
|
||||
SBE_NODISCARD static SBE_CONSTEXPR std::uint64_t encodedLength() SBE_NOEXCEPT
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
SBE_NODISCARD std::uint64_t offset() const SBE_NOEXCEPT
|
||||
{
|
||||
return m_offset;
|
||||
}
|
||||
|
||||
SBE_NODISCARD const char * buffer() const SBE_NOEXCEPT
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
SBE_NODISCARD char * buffer() SBE_NOEXCEPT
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
SBE_NODISCARD std::uint64_t bufferLength() const SBE_NOEXCEPT
|
||||
{
|
||||
return m_bufferLength;
|
||||
}
|
||||
|
||||
SBE_NODISCARD std::uint64_t actingVersion() const SBE_NOEXCEPT
|
||||
{
|
||||
return m_actingVersion;
|
||||
}
|
||||
|
||||
SBE_NODISCARD static SBE_CONSTEXPR std::uint16_t sbeSchemaId() SBE_NOEXCEPT
|
||||
{
|
||||
return (std::uint16_t)8;
|
||||
}
|
||||
|
||||
SBE_NODISCARD static SBE_CONSTEXPR std::uint16_t sbeSchemaVersion() SBE_NOEXCEPT
|
||||
{
|
||||
return (std::uint16_t)5;
|
||||
}
|
||||
|
||||
SBE_NODISCARD static const char * mantissaMetaAttribute(const MetaAttribute metaAttribute) SBE_NOEXCEPT
|
||||
{
|
||||
switch (metaAttribute)
|
||||
{
|
||||
case MetaAttribute::PRESENCE: return "optional";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::uint16_t mantissaId() SBE_NOEXCEPT
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
SBE_NODISCARD static SBE_CONSTEXPR std::uint64_t mantissaSinceVersion() SBE_NOEXCEPT
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SBE_NODISCARD bool mantissaInActingVersion() SBE_NOEXCEPT
|
||||
{
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wtautological-compare"
|
||||
#endif
|
||||
return m_actingVersion >= mantissaSinceVersion();
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
SBE_NODISCARD static SBE_CONSTEXPR std::size_t mantissaEncodingOffset() SBE_NOEXCEPT
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::int32_t mantissaNullValue() SBE_NOEXCEPT
|
||||
{
|
||||
return 2147483647;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::int32_t mantissaMinValue() SBE_NOEXCEPT
|
||||
{
|
||||
return -2147483647;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::int32_t mantissaMaxValue() SBE_NOEXCEPT
|
||||
{
|
||||
return 2147483647;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::size_t mantissaEncodingLength() SBE_NOEXCEPT
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
SBE_NODISCARD std::int32_t mantissa() const SBE_NOEXCEPT
|
||||
{
|
||||
std::int32_t val;
|
||||
std::memcpy(&val, m_buffer + m_offset + 0, sizeof(std::int32_t));
|
||||
return SBE_LITTLE_ENDIAN_ENCODE_32(val);
|
||||
}
|
||||
|
||||
Decimal32NULL &mantissa(const std::int32_t value) SBE_NOEXCEPT
|
||||
{
|
||||
std::int32_t val = SBE_LITTLE_ENDIAN_ENCODE_32(value);
|
||||
std::memcpy(m_buffer + m_offset + 0, &val, sizeof(std::int32_t));
|
||||
return *this;
|
||||
}
|
||||
|
||||
SBE_NODISCARD static const char * exponentMetaAttribute(const MetaAttribute metaAttribute) SBE_NOEXCEPT
|
||||
{
|
||||
switch (metaAttribute)
|
||||
{
|
||||
case MetaAttribute::PRESENCE: return "optional";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::uint16_t exponentId() SBE_NOEXCEPT
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
SBE_NODISCARD static SBE_CONSTEXPR std::uint64_t exponentSinceVersion() SBE_NOEXCEPT
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SBE_NODISCARD bool exponentInActingVersion() SBE_NOEXCEPT
|
||||
{
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wtautological-compare"
|
||||
#endif
|
||||
return m_actingVersion >= exponentSinceVersion();
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
SBE_NODISCARD static SBE_CONSTEXPR std::size_t exponentEncodingOffset() SBE_NOEXCEPT
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::int8_t exponentNullValue() SBE_NOEXCEPT
|
||||
{
|
||||
return (std::int8_t)127;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::int8_t exponentMinValue() SBE_NOEXCEPT
|
||||
{
|
||||
return (std::int8_t)-127;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::int8_t exponentMaxValue() SBE_NOEXCEPT
|
||||
{
|
||||
return (std::int8_t)127;
|
||||
}
|
||||
|
||||
static SBE_CONSTEXPR std::size_t exponentEncodingLength() SBE_NOEXCEPT
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
SBE_NODISCARD std::int8_t exponent() const SBE_NOEXCEPT
|
||||
{
|
||||
std::int8_t val;
|
||||
std::memcpy(&val, m_buffer + m_offset + 4, sizeof(std::int8_t));
|
||||
return (val);
|
||||
}
|
||||
|
||||
Decimal32NULL &exponent(const std::int8_t value) SBE_NOEXCEPT
|
||||
{
|
||||
std::int8_t val = (value);
|
||||
std::memcpy(m_buffer + m_offset + 4, &val, sizeof(std::int8_t));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename CharT, typename Traits>
|
||||
friend std::basic_ostream<CharT, Traits>& operator << (
|
||||
std::basic_ostream<CharT, Traits>& builder, Decimal32NULL writer)
|
||||
{
|
||||
builder << '{';
|
||||
builder << R"("mantissa": )";
|
||||
builder << +writer.mantissa();
|
||||
|
||||
builder << ", ";
|
||||
builder << R"("exponent": )";
|
||||
builder << +writer.exponent();
|
||||
|
||||
builder << '}';
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Loaded 100 of 313 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user