Fix problem not checking SellDate.

This commit is contained in:
2024-10-26 07:35:44 -04:00
parent 3aa0edff0f
commit b8282f54fd
2 changed files with 35 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
<Window x:Class="TradeBlotter.UIUtils.CMTTrendModelClosePositionDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Close Position" Height="240" Width="200"
Title="Close Position" Height="260" Width="200"
xmlns:wpfx="http://schemas.xceed.com/wpf/xaml/toolkit"
WindowStartupLocation="CenterScreen"
SizeToContent="WidthAndHeight"
@@ -29,6 +29,7 @@
<RowDefinition Height="25" />
<RowDefinition Height="25" />
<RowDefinition Height="25" />
<RowDefinition Height="25" />
</Grid.RowDefinitions>
<Label Name="lblCompanyName" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3"></Label>
@@ -40,7 +41,7 @@
<DatePicker Name="dpPurchaseDate" IsEnabled="False" Grid.Row="3" Grid.Column="2"></DatePicker>
<Label Name="lblSellDate" Grid.Row="4" Grid.Column="0" MinWidth="75">Sell Date</Label>
<DatePicker Name="dpSellDate" Grid.Row="4" Grid.Column="2"></DatePicker>
<DatePicker Name="dpSellDate" Grid.Row="4" Grid.Column="2" SelectedDateChanged="dpSellDate_SelectionChanged"></DatePicker>
<Label Name="lblSellPrice" Grid.Row="5" Grid.Column="0">Sell Price</Label>
<TextBox Name="txtSellPrice" Grid.Row="5" Grid.Column="2" MinWidth="75" LostFocus="txtSellPrice_OnLostFocusHandler" KeyDown="txtSellPrice_OnKeyDownHandler">100.00</TextBox>
@@ -48,6 +49,8 @@
<CheckBox Name="cbDeleteStop" Grid.Row="7" Grid.Column="0">Delete Stop</CheckBox>
<Label Name="lblMessage" Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="5"></Label>
<Button Content="_Ok" MinWidth="75" IsDefault="False" Margin="2" Name="btnOk" Click="btnOk_Click" Grid.Row="9" Grid.Column="0"/>
<Button Content="_Cancel" MinWidth="75" IsCancel="True" Margin="2" Name="btnCancel" Click="btnCancel_Click" Grid.Row="9" Grid.Column="2"/>
</Grid>

View File

@@ -138,11 +138,32 @@ namespace TradeBlotter.UIUtils
private bool Validate()
{
DateGenerator dateGenerator=new DateGenerator();
if(null==Symbol) return false;
if(Utility.IsEpoch(PurchaseDate)) return false;
if(Utility.IsEpoch(SellDate))return false;
if(!dateGenerator.IsMarketOpen(SellDate)) return false;
if(double.IsNaN(SellPrice)) return false;
if(null==Symbol)
{
SetMessage("Invalid Symbol.");
return false;
}
if(Utility.IsEpoch(PurchaseDate))
{
SetMessage("Invalid Purchase Date.");
return false;
}
if(Utility.IsEpoch(SellDate))
{
SetMessage("Invalid Sell Date.");
return false;
}
if(!dateGenerator.IsMarketOpen(SellDate))
{
SetMessage("Market closed on Sell Date.");
return false;
}
if(double.IsNaN(SellPrice))
{
SetMessage("Invalid Sell Price.");
return false;
}
SetMessage("");
return true;
}
private void UpdateSellPrice()
@@ -155,5 +176,9 @@ namespace TradeBlotter.UIUtils
if(null==companyProfile||null==companyProfile.CompanyName) return;
lblCompanyName.Content=companyProfile.CompanyName.ToUpper();
}
private void SetMessage(String message)
{
lblMessage.Content=message;
}
}
}