Strategy Agent Java Class

3 messages Options
Embed this post
Permalink
RelativeLogic

Strategy Agent Java Class

Reply Threaded More More options
Print post
Permalink
I am looking for help with the java implementation of the Strategy Agent.  The Ruby classes run fine on my machine with v1.0.0.  I am trying to reproduce the MarketData.rb behavior with a MarketData.java class.  My code looks like this:

import org.marketcetera.strategy.java.Strategy;
class MarketData extends Strategy
{
    String Symbols = "INTC";
    String MarketDataProvider = "marketcetera";
    public void onStart()
    {
        requestMarketData(Symbols,MarketDataProvider);
    }
    public void onStop()
    {
    }
    public void onBid(org.marketcetera.event.BidEvent inBid)
    {
        System.out.println("Bid: " + inBid.toString());
    }
    public void onAsk(org.marketcetera.event.AskEvent inAsk)
    {
        System.out.println("Ask: " + inAsk.toString());
    }
}

In the ultimate implementation these values will be loaded into a MySQL DB and used for backtesting.  Do you see anything wrong with this class?  

Thank you,

Walter
Colin DuPlantis-2

Re: Strategy Agent Java Class

Reply Threaded More More options
Print post
Permalink
Should work fine if you make MarketData public.  The way the strategy
executor is currently set up requires reflection and doesn't override
the default protections.

Also, make sure that you start the market data provider in your Strategy
Agent command files.

RelativeLogic wrote:

> I am looking for help with the java implementation of the Strategy Agent.
> The Ruby classes run fine on my machine with v1.0.0.  I am trying to
> reproduce the MarketData.rb behavior with a MarketData.java class.  My code
> looks like this:
>
> import org.marketcetera.strategy.java.Strategy;
> class MarketData extends Strategy
> {
>     String Symbols = "INTC";
>     String MarketDataProvider = "marketcetera";
>     public void onStart()
>     {
>         requestMarketData(Symbols,MarketDataProvider);
>     }
>     public void onStop()
>     {
>     }
>     public void onBid(org.marketcetera.event.BidEvent inBid)
>     {
>         System.out.println("Bid: " + inBid.toString());
>     }
>     public void onAsk(org.marketcetera.event.AskEvent inAsk)
>     {
>         System.out.println("Ask: " + inAsk.toString());
>     }
> }
>
> In the ultimate implementation these values will be loaded into a MySQL DB
> and used for backtesting.  Do you see anything wrong with this class?  
>
> Thank you,
>
> Walter

_______________________________________________
m-etc-dev mailing list
[hidden email]
http://lists.marketcetera.org/mailman/listinfo/m-etc-dev_lists.marketcetera.org
toli

Re: Strategy Agent Java Class

Reply Threaded More More options
Print post
Permalink
In reply to this post by RelativeLogic
Walter,

Sorry for the delay - your email sat in the moderator approval queue
since you weren't a member.

I've tried the script you submitted and it worked fine - the only
change was to make the entire class public:
public class MarketData extends Strategy

I just modified the existing sample samples/commands/MarketData.txt
script to use the Java strategy and it worked:
createModule;metc:strategy:system;marketData,MarketData,JAVA,samples/scripts/MarketData.java,,,metc:sink:system,metc:sink:s
ystem
# Start the market data module
startModule;metc:mdata:marketcetera:single
# Start the strategy
startModule;metc:strategy:system:marketData

Let me know if that doesn't work for you.


On Mon, Jan 5, 2009 at 12:15 PM, RelativeLogic <[hidden email]> wrote:

>
> I am looking for help with the java implementation of the Strategy Agent.
> The Ruby classes run fine on my machine with v1.0.0.  I am trying to
> reproduce the MarketData.rb behavior with a MarketData.java class.  My code
> looks like this:
>
> import org.marketcetera.strategy.java.Strategy;
> class MarketData extends Strategy
> {
>    String Symbols = "INTC";
>    String MarketDataProvider = "marketcetera";
>    public void onStart()
>    {
>        requestMarketData(Symbols,MarketDataProvider);
>    }
>    public void onStop()
>    {
>    }
>    public void onBid(org.marketcetera.event.BidEvent inBid)
>    {
>        System.out.println("Bid: " + inBid.toString());
>    }
>    public void onAsk(org.marketcetera.event.AskEvent inAsk)
>    {
>        System.out.println("Ask: " + inAsk.toString());
>    }
> }
>
> In the ultimate implementation these values will be loaded into a MySQL DB
> and used for backtesting.  Do you see anything wrong with this class?
>
> Thank you,
>
> Walter
> --
> View this message in context: http://n2.nabble.com/Strategy-Agent-Java-Class-tp2114642p2114642.html
> Sent from the m-etc-dev mailing list archive at Nabble.com.
>
>
> _______________________________________________
> m-etc-dev mailing list
> [hidden email]
> http://lists.marketcetera.org/mailman/listinfo/m-etc-dev_lists.marketcetera.org
>



--
Toli Kuznets
http://www.marketcetera.com: Open-Source Trading Platform
download.run.trade.

_______________________________________________
m-etc-dev mailing list
[hidden email]
http://lists.marketcetera.org/mailman/listinfo/m-etc-dev_lists.marketcetera.org