Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Commission value?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Commission value?

    It appears that:
    Code:
    LastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1];
    
    Commission = LastTrade.Commission;
    ​
    When a partial order is filled, it will report the commission of the last trade of the partial fill. So if the order is for 20 contracts (MES, comission is $24.40) and 19 are partially filled, then the last trade is 1 contract (MES comission is $1.22) then the above code will return a comission of $1.22.

    What I would like to get instead is the comission of the entire order of 20 contracts.

    Currently I'm using this code:
    Code:
    protected override void OnPositionUpdate(Position position, double averagePrice, int quantity, MarketPosition marketPosition)
    
    {
    
    if (Position.MarketPosition == MarketPosition.Flat && SystemPerformance.AllTrades.Count > 0)
    
    {
    
    if (Position.MarketPosition == MarketPosition.Flat && SystemPerformance.AllTrades.Count > 0)
    
    {
    
    if (Position.Instrument.FullName == Instrument.FullName)
    
    {
    
    string OrderAction = "";
    
    string OrderType = "";
    
    double EntryPrice = 0;
    
    double ExitPrice = 0;
    
    double GrossProfit = 0;
    
    double NetProfit = 0;
    
    double Commission = 0;
    
    double Fees = 0;
    
    Trade LastTrade;
    
    
    
    // Get commission for the order/position
    
    LastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1];
    
    Commission = LastTrade.Commission;
    ​

    #2
    Hello Skechers,

    Thank you for your post.

    When an order is partially filled, it is a separate Trade in the TradeCollection. You are getting the commission of the last trade of the partial fill because you are only working with LastTrade.Commission. If you want all commissions for the separate partial fills added together, you may need to modify your code to evaluate multiple trade objects and not just the last trade. You may verify what values and quantities you are working with by adding prints, such as printing the count to get the number of trades in the collection (SystemPerformance.AllTrades.Count) as well as printing a trade ToString(), like LastTrade.ToString(). For more details on Trade objects, TradeCollection, and SystemPerformance.AllTrades, please see the links below:Please let us know if we may be of further assistance.

    Comment


      #3
      How do I access the comission value for 1 contract?

      Thanks!

      Comment


        #4
        Hello Skechers,

        Thank you for your reply.

        Getting a commission value from an instrument is not currently supported. I can add your vote to feature request SFT-1645. If this feature is included in a future release, it will be listed in the release notes:


        That said, there is some code that is not documented in the help guide that you could try as mentioned here:


        Please let us know if we may be of further assistance.

        Comment


          #5
          Many Thanks Emily!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          71 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          143 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          76 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          47 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          51 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X