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@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...");
DecisionRequest request = new DecisionRequest();
subscribeToCandleStream(
new InstrumentSpecification(new Symbol("^GSPC")),
TimeFrame.TIMEFRAME_1_DAY );
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 = 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 = 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@gmail.com
> ccapi@activestocks.de <mailto:ccapi@activestocks.de>> <mailto:canterburry@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