<!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
<
<a moz-do-not-send="true" href="mailto:canterburry@gmail.com">canterburry@gmail.com</a>>
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<Order>("orders"));
<br>
request.addRequestObject("constraints", new<br>
NamedCollection<OrderConstraint>("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>
> Henry, you like to live dangerously :). This stuff is 1 day old.
Not<br>
> even discussed/approved.<br>
><br>
> Are you using base class for your TS? If yes, which one? Did you
just<br>
> re-worked "SampleTradeSystem" ?<br>
><br>
> -Mike<br>
><br>
> On Jan 18, 2008 4:04 PM, Henry Canterburry <<a
moz-do-not-send="true" href="mailto:canterburry@gmail.com">
canterburry@gmail.com</a><br>
</div>
<div>
<div class="Wj3C7c">> <mailto:<a moz-do-not-send="true"
href="mailto:canterburry@gmail.com">canterburry@gmail.com</a>>>
wrote:<br>
><br>
> I have refactored my working back testing strategy into the
new
<br>
> HEAD TradeSystem implementation. I looked at the
SampleTradeSystem<br>
> and configuration to derive this.<br>
><br>
> I have created a new DaoCandleIteratatorSource to pull quotes
from<br>
> the DB and "stream" them. This seems to be working, I see data
<br>
> being passed from my tables when I debug. The @Start method in
my<br>
> strategy is called, however, the onCandle method in my strategy<br>
> isn't being called at all even though the context iterates
over my
<br>
> DaoCandeIteratorSource and pulls Candles.<br>
><br>
> I do have this statement in my start():<br>
><br>
> subscribeToCandleStream(<br>
> new InstrumentSpecification(new
Symbol("^GSPC")),
<br>
> TimeFrame.TIMEFRAME_1_DAY);<br>
><br>
> Any ideas?<br>
><br>
> Thanks<br>
> HC<br>
><br>
> Here is my configuration file (I also have a stand alone
strategy<br>
> config file with just my strategy defined in it):
<br>
> <?xml version="1.0" encoding="UTF-8"?><br>
> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"<br>
> "<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>
> <<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>
> <beans><br>
><br>
><br>
> <bean id="broker"
class="org.activequant.broker2.MockBroker" /><br>
> <bean id="reportingService"<br>
> class="
org.activequant.container.report.MockReportingService" /><br>
> <bean id="storeService"<br>
> class="org.activequant.util.store.MockStore" /><br>
><br>
> <!-- DATA ACCESS -->
<br>
> <bean<br>
>
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><br>
> <property name="locations"><br>
> <list>
<br>
><br>
>
<value>classpath:data/database/database.properties</value><br>
><br>
>
<value>classpath:application/backtest/exits/config.properties</value><br>
> </list>
<br>
> </property><br>
> </bean><br>
> <import
resource="classpath:dao/hibernate/dao-hibernate.xml"/><br>
> <bean id="candleSeriesSource"
<br>
>
class="org.activequant.data.retrieval.integration.series.DaoCandleIteratorSource"><br>
> <constructor-arg ref="candleDao"/><br>
> </bean><br>
> <!-- DATA ACCESS END -->
<br>
><br>
> <bean id="default"<br>
> class="org.activequant.container.context.DefaultBeanList"><br>
> <constructor-arg ref="broker" /><br>
> </bean>
<br>
><br>
> <!-- REPLAY --><br>
> <bean id="replayService"<br>
> class="org.activequant.data.util.MarketDataReplayService" ><br>
> <property name="candleSeriesDataSource"
<br>
> ref="candleSeriesSource" /><br>
> <property name="startTimeStamp"
value="20071205"/><br>
> <property name="endTimeStamp" value="20071211"/>
<br>
> </bean><br>
> <bean id="runner"<br>
> class="org.activequant.container.context.BacktestRunner"><br>
> <constructor-arg ref="replayService" />
<br>
> </bean><br>
> <!-- REPLAY END --><br>
><br>
> <!-- ACCOUNT --><br>
> <bean id="accountDao"<br>
> class="org.activequant.dao.mock.MockAccountDao
" /><br>
> <bean id="accountLookup"<br>
> class="org.activequant.util.spring.AccountLookup"><br>
> <property name="accountDao" ref="accountDao"/>
<br>
> <property name="accountId" value="1"/><br>
> </bean><br>
> <!-- ACCOUNT END --><br>
><br>
> <bean id="replayService.candleSubscriptionSource
"<br>
>
class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/><br>
> </beans><br>
><br>
> _______________________________________________<br>
> ccapi mailing list
<br>
</div>
</div>
> <a moz-do-not-send="true" href="mailto:ccapi@activestocks.de">ccapi@activestocks.de</a>
<mailto:<a moz-do-not-send="true" href="mailto:ccapi@activestocks.de">ccapi@activestocks.de</a>><br>
<div>
<div class="Wj3C7c">> <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>
><br>
><br>
<br>
</div>
</div>
</blockquote>
</div>
<br>
</blockquote>
<br>
</body>
</html>