Example #1
0
        public double GetTradeExecutionPrice(DateTime fromDate,
                                             DateTime toDate,
                                             InstrumentType instrumentType,
                                             string orderRefString)
        {
            double executionPrice = -1;

            BrokerErrorCode errorCode = BrokerErrorCode.Success;

            if (instrumentType.Equals(InstrumentType.Share))
            {
                errorCode = RefreshEquityTradeBook(this, fromDate, toDate, false);
                if (!errorCode.Equals(BrokerErrorCode.Success))
                {
                    return(executionPrice);
                }
                lock (lockObjectEquity)
                {
                    if (mEquityTradeBook.ContainsKey(orderRefString))
                    {
                        executionPrice = mEquityTradeBook[orderRefString].Price;
                    }
                }
            }

            return(executionPrice);
        }
Example #2
0
        public void Build()
        {
            foreach (var methodTranList in MethodTrans)
            {
                Console.Error.WriteLine("MESSAGE: Exporting method {0}", Path.GetFileName(methodTranList.FinalMethod));
                if (string.IsNullOrEmpty(methodTranList.TransitionList))
                {
                    throw new IOException(string.Format("Failure creating method file {0}. The mass list is empty.", methodTranList.FinalMethod));
                }

                string outMeth = EnsureExtension(methodTranList.OutputMethod, ".meth");  // Thermo needs the extension to be .meth
                if (!Equals(outMeth, methodTranList.OutputMethod) && File.Exists(methodTranList.OutputMethod))
                {
                    File.Move(methodTranList.OutputMethod, outMeth);
                }

                try
                {
                    using (IMethodXMLContext mxc = MethodXMLFactory.CreateContext(InstrumentType, InstrumentVersion))
                        using (IMethodXML mx = mxc.Create())
                        {
                            mx.Open(TemplateMethod);
                            mx.EnableValidation(true);

                            ListItem[] listItems = ParseList(methodTranList.TransitionList).ToArray();
                            if (!listItems.Any())
                            {
                                throw new IOException("Empty mass list found.");
                            }

                            if (InstrumentType.Equals(InstrumentFusion))
                            {
                                mx.ApplyMethodModificationsFromXML(GetFusionModificationXml(listItems, outMeth));
                            }
                            else
                            {
                                mx.ImportMassListFromXML(GetTsqMassListXml(listItems, outMeth));
                            }
                            mx.SaveAs(outMeth);
                        }

                    if (!File.Exists(outMeth))
                    {
                        throw new IOException(string.Format("Failure creating method file {0}.", methodTranList.FinalMethod));
                    }
                }
                finally
                {
                    if (!Equals(outMeth, methodTranList.OutputMethod))
                    {
                        File.Move(outMeth, methodTranList.OutputMethod);
                    }
                }
            }
        }