Example #1
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 20, Configuration.FieldSeparator),
                       Id,
                       OrderControl,
                       PlacerOrderNumber?.ToDelimitedString(),
                       FillerOrderNumber?.ToDelimitedString(),
                       PlacerGroupNumber?.ToDelimitedString(),
                       OrderStatus,
                       ResponseFlag,
                       QuantityTiming?.ToDelimitedString(),
                       ParentOrder?.ToDelimitedString(),
                       DateTimeOfTransaction.HasValue ? DateTimeOfTransaction.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       EnteredBy?.ToDelimitedString(),
                       VerifiedBy?.ToDelimitedString(),
                       OrderingProvider?.ToDelimitedString(),
                       EnterersLocation?.ToDelimitedString(),
                       CallBackPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, CallBackPhoneNumber.Select(x => x.ToDelimitedString())) : null,
                       OrderEffectiveDateTime.HasValue ? OrderEffectiveDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       OrderControlCodeReason?.ToDelimitedString(),
                       EnteringOrganization?.ToDelimitedString(),
                       EnteringDevice?.ToDelimitedString(),
                       ActionBy?.ToDelimitedString()
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Example #2
0
        private void btn_CloseParentTrailing_Click(object sender, RoutedEventArgs e)
        {
            //TODO open dialog and place trailing order

            try
            {
                ParentOrder parent = (ParentOrder)dg_ParentOrders.SelectedItem;

                if (parent == null)
                {
                    MessageBox.Show("Please select parent order");
                }
                else
                {
                    ParentOrderManager.Instance.StopParentOrder(parent.ID);
                    Thread.Sleep(500);

                    TrailingOrder trailingOrder = new TrailingOrder(parent);

                    trailingOrder.ShowDialog();
                    Log.Info(string.Format("Parent order {0} is paused.", parent.ID));
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                Log.Error(ex.StackTrace);
                MessageBox.Show("Fail to retrieve parent order, error: " + ex.Message);
            }
        }
Example #3
0
        private void btn_StopParent_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ParentOrder parent = (ParentOrder)dg_ParentOrders.SelectedItem;
                //ParentOrder parent = ParentOrderManager.Instance.GetParentOrderByParentID(po.ID);

                if (parent == null)
                {
                    MessageBox.Show("Please select parent order");
                }
                else
                {
                    ParentOrderManager.Instance.StopParentOrder(parent.ID);
                    dg_ParentOrders.Items.Refresh();
                    Log.Info(string.Format("Parent order {0} is stopped.", parent.ID));
                    MessageBox.Show(string.Format("Parent order {0} is stopped.", parent.Symbol));

                    childOrderList.Clear();
                }
            }
            catch (Exception ex)
            {
                Log.Info(string.Format("Failed to pause parent order "));
                Log.Error(ex.Message);
                Log.Error(ex.StackTrace);
                MessageBox.Show("Fail to retrieve parent order, error: " + ex.Message);
            }
        }
Example #4
0
        private void btn_editTrademap_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ParentOrder po = (ParentOrder)dg_ParentOrders.SelectedItem;

                if (po == null)
                {
                    Dispatcher.InvokeAsync(() => MessageBox.Show("Please select parent order"));
                }
                else
                {
                    ParentOrderManager.Instance.StopParentOrder(po.ID);
                    dg_ParentOrders.Items.Refresh();


                    EditTradeMap editTradeMap = new EditTradeMap(po);
                    editTradeMap.ShowDialog();

                    RollingAlgo algo = (RollingAlgo)po.Algo;
                    var         list = algo.TradeMap.Values.OrderBy(o => o.Level).ToList();
                    dg_Trademap.ItemsSource = list;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                Log.Error(ex.StackTrace);
                MessageBox.Show("Fail to edit trademap, error: " + ex.Message);
            }
        }
        /// <summary>
        /// 重设当前可显示的内容,为各项内容间加上空格
        /// </summary>
        protected override void ResetDisplayTexts()
        {
            InitBaseDisplayTexts();

            // 顺序为:项目 数量单位 [用法] [频次] [嘱托]
            if (Item == null) // 如果没有项目,则默认为显示内容为空
            {
                return;
            }

            string tail = ""; // 长度大于1表示已经有结尾了,已便于在各项内容间插入空格

            if (!String.IsNullOrEmpty(EntrustContent))
            {
                Texts.Insert(0, new OutputInfoStruct(EntrustContent.Trim()
                                                     , OrderOutputTextType.EntrustContent));
                tail = " ";
            }
            // 长期医嘱才显示频次
            if ((ParentOrder == null) || (ParentOrder.GetType() == typeof(LongOrder)))
            {
                if ((ItemFrequency != null) && (ItemFrequency.KeyInitialized))
                {
                    Texts.Insert(0, new OutputInfoStruct(ItemFrequency.ToString().Trim() + tail
                                                         , OrderOutputTextType.ItemFrequency));
                    if (tail.Length == 0)
                    {
                        tail = " ";
                    }
                }
            }
            if ((ItemUsage != null) && (ItemUsage.KeyInitialized))
            {
                Texts.Insert(0, new OutputInfoStruct(ItemUsage.ToString().Trim() + tail
                                                     , OrderOutputTextType.ItemUsage));
                if (tail.Length == 0)
                {
                    tail = " ";
                }
            }

            // 要根据项目的显示控制属性来决定显示的内容
            ChargeItem chargeItem = Item as ChargeItem;

            if ((chargeItem.PrintAttributes & ItemPrintAttributeFlag.NotShowAmount) == 0)
            {
                Texts.Insert(0
                             //, new OutputInfoStruct(Amount.ToString("#.##", CultureInfo.CurrentCulture) + CurrentUnit.Name.Trim() + tail
                             , new OutputInfoStruct(Amount.ToString() + CurrentUnit.Name.Trim() + tail
                                                    , OrderOutputTextType.ItemAmount));
                if (tail.Length == 0)
                {
                    tail = " ";
                }
            }

            Texts.Insert(0, new OutputInfoStruct(Item.Name.Trim() + tail
                                                 , OrderOutputTextType.ItemName));
        }
Example #6
0
        public TrailingOrder(ParentOrder p)
        {
            InitializeComponent();
            this.parent = p;

            lbl_Place_TrailOrder.Content = String.Format("Sell Parent {0}, Ticker {1}, Qty {2}",
                                                         p.ID, p.Symbol, p.Qty);
        }
Example #7
0
        public EditTradeMap(ParentOrder p)
        {
            InitializeComponent();
            this.parent = p;

            RefreshTM();

            txt_editTM_lvl.Text = ((RollingAlgo)p.Algo).CurrentLevel.ToString();

            lbl_EditTradeMap.Content = String.Format("Parent Order {0}, Ticker {1}, Qty {2}, CurrentLvl {3}", p.ID, p.Symbol, p.Qty, ((RollingAlgo)p.Algo).CurrentLevel);
        }
Example #8
0
        private void btn_getchild_Click(object sender, RoutedEventArgs e)
        {
            //if (!TradeManager.Instance.IsConnected)
            //{
            //    MessageBox.Show("IB is not connected, please reconnect first!");
            //    Log.Error("IB is not connected, please reconnect first");
            //    return;
            //}

            try
            {
                ParentOrder parent = (ParentOrder)dg_ParentOrders.SelectedItem;
                //ParentOrder parent = ParentOrderManager.Instance.GetParentOrderByParentID(po.ID);

                if (parent == null)
                {
                    Dispatcher.InvokeAsync(() => MessageBox.Show("Please select parent order"));
                }
                else
                {
                    childOrderList.Clear();
                    foreach (var to in parent.TradeOrders)
                    {
                        if (to.Status != TradeOrderStatus.Cancelled)
                        {
                            childOrderList.Add(to);
                        }
                    }


                    dg_Details.ItemsSource = childOrderList;

                    //dg_Details.ItemsSource = parent.TradeOrders;

                    if (dg_ParentOrders.ItemsSource != null)
                    {
                        dg_ParentOrders.Items.Refresh();
                    }
                    //if (dg_Details.ItemsSource != null) dg_Details.Items.Refresh();
                    if (dg_Trademap.ItemsSource != null)
                    {
                        dg_Trademap.Items.Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                Log.Error(ex.StackTrace);
                MessageBox.Show("Fail to retrieve parent order, error: " + ex.Message);
            }
        }
Example #9
0
        /// <summary>
        /// 重设当前可显示的内容,为各项内容间加上空格
        /// </summary>
        protected override void ResetDisplayTexts()
        {
            InitBaseDisplayTexts();

            // 顺序为:项目 数量单位 [用法] [频次] [嘱托]
            if (Item == null) // 如果没有项目,则默认为显示内容为空
            {
                return;
            }

            string tail = ""; // 长度大于1表示已经有结尾了,已便于在各项内容间插入空格

            if ((Attributes & OrderAttributeFlag.Provide4Oneself) > 0)
            {
                Texts.Insert(0, new OutputInfoStruct("自备", OrderOutputTextType.SelfProvide));
                tail = " ";
            }
            if (!String.IsNullOrEmpty(EntrustContent))
            {
                Texts.Insert(0, new OutputInfoStruct(EntrustContent.Trim(), OrderOutputTextType.EntrustContent));
                tail = " ";
            }
            // 长期医嘱才显示频次
            if ((ParentOrder == null) || (ParentOrder.GetType() == typeof(LongOrder)))
            {
                if ((ItemFrequency != null) && (ItemFrequency.KeyInitialized))
                {
                    Texts.Insert(0, new OutputInfoStruct(ItemFrequency.ToString().Trim() + tail, OrderOutputTextType.ItemFrequency));
                    if (tail.Length == 0)
                    {
                        tail = " ";
                    }
                }
            }
            if ((ItemUsage != null) && (ItemUsage.KeyInitialized))
            {
                Texts.Insert(0, new OutputInfoStruct(ItemUsage.ToString().Trim() + tail, OrderOutputTextType.ItemUsage));
                if (tail.Length == 0)
                {
                    tail = " ";
                }
            }

            Texts.Insert(0, new OutputInfoStruct(Amount.ToString() + CurrentUnit.Name.Trim() + tail, OrderOutputTextType.ItemAmount));

            Texts.Insert(0, new OutputInfoStruct(Item.ToString().Trim() + " ", OrderOutputTextType.ItemName));
        }
Example #10
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 35, Configuration.FieldSeparator),
                       Id,
                       OrderControl,
                       PlacerOrderNumber?.ToDelimitedString(),
                       FillerOrderNumber?.ToDelimitedString(),
                       PlacerGroupNumber?.ToDelimitedString(),
                       OrderStatus,
                       ResponseFlag,
                       QuantityTiming != null ? string.Join(Configuration.FieldRepeatSeparator, QuantityTiming) : null,
                       ParentOrder?.ToDelimitedString(),
                       DateTimeOfTransaction.HasValue ? DateTimeOfTransaction.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       EnteredBy != null ? string.Join(Configuration.FieldRepeatSeparator, EnteredBy.Select(x => x.ToDelimitedString())) : null,
                       VerifiedBy != null ? string.Join(Configuration.FieldRepeatSeparator, VerifiedBy.Select(x => x.ToDelimitedString())) : null,
                       OrderingProvider != null ? string.Join(Configuration.FieldRepeatSeparator, OrderingProvider.Select(x => x.ToDelimitedString())) : null,
                       EnterersLocation?.ToDelimitedString(),
                       CallBackPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, CallBackPhoneNumber.Select(x => x.ToDelimitedString())) : null,
                       OrderEffectiveDateTime.HasValue ? OrderEffectiveDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       OrderControlCodeReason?.ToDelimitedString(),
                       EnteringOrganization?.ToDelimitedString(),
                       EnteringDevice?.ToDelimitedString(),
                       ActionBy != null ? string.Join(Configuration.FieldRepeatSeparator, ActionBy.Select(x => x.ToDelimitedString())) : null,
                       AdvancedBeneficiaryNoticeCode?.ToDelimitedString(),
                       OrderingFacilityName != null ? string.Join(Configuration.FieldRepeatSeparator, OrderingFacilityName.Select(x => x.ToDelimitedString())) : null,
                       OrderingFacilityAddress != null ? string.Join(Configuration.FieldRepeatSeparator, OrderingFacilityAddress.Select(x => x.ToDelimitedString())) : null,
                       OrderingFacilityPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, OrderingFacilityPhoneNumber.Select(x => x.ToDelimitedString())) : null,
                       OrderingProviderAddress != null ? string.Join(Configuration.FieldRepeatSeparator, OrderingProviderAddress.Select(x => x.ToDelimitedString())) : null,
                       OrderStatusModifier?.ToDelimitedString(),
                       AdvancedBeneficiaryNoticeOverrideReason?.ToDelimitedString(),
                       FillersExpectedAvailabilityDateTime.HasValue ? FillersExpectedAvailabilityDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       ConfidentialityCode?.ToDelimitedString(),
                       OrderType?.ToDelimitedString(),
                       EntererAuthorizationMode?.ToDelimitedString(),
                       ParentUniversalServiceIdentifier?.ToDelimitedString(),
                       AdvancedBeneficiaryNoticeDate.HasValue ? AdvancedBeneficiaryNoticeDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null,
                       AlternatePlacerOrderNumber != null ? string.Join(Configuration.FieldRepeatSeparator, AlternatePlacerOrderNumber.Select(x => x.ToDelimitedString())) : null,
                       OrderWorkflowProfile != null ? string.Join(Configuration.FieldRepeatSeparator, OrderWorkflowProfile.Select(x => x.ToDelimitedString())) : null
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Example #11
0
        private void btn_RemoveParent_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ParentOrder parent = (ParentOrder)dg_ParentOrders.SelectedItem;
                //ParentOrder parent = ParentOrderManager.Instance.GetParentOrderByParentID(po.ID);

                if (parent == null)
                {
                    MessageBox.Show("Please select parent order");
                }
                else
                {
                    ParentOrderManager.Instance.RemoveParentOrderByID(parent.ID);

                    Log.Info(string.Format("Parent order {0} is removed.", parent.ID));
                    MessageBox.Show(string.Format("Parent order of {0} is removed", parent.Symbol));

                    parentOrderList.Clear();
                    List <ParentOrder> parents = ParentOrderManager.Instance.GetAllParentOrders();
                    foreach (var p in parents)
                    {
                        parentOrderList.Add(p);
                    }

                    dg_ParentOrders.ItemsSource = parentOrderList;

                    if (dg_Details.ItemsSource != null)
                    {
                        dg_Details.Items.Refresh();
                    }
                    if (dg_Trademap.ItemsSource != null)
                    {
                        dg_Trademap.Items.Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                Log.Error(ex.StackTrace);
                MessageBox.Show("Fail to retrieve parent order, error: " + ex.Message);
            }
        }
Example #12
0
        public void ToDelimitedString_WithAllProperties_ReturnsCorrectlySequencedFields()
        {
            IType hl7Type = new ParentOrder
            {
                PlacerAssignedIdentifier = new EntityIdentifier
                {
                    EntityId = "1"
                },
                FillerAssignedIdentifier = new EntityIdentifier
                {
                    EntityId = "2"
                }
            };

            string expected = "1^2";
            string actual   = hl7Type.ToDelimitedString();

            Assert.Equal(expected, actual);
        }
Example #13
0
        private void btn_getExecution_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ParentOrder parent = (ParentOrder)dg_ParentOrders.SelectedItem;
                //ParentOrder parent = ParentOrderManager.Instance.GetParentOrderByParentID(po.ID);

                if (parent == null)
                {
                    Dispatcher.InvokeAsync(() => MessageBox.Show("Please select parent order"));
                }

                else
                {
                    executionList.Clear();
                    foreach (var ex in parent.Executions)
                    {
                        executionList.Add(ex);
                    }

                    dg_Details.ItemsSource = executionList;

                    //dg_Details.ItemsSource = parent.Executions;
                    if (dg_ParentOrders.ItemsSource != null)
                    {
                        dg_ParentOrders.Items.Refresh();
                    }
                    //if (dg_Details.ItemsSource != null) dg_Details.Items.Refresh();
                    if (dg_Trademap.ItemsSource != null)
                    {
                        dg_Trademap.Items.Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                Log.Error(ex.StackTrace);
                MessageBox.Show("Fail to retrieve parent order, error: " + ex.Message);
            }
        }
Example #14
0
        private void btn_getTrademap_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ParentOrder po = (ParentOrder)dg_ParentOrders.SelectedItem;



                if (po == null)
                {
                    Dispatcher.InvokeAsync(() => MessageBox.Show("Please select parent order"));
                }
                else
                {
                    RollingAlgo algo = (RollingAlgo)po.Algo;
                    dg_Trademap.ItemsSource = null;
                    if (algo.TradeMap != null && algo.TradeMap.Count > 0)
                    {
                        var list = algo.TradeMap.Values.OrderBy(o => o.Level).ToList();
                        dg_Trademap.ItemsSource = list;

                        if (dg_ParentOrders.ItemsSource != null)
                        {
                            dg_ParentOrders.Items.Refresh();
                        }
                        if (dg_Details.ItemsSource != null)
                        {
                            dg_Details.Items.Refresh();
                        }
                        // if (dg_Trademap.ItemsSource != null) dg_Trademap.Items.Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                Log.Error(ex.StackTrace);
                MessageBox.Show("Fail to retrieve parent order, error: " + ex.Message);
            }
        }
Example #15
0
        public void FromDelimitedString_WithAllProperties_ReturnsCorrectlyInitializedFields()
        {
            IType expected = new ParentOrder
            {
                PlacerAssignedIdentifier = new EntityIdentifier
                {
                    IsSubcomponent = true,
                    EntityId       = "1"
                },
                FillerAssignedIdentifier = new EntityIdentifier
                {
                    IsSubcomponent = true,
                    EntityId       = "2"
                }
            };

            IType actual = new ParentOrder();

            actual.FromDelimitedString("1^2");

            expected.Should().BeEquivalentTo(actual);
        }
Example #16
0
        private void btn_getAlgo_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ParentOrder parent = (ParentOrder)dg_ParentOrders.SelectedItem;
                //ParentOrder parent = ParentOrderManager.Instance.GetParentOrderByParentID(po.ID);

                if (parent == null)
                {
                    Dispatcher.InvokeAsync(() => MessageBox.Show("Please select parent order"));
                }
                else
                {
                    algoList.Clear();

                    algoList.Add((RollingAlgo)parent.Algo);

                    dg_Details.ItemsSource = algoList;

                    //dg_Details.ItemsSource = new List<RollingAlgo>() { (RollingAlgo)parent.Algo };

                    if (dg_ParentOrders.ItemsSource != null)
                    {
                        dg_ParentOrders.Items.Refresh();
                    }
                    //if (dg_Details.ItemsSource != null) dg_Details.Items.Refresh();
                    if (dg_Trademap.ItemsSource != null)
                    {
                        dg_Trademap.Items.Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                Log.Error(ex.StackTrace);
                MessageBox.Show("Fail to retrieve parent order, error: " + ex.Message);
            }
        }
Example #17
0
        private void btn_CloseParent_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ParentOrder parent = (ParentOrder)dg_ParentOrders.SelectedItem;

                if (parent == null)
                {
                    MessageBox.Show("Please select parent order");
                }
                else
                {
                    ParentOrderManager.Instance.CloseParentOrderByID(parent.ID);
                    dg_ParentOrders.Items.Refresh();
                    Log.Info(string.Format("Parent order {0} is closed.", parent.ID));
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                Log.Error(ex.StackTrace);
                MessageBox.Show("Fail to retrieve parent order, error: " + ex.Message);
            }
        }
Example #18
0
        private void btn_submit_Click(object sender, RoutedEventArgs e)
        {
            if (!TradeManager.Instance.IsConnected || !ParentOrderManager.Instance.IsInit)
            {
                MessageBox.Show("IB is not connected, please reconnect first!");
                Log.Error("IB is not connected, please reconnect first");
                return;
            }

            List <ITradeRule> rules = new List <ITradeRule>()
            {
                new RollingAlgoBuyRule(), new RollingAlgoSellRule()
            };
            RollingAlgo algo = null;
            string      symbol;
            double      beginPrice;
            double      shareOrDollarAmt;
            double      scaleFactor;
            int         scaleLevel;

            try
            {
                symbol           = txt_symbol.Text.Trim().ToUpper();
                beginPrice       = Convert.ToDouble(txt_price.Text);
                scaleFactor      = Convert.ToDouble(txt_scaleFactor.Text);
                scaleLevel       = Convert.ToInt32(txt_scalelvl.Text) - 1;
                shareOrDollarAmt = Convert.ToDouble(txt_shareAmt.Text);
                bool isPctScaleFactor = comb_scale.SelectedIndex == 1;

                bool buyBackLvlZero = chk_buyback.IsChecked.Value;

                double adjQty   = Convert.ToDouble(txt_adj.Text);
                bool   isAdjPct = comb_adj.SelectedIndex == 0;
                bool   isShare  = comb_shareAmt.SelectedIndex == 0;

                scaleFactor = isPctScaleFactor ? scaleFactor / 100 : scaleFactor;


                if (beginPrice <= 0 || scaleLevel <= 0 || scaleFactor <= 0 || (isPctScaleFactor && scaleFactor >= 100) || (isAdjPct && Math.Abs(adjQty) >= 100))
                {
                    MessageBox.Show("Invalid price, scale inputs. scale factor pct must be between 0% and 100%. adj Pct must between 0% and 100%");
                    return;
                }

                algo = new RollingAlgo(beginPrice, scaleLevel, scaleFactor, isPctScaleFactor, shareOrDollarAmt, isShare, buyBackLvlZero, adjQty, isAdjPct);


                //Establish rules
                double pctGain = Convert.ToDouble(txt_pricegain.Text) / 100;
                double pctSell = Convert.ToDouble(txt_pctsell.Text) / 100;
                RollingAlgoFirstLevelSellRule sellRule = new RollingAlgoFirstLevelSellRule(pctSell, pctGain);

                rules.Add(sellRule);

                if (chk_buyback.IsChecked.Value)
                {
                    rules.Add(new RollingAlgoFirstLevelBuyRule());
                }

                algo.TradeRules = rules;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Invalid input parameters, Error: " + ex.Message);
                return;
            }

            var result = MessageBox.Show(string.Format(@"Please confirm to Place order:
                Symbol: {0}
                Begin Px: {1:0.00}
                Share/Amt: {2}
                Levels: {3}
                Scale factor: {4:0.00}",
                                                       symbol, beginPrice, shareOrDollarAmt, scaleLevel + 1, scaleFactor), "Order Confirmation", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.No)
            {
                return;
            }

            ParentOrder order = ParentOrderManager.Instance.CreateParentOrder(symbol, 0, algo);

            order.IsActive = true;
            ParentOrderManager.Instance.AddParentOrder(order);

            if (!ParentOrderManager.Instance.IsStarted)
            {
                ParentOrderManager.Instance.Start();
            }

            if (dg_ParentOrders.ItemsSource != null)
            {
                dg_ParentOrders.Items.Refresh();
            }
            if (dg_Details.ItemsSource != null)
            {
                dg_Details.Items.Refresh();
            }
            if (dg_Trademap.ItemsSource != null)
            {
                dg_Trademap.Items.Refresh();
            }

            Dispatcher.InvokeAsync(() =>
                                   MessageBox.Show(string.Format("Parent order created. Symbol {0}, Begin price {1}, share/amt {2}", symbol, beginPrice, shareOrDollarAmt)));
        }
Example #19
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 56, Configuration.FieldSeparator),
                       Id,
                       SetIdObr.HasValue ? SetIdObr.Value.ToString(culture) : null,
                       PlacerOrderNumber?.ToDelimitedString(),
                       FillerOrderNumber?.ToDelimitedString(),
                       UniversalServiceIdentifier?.ToDelimitedString(),
                       Priority,
                       RequestedDateTime.HasValue ? RequestedDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       ObservationDateTime.HasValue ? ObservationDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       ObservationEndDateTime.HasValue ? ObservationEndDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       CollectionVolume?.ToDelimitedString(),
                       CollectorIdentifier != null ? string.Join(Configuration.FieldRepeatSeparator, CollectorIdentifier.Select(x => x.ToDelimitedString())) : null,
                       SpecimenActionCode,
                       DangerCode?.ToDelimitedString(),
                       RelevantClinicalInformation != null ? string.Join(Configuration.FieldRepeatSeparator, RelevantClinicalInformation.Select(x => x.ToDelimitedString())) : null,
                       SpecimenReceivedDateTime.HasValue ? SpecimenReceivedDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       SpecimenSource,
                       OrderingProvider != null ? string.Join(Configuration.FieldRepeatSeparator, OrderingProvider.Select(x => x.ToDelimitedString())) : null,
                       OrderCallbackPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, OrderCallbackPhoneNumber.Select(x => x.ToDelimitedString())) : null,
                       PlacerField1,
                       PlacerField2,
                       FillerField1,
                       FillerField2,
                       ResultsRptStatusChngDateTime.HasValue ? ResultsRptStatusChngDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       ChargeToPractice?.ToDelimitedString(),
                       DiagnosticServSectId,
                       ResultStatus,
                       ParentResult?.ToDelimitedString(),
                       QuantityTiming != null ? string.Join(Configuration.FieldRepeatSeparator, QuantityTiming) : null,
                       ResultCopiesTo != null ? string.Join(Configuration.FieldRepeatSeparator, ResultCopiesTo.Select(x => x.ToDelimitedString())) : null,
                       ParentResultsObservationIdentifier?.ToDelimitedString(),
                       TransportationMode,
                       ReasonForStudy != null ? string.Join(Configuration.FieldRepeatSeparator, ReasonForStudy.Select(x => x.ToDelimitedString())) : null,
                       PrincipalResultInterpreter?.ToDelimitedString(),
                       AssistantResultInterpreter != null ? string.Join(Configuration.FieldRepeatSeparator, AssistantResultInterpreter.Select(x => x.ToDelimitedString())) : null,
                       Technician != null ? string.Join(Configuration.FieldRepeatSeparator, Technician.Select(x => x.ToDelimitedString())) : null,
                       Transcriptionist != null ? string.Join(Configuration.FieldRepeatSeparator, Transcriptionist.Select(x => x.ToDelimitedString())) : null,
                       ScheduledDateTime.HasValue ? ScheduledDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       NumberOfSampleContainers.HasValue ? NumberOfSampleContainers.Value.ToString(Consts.NumericFormat, culture) : null,
                       TransportLogisticsOfCollectedSample != null ? string.Join(Configuration.FieldRepeatSeparator, TransportLogisticsOfCollectedSample.Select(x => x.ToDelimitedString())) : null,
                       CollectorsComment != null ? string.Join(Configuration.FieldRepeatSeparator, CollectorsComment.Select(x => x.ToDelimitedString())) : null,
                       TransportArrangementResponsibility?.ToDelimitedString(),
                       TransportArranged,
                       EscortRequired,
                       PlannedPatientTransportComment != null ? string.Join(Configuration.FieldRepeatSeparator, PlannedPatientTransportComment.Select(x => x.ToDelimitedString())) : null,
                       ProcedureCode?.ToDelimitedString(),
                       ProcedureCodeModifier != null ? string.Join(Configuration.FieldRepeatSeparator, ProcedureCodeModifier.Select(x => x.ToDelimitedString())) : null,
                       PlacerSupplementalServiceInformation != null ? string.Join(Configuration.FieldRepeatSeparator, PlacerSupplementalServiceInformation.Select(x => x.ToDelimitedString())) : null,
                       FillerSupplementalServiceInformation != null ? string.Join(Configuration.FieldRepeatSeparator, FillerSupplementalServiceInformation.Select(x => x.ToDelimitedString())) : null,
                       MedicallyNecessaryDuplicateProcedureReason?.ToDelimitedString(),
                       ResultHandling?.ToDelimitedString(),
                       ParentUniversalServiceIdentifier?.ToDelimitedString(),
                       ObservationGroupId?.ToDelimitedString(),
                       ParentObservationGroupId?.ToDelimitedString(),
                       AlternatePlacerOrderNumber != null ? string.Join(Configuration.FieldRepeatSeparator, AlternatePlacerOrderNumber.Select(x => x.ToDelimitedString())) : null,
                       ParentOrder != null ? string.Join(Configuration.FieldRepeatSeparator, ParentOrder.Select(x => x.ToDelimitedString())) : null,
                       ActionCode
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }