Not logged in
Viewing 4 posts - 1 through 4 (of 4 total)
  • #114485|
    Customer
    447 Posts
    package com.strategyquant.extend.WhatIf;
    import java.util.Date;
    import java.util.Iterator;
    import com.strategyquant.lib.snippets.WhatIf;
    import com.strategyquant.lib.results.SQOrderList;
    import com.strategyquant.lib.results.SQOrder;
    import com.strategyquant.lib.time.SQTime;
    
    public class RemoveTradesPriorYYYY extends WhatIf {
    
    	public RemoveTradesPriorYYYY() {
    		setName("RemoveTradesPriorYYYY");
    
    
    
             addIntParameter("Year", "Year", 2003, 1, Integer.MAX_VALUE, 1);
    
    
            // set name of this method that will be displayed with parameter(s)
    		setFormatedName("Remove trades prior to {Year}");
    	}
    	
    	/**
    	 * Function receives list of all orders sorted by open time and it could manipulate 
    	 * the list and remove any order that matches certain filter from the list.     
    	 * 
    	 * Order structure is available in the documentation here:
    	 * http://www.strategyquant.com/doc/api/com/strategyquant/lib/results/SQOrder.html
    	 *
    	 * @param originalOrders - list of original orders that can be changed. Each order has the order properties specified above
    	 */    
    	@Override
    	public void filter(SQOrderList originalOrders) throws Exception {
    		int parameter = getIntParameterValue("Year");
    int  currentYear;	
    		for(Iterator<SQOrder> i = originalOrders.listIterator(); i.hasNext();) {
    			SQOrder order = i.next();
    			
    			// todo - your custom action
    			// orders can be skipped or manipulated here
      SQTime dateTime = new SQTime(order.OpenTime); //order.CloseTime
    
      currentYear = dateTime.getFullYear();
      if(currentYear < parameter) { 
        i.remove();
      }
    
           
    		}			
    	}
    }
    
    
    #134243
    Customer
    62 Posts

    Notch, thanks for the snippet. Maybe it will help to somebody :)

     

    Tomas

    #134249
    Customer
    243 Posts

    Excellent Notch.
    Tamas may i ask you? In next update of QA dou you have plans to upgrade logging process? Something like console/output for reading data ? Better then java logger4?

    #134293
    Customer
    62 Posts

    Hello clonex,

     

    yes, “Debug Console” will be in the next update. Thanks for the idea ;)

     

    Best regards,

    Tomas

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.