From b9fd0e2e28d09eede3b664c22e69b434fd1e89c4 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 23 Sep 2019 12:31:03 -0400 Subject: [PATCH 01/15] in SIM you can trade an expired security and if we leave it out of this map we will later attempt to add this fill twice while testing SOD because the test asks to delete the fills db --- src/lib/orderman/actors/FillStore.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/orderman/actors/FillStore.cpp b/src/lib/orderman/actors/FillStore.cpp index c5a492fa7..7d0eb01dd 100644 --- a/src/lib/orderman/actors/FillStore.cpp +++ b/src/lib/orderman/actors/FillStore.cpp @@ -59,8 +59,13 @@ void FillStore::init() { auto sec = me->oracle.get_security(SecurityKey(fill.security_key())); if (sec) { if (config::get().enabled() && - securities::is_expired(*sec)) + securities::is_expired(*sec)) { + //KD -- in SIM you can trade an expired security and if we leave it out of this map + //we will later attempt to add this fill twice while testing SOD because the test asks to delete the fills db + auto fk = kvp.first; + me->known_fills.insert(fk); continue; + } else { auto fk = kvp.first; me->known_fills.insert(fk); From 9bf7666c30d86bbd56165673f53295b14ac1b565 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 23 Sep 2019 11:56:57 -0500 Subject: [PATCH 02/15] downgrade pnl rounding error Log assert to warning --- .../spark/Modules/Trading/PNL/View/PNLRowCollectionView.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/spark/Modules/Trading/PNL/View/PNLRowCollectionView.cs b/src/client/spark/Modules/Trading/PNL/View/PNLRowCollectionView.cs index 083556ab7..d3dec5aa3 100644 --- a/src/client/spark/Modules/Trading/PNL/View/PNLRowCollectionView.cs +++ b/src/client/spark/Modules/Trading/PNL/View/PNLRowCollectionView.cs @@ -373,7 +373,9 @@ namespace bts.shell.pnl { var less_last = data - last_data; var plus_new = less_last + new_data; data += new_data - last_data; - Log.assert(plus_new == data); + if (plus_new != data) { + Log.Ui.warn($"Detected PNL arithmetic rounding error in the group sum for '{string.Join(" ", GroupNamePath)}' (this bug is under investigation)."); + } last_data = new_data; } void on_is_selected_changed(bool is_selected) { From 5968ac10d2b81160ffa17dd1313984a31cbb72c2 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 23 Sep 2019 13:48:26 -0400 Subject: [PATCH 03/15] The fix is right, but the code was a bit clumsy. --- src/lib/orderman/actors/FillStore.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/lib/orderman/actors/FillStore.cpp b/src/lib/orderman/actors/FillStore.cpp index 7d0eb01dd..ef5ebfb60 100644 --- a/src/lib/orderman/actors/FillStore.cpp +++ b/src/lib/orderman/actors/FillStore.cpp @@ -58,17 +58,10 @@ void FillStore::init() { fill.set_fill_kind(Fill::FILL_KIND_SOD); auto sec = me->oracle.get_security(SecurityKey(fill.security_key())); if (sec) { - if (config::get().enabled() && - securities::is_expired(*sec)) { - //KD -- in SIM you can trade an expired security and if we leave it out of this map - //we will later attempt to add this fill twice while testing SOD because the test asks to delete the fills db - auto fk = kvp.first; - me->known_fills.insert(fk); - continue; - } - else { - auto fk = kvp.first; - me->known_fills.insert(fk); + auto fk = kvp.first; + me->known_fills.insert(fk); + if (!config::get().enabled() || + !securities::is_expired(*sec)) { stored_batch.emplace_back(fill, *sec); } } else From 0cc581793266abf1068dc6cb70cb3a356ac8dac2 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 23 Sep 2019 22:38:24 -0500 Subject: [PATCH 04/15] expand synthetic leg columns to fit name --- .../spark/Modules/Spreader/ExecutionStrategyEditor.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml.cs b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml.cs index 83d205f2d..ef8137e25 100644 --- a/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml.cs +++ b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml.cs @@ -227,7 +227,7 @@ namespace mbts.ui.spark { } DataGridColumn _column_factory(LegSpreaderParamsTuple l) { - var col = new DataGridColumnInternal(l.leg.Security, ParameterCellTemplateConverter, ParameterCellEditingTemplateConverter) { Width = 75, }; + var col = new DataGridColumnInternal(l.leg.Security, ParameterCellTemplateConverter, ParameterCellEditingTemplateConverter); col.HeaderTemplate = (DataTemplate)FindResource(IsNew ? RemovableColumnHeaderTemplateKey : NonRemovableColumnHeaderTemplateKey); DataGridEx.SetRightBorder(col, new DataGridExVerticalLine(false, true, Colors.DarkGray, 1)); return col; From 016ddf9b6950c83dd2a35a7787229f627376e895 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 24 Sep 2019 08:21:56 -0500 Subject: [PATCH 05/15] fixing pay less definition --- doc/user/content/bts_spark/Spreader/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/user/content/bts_spark/Spreader/_index.md b/doc/user/content/bts_spark/Spreader/_index.md index a69a3731e..79a1c6168 100644 --- a/doc/user/content/bts_spark/Spreader/_index.md +++ b/doc/user/content/bts_spark/Spreader/_index.md @@ -154,7 +154,7 @@ insert_anchor_links = "right" - Pay Less - If enabled by checking the checkbox, the spreader will attempt to pay less when the quantity at the level of the calculated - hedge price is more than the threshold defined.  The hedge order is + hedge price is less than the threshold defined.  The hedge order is paid less by the “Payless Ticks” as defined per leg. - Pay Up - If enabled by checking the checkbox, the spreader will pay up when the quantity at the level of the calculated hedge price is From d033275694eed0a88515672c28db2616951b5866 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 23 Sep 2019 12:26:07 -0500 Subject: [PATCH 06/15] remove unused member OrdersModel.on_account_pnl --- src/client/spark/Orders/OrdersModel.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/client/spark/Orders/OrdersModel.cs b/src/client/spark/Orders/OrdersModel.cs index 278324bcb..920acfca3 100644 --- a/src/client/spark/Orders/OrdersModel.cs +++ b/src/client/spark/Orders/OrdersModel.cs @@ -75,7 +75,6 @@ namespace mbts.spark { .TableCheckedAutoCorrect(EqualityComparer<(SecurityImmutable? sec, PNLUnitImmutable data)>.Default) .Where(t => t.has_changes()) .Cache(); - on_account_pnl = _position_service.subscribei_pnl_account_data().Naggle(interval, scheduler).Table().Cache(); var working_orders = on_orders.Filter(tup => tup.order.is_active()); this.working_orders = on_orders.Scan( @@ -265,7 +264,6 @@ namespace mbts.spark { public IObservable> working_orders { get; } public IObservable> on_pnl { get; } public IObservable> security_account_pnl { get; } - public IObservable> on_account_pnl { get; } public IObservable> on_positions { get; } public IObservable> studio_algos_with_meta { get; } public IObservable> on_manual_fills_securities { get; } From a3730eb20354df481fe56d18f0c6a10aa1686876 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 23 Sep 2019 18:08:38 -0500 Subject: [PATCH 07/15] Update.naggle merge maintains changes (could get into state where changes became adds/removes) --- src/client/spark_api/api/Update.cs | 99 ++++++++++++++++-------------- 1 file changed, 54 insertions(+), 45 deletions(-) diff --git a/src/client/spark_api/api/Update.cs b/src/client/spark_api/api/Update.cs index 80ed9b1cf..004e81dec 100644 --- a/src/client/spark_api/api/Update.cs +++ b/src/client/spark_api/api/Update.cs @@ -8,7 +8,6 @@ using System.Linq; using System.Reactive.Concurrency; using System.Reactive.Disposables; using System.Reactive.Linq; -using System.Reactive.Subjects; using System.Text; namespace bts.api.core { @@ -94,38 +93,38 @@ namespace bts.api.core { new Update(new T[0], new T[0], new Change[0], new T[0], key_extractor); public Update merge(Update next) { - var comp = new RowEqualityComparer(_key); - var added = this.added as HashSet ?? new HashSet(this.added, comp); + var added = this.added as KeyedValueSet ?? new KeyedValueSet(this.added, _key); var changes = this.changed as ChangeDict ?? new ChangeDict(this.changes, _key); - var removed = this.removed as HashSet ?? new HashSet(this.removed, comp); + var removed = this.removed as KeyedValueSet ?? new KeyedValueSet(this.removed, _key); // Add - added.UnionWith(next.added); + foreach (var v in next.added) { + var k = _key(v); + if (removed.TryPop(k, out var oldval)) { + changes.AddOrMerge(new Change(oldval, v)); + } else { + added[k] = v; + } + } // Change foreach (var c in next.changes) { - if (added.Contains(c.Old)) { - added.Remove(c.Old); - added.Add(c.New); - } - else { + var k = _key(c.Old); + if (!added.TryReplace(k, c.New)) changes.AddOrMerge(c); - } } // Remove foreach (var r in next.removed) { - if (!added.Remove(r)) { - removed.Add(r); - } - changes.Remove(_key(r)); + var k = _key(r); + if (!added.Remove(k)) + removed[k] = changes.TryRemove(k, out var ch) ? ch.Old : r; } return new Update( next.all, added, changes, removed, - _key - ); + _key); } public IEnumerable all { get; } @@ -148,6 +147,39 @@ namespace bts.api.core { #endif } + class KeyedValueSet : IEnumerable { + readonly Dictionary _cache = new Dictionary(); + + public KeyedValueSet(IEnumerable value, Func key) { + foreach (var v in value) + _cache[key(v)] = v; + } + + public TValue this[TKey key] { + set => _cache[key] = value; + } + + public bool Remove(TKey key) => + _cache.Remove(key); + + public bool TryPop(TKey key, out TValue value) => + _cache.TryGetValue(key, out value) && _cache.Remove(key); + + public bool TryReplace(TKey key, TValue value) { + if (_cache.ContainsKey(key)) { + _cache[key] = value; + return true; + } + return false; + } + + public IEnumerator GetEnumerator() => + _cache.Values.GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => + GetEnumerator(); + } + class ChangeDict : IEnumerable> { Dictionary> _changes; Func, TKey> _key; @@ -167,9 +199,11 @@ namespace bts.api.core { return null; } - public void Remove(TKey key) { + public bool Remove(TKey key) => _changes.Remove(key); - } + + public bool TryRemove(TKey key, out Change result) => + _changes.TryGetValue(key, out result) && _changes.Remove(key); #region IEnumerable public IEnumerator> GetEnumerator() { @@ -181,31 +215,6 @@ namespace bts.api.core { #endregion } - struct RowEqualityComparer : IEqualityComparer, IEqualityComparer> - where TKey : IEquatable { - readonly Func _key; - - public RowEqualityComparer(Func key) { - _key = key; - } - - public bool Equals(T x, T y) { - return _key(x).Equals(_key(y)); - } - - public bool Equals(Change x, Change y) { - return Equals(x.New, y.New); - } - - public int GetHashCode(T obj) { - return _key(obj).GetHashCode(); - } - - public int GetHashCode(Change c) { - return GetHashCode(c.New); - } - } - public class TableUpdate where TKey : IEquatable { // warning: this does not have a key_extractor public static readonly TableUpdate empty = new TableUpdate(ImmutableDictionary.Empty, Array.Empty(), Array.Empty>(), Array.Empty(), null); @@ -922,4 +931,4 @@ namespace bts.api.core { $"T is '{typeof(T)}', TKey is '{typeof(TKey)}'"; } } -} \ No newline at end of file +} From 2a36c05d7597d7ddc121224ee505131f15b3b935 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 23 Sep 2019 18:12:09 -0500 Subject: [PATCH 08/15] fix PNLRowData Equals impl (was not comparing market prices) --- src/client/spark/Modules/Trading/PNL/Data/PNLData.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client/spark/Modules/Trading/PNL/Data/PNLData.cs b/src/client/spark/Modules/Trading/PNL/Data/PNLData.cs index 9c941fc55..b6a83ae6a 100644 --- a/src/client/spark/Modules/Trading/PNL/Data/PNLData.cs +++ b/src/client/spark/Modules/Trading/PNL/Data/PNLData.cs @@ -501,6 +501,12 @@ namespace bts.shell.pnl { account_name == other.account_name && sod == other.sod && day == other.day && + bid_price.Equals(other.bid_price) && + ask_price.Equals(other.ask_price) && + last_price.Equals(other.last_price) && + mid_price.Equals(other.mid_price) && + settlement_price.Equals(other.settlement_price) && + calc_type.Equals(other.calc_type) && raw_day == other.raw_day && working.summary == other.working.summary; From ffb571d1cfbf0318d8fce5626df6a3ce7623b7b5 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 23 Sep 2019 18:14:34 -0500 Subject: [PATCH 09/15] fix pnl rounding issues (use 9 decimal places) --- .../spark/Modules/Trading/PNL/VM/PNLRowVM.cs | 20 +++++++++---------- .../spark/view/Controls/DIYGrid/DoubleUtil.cs | 10 ++++++---- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/client/spark/Modules/Trading/PNL/VM/PNLRowVM.cs b/src/client/spark/Modules/Trading/PNL/VM/PNLRowVM.cs index f32cee536..52cfa3ff0 100644 --- a/src/client/spark/Modules/Trading/PNL/VM/PNLRowVM.cs +++ b/src/client/spark/Modules/Trading/PNL/VM/PNLRowVM.cs @@ -97,22 +97,22 @@ namespace bts.shell.pnl { if (security.HasValue && security.Value.ContractCase != Security.ContractOneofCase.Future) { day_long = day_short = sod_long = sod_short = 0; } else { - day_long = (decimal)DoubleUtil.nan_to_zero(data.day.long_pos); - day_short = (decimal)DoubleUtil.nan_to_zero(data.day.short_pos); - sod_long = (decimal)DoubleUtil.nan_to_zero(data.sod.long_pos); - sod_short = (decimal)DoubleUtil.nan_to_zero(data.sod.short_pos); + day_long = DoubleUtil.round_to_decimal(data.day.long_pos); + day_short = DoubleUtil.round_to_decimal(data.day.short_pos); + sod_long = DoubleUtil.round_to_decimal(data.sod.long_pos); + sod_short = DoubleUtil.round_to_decimal(data.sod.short_pos); } var nd = new PNLNormalizedData( - (decimal)DoubleUtil.nan_to_zero(day_pnl.value), + DoubleUtil.round_to_decimal(day_pnl.value), day_long, day_short, - (decimal)DoubleUtil.nan_to_zero(data.raw_day.long_pos), - (decimal)DoubleUtil.nan_to_zero(data.raw_day.short_pos), - (decimal)DoubleUtil.nan_to_zero(sod_pnl.value), + DoubleUtil.round_to_decimal(data.raw_day.long_pos), + DoubleUtil.round_to_decimal(data.raw_day.short_pos), + DoubleUtil.round_to_decimal(sod_pnl.value), sod_long, sod_short, - (decimal)DoubleUtil.nan_to_zero(data.working_long_pos), - (decimal)DoubleUtil.nan_to_zero(data.working_short_pos)); + DoubleUtil.round_to_decimal(data.working_long_pos), + DoubleUtil.round_to_decimal(data.working_short_pos)); if (_normalized_data != nd) { _normalized_data = nd; updated?.Invoke(nd); diff --git a/src/client/spark/view/Controls/DIYGrid/DoubleUtil.cs b/src/client/spark/view/Controls/DIYGrid/DoubleUtil.cs index 2ac6f579b..aa2019135 100644 --- a/src/client/spark/view/Controls/DIYGrid/DoubleUtil.cs +++ b/src/client/spark/view/Controls/DIYGrid/DoubleUtil.cs @@ -1,10 +1,9 @@ using System; using System.Linq; -namespace mbts.ui.controls -{ - internal class DoubleUtil - { +namespace mbts.ui.controls { + static class DoubleUtil { + public const int API_DECIMAL_PRECISION = 9; /* smallest such that 1.0+DBL_EPSILON != 1.0 */ private const double EPSILON = 2.2204460492503131e-016; private const double BIG_EPSILON = EPSILON * 10; @@ -36,6 +35,9 @@ namespace mbts.ui.controls (double.IsNaN(right) ? double.NaN : -right) : (double.IsNaN(right) ? left : left - right); + public static decimal round_to_decimal(double value, int decimals = API_DECIMAL_PRECISION) => + double.IsNaN(value) ? 0 : (decimal)Math.Round(value, decimals, MidpointRounding.AwayFromZero); + internal static bool AreClose(double v1, double v2) { if (v1 == v2) return true; double delta = Math.Abs(v1 - v2); From ddc50e1fbacd0b57ea3adeba52caf20c6b711f93 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 23 Sep 2019 21:57:54 -0500 Subject: [PATCH 10/15] pnl initial calc type was not being applied to data --- src/client/spark/Modules/Trading/PNL/VM/PNLVM.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark/Modules/Trading/PNL/VM/PNLVM.cs b/src/client/spark/Modules/Trading/PNL/VM/PNLVM.cs index b04c03ead..19b6ff8da 100644 --- a/src/client/spark/Modules/Trading/PNL/VM/PNLVM.cs +++ b/src/client/spark/Modules/Trading/PNL/VM/PNLVM.cs @@ -103,7 +103,7 @@ namespace bts.shell.pnl { load_from(settings); _dispose = Disposable.Create( pnl_source.Operate( - _calculation_type.observe_current(), + _calculation_type.observe_current(true), (data, calc) => data.with(calc_type: calc) ).FilterWithRaw(filter_src, PNLRowData.key_fn, null) .OnDispatcher() From 055f0015e78b69e10e4919b0758d9b2e03bd5653 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 24 Sep 2019 17:28:06 -0500 Subject: [PATCH 11/15] Update.naggle pr edit: 'TryPop' is an innappropriate name (just use 'Remove') --- src/client/spark_api/api/Update.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/spark_api/api/Update.cs b/src/client/spark_api/api/Update.cs index 004e81dec..8522a6430 100644 --- a/src/client/spark_api/api/Update.cs +++ b/src/client/spark_api/api/Update.cs @@ -100,7 +100,7 @@ namespace bts.api.core { // Add foreach (var v in next.added) { var k = _key(v); - if (removed.TryPop(k, out var oldval)) { + if (removed.Remove(k, out var oldval)) { changes.AddOrMerge(new Change(oldval, v)); } else { added[k] = v; @@ -110,7 +110,7 @@ namespace bts.api.core { // Change foreach (var c in next.changes) { var k = _key(c.Old); - if (!added.TryReplace(k, c.New)) + if (!added.Replace(k, c.New)) changes.AddOrMerge(c); } @@ -162,10 +162,10 @@ namespace bts.api.core { public bool Remove(TKey key) => _cache.Remove(key); - public bool TryPop(TKey key, out TValue value) => + public bool Remove(TKey key, out TValue value) => _cache.TryGetValue(key, out value) && _cache.Remove(key); - public bool TryReplace(TKey key, TValue value) { + public bool Replace(TKey key, TValue value) { if (_cache.ContainsKey(key)) { _cache[key] = value; return true; From a878a55ac15eb592c0f6634251b95a46e58d038b Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Wed, 25 Sep 2019 10:00:20 -0400 Subject: [PATCH 12/15] moved externals --- docker/linux | 2 +- externals | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/linux b/docker/linux index e13bb5d8d..b09d4c035 160000 --- a/docker/linux +++ b/docker/linux @@ -1 +1 @@ -Subproject commit e13bb5d8df14171a9a5abfdb8b6b4ecbc519032a +Subproject commit b09d4c035b4c0d0e600c7639cd9cb5edaee98d2e diff --git a/externals b/externals index b5ca26428..6b8c745fb 160000 --- a/externals +++ b/externals @@ -1 +1 @@ -Subproject commit b5ca264286e2a7033b7ce6ad0000254dea03dc8a +Subproject commit 6b8c745fb2725ad92fc0292b7836e0838e7e1679 From da42e957541b325df5a5f64655f1137189841e4b Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Wed, 25 Sep 2019 10:59:58 -0400 Subject: [PATCH 13/15] fixed externals and docker --- docker/linux | 2 +- externals | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/linux b/docker/linux index b09d4c035..c40e6eba4 160000 --- a/docker/linux +++ b/docker/linux @@ -1 +1 @@ -Subproject commit b09d4c035b4c0d0e600c7639cd9cb5edaee98d2e +Subproject commit c40e6eba4ba72480a68cf784b6ffbcacc3fbf4af diff --git a/externals b/externals index 6b8c745fb..6d8f64ca5 160000 --- a/externals +++ b/externals @@ -1 +1 @@ -Subproject commit 6b8c745fb2725ad92fc0292b7836e0838e7e1679 +Subproject commit 6d8f64ca5cee3acbf9addb51428f25d54b9f906a From dfd83487240abe0d632468a8c7135318b6f4827a Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 30 Sep 2019 11:03:03 -0400 Subject: [PATCH 14/15] add temporary config to ignore nan day pnl to stop the loss limit from keeping traders out of market --- src/lib/config/protos/toggles.proto | 4 ++++ .../sparkd/position/PositionServicePNLHelper.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/lib/config/protos/toggles.proto b/src/lib/config/protos/toggles.proto index f1733290f..5c3c87ee0 100644 --- a/src/lib/config/protos/toggles.proto +++ b/src/lib/config/protos/toggles.proto @@ -58,3 +58,7 @@ message EnsureOnScreenWithWorkAreaRect { // Should verify that the code works with every monitor arrangement before enabling by default. optional bool enabled = 1 [default = false]; } + +message IgnoreNansInDayPnL { + optional bool enabled = 1 [default = true]; +} \ No newline at end of file diff --git a/src/server/sparkd/position/PositionServicePNLHelper.cpp b/src/server/sparkd/position/PositionServicePNLHelper.cpp index 403c9b52b..a547f6643 100644 --- a/src/server/sparkd/position/PositionServicePNLHelper.cpp +++ b/src/server/sparkd/position/PositionServicePNLHelper.cpp @@ -4,6 +4,7 @@ #include "lib/os/os.h" #include "PositionServicePNLHelper.h" #include "lib/config/protos/cme_reference_data.pb.h" +#include "lib/config/protos/toggles.pb.h" #include "lib/config/config.h" #include "lib/utils/PBUtils.h" @@ -217,6 +218,15 @@ double PositionServicePNLHelper::_compute_day_pnl ( (md - u.pos().day_long_avg_price()), short_pnl = std::abs(u.pos().day_short_pos()) * u.cash_value() * (u.pos().day_short_avg_price() - md); + + if(config::get().enabled()) + { + if(bts::os::is_nan(long_pnl)) + long_pnl = 0.0; + if(bts::os::is_nan(short_pnl)) + short_pnl = 0.0; + } + pnl = long_pnl + short_pnl; break; } From 50e61604bab8d50ecaeb7505d9b51855911ae101 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 30 Sep 2019 11:53:44 -0400 Subject: [PATCH 15/15] move default keycode exp to 12/31/2019 to fix unit tests --- src/lib/config/defaults/keycode.conf | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib/config/defaults/keycode.conf b/src/lib/config/defaults/keycode.conf index 49832fb86..5b41d0705 100644 --- a/src/lib/config/defaults/keycode.conf +++ b/src/lib/config/defaults/keycode.conf @@ -1,9 +1,13 @@ + + #nusers: 1 -#allow concurrent : false -#expires: 2019-Sep-30 00:00:00 637053984000000000 -#generation_time: 2019-Jun-18 18:25:44.333280 5248650809870720704 +#allow concurrent : true +#expires: 2019-Dec-31 00:00:00 637133472000000000 +#generation_time: 2019-Sep-30 15:52:10.434845 5248740573731736354 EncryptedKeyCode { value { - keycode: "pgtv/OmievnpmNlgxTYuN801Hbetgu7ZGkHnlGWtK+DBrKSEgKxr5lGvCW1ld/jsztkWhKHDh0iediMDjrPm4+C5qmXlt4JJlAFvKolMN8HVC59m82fECvakcqKq28WSEjf6/DuPJNP1ZwxjcmKouxx1LZ15VlNkECtNrC9pkCnifazbfQZGV3kD08zMEyw/RPmOaVLFFeav8lwI5UpcjPYBIK1rJowXdGSvm1CJViwG5Z2JbdHR39QbKjVx112d5VbVtBq9nO3i0FEKvobjN/Gzcz/5x4TgQtEShKsbmgEN+MBVL3AItQlcFzZvE/05JLmfACUFmk5Eu0a3DlLs3A==" + keycode: "fVZlub92ulkXME+uZSyO9+WmyAXYKD735Qzxxfdj4G+SqEDTuwfNxOZVPS3TCFQqWPDmgjKTbbvfqIrGe3icxkVObUcUoS7lBXRXFrSvzOfs9eTz9RqHRvquDidnOzKxmSXsxV2bMb21UqBCJFeTzb4Q6Agp8EtjXJRc57UMVVygvdXg528S3ocBIq1V4W5NYraFn5WpqrTuBhpYbnsZAHi77s/EEwUT+6la3J2OHPtbiQnB6JFb0zsExMuzE4gwp79ojuQ5pnV2DXBZFNwxYvFyBUU/ac6oU89saZ/ay1DbOjz76TNqnNFewZvzdXZl3y6+X1eblX2streH2pn7gg==" } -} \ No newline at end of file +} + +