Exemplo n.º 1
0
        private static string ReportToXml(CommissionReport commission)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.AppendChild(xmlDoc.CreateXmlDeclaration("1.0", null, null));
            XmlElement rootNode = xmlDoc.CreateElement("REPORT");

            xmlDoc.AppendChild(rootNode);

            XmlElement contractNode = xmlDoc.CreateElement("COMMISSION");

            rootNode.AppendChild(contractNode);
            foreach (var property in commission.GetType().GetProperties())
            {
                XmlElement fieldNode = xmlDoc.CreateElement(property.Name.Replace(" ", "").Replace("/", "").Replace("'", "").Replace("&", "n").Replace("-", "").Replace("%", "Pct"));
                fieldNode.AppendChild(xmlDoc.CreateTextNode(property.GetValue(commission).ToString()));
                contractNode.AppendChild(fieldNode);
            }

            using (StringWriter stringWriter = new StringWriter())
            {
                XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);
                xmlDoc.WriteTo(xmlTextWriter);
                return(stringWriter.ToString());
            }
        }
Exemplo n.º 2
0
        public virtual void commissionReport(CommissionReport commissionReport)
        {
            logger.Info("CommissionReport. " + commissionReport.ExecId + " - " + commissionReport.Commission + " " +
                        commissionReport.Currency + " RPNL " + commissionReport.RealizedPNL + "\n");

            Client.PushOrdersInfo(commissionReport.Map <CommissionReport, CommissionMessage>(), PushMessageType.CommissionPush);
        }
Exemplo n.º 3
0
        public static int SaveCommissionReport(CommissionReport commissionReport)
        {
            int result = -1;

            try
            {
                SqlConnection sqlConnection = new SqlConnection(connectionString);
                SqlCommand    sqlCommand    = new SqlCommand("SaveCommissionReport", sqlConnection);
                sqlCommand.CommandType = CommandType.StoredProcedure;

                sqlCommand.Parameters.AddWithValue("@execution_id", commissionReport.ExecId);
                sqlCommand.Parameters.AddWithValue("@commission", commissionReport.Commission);
                sqlCommand.Parameters.AddWithValue("@currency", commissionReport.Currency);
                sqlCommand.Parameters.AddWithValue("@realised_pnl", commissionReport.RealizedPNL);
                sqlCommand.Parameters.AddWithValue("@yield", commissionReport.Yield);
                sqlCommand.Parameters.AddWithValue("@yield_redemption_date", commissionReport.YieldRedemptionDate);

                sqlConnection.Open();
                result = Convert.ToInt32(sqlCommand.ExecuteScalar());
                sqlConnection.Close();
            }
            catch (Exception ex)
            {
                string errorMessage = "SaveCommissionReport insert failed: " + ex;
                Console.Write(errorMessage);
                SaveErrorMessage(errorMessage, GlobalValues.ErrorMessageTypes.ApplicationError);
            }

            return(result);
        }
Exemplo n.º 4
0
 public void commissionReport(CommissionReport commissionReport)
 {
     CommissionUpdateReceived?.Invoke(this, new CommissionUpdate
     {
         ExecutionId = commissionReport.ExecId,
         Commission  = commissionReport.Commission
     });
 }
Exemplo n.º 5
0
 public virtual void commissionReport(CommissionReport commissionReport)
 {
     db.runNonQuery("insert into commissions values ('" + commissionReport.ExecId + "'," + db.getSqlDateTime(clientSocket.getCurrentLocalTime()) + "," + commissionReport.Commission.ToString() + ",'" + commissionReport.Currency + "'," + db.getSqlDouble(commissionReport.RealizedPNL) + "," + db.getSqlDouble(commissionReport.Yield) + ",'')");
     if (verbose)
     {
         Console.WriteLine("Commission Report. Report: " + commissionReport.ToString());
     }
 }
Exemplo n.º 6
0
        public virtual void commissionReport(CommissionReport commissionReport)
        {
            String str;

            str = "CommissionReport, id = " + commissionReport.ExecId
                  + " commision = " + commissionReport.Commission;

            AddTextToResponseListWindow(str);
        }
Exemplo n.º 7
0
        void EWrapper.commissionReport(CommissionReport commissionReport)
        {
            var tmp = CommissionReport;

            if (tmp != null)
            {
                tmp(commissionReport);
            }
        }
Exemplo n.º 8
0
        void EWrapper.commissionReport(CommissionReport commissionReport)
        {
            var tmp = CommissionReport;

            if (tmp != null)
            {
                sc.Post((t) => tmp(commissionReport), null);
            }
        }
Exemplo n.º 9
0
        void EWrapper.commissionReport(CommissionReport commissionReport)
        {
            var tmp = CommissionReport;

            if (tmp != null)
            {
                FireEvent(t => tmp(commissionReport), null);
            }
        }
Exemplo n.º 10
0
 public virtual void commissionReport(CommissionReport commissionReport)
 {
     MyLogger.Instance.CreateEntry("CommissionReport. " + commissionReport.ExecId + " - " + commissionReport.Commission + " " + commissionReport.Currency + " RPNL " + commissionReport.RealizedPNL + "\n");
     Console.WriteLine("CommissionReport. " + commissionReport.ExecId + " - " + commissionReport.Commission + " " + commissionReport.Currency + " RPNL " + commissionReport.RealizedPNL + "\n");
     foreach (var tmpPosPair in PairPosDict.Values)
     {
         // save price and share to PosPair obj
         tmpPosPair.saveCommPNL(commissionReport.ExecId, commissionReport.Commission, commissionReport.RealizedPNL);
     }
 }
Exemplo n.º 11
0
 public void commissionReport(CommissionReport commissionReport)
 {
     try
     {
         if (m_commissionReportEventHandler != null)
         {
             m_commissionReportEventHandler(this, new TWSReportEventArgs(commissionReport));
         }
     }
     catch (Exception ex) { Error("Exception in commissionReport callback", ex); }
 }
Exemplo n.º 12
0
        void EWrapper.commissionReport(CommissionReport commissionReport)
        {
            var tmp = CommissionReport;

            if (tmp != null)
            {
                new Task(() =>
                         tmp(commissionReport)
                         ).RunSynchronously(scheduler);
            }
        }
Exemplo n.º 13
0
        public void commissionReport(CommissionReport commissionReport)
        {
            //find order by execId
            var orderStatus = OrderStatusDic.FirstOrDefault(o => o.Value.ExecId == commissionReport.ExecId);

            if (orderStatus.Equals(new KeyValuePair <int, IBOrderStatusWrapper>()))
            {
                Logger.Error("Received commission report with execId not found " +
                             $"in orders list, execId is {commissionReport.ExecId}");
                return;
            }

            orderStatus.Value.Data.Commission = commissionReport.Commission;
            Consumer.Enqueue(orderStatus.Value.Data);
        }
Exemplo n.º 14
0
        private void OnCommissionReportsChanged(PropertyChangedEventArgs eventArgs)
        {
            IList <CommissionReport> reports = service.CommissionReports;

            if (reports.IsNullOrEmpty())
            {
                return;
            }

            CommissionReport lastReport      = reports.Last();
            double           lastCommission  = lastReport.Commission;
            double           totalCommission = reports.Sum(report => report.Commission);

            IO.ShowMessage(Messages.CommissionFormat,
                           lastCommission.ToCurrencyString(),
                           totalCommission.ToCurrencyString());
        }
Exemplo n.º 15
0
 public virtual void commissionReport(CommissionReport commissionReport)
 {
     //parentUI.HandleMessage(new CommissionMessage(commissionReport));
 }
 /// <inheritdoc/>
 public void commissionReport(CommissionReport commissionReport)
 {
     this.CommissionReportEvent?.Invoke(this, new CommissionReportEventArgs(commissionReport));
 }
Exemplo n.º 17
0
 public CommissionMessage(CommissionReport commissionReport)
 {
     CommissionReport = commissionReport;
 }
Exemplo n.º 18
0
 private void OnCommissionReport(CommissionReport report)
 {
     CommissionReports.Add(report);
     PropertyChanged.RaiseEvent(CommissionReports, nameof(CommissionReports));
 }
Exemplo n.º 19
0
 public CommissionMessage(CommissionReport commissionReport)
 {
     Type             = MessageType.CommissionsReport;
     CommissionReport = commissionReport;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommissionReportEventArgs"/> class
 /// </summary>
 public CommissionReportEventArgs(CommissionReport commissionReport)
 {
     CommissionReport = commissionReport;
 }
Exemplo n.º 21
0
 private void OnCommissionReport(CommissionReport commissionReport)
 {
 }
 public virtual void commissionReport(CommissionReport commissionReport)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 23
0
        //! [execdetailsend]

        //! [commissionreport]
        public virtual void commissionReport(CommissionReport commissionReport)
        {
            Console.WriteLine("CommissionReport. " + commissionReport.ExecId + " - " + commissionReport.Commission + " " + commissionReport.Currency + " RPNL " + commissionReport.RealizedPNL);
        }
Exemplo n.º 24
0
 /// <inheritdoc/>
 public void commissionReport(CommissionReport commissionReport)
 {
     // Unimplemented because we don't care
 }
Exemplo n.º 25
0
 /// <summary>
 /// CommissionReport event invocator
 /// </summary>
 protected virtual void OnCommissionReport(CommissionReportEventArgs e)
 {
     CommissionReport?.Invoke(this, e);
 }
Exemplo n.º 26
0
 /// <summary>
 /// This callback returns the commission report portion of an execution and is triggered immediately after a trade execution, or by calling reqExecution().
 /// </summary>
 /// <param name="commissionReport">The structure that contains commission details.</param>
 public override void commissionReport(CommissionReport commissionReport)
 {
     OnCommissionReport(new CommissionReportEventArgs(commissionReport));
 }
 public virtual void commissionReport(CommissionReport commissionReport)
 {
     CommissionReport?.Invoke(this, new CommissionReportArgs(commissionReport));
 }
Exemplo n.º 28
0
 protected bool Equals(CommissionReport other)
 {
     return(ExecId == other.ExecId);
 }
Exemplo n.º 29
0
 public TWSReportEventArgs(CommissionReport commission)
 {
     RequestId = -1;
     Report    = ReportToXml(commission);
 }
Exemplo n.º 30
0
 public void commissionReport(CommissionReport commissionReport)
 {
 }
Exemplo n.º 31
0
    private void ProcessCommissionReport()
    {
      var version = _enc.DecodeInt();

      var commissionReport = new CommissionReport
      {
        ExecId = _enc.DecodeString(),
        Commission = _enc.DecodeDouble(),
        Currency = _enc.DecodeString(),
        RealizedPnl = _enc.DecodeDouble(),
        Yield = _enc.DecodeDouble(),
        YieldRedemptionDate = _enc.DecodeInt()
      };
      OnCommissionReport(commissionReport);
    }
Exemplo n.º 32
0
 void EWrapper.commissionReport(CommissionReport commissionReport)
 {
     CommissionReport?.Invoke(commissionReport);
 }
Exemplo n.º 33
0
 /// <summary>
 /// Full Constructor
 /// </summary>
 /// <param name="accountName">Account Name</param>
 public CommissionReportEventArgs(CommissionReport report)
 {
     Report = report;
 }