예제 #1
0
 /**
  * Retrieve and process the requests for collateral reports on this session, adding
  * each to the internal map
  */
 public override void onMessage(QuickFix44.CollateralReport report, QuickFix.SessionID session)
 {
     if (newAccountReq) // only if the CollateralReport is newly requested
     {
         // create a new RequestForPositions
         QuickFix44.RequestForPositions req = new QuickFix44.RequestForPositions(
             new QuickFix.PosReqID(nextID().ToString()),
             new QuickFix.PosReqType(QuickFix.PosReqType.POSITIONS),                                           // open positions
             report.getAccount(),                                                                              // the account
             new QuickFix.AccountType(
                 QuickFix.AccountType.ACCOUNT_IS_CARRIED_ON_NON_CUSTOMER_SIDE_OF_BOOKS_AND_IS_CROSS_MARGINED), // this AccountType is required
             new QuickFix.ClearingBusinessDate(getDate()),                                                     // limits the scope to the current day, still max of 300 records
             new QuickFix.TransactTime()
             );
         req.set(subscriptionType); // set the subscription type
         // send to the API
         send(req, session);
         // create another RequestForPositions
         req = new QuickFix44.RequestForPositions(
             new QuickFix.PosReqID(nextID().ToString()),
             new QuickFix.PosReqType(QuickFix.PosReqType.TRADES),                                              // closed positions
             report.getAccount(),                                                                              // the account
             new QuickFix.AccountType(
                 QuickFix.AccountType.ACCOUNT_IS_CARRIED_ON_NON_CUSTOMER_SIDE_OF_BOOKS_AND_IS_CROSS_MARGINED), // this AccountType is required
             new QuickFix.ClearingBusinessDate(getDate()),                                                     // limits the scope to the current day, still max of 300 records
             new QuickFix.TransactTime()
             );
         req.set(subscriptionType); // set the subscription type
         // send to the API
         send(req, session);
         // change whether these requests will be sent based on whether the current report is the last requested
         newAccountReq = !report.getLastRptRequested().getValue();
     }
     // fire an event that a collateral report is updated
     if (this.messageRecieved != null)
     {
         this.messageRecieved(report);
     }
 }
예제 #2
0
 /**
  * Update the DataGridView based on the given CollateralReport, thread-safe
  */
 public void update(QuickFix44.CollateralReport report)
 {
     if (grdAccounts.InvokeRequired)
     {
         updateCallback d = new updateCallback(update);
         this.Invoke(d, new object[] { report });
     }
     else
     {
         QuickFix.Account account = report.getAccount();
         double           balance = 0D, used = 0D;
         // try to set the balance and used margin values from the report, if they exist
         try
         {
             balance = report.getEndCash().getValue();
             used    = report.getDouble(9038); // FXCMUsedMargin
         }
         catch (Exception e) {}
         // if the account is already in the DataGridView
         if (map.ContainsKey(account))
         {
             // update the cells with the values that changed
             DataGridViewRow row = grdAccounts.Rows[map[account]];
             row.Cells["Balance"].Value    = balance;
             row.Cells["UsedMargin"].Value = used;
         }
         else // otherwise add it to the DataGridView
         {
             map.Add(account, map.Count);
             grdAccounts.Rows.Add(
                 account.getValue(),
                 balance,
                 used
                 );
         }
         // force the interface to refresh
         Application.DoEvents();
     }
 }