/// <summary> /// Print accounts table /// </summary> /// <param name="session"></param> private static void PrintCommissionDetails(O2GSession session, SampleParams sampleParams) { //wait until commissions related information will be loaded O2GCommissionsProvider commissionProvider = session.getCommissionsProvider(); while (commissionProvider.getStatus() == O2GCommissionStatus.CommissionStatusLoading) { System.Threading.Thread.Sleep(1000); } if (commissionProvider.getStatus() != O2GCommissionStatus.CommissionStatusReady) { throw new Exception("Could not calculate the estimated commissions."); } //retrieve the required parameter values from the sampleParams O2GAccountRow account = GetAccount(session, sampleParams.AccountID); O2GOfferRow offer = GetOffer(session, sampleParams.Instrument); if (offer == null || account == null) { throw new Exception("Incorrect input parameters."); } O2GCommissionDescriptionsCollection commList = commissionProvider.getCommissionDescriptions(offer.OfferID, account.ATPID); foreach (O2GCommissionDescription descr in commList) { Console.WriteLine("Commission : {0}, {1}, {2}", descr.Stage, descr.UnitType, descr.CommissionValue); } }
/// <summary> /// Print estimates trading commissions /// </summary> private static void printEstimatedTradingCommissions(O2GSession session, O2GOfferTableRow offer, O2GAccountTableRow account, int iAmount, string sBuySell) { //wait until commissions related information will be loaded O2GCommissionsProvider commissionProvider = session.getCommissionsProvider(); while (commissionProvider.getStatus() == O2GCommissionStatus.CommissionStatusLoading) { System.Threading.Thread.Sleep(1000); } if (commissionProvider.getStatus() != O2GCommissionStatus.CommissionStatusReady) { throw new Exception("Could not calculate the estimated commissions."); } //calculate commissions Console.WriteLine("Commission for open the position is {0}.", commissionProvider.calcOpenCommission(offer, account, iAmount, sBuySell, 0)); Console.WriteLine("Commission for close the position is {0}.", commissionProvider.calcCloseCommission(offer, account, iAmount, sBuySell, 0)); Console.WriteLine("Total commission for open and close the position is {0}.", commissionProvider.calcTotalCommission(offer, account, iAmount, sBuySell, 0, 0)); }