<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Mike,<br>
<br>
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.<br>
<br>
I'll remove my broker setter too.<br>
<br>
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. <br>
<br>
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.<br>
<br>
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. <br>
<br>
HC<br>
<br>
<br>
Mike Kroutikov wrote:
<blockquote
 cite="mid:e2d72d830801182130g19f6fadbk5599345ba6a7b898@mail.gmail.com"
 type="cite">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?).<br>
  <br>
Please, update from the head: TradeSystemBase has been changed
slightly: rename your start()/stop() to onStart()/onStop().
  <br>
  <br>
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.... <br>
  <br>
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.
  <br>
  <br>
Thanks for using this, and especially for the choice to live
dangerously! You comments, feedback, and contributions are very needed.<br>
  <br>
-Mike<br>
  <br>
  <div class="gmail_quote">On Jan 18, 2008 10:24 PM, Henry Canterburry
&lt;
  <a moz-do-not-send="true" href="mailto:canterburry@gmail.com">canterburry@gmail.com</a>&gt;
wrote:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Mike...yes...I
do live dangerously but it's because I see all the good
    <br>
things you guys are cranking out and I don't want to miss out on the<br>
latest. I am seeing however how it causes me headaches tho :-)<br>
    <br>
Yes, I am using the TradeSystemBase from simple and I primarily based
my
    <br>
strategy off of SampleTradeSystem:<br>
    <br>
@TradeSystem<br>
public class RuleBaseTradeSystem extends TradeSystemBase {<br>
    <br>
   private String[] ruleFiles;<br>
   private String[] flowFiles;<br>
   private StatefulEngine engine;
    <br>
   private String description;<br>
   private String name;<br>
   private String flowID;<br>
    <br>
   private Account account;<br>
   @Inject<br>
   private IStoreService storeService;<br>
    <br>
   private IBroker broker;
    <br>
    <br>
   @Inject(name="broker")<br>
   public void setBroker(IBroker broker) {<br>
       this.broker = broker;<br>
   }<br>
    <br>
   @Start<br>
   public void start() throws Exception {<br>
    <br>
       log.info
("start(): RuleBaseTradeSystem started...");<br>
    <div class="Ih2E3d"><br>
       subscribeToCandleStream(<br>
               new InstrumentSpecification(new Symbol("^GSPC")),<br>
               TimeFrame.TIMEFRAME_1_DAY
);<br>
    <br>
    </div>
       DecisionRequest request = new DecisionRequest();<br>
       request.addRequestObject("account", account);<br>
       request.addRequestObject("orders", new<br>
NamedCollection&lt;Order&gt;("orders"));
    <br>
       request.addRequestObject("constraints", new<br>
NamedCollection&lt;OrderConstraint&gt;("constraints"));<br>
       request.setRuleflowID(this.flowID);<br>
    <br>
       DecisionResponse response = engine.execute(request);<br>
   }<br>
    <br>
   public void setAccount(Account account) {<br>
       this.account = account;<br>
   }<br>
    <br>
   public RuleBaseTradeSystem(String name,<br>
           String description,<br>
           String[] ruleFiles) throws Exception {
    <br>
    <br>
       <a moz-do-not-send="true" href="http://this.name" target="_blank">this.name</a>
= name;<br>
       this.description = description;<br>
       this.ruleFiles = ruleFiles;<br>
       this.engine =<br>
RuleServiceFactory.getInstance
().newStatefulEngine(ruleFiles);<br>
   }<br>
    <br>
   public RuleBaseTradeSystem(String name,<br>
           String description,<br>
           String[] ruleFiles,<br>
           String[] ruleFlowFiles,<br>
           String flowID) throws Exception {
    <br>
    <br>
       <a moz-do-not-send="true" href="http://this.name" target="_blank">this.name</a>
= name;<br>
       this.description = description;<br>
       this.ruleFiles = ruleFiles;<br>
       this.flowFiles = ruleFlowFiles;<br>
       this.engine =<br>
RuleServiceFactory.getInstance().newStatefulEngine(ruleFiles,<br>
ruleFlowFiles);<br>
       this.flowID = flowID;<br>
   }<br>
    <br>
   public String getDescription() {<br>
       return description;<br>
   }<br>
    <br>
   public String getName() {
    <br>
       return name;<br>
   }<br>
    <br>
    <br>
   @Override<br>
   public void onCandle(Candle candle) throws Exception {<br>
       this.engine.onCandle(candle);<br>
   }<br>
    <br>
    <br>
   @Override<br>
   public void onQuote(Quote quote) throws Exception {
    <br>
       this.engine.onQuote(quote);<br>
   }<br>
    <br>
    <br>
    <br>
   @Override<br>
   public void stop() {<br>
       super.stop();<br>
       destroy();<br>
   }<br>
    <br>
   public void destroy(){<br>
       this.engine.destroy
();<br>
       this.engine = null;<br>
    <div class="Ih2E3d">    }<br>
    <br>
    <br>
    <br>
}<br>
    <br>
Mike Kroutikov wrote:<br>
&gt; Henry, you like to live dangerously :). This stuff is 1 day old.
Not<br>
&gt; even discussed/approved.<br>
&gt;<br>
&gt; Are you using base class for your TS? If yes, which one? Did you
just<br>
&gt; re-worked "SampleTradeSystem" ?<br>
&gt;<br>
&gt; -Mike<br>
&gt;<br>
&gt; On Jan 18, 2008 4:04 PM, Henry Canterburry &lt;<a
 moz-do-not-send="true" href="mailto:canterburry@gmail.com">
canterburry@gmail.com</a><br>
    </div>
    <div>
    <div class="Wj3C7c">&gt; &lt;mailto:<a moz-do-not-send="true"
 href="mailto:canterburry@gmail.com">canterburry@gmail.com</a>&gt;&gt;
wrote:<br>
&gt;<br>
&gt;     I have refactored my working back testing strategy into the
new
    <br>
&gt;     HEAD TradeSystem implementation. I looked at the
SampleTradeSystem<br>
&gt;     and configuration to derive this.<br>
&gt;<br>
&gt;     I have created a new DaoCandleIteratatorSource to pull quotes
from<br>
&gt;     the DB and "stream" them. This seems to be working, I see data
    <br>
&gt;     being passed from my tables when I debug. The @Start method in
my<br>
&gt;     strategy is called, however, the onCandle method in my strategy<br>
&gt;     isn't being called at all even though the context iterates
over my
    <br>
&gt;     DaoCandeIteratorSource and pulls Candles.<br>
&gt;<br>
&gt;     I do have this statement in my start():<br>
&gt;<br>
&gt;         subscribeToCandleStream(<br>
&gt;                     new InstrumentSpecification(new
Symbol("^GSPC")),
    <br>
&gt;                     TimeFrame.TIMEFRAME_1_DAY);<br>
&gt;<br>
&gt;     Any ideas?<br>
&gt;<br>
&gt;     Thanks<br>
&gt;     HC<br>
&gt;<br>
&gt;     Here is my configuration file (I also have a stand alone
strategy<br>
&gt;     config file with just my strategy defined in it):
    <br>
&gt;     &lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>
&gt;     &lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"<br>
&gt;     "<a moz-do-not-send="true"
 href="http://www.springframework.org/dtd/spring-beans-2.0.dtd"
 target="_blank">
http://www.springframework.org/dtd/spring-beans-2.0.dtd</a>"<br>
&gt;     &lt;<a moz-do-not-send="true"
 href="http://www.springframework.org/dtd/spring-beans-2.0.dtd"
 target="_blank">http://www.springframework.org/dtd/spring-beans-2.0.dtd</a>
&gt;&gt;<br>
&gt;     &lt;beans&gt;<br>
&gt;<br>
&gt;<br>
&gt;         &lt;bean id="broker"
class="org.activequant.broker2.MockBroker" /&gt;<br>
&gt;         &lt;bean id="reportingService"<br>
&gt;     class="
org.activequant.container.report.MockReportingService" /&gt;<br>
&gt;         &lt;bean id="storeService"<br>
&gt;     class="org.activequant.util.store.MockStore" /&gt;<br>
&gt;<br>
&gt;         &lt;!--  DATA ACCESS --&gt;
    <br>
&gt;         &lt;bean<br>
&gt;    
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;<br>
&gt;             &lt;property name="locations"&gt;<br>
&gt;                 &lt;list&gt;
    <br>
&gt;<br>
&gt;    
&lt;value&gt;classpath:data/database/database.properties&lt;/value&gt;<br>
&gt;<br>
&gt;    
&lt;value&gt;classpath:application/backtest/exits/config.properties&lt;/value&gt;<br>
&gt;                 &lt;/list&gt;
    <br>
&gt;             &lt;/property&gt;<br>
&gt;         &lt;/bean&gt;<br>
&gt;         &lt;import
resource="classpath:dao/hibernate/dao-hibernate.xml"/&gt;<br>
&gt;         &lt;bean id="candleSeriesSource"
    <br>
&gt;    
class="org.activequant.data.retrieval.integration.series.DaoCandleIteratorSource"&gt;<br>
&gt;             &lt;constructor-arg ref="candleDao"/&gt;<br>
&gt;         &lt;/bean&gt;<br>
&gt;         &lt;!--  DATA ACCESS END --&gt;
    <br>
&gt;<br>
&gt;         &lt;bean id="default"<br>
&gt;     class="org.activequant.container.context.DefaultBeanList"&gt;<br>
&gt;             &lt;constructor-arg ref="broker" /&gt;<br>
&gt;         &lt;/bean&gt;
    <br>
&gt;<br>
&gt;         &lt;!-- REPLAY --&gt;<br>
&gt;         &lt;bean id="replayService"<br>
&gt;     class="org.activequant.data.util.MarketDataReplayService" &gt;<br>
&gt;             &lt;property name="candleSeriesDataSource"
    <br>
&gt;     ref="candleSeriesSource" /&gt;<br>
&gt;             &lt;property name="startTimeStamp"
value="20071205"/&gt;<br>
&gt;             &lt;property name="endTimeStamp" value="20071211"/&gt;
    <br>
&gt;         &lt;/bean&gt;<br>
&gt;         &lt;bean id="runner"<br>
&gt;     class="org.activequant.container.context.BacktestRunner"&gt;<br>
&gt;             &lt;constructor-arg ref="replayService" /&gt;
    <br>
&gt;         &lt;/bean&gt;<br>
&gt;         &lt;!-- REPLAY END --&gt;<br>
&gt;<br>
&gt;         &lt;!-- ACCOUNT --&gt;<br>
&gt;         &lt;bean id="accountDao"<br>
&gt;     class="org.activequant.dao.mock.MockAccountDao
" /&gt;<br>
&gt;         &lt;bean id="accountLookup"<br>
&gt;     class="org.activequant.util.spring.AccountLookup"&gt;<br>
&gt;             &lt;property name="accountDao" ref="accountDao"/&gt;
    <br>
&gt;             &lt;property name="accountId" value="1"/&gt;<br>
&gt;         &lt;/bean&gt;<br>
&gt;         &lt;!--  ACCOUNT END --&gt;<br>
&gt;<br>
&gt;         &lt;bean id="replayService.candleSubscriptionSource
"<br>
&gt;    
class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/&gt;<br>
&gt;     &lt;/beans&gt;<br>
&gt;<br>
&gt;     _______________________________________________<br>
&gt;     ccapi mailing list
    <br>
    </div>
    </div>
&gt;     <a moz-do-not-send="true" href="mailto:ccapi@activestocks.de">ccapi@activestocks.de</a>
&lt;mailto:<a moz-do-not-send="true" href="mailto:ccapi@activestocks.de">ccapi@activestocks.de</a>&gt;<br>
    <div>
    <div class="Wj3C7c">&gt;     <a moz-do-not-send="true"
 href="http://activestocks.de/cgi-bin/mailman/listinfo/ccapi"
 target="_blank">
http://activestocks.de/cgi-bin/mailman/listinfo/ccapi</a><br>
&gt;<br>
&gt;<br>
    <br>
    </div>
    </div>
  </blockquote>
  </div>
  <br>
</blockquote>
<br>
</body>
</html>