merge from master
This commit is contained in:
commit
2f5b06b628
24 files changed
+313
-63
No files matched your search
@@ -1,5 +1,28 @@
|
||||
# Release Notes
|
||||
|
||||
## 1.4.1
|
||||
|
||||
### Tabs
|
||||
- Tabs now shrink and expand to make better use of horizontal space
|
||||
### Bug Fixes
|
||||
- Fixed a bug that could cause excessive CPU usage when a connection broke
|
||||
- Fixed a layout bug in hedging/requoting performance reports
|
||||
- Fixed account name mismatching bug for old fills
|
||||
### Absolute Position limits
|
||||
- Positions can now be netted or absolute for purposes of limit enforcing
|
||||
|
||||
## 1.4.0
|
||||
|
||||
### Speed Enhancements
|
||||
- Improved requoting and hedging performance
|
||||
- Improved order book form performance
|
||||
### Server Side SDK
|
||||
- Added beta version of the server side SDK
|
||||
### Front End
|
||||
- Added status bars to all UI grids
|
||||
### Reporting
|
||||
- Added reporting of hedging and requoting performance
|
||||
|
||||
## 1.3.8
|
||||
|
||||
### Speed Enhancements
|
||||
@@ -139,4 +162,4 @@
|
||||
- PnL report now has PnL columns calculated based on your start of day, current day, and total position
|
||||
- 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
|
||||
- PnL report will now remember any customizations you make to filtering and/or sorting criteria
|
||||
@@ -0,0 +1,50 @@
|
||||
using bts;
|
||||
using mbts.spark.filters;
|
||||
using mbts.ui.controls.adorners;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
|
||||
namespace mbts.ui.controls {
|
||||
public class UniformTabGrid : UniformGrid {
|
||||
public UniformTabGrid () {
|
||||
this.IsItemsHost = true;
|
||||
this.Rows = 1;
|
||||
}
|
||||
|
||||
protected override Size MeasureOverride(Size constraint) {
|
||||
var child_tabs = this.Children.OfType<TabItem>();
|
||||
var child_tabs_max_width = child_tabs.Sum(t => t.MaxWidth);
|
||||
// I noticed when debugging that this can sometimes be infinty,
|
||||
// especially when a TabItem has not been set with a MaxWidth.
|
||||
if (!double.IsInfinity(child_tabs_max_width)) {
|
||||
// if the window width is greater than the total tab width, then
|
||||
// there is more than enough space for all the tabs. If this
|
||||
// is set to the default of Stretch and the window has only 1
|
||||
// tab or few tabs, the tab appears in the middle, which is not good.
|
||||
// i.e. we want tabs to added left to right, so align left
|
||||
//
|
||||
// When the window is less than the total tab width, then align
|
||||
// can be set to stretch b/c the UniformGrid will take care of
|
||||
// sizing each tab accordingly.
|
||||
this.HorizontalAlignment = (constraint.Width > child_tabs_max_width)
|
||||
? HorizontalAlignment.Left
|
||||
: HorizontalAlignment.Stretch;
|
||||
|
||||
// this bit here is necessary because when the window is expanded
|
||||
// beyond the maxwidth of all the tabs, we switch to Left and the
|
||||
// headers snap to some smaller than MaxWidth size, which is not
|
||||
// the behavior we want
|
||||
foreach (var child in child_tabs) {
|
||||
child.Width = this.HorizontalAlignment == HorizontalAlignment.Left
|
||||
? child.MaxWidth
|
||||
: double.NaN;
|
||||
}
|
||||
}
|
||||
|
||||
return base.MeasureOverride(constraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
|
||||
xmlns:ui="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
mc:Ignorable="d" AllowDrop="True"
|
||||
Style="{StaticResource BTSFloatingWindow}"
|
||||
d:DesignHeight="300" d:DesignWidth="300"
|
||||
@@ -25,18 +26,25 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<WrapPanel x:Name="HeaderPanel" Orientation="Horizontal" Margin="0,0,100,0"
|
||||
<!-- This stack panel serves as the area between the last tab and the widget control on right side of title bar (below).
|
||||
It allows the region in between (if such a region exists) to be grabbed to move the window.
|
||||
-->
|
||||
<StackPanel Grid.Row="0" Margin="0,0,100,0" Background="Transparent" ui:WindowStyle.IsNonClientArea="True">
|
||||
<c:UniformTabGrid x:Name="HeaderPanel"
|
||||
Grid.Row="0"
|
||||
Panel.ZIndex="1"
|
||||
IsItemsHost="True"
|
||||
KeyboardNavigation.TabIndex="1"
|
||||
Background="Transparent" ui:WindowStyle.IsNonClientArea="True">
|
||||
</WrapPanel>
|
||||
Background="Transparent"
|
||||
ui:WindowStyle.IsNonClientArea="True"
|
||||
>
|
||||
</c:UniformTabGrid>
|
||||
</StackPanel>
|
||||
<Border Grid.Row="1" BorderThickness="0"
|
||||
Padding="{Binding Path=Padding, RelativeSource={RelativeSource AncestorType=Window}}" ui:WindowStyle.IsNonClientArea="False" >
|
||||
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" />
|
||||
</Border>
|
||||
<Border Grid.Row="0" Width="100" HorizontalAlignment="Right" VerticalAlignment="Stretch" Panel.ZIndex="2" Background="Transparent" ui:WindowStyle.IsNonClientArea="True">
|
||||
<!-- Window widget control area-->
|
||||
<Border Grid.Row="0" MinWidth="100" HorizontalAlignment="Right" Panel.ZIndex="2" Background="Transparent" ui:WindowStyle.IsNonClientArea="True">
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Panel.ZIndex="2" Background="Transparent" Margin="5">
|
||||
<Button Style="{StaticResource RoundMinimizeButton}" HorizontalAlignment="Right" Command="{x:Static SystemCommands.MinimizeWindowCommand}" />
|
||||
<Button Style="{StaticResource RoundMaximizeButton}" HorizontalAlignment="Right" Command="{x:Static SystemCommands.MaximizeWindowCommand}" />
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
</TabItem.RenderTransform>
|
||||
<TabItem.Template>
|
||||
<ControlTemplate TargetType="{x:Type TabItem}">
|
||||
<Border x:Name="bd" BorderBrush="Black" BorderThickness="0,0,0.5,0" Background="#d6d6d6" Width="{DynamicResource TabWidth}" Height="{DynamicResource TabHeight}" MinWidth="40" Margin="0" SnapsToDevicePixels="True" DockPanel.Dock="Left">
|
||||
<Border x:Name="bd" BorderBrush="Black" BorderThickness="0,0,0.5,0" Background="#d6d6d6" Height="{DynamicResource TabHeight}" MinWidth="40" Margin="0" SnapsToDevicePixels="True" DockPanel.Dock="Left">
|
||||
<Border.ToolTip>
|
||||
<TextBlock Text="{Binding Title}" />
|
||||
</Border.ToolTip>
|
||||
@@ -90,6 +90,7 @@
|
||||
</TabItem.Template>
|
||||
<TabItem.Style>
|
||||
<Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}">
|
||||
<Setter Property="MaxWidth" Value="{DynamicResource TabWidth}" />
|
||||
<Setter Property="HeaderTemplate" Value="{StaticResource _template}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding EditMode}" Value="True">
|
||||
|
||||
@@ -37,13 +37,17 @@ $( document ).ready(function (){
|
||||
$("#output").html(summary_info);
|
||||
|
||||
let whole_result = result.requotes.concat(result.hedges);
|
||||
let unique_sessions = whole_result.filter(function(value, index, self){
|
||||
return self.find(function(elm){
|
||||
return elm.session_name === value.session_name;
|
||||
});
|
||||
let unique_sessions = [];
|
||||
whole_result.filter(function(value) {
|
||||
if (unique_sessions.find(function(elm) {
|
||||
return elm.session_name === value.session_name;
|
||||
}) === undefined) {
|
||||
unique_sessions.push(value);
|
||||
}
|
||||
});
|
||||
|
||||
$(unique_sessions).each(function (index, sess_val){
|
||||
console.log(sess_val.session_name);
|
||||
let r = result.requotes.find(function(elm){
|
||||
return elm.session_name === sess_val.session_name;
|
||||
});
|
||||
|
||||
@@ -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/services/AdminService.proto;api/services/ApiUnitTestService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.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/services/UserService.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/Executor.conf;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/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.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/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.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/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/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.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;metrics/system_metrics.cpp;orderman/actors/AsyncFactory.cpp;orderman/actors/ExecutionGateway.cpp;orderman/actors/FillStore.cpp;orderman/actors/MDSupplementarySource.cpp;orderman/actors/OrderStore.cpp;orderman/actors/SODPosition.cpp;orderman/actors/SecuritySrc.cpp;orderman/actors/ServiceBridge.cpp;orderman/actors/order_manager/OrderBuilder.cpp;orderman/actors/order_manager/OrderManager.cpp;orderman/actors/order_manager/OrderServicesData.cpp;orderman/events/CancelRejectEvent.cpp;orderman/events/NewExecutionReportEvent.cpp;orderman/limiter/LimitStore.cpp;orderman/limiter/Limiter.cpp;orderman/limiter/ProductLimitNode.cpp;orderman/limiter/ProductLimitTree.cpp;orderman/limiter/SecurityLimitNode.cpp;orderman/limiter/SecurityLimitTree.cpp;orderman/limiter/tests/limit_tests.cpp;orderman/order_factory/DynamiLine 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/services/AdminService.proto;api/services/ApiUnitTestService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.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/services/UserService.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/Executor.conf;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/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.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/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.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/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_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/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/thread_manager.cpp)
|
||||
@@ -141,6 +141,12 @@ message BTSAccount{
|
||||
AccountSecurityClipLimits security_clip_limits = 90;
|
||||
AccountExchangeConnections connections = 100;
|
||||
ExchangeAccountData exchange_account_data = 110;
|
||||
// extra parameters for risk enforcement
|
||||
RiskLimitEnforcement risk_limit_enforcement=120;
|
||||
}
|
||||
|
||||
message RiskLimitEnforcement{
|
||||
bool product_limit_in_net_terms = 10;
|
||||
}
|
||||
|
||||
message AccountProductPositionLimitUnit{
|
||||
|
||||
@@ -38,7 +38,7 @@ sqlite3_ptr open_db() {
|
||||
bts_assert(dbptr);
|
||||
auto db = dbptr.get();
|
||||
sqlite3_busy_timeout(db, 9999);
|
||||
sqlite::exec_nofail(db, "PRAGMA journal_mode=OFF");
|
||||
sqlite::exec_nofail(db, "PRAGMA journal_mode=WAL");
|
||||
sqlite::exec_nofail(db, "PRAGMA syncronous=0");
|
||||
|
||||
sqlite::exec_nofail(db,
|
||||
|
||||
@@ -98,7 +98,7 @@ SettlementRecorder::SettlementRecorder(Platform platform) :
|
||||
bts_assert_msg(_self->db, db_path.c_str());
|
||||
sqlite3* db = _self->db.get();
|
||||
sqlite3_busy_timeout(db, 9999);
|
||||
sqlite::exec_nofail(db, "PRAGMA journal_mode=OFF");
|
||||
sqlite::exec_nofail(db, "PRAGMA journal_mode=WAL");
|
||||
sqlite::exec_nofail(db, "PRAGMA syncronous=0");
|
||||
// key=(security_key+date)
|
||||
sqlite::exec_nofail(db,
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <unordered_map>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
@@ -123,10 +124,11 @@ void OrderManager::on_fill_recovery(
|
||||
update.events->size());
|
||||
me->state = State::WAIT_ORDERS;
|
||||
|
||||
for (auto const &ev : *(update.events))
|
||||
me->services_data.limiter.add(*ev.security, ev.fill.account(),
|
||||
ev.fill.side(),
|
||||
for (auto const &ev : *(update.events)) {
|
||||
auto trimmed_account_name = boost::algorithm::trim_copy(ev.fill.account());
|
||||
me->services_data.limiter.add(*ev.security, trimmed_account_name,ev.fill.side(),
|
||||
Quantity(ev.fill.last_shares()));
|
||||
}
|
||||
|
||||
me->stored_order_sub = subscribe<StoredOrderEvent>(
|
||||
[this](auto const &orders) { this->on_order_recovery(orders); });
|
||||
|
||||
@@ -9,10 +9,13 @@ namespace orderman{
|
||||
|
||||
class LimiterUtils{
|
||||
public:
|
||||
static void can_send_new_order(api::Side side, Quantity quantity, bool is_security_level,
|
||||
int long_pos_limit, int short_pos_limit,
|
||||
int net_pos,
|
||||
Limiter::LimiterQueryResult& out_res){
|
||||
static void can_send_new_order_net(api::Side side,
|
||||
Quantity quantity,
|
||||
bool is_security_level,
|
||||
int long_pos_limit,
|
||||
int short_pos_limit,
|
||||
int net_pos,
|
||||
Limiter::LimiterQueryResult& out_res){
|
||||
out_res.ok = true;
|
||||
bts_assert(long_pos_limit >= 0);
|
||||
bts_assert(short_pos_limit <= 0);
|
||||
@@ -35,13 +38,15 @@ public:
|
||||
else
|
||||
out_res.error_msg = fmt::format("Product Short Position (Max {} Current {})", short_pos_limit, net_pos);
|
||||
}
|
||||
}
|
||||
static void can_update_order (api::Side side,
|
||||
Quantity from, Quantity to,
|
||||
bool is_security_level,
|
||||
int long_pos_limit, int short_pos_limit,
|
||||
int net_pos,
|
||||
Limiter::LimiterQueryResult& out_res){
|
||||
}
|
||||
static void can_update_order_net (api::Side side,
|
||||
Quantity from,
|
||||
Quantity to,
|
||||
bool is_security_level,
|
||||
int long_pos_limit,
|
||||
int short_pos_limit,
|
||||
int net_pos,
|
||||
Limiter::LimiterQueryResult& out_res){
|
||||
out_res.ok = true;
|
||||
if (to.value() > from.value()){
|
||||
int net_pos_new = 0;
|
||||
@@ -65,6 +70,60 @@ public:
|
||||
out_res.error_msg = fmt::format("Product Short Position (Max {} Current {})", short_pos_limit, net_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
static void can_send_new_order_abs(api::Side side,
|
||||
Quantity quantity,
|
||||
uint32_t long_pos_limit,
|
||||
uint32_t short_pos_limit,
|
||||
uint32_t long_pos,
|
||||
uint32_t short_pos,
|
||||
Limiter::LimiterQueryResult& out_res){
|
||||
out_res.ok = true;
|
||||
if(side == api::Side::SIDE_BUY){
|
||||
if(long_pos + quantity.value() > long_pos_limit){
|
||||
out_res.error_msg = fmt::format("Long Position (Abs) "
|
||||
"(Max {} Current {})",
|
||||
long_pos_limit,long_pos);
|
||||
out_res.ok = false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(short_pos + quantity.value() > short_pos_limit){
|
||||
out_res.error_msg = fmt::format("Short Position (Abs) "
|
||||
"(Max {} Current {})",
|
||||
short_pos_limit,short_pos);
|
||||
out_res.ok = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
static void can_update_order_abs (api::Side side,
|
||||
Quantity from,
|
||||
Quantity to,
|
||||
uint32_t long_pos_limit,
|
||||
uint32_t short_pos_limit,
|
||||
uint32_t long_pos,
|
||||
uint32_t short_pos,
|
||||
Limiter::LimiterQueryResult& out_res){
|
||||
out_res.ok = true;
|
||||
if (to.value() > from.value()){
|
||||
uint32_t diff = to.value() - from.value();
|
||||
if(side == api::Side::SIDE_BUY){
|
||||
if(long_pos + diff > long_pos_limit){
|
||||
out_res.error_msg = fmt::format("Long Position (Abs) "
|
||||
"(Max {} Current {})",
|
||||
long_pos_limit,long_pos);
|
||||
out_res.ok = false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(short_pos + diff > short_pos_limit){
|
||||
out_res.error_msg = fmt::format("Short Position (Abs) "
|
||||
"(Max {} Current {})",
|
||||
short_pos_limit,short_pos);
|
||||
out_res.ok = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static api::Side invert_side(api::Side side){
|
||||
return side == api::SIDE_BUY ? api::SIDE_SELL : api::SIDE_BUY;
|
||||
|
||||
@@ -5,14 +5,17 @@ namespace orderman{
|
||||
|
||||
ProductLimitNode::ProductLimitNode(uint32_t account_id,
|
||||
uint32_t, // parent_account_id,
|
||||
const bts::api::admin::AccountProductPositionLimitUnit& limit)
|
||||
const bts::api::admin::AccountProductPositionLimitUnit& limit,
|
||||
bool enforce_net)
|
||||
:
|
||||
_account_id(account_id),
|
||||
//_parent_account_id(parent_account_id),
|
||||
_limit(limit),
|
||||
_enforce_net(enforce_net),
|
||||
_long_pos_limit (limit.long_position_limit()),
|
||||
_short_pos_limit (-1 * limit.short_position_limit()),
|
||||
_net_pos(0)
|
||||
_short_pos_limit (limit.short_position_limit()),
|
||||
_long_pos(0),
|
||||
_short_pos(0)
|
||||
{}
|
||||
}}
|
||||
|
||||
@@ -20,49 +20,92 @@ class ProductLimitNode{
|
||||
private:
|
||||
const uint32_t _account_id; // , _parent_account_id;
|
||||
const bts::api::admin::AccountProductPositionLimitUnit& _limit;
|
||||
const int _long_pos_limit, _short_pos_limit;
|
||||
int _net_pos;
|
||||
const bool _enforce_net;
|
||||
const uint32_t _long_pos_limit, _short_pos_limit;
|
||||
// this is the only state here
|
||||
uint32_t _long_pos, _short_pos;
|
||||
public:
|
||||
ProductLimitNode(uint32_t account_id,
|
||||
uint32_t parent_account_id,
|
||||
const bts::api::admin::AccountProductPositionLimitUnit& limit);
|
||||
const bts::api::admin::AccountProductPositionLimitUnit& limit,
|
||||
bool enforce_net);
|
||||
// accessors
|
||||
////////////
|
||||
uint32_t account_id() const {return _account_id;}
|
||||
int net_pos() const {return _net_pos;}
|
||||
int net_pos() const {
|
||||
return static_cast<int>(_long_pos)-static_cast<int>(_short_pos);
|
||||
}
|
||||
// position updates
|
||||
///////////////////
|
||||
void copy_positions_from(const ProductLimitNode& source){
|
||||
_net_pos = source.net_pos();
|
||||
_long_pos=source._long_pos;
|
||||
_short_pos=source._short_pos;
|
||||
}
|
||||
void add_position(api::Side side, uint32_t qty){
|
||||
if (side==api::Side::SIDE_BUY)
|
||||
_net_pos += qty;
|
||||
_long_pos += qty;
|
||||
else
|
||||
_net_pos -= qty;
|
||||
_short_pos += qty;
|
||||
}
|
||||
void remove_position(api::Side side, uint32_t qty){
|
||||
if (side==api::Side::SIDE_BUY)
|
||||
_net_pos -= qty;
|
||||
_long_pos = _subtract_unsigned(_long_pos, qty);
|
||||
else
|
||||
_net_pos += qty;
|
||||
_short_pos = _subtract_unsigned(_short_pos, qty);
|
||||
}
|
||||
// risk limit checks
|
||||
////////////////////
|
||||
Limiter::LimiterQueryResult can_send_new_order(api::Side side, Quantity quantity) const{
|
||||
Limiter::LimiterQueryResult result;
|
||||
LimiterUtils::can_send_new_order (side, quantity, false,
|
||||
_long_pos_limit, _short_pos_limit,
|
||||
_net_pos, result);
|
||||
if (_enforce_net)
|
||||
LimiterUtils::can_send_new_order_net (side,
|
||||
quantity,
|
||||
false,
|
||||
static_cast<int>(_long_pos_limit),
|
||||
-1 * static_cast<int>(_short_pos_limit),
|
||||
net_pos(),
|
||||
result);
|
||||
else
|
||||
LimiterUtils::can_send_new_order_abs (side,
|
||||
quantity,
|
||||
_long_pos_limit,
|
||||
_short_pos_limit,
|
||||
_long_pos,
|
||||
_short_pos,
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
Limiter::LimiterQueryResult can_update_order(api::Side side, Quantity from, Quantity to) const{
|
||||
Limiter::LimiterQueryResult result;
|
||||
LimiterUtils::can_update_order (side, from, to, false,
|
||||
_long_pos_limit, _short_pos_limit,
|
||||
_net_pos, result);
|
||||
if(_enforce_net)
|
||||
LimiterUtils::can_update_order_net (side,
|
||||
from,
|
||||
to,
|
||||
false,
|
||||
static_cast<int>(_long_pos_limit),
|
||||
-1 * static_cast<int>(_short_pos_limit),
|
||||
net_pos(),
|
||||
result);
|
||||
else
|
||||
LimiterUtils::can_update_order_abs (side,
|
||||
from,
|
||||
to,
|
||||
_long_pos_limit,
|
||||
_short_pos_limit,
|
||||
_long_pos,
|
||||
_short_pos,
|
||||
result);
|
||||
return result;
|
||||
}
|
||||
uint32_t _subtract_unsigned(uint32_t n1, uint32_t n2){
|
||||
if(n1 >= n2)
|
||||
return n1-n2;
|
||||
else{
|
||||
LOG(OrderMan, Error, "ProductLimitNode._subtract_unsigned {0}-{1} ",
|
||||
n1, n2);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// test only functions
|
||||
//////////////////////
|
||||
const bts::api::admin::AccountProductPositionLimitUnit& test_only_func_limit() const {return _limit;}
|
||||
|
||||
@@ -10,8 +10,14 @@ ProductLimitTree::ProductLimitTree(const api::Product& product,
|
||||
_product (product)
|
||||
{
|
||||
for(const auto& account : admin_data.accounts()){
|
||||
bool enforce_net=true; // default is net
|
||||
if(account.has_risk_limit_enforcement())
|
||||
enforce_net=account.risk_limit_enforcement().product_limit_in_net_terms();
|
||||
const bts::api::admin::AccountProductPositionLimitUnit* limit = bts::admin::AdminServiceUtils::find_account_product_position_limit(account, _product);
|
||||
_tree.emplace_back(account.id(), bts::admin::AdminServiceUtils::has_id(account.parent_account_id()) ? account.parent_account_id() : 0, limit != nullptr ? *limit : zero_limit);
|
||||
_tree.emplace_back(account.id(),
|
||||
bts::admin::AdminServiceUtils::has_id(account.parent_account_id()) ? account.parent_account_id() : 0,
|
||||
limit != nullptr ? *limit : zero_limit,
|
||||
enforce_net);
|
||||
}
|
||||
}
|
||||
}}
|
||||
@@ -71,9 +71,9 @@ public:
|
||||
return result;
|
||||
}
|
||||
if (_apply_sec_position_limits)
|
||||
LimiterUtils::can_send_new_order (side, quantity, true,
|
||||
_long_pos_limit, _short_pos_limit,
|
||||
_net_pos, result);
|
||||
LimiterUtils::can_send_new_order_net (side, quantity, true,
|
||||
_long_pos_limit, _short_pos_limit,
|
||||
_net_pos, result);
|
||||
if (result.ok)
|
||||
result = _product_node.can_send_new_order(side, quantity);
|
||||
return result;
|
||||
@@ -86,9 +86,9 @@ public:
|
||||
return result;
|
||||
}
|
||||
if (_apply_sec_position_limits)
|
||||
LimiterUtils::can_update_order (side, from, to, true,
|
||||
_long_pos_limit, _short_pos_limit,
|
||||
_net_pos, result);
|
||||
LimiterUtils::can_update_order_net (side, from, to, true,
|
||||
_long_pos_limit, _short_pos_limit,
|
||||
_net_pos, result);
|
||||
if (result.ok)
|
||||
result = _product_node.can_update_order(side, from, to);
|
||||
return result;
|
||||
|
||||
@@ -167,7 +167,7 @@ void QBConnection::recv_msg_body()
|
||||
handle_msg(&m);
|
||||
}
|
||||
else
|
||||
recv_msg_body();
|
||||
close_connection(error.message());
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "spark/lib/orderman/actors/order_manager/OrderBuilder.h"
|
||||
#include "spark/lib/orderman/orders/DynamicOrder.h"
|
||||
#include "spark/lib/utils/PBUtils.h"
|
||||
#include "lib/config/protos/system.pb.h"
|
||||
#include "lib/config/config.h"
|
||||
|
||||
using namespace bts::api::orderman;
|
||||
using namespace bts::orderman;
|
||||
@@ -379,7 +381,9 @@ DynamicOrderDescriptor get_dynamic_iceberg_order_desc()
|
||||
extern "C" void init_spark_plugin(bts::SparkServices &serv) {
|
||||
using namespace bts;
|
||||
|
||||
serv.register_dynamic_order(get_dynamic_iceberg_order_desc(),
|
||||
[]() { return std::make_unique<bts::order_example::DynamicIcebergOrder>(); });
|
||||
LOG(Plugin,Info, "Initialized order_plugin_example.so");
|
||||
if (config::get<config::DeploymentType>().type() == "dev") {
|
||||
serv.register_dynamic_order(get_dynamic_iceberg_order_desc(),
|
||||
[]() { return std::make_unique<bts::order_example::DynamicIcebergOrder>(); });
|
||||
LOG(Plugin,Info, "Initialized order_plugin_example.so");
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ AdminServiceServer::AdminServiceServer(bts::api::ServiceContext& context)
|
||||
if (_state.ParseFromString(ser_data))
|
||||
{
|
||||
data_found = true;
|
||||
AdminServiceUtils::fill_connections_from_config(_state);
|
||||
_check_data_on_start();
|
||||
_update_and_publish(false);
|
||||
}
|
||||
}
|
||||
@@ -249,4 +249,10 @@ void AdminServiceServer::_publish_md_permissions(){
|
||||
_md_perm_publisher.add_or_update(p);
|
||||
_md_perm_publisher.flush();
|
||||
}
|
||||
void AdminServiceServer::_check_data_on_start (){
|
||||
AdminServiceUtils::fill_connections_from_config(_state);
|
||||
for(int i=0; i<_state.accounts().size(); i++)
|
||||
if(!_state.mutable_accounts(i)->has_risk_limit_enforcement())
|
||||
_state.mutable_accounts(i)->mutable_risk_limit_enforcement()->set_product_limit_in_net_terms(true);
|
||||
}
|
||||
}}
|
||||
@@ -68,12 +68,17 @@ public:
|
||||
const api::Response<bts::api::VoidMessage>& reply) override;
|
||||
|
||||
private:
|
||||
// this is mainly does 2 things :
|
||||
// 1. some data is in partially in config, this copies
|
||||
// that to here
|
||||
// 2. for new data fields, it initializes them here
|
||||
void _check_data_on_start();
|
||||
void _update_and_publish (bool is_insert);
|
||||
void _publish_md_entitlements();
|
||||
void _publish_md_permissions();
|
||||
void _add_live_order(map<string,map<string,OrdersSummaryUnit>>& agg,
|
||||
const OrderRecord& order);
|
||||
void _cancel_orders(const std::vector<string>& accounts,
|
||||
const std::vector<string>& users);
|
||||
const std::vector<string>& users);
|
||||
};
|
||||
}}
|
||||
@@ -102,6 +102,9 @@ module Accounts =
|
||||
clearingAccount = ""
|
||||
}
|
||||
}
|
||||
riskLimitEnforcement =
|
||||
{ productLimitInNetTerms = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -279,6 +279,8 @@ let update msg (model:Model) : Model * Cmd<Msg> =
|
||||
| DeleteProductLimit i ->
|
||||
let limits = erase model.scratch.productPositionLimits i
|
||||
{ model with scratch = { model.scratch with productPositionLimits = limits } }, Cmd.Empty
|
||||
| EnforceProductLimitInNetTerms value ->
|
||||
{model with scratch = {model.scratch with riskLimitEnforcement = {productLimitInNetTerms = value}}}, Cmd.none
|
||||
| SecurityLimits limits ->
|
||||
{ model with scratch = { model.scratch with securityPositionLimits = limits } }, Cmd.Empty
|
||||
| DeleteSecurityLimit i ->
|
||||
|
||||
@@ -70,6 +70,7 @@ type Msg =
|
||||
| ProductLimits of AccountProductPositionLimitUnit * AccountProductPositionLimitUnit
|
||||
| AddProductLimit of AccountProductPositionLimitUnit
|
||||
| DeleteProductLimit of int
|
||||
| EnforceProductLimitInNetTerms of bool
|
||||
|
||||
| SecurityLimits of AccountSecurityPositionLimitUnit[]
|
||||
| DeleteSecurityLimit of int
|
||||
|
||||
@@ -358,8 +358,8 @@ let productLimits model dispatch =
|
||||
TableControl.Cell (str "Exchange")
|
||||
TableControl.Cell (str "Security Type")
|
||||
TableControl.Cell (str "Symbol")
|
||||
TableControl.Cell (str "Max Net Long Position")
|
||||
TableControl.Cell (str "Max Net Short Position")
|
||||
TableControl.Cell (str "Max Long Position")
|
||||
TableControl.Cell (str "Max Short Position")
|
||||
]
|
||||
className = ""
|
||||
header = None
|
||||
@@ -524,6 +524,10 @@ let productLimits model dispatch =
|
||||
div [ ClassName "column is-size-7 has-text-grey-mid is-help-text" ]
|
||||
[str "This limits the net position for a product (i.e. accumulated position over all securities belonging to a product). This can be set for one product, or for all products within a security type by selecting \"All\" for symbol. (Note that \"All\" applies the same limits to each symbol, not the combiled position of all symbols)"]
|
||||
]
|
||||
div [][
|
||||
Fields.radioButton "Use Net Contracts" "" model.scratch.riskLimitEnforcement.productLimitInNetTerms [] (EnforceProductLimitInNetTerms >> dispatch)
|
||||
Fields.radioButton "Use Absolute Contracts" "" (not model.scratch.riskLimitEnforcement.productLimitInNetTerms) [] (not >> EnforceProductLimitInNetTerms >> dispatch)
|
||||
]
|
||||
TableControl.createDataTable (Some headerRow) rws (Button.button "Add" "" "plus-circle" Button.Enabled addRow)
|
||||
br []
|
||||
]
|
||||
@@ -539,8 +543,8 @@ let securityLimitsView model dispatch =
|
||||
TableControl.Cell (str "Security Type")
|
||||
TableControl.Cell (str "Symbol")
|
||||
TableControl.Cell (str "Security")
|
||||
TableControl.Cell (str "Max Net Long Position")
|
||||
TableControl.Cell (str "Max Net Short Position")
|
||||
TableControl.Cell (str "Max Long Position")
|
||||
TableControl.Cell (str "Max Short Position")
|
||||
]
|
||||
className = ""
|
||||
header = None
|
||||
|
||||
@@ -173,6 +173,26 @@ let checkbox (lbl:string) (description:string) (dv:bool) (attrs:IHTMLProp list)
|
||||
]
|
||||
]
|
||||
|
||||
let radioButton (lbl:string) (description:string) (dv:bool) (attrs:IHTMLProp list) (onchange:bool->unit) =
|
||||
div [ ClassName "field" ]
|
||||
[
|
||||
div [ ClassName "control" ]
|
||||
[
|
||||
label [ ] [
|
||||
input ([
|
||||
ClassName "checkbox"
|
||||
Type "radio"
|
||||
Checked dv
|
||||
OnChange (fun ev -> !!ev.target?``checked`` |> onchange)
|
||||
] @ attrs)
|
||||
str (" " + lbl)
|
||||
]
|
||||
nbsp.element
|
||||
span [ClassName "is-size-7 has-text-grey-mid"][ str description]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
let mapSelect (lbl:string) (options:Map<string,string>) (defaultText:string option) (defaultValue:string option) (onchange:'a->unit) =
|
||||
let optList:ReactElement list =
|
||||
match defaultText with
|
||||
|
||||
Reference in new issue
Block a user