fix bug arising from nesting algos

This commit is contained in:
Kevin Darby committed 2018-08-31 13:09:47 -04:00
1 parent 4e7f3ed036
commit fb8904fed4
2 files changed
+15 -26

No files matched your search

@@ -255,12 +255,6 @@
<RowDefinition Height="4" />
<RowDefinition Height="Auto"/>
<RowDefinition Height="4" />
<RowDefinition Height="Auto"/>
<RowDefinition Height="4" />
<RowDefinition Height="Auto"/>
<RowDefinition Height="4" />
<RowDefinition Height="Auto"/>
<RowDefinition Height="4" />
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
@@ -270,23 +264,11 @@
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="1" VerticalAlignment="Center">Join Thresh</TextBlock>
<uag:QuantityMeasureControl Grid.Row="1" Grid.Column="2" QuantityMeasure="{Binding join_threshold}"/>
<CheckBox Grid.Row="3" Grid.Column="2" VerticalAlignment="Center" Margin="0,0,0,0" IsChecked="{Binding enable_hedge}">Enable Hedge</CheckBox>
<TextBlock Grid.Row="5" VerticalAlignment="Center">Hedge Ticks</TextBlock>
<c:TickUpDownInt Grid.Row="5" Grid.Column="2" Value="{Binding hedge_ticks}"/>
<TextBlock Grid.Row="7">Hedge</TextBlock>
<TextBlock Grid.Row="3" VerticalAlignment="Center">Tick Offset</TextBlock>
<c:TickUpDownUInt Grid.Row="3" Grid.Column="2" Value="{Binding tick_offset_on_deploy}"/>
<TextBlock Grid.Row="5">Child</TextBlock>
<uag:OrderDetailsPopupControl
Grid.Row="7" Grid.Column="2"
IsEnabled="{Binding enable_hedge}"
IsOpen="{Binding hedge_order.editable_properties_open, FallbackValue=False}"
ItemsSource="{Binding hedge_order_types}"
SelectedItem="{Binding hedge_order}"
HasEditableProperties="{Binding hedge_order.has_editable_properties, FallbackValue=False}"
/>
<TextBlock Grid.Row="9" VerticalAlignment="Center">Initial Tick Offset</TextBlock>
<c:TickUpDownUInt Grid.Row="9" Grid.Column="2" Value="{Binding tick_offset_on_deploy}"/>
<TextBlock Grid.Row="11">Child</TextBlock>
<uag:OrderDetailsPopupControl
Grid.Row="11" Grid.Column="2"
Grid.Row="5" Grid.Column="2"
IsOpen="{Binding child_order.editable_properties_open, FallbackValue=False}"
ItemsSource="{Binding child_order_types}"
SelectedItem="{Binding child_order}"
@@ -364,8 +346,8 @@
<ColumnDefinition Width="12"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="1" VerticalAlignment="Center" IsEnabled="{Binding enable_hedge}" >Hedge Ticks</TextBlock>
<c:TickUpDownInt Grid.Row="1" Grid.Column="2" IsEnabled="{Binding enable_hedge}" Value="{Binding hedge_ticks}"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" >Hedge Ticks</TextBlock>
<c:TickUpDownInt Grid.Row="1" Grid.Column="2" Value="{Binding hedge_ticks}"/>
<TextBlock Grid.Row="3">Hedge</TextBlock>
<uag:OrderDetailsPopupControl
Grid.Row="3" Grid.Column="2"
@@ -12,7 +12,7 @@ using namespace api::orderman;
struct BookAlgo::PImpl
{
PImpl() : services(nullptr), fake_detached_child(false),
supports_hedge(false)
supports_hedge(false), has_activated_child(false)
{
}
@@ -33,6 +33,7 @@ struct BookAlgo::PImpl
HedgeStateMap hedges_state;
double tick_size;
bool has_activated_child;
};
BookAlgo::BookAlgo() : me(new PImpl())
@@ -80,7 +81,12 @@ void BookAlgo::set_child_quantity(uint32_t s)
void BookAlgo::activate_child(Price p, Quantity q)
{
me->child.activate(p, q);
//per Pedro, activating the child is not a synchronous calls, and he asserts that this is done only once
if(!me->has_activated_child)
{
me->child.activate(p, q);
me->has_activated_child = true;
}
}
void BookAlgo::update_child(Price p, Quantity q)
@@ -398,6 +404,7 @@ void BookAlgo::report_state()
merged_state.set_filled_quantity(child_state().filled_quantity());
merged_state.set_last_price(child_state().last_price());
merged_state.set_avg_price(child_state().avg_price());
merged_state.set_display_status(bts::api::orderman::OrderState_DisplayStatus::OrderState_DisplayStatus_HIDDEN);
me->services->report_state(merged_state);
}