[rules-users] Re: [ccapi] Trying out the new TradeSystem...onCandle isnt being called

Henry Canterburry canterburry at gmail.com
Sat Jan 19 02:00:07 EST 2008


Mike,

Yup...I saw earlier that start had become final so I changed it to setup 
and terminate which you commented should be extended. I also removed the 
@Start annotation and are not observing any duplicate activation.

I'll remove my broker setter too.

As I was mentioning to Eric earlier, I would really like to see some 
interfaces for TradeSystem....not just a base class. Maybe the number of 
interfaces prior to the last refactoring was a bit excessive, but having 
no interfaces I don't think is a good idea.

I just migrated to using the SeriesSourceToIterator... data util but 
that seems not to have fixed my earlier problem of onCandle not being 
called. Didn't see this functionality so I wrote that iterator. There is 
so much functionality lying around AQ that I have no clue what it really 
does.

As to my trade system...you can essentially ignore any of the engine 
stuff...I think it would be a perfectly valid test if you simply 
commented out anything rule engine related in that system class and put 
in sysouts instead. I actually tried that already to see if any of the 
engine setup was causing the problem but I observe the same behavior 
when the class essentially does nothing. The onCandle method is still 
not being called. I was looking at all the different java contexts in 
the samples but couldn't figure out what would make a difference. Would 
it matter how I load the system? I use the SpringContextBuilder.build 
and pass a factory file and then call start on the context.

HC


Mike Kroutikov wrote:
> Its most likely a context problem... I will get to it shortly. If you 
> can provide a simpler reproduction, that would be helpful (i.e. maybe 
> SampleTradeSystem with just few changes?).
>
> Please, update from the head: TradeSystemBase has been changed 
> slightly: rename your start()/stop() to onStart()/onStop().
>
> minor thing: you can just use brokerService from the base class, no 
> need to request it second time... unless you need it as a setter 
> elsewhere....
>
> And be careful with @Start annotation: AQ context will execute *all* 
> methods annotated with @Start, even if one routes control to another. 
> So when you switch to "onStart()", make sure you do not annotate it.
>
> Thanks for using this, and especially for the choice to live 
> dangerously! You comments, feedback, and contributions are very needed.
>
> -Mike
>
> On Jan 18, 2008 10:24 PM, Henry Canterburry < canterburry at gmail.com 
> <mailto:canterburry at gmail.com>> wrote:
>
>     Mike...yes...I do live dangerously but it's because I see all the
>     good
>     things you guys are cranking out and I don't want to miss out on the
>     latest. I am seeing however how it causes me headaches tho :-)
>
>     Yes, I am using the TradeSystemBase from simple and I primarily
>     based my
>     strategy off of SampleTradeSystem:
>
>     @TradeSystem
>     public class RuleBaseTradeSystem extends TradeSystemBase {
>
>        private String[] ruleFiles;
>        private String[] flowFiles;
>        private StatefulEngine engine;
>        private String description;
>        private String name;
>        private String flowID;
>
>        private Account account;
>        @Inject
>        private IStoreService storeService;
>
>        private IBroker broker;
>
>        @Inject(name="broker")
>        public void setBroker(IBroker broker) {
>            this.broker = broker;
>        }
>
>        @Start
>        public void start() throws Exception {
>
>            log.info ("start(): RuleBaseTradeSystem started...");
>
>            subscribeToCandleStream(
>                    new InstrumentSpecification(new Symbol("^GSPC")),
>                    TimeFrame.TIMEFRAME_1_DAY );
>
>            DecisionRequest request = new DecisionRequest();
>            request.addRequestObject("account", account);
>            request.addRequestObject("orders", new
>     NamedCollection<Order>("orders"));
>            request.addRequestObject("constraints", new
>     NamedCollection<OrderConstraint>("constraints"));
>            request.setRuleflowID(this.flowID);
>
>            DecisionResponse response = engine.execute(request);
>        }
>
>        public void setAccount(Account account) {
>            this.account = account;
>        }
>
>        public RuleBaseTradeSystem(String name,
>                String description,
>                String[] ruleFiles) throws Exception {
>
>            this.name <http://this.name> = name;
>            this.description = description;
>            this.ruleFiles = ruleFiles;
>            this.engine =
>     RuleServiceFactory.getInstance ().newStatefulEngine(ruleFiles);
>        }
>
>        public RuleBaseTradeSystem(String name,
>                String description,
>                String[] ruleFiles,
>                String[] ruleFlowFiles,
>                String flowID) throws Exception {
>
>            this.name <http://this.name> = name;
>            this.description = description;
>            this.ruleFiles = ruleFiles;
>            this.flowFiles = ruleFlowFiles;
>            this.engine =
>     RuleServiceFactory.getInstance().newStatefulEngine(ruleFiles,
>     ruleFlowFiles);
>            this.flowID = flowID;
>        }
>
>        public String getDescription() {
>            return description;
>        }
>
>        public String getName() {
>            return name;
>        }
>
>
>        @Override
>        public void onCandle(Candle candle) throws Exception {
>            this.engine.onCandle(candle);
>        }
>
>
>        @Override
>        public void onQuote(Quote quote) throws Exception {
>            this.engine.onQuote(quote);
>        }
>
>
>
>        @Override
>        public void stop() {
>            super.stop();
>            destroy();
>        }
>
>        public void destroy(){
>            this.engine.destroy ();
>            this.engine = null;
>        }
>
>
>
>     }
>
>     Mike Kroutikov wrote:
>     > Henry, you like to live dangerously :). This stuff is 1 day old. Not
>     > even discussed/approved.
>     >
>     > Are you using base class for your TS? If yes, which one? Did you
>     just
>     > re-worked "SampleTradeSystem" ?
>     >
>     > -Mike
>     >
>     > On Jan 18, 2008 4:04 PM, Henry Canterburry <
>     canterburry at gmail.com <mailto:canterburry at gmail.com>
>     > <mailto:canterburry at gmail.com <mailto:canterburry at gmail.com>>>
>     wrote:
>     >
>     >     I have refactored my working back testing strategy into the new
>     >     HEAD TradeSystem implementation. I looked at the
>     SampleTradeSystem
>     >     and configuration to derive this.
>     >
>     >     I have created a new DaoCandleIteratatorSource to pull
>     quotes from
>     >     the DB and "stream" them. This seems to be working, I see data
>     >     being passed from my tables when I debug. The @Start method
>     in my
>     >     strategy is called, however, the onCandle method in my strategy
>     >     isn't being called at all even though the context iterates
>     over my
>     >     DaoCandeIteratorSource and pulls Candles.
>     >
>     >     I do have this statement in my start():
>     >
>     >         subscribeToCandleStream(
>     >                     new InstrumentSpecification(new
>     Symbol("^GSPC")),
>     >                     TimeFrame.TIMEFRAME_1_DAY);
>     >
>     >     Any ideas?
>     >
>     >     Thanks
>     >     HC
>     >
>     >     Here is my configuration file (I also have a stand alone
>     strategy
>     >     config file with just my strategy defined in it):
>     >     <?xml version="1.0" encoding="UTF-8"?>
>     >     <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
>     >     " http://www.springframework.org/dtd/spring-beans-2.0.dtd"
>     >     <http://www.springframework.org/dtd/spring-beans-2.0.dtd >>
>     >     <beans>
>     >
>     >
>     >         <bean id="broker"
>     class="org.activequant.broker2.MockBroker" />
>     >         <bean id="reportingService"
>     >     class="
>     org.activequant.container.report.MockReportingService" />
>     >         <bean id="storeService"
>     >     class="org.activequant.util.store.MockStore" />
>     >
>     >         <!--  DATA ACCESS -->
>     >         <bean
>     >    
>     class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
>     >             <property name="locations">
>     >                 <list>
>     >
>     >     <value>classpath:data/database/database.properties</value>
>     >
>     >    
>     <value>classpath:application/backtest/exits/config.properties</value>
>     >                 </list>
>     >             </property>
>     >         </bean>
>     >         <import
>     resource="classpath:dao/hibernate/dao-hibernate.xml"/>
>     >         <bean id="candleSeriesSource"
>     >    
>     class="org.activequant.data.retrieval.integration.series.DaoCandleIteratorSource">
>     >             <constructor-arg ref="candleDao"/>
>     >         </bean>
>     >         <!--  DATA ACCESS END -->
>     >
>     >         <bean id="default"
>     >     class="org.activequant.container.context.DefaultBeanList">
>     >             <constructor-arg ref="broker" />
>     >         </bean>
>     >
>     >         <!-- REPLAY -->
>     >         <bean id="replayService"
>     >     class="org.activequant.data.util.MarketDataReplayService" >
>     >             <property name="candleSeriesDataSource"
>     >     ref="candleSeriesSource" />
>     >             <property name="startTimeStamp" value="20071205"/>
>     >             <property name="endTimeStamp" value="20071211"/>
>     >         </bean>
>     >         <bean id="runner"
>     >     class="org.activequant.container.context.BacktestRunner">
>     >             <constructor-arg ref="replayService" />
>     >         </bean>
>     >         <!-- REPLAY END -->
>     >
>     >         <!-- ACCOUNT -->
>     >         <bean id="accountDao"
>     >     class="org.activequant.dao.mock.MockAccountDao " />
>     >         <bean id="accountLookup"
>     >     class="org.activequant.util.spring.AccountLookup">
>     >             <property name="accountDao" ref="accountDao"/>
>     >             <property name="accountId" value="1"/>
>     >         </bean>
>     >         <!--  ACCOUNT END -->
>     >
>     >         <bean id="replayService.candleSubscriptionSource "
>     >    
>     class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
>     >     </beans>
>     >
>     >     _______________________________________________
>     >     ccapi mailing list
>     >     ccapi at activestocks.de <mailto:ccapi at activestocks.de>
>     <mailto:ccapi at activestocks.de <mailto:ccapi at activestocks.de>>
>     >     http://activestocks.de/cgi-bin/mailman/listinfo/ccapi
>     >
>     >
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080119/1bdd95e6/attachment.html 


More information about the rules-users mailing list