edu.cuny.cat.trader.strategy
Class MomentumStrategy

java.lang.Object
  extended by java.util.Observable
      extended by edu.cuny.cat.trader.strategy.AbstractStrategy
          extended by edu.cuny.cat.trader.strategy.FixedQuantityStrategyImpl
              extended by edu.cuny.cat.trader.strategy.AdaptiveStrategyImpl
                  extended by edu.cuny.cat.trader.strategy.MomentumStrategy
All Implemented Interfaces:
AuctionEventListener, AdaptiveStrategy, FixedQuantityStrategy, Strategy, edu.cuny.config.param.Parameterizable, edu.cuny.obj.Prototypeable, edu.cuny.obj.Resetable, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
PriestVanTolStrategy, ZIPStrategy, ZIQStrategy

public abstract class MomentumStrategy
extends AdaptiveStrategyImpl
implements java.io.Serializable

A trading strategy that learns to adapt the price to offer. It uses a MimicryLearner to learn a profit margin, which together with the trader's private value determines the price to offer.

It also brings randomness to some extent by perturbing the price to be offered.

Parameters

base.scaling
double >= 0 (by default 0.05)
(the maximum of perturbation on price)
base.learner
name of class, implementing MimicryLearner
(the learning algorithm to adapt price)

Default Base

momentum_strategy

Version:
$Revision: 1.25 $
Author:
Steve Phelps
See Also:
Serialized Form

Field Summary
protected  cern.jet.random.AbstractContinousDistribution absolutePerterbationDistribution
           
protected  double currentPrice
           
protected  cern.jet.random.AbstractContinousDistribution initialMarginDistribution
           
protected  Shout lastShout
           
protected  boolean lastShoutAccepted
           
protected  double lastShoutPrice
           
protected  edu.cuny.ai.learning.MimicryLearner learner
           
static java.lang.String P_DEF_BASE
           
static java.lang.String P_LEARNER
           
static java.lang.String P_SCALING
           
protected  cern.jet.random.AbstractContinousDistribution relativePerterbationDistribution
           
protected  double scaling
          A parameter used to scale the randomly drawn price adjustment perturbation values.
 
Fields inherited from class edu.cuny.cat.trader.strategy.FixedQuantityStrategyImpl
quantity
 
Fields inherited from class edu.cuny.cat.trader.strategy.AbstractStrategy
agent, currentShout, MIN_PRICE_DIFFERENCE
 
Constructor Summary
MomentumStrategy()
           
MomentumStrategy(AbstractTradingAgent agent)
           
 
Method Summary
protected abstract  void adjustMargin()
           
protected  void adjustMargin(double targetMargin)
           
protected  double calculatePrice(double margin)
           
 void eventOccurred(AuctionEvent event)
           
 double getCurrentPrice()
           
 Shout getLastShout()
           
 edu.cuny.ai.learning.Learner getLearner()
           
 double getScaling()
           
protected  void initMargin()
           
 boolean isLastShoutAccepted()
           
 boolean modifyShout(Shout.MutableShout shout)
          Modify the price and quantity of the given shout according to this strategy.
protected  double perterb(double price)
           
protected  void processDayClosed()
          if there is a shout placed as the last activity, since no more shout or transaction is coming, this last shout needs to be processed just as other shouts with following shouts were done.
protected  void processLastShout(Shout lastShout)
           
 boolean requiresAuctionHistory()
           
 void setLearner(edu.cuny.ai.learning.Learner learner)
           
 void setMargin(double margin)
           
 void setScaling(double scaling)
           
 void setup(edu.cuny.config.param.ParameterDatabase parameters, edu.cuny.config.param.Parameter base)
           
protected  void shoutPosted(ShoutPostedEvent event)
           
protected  double targetMargin(double targetPrice)
           
 java.lang.String toString()
           
protected  void transactionPosted(TransactionPostedEvent event)
           
 
Methods inherited from class edu.cuny.cat.trader.strategy.FixedQuantityStrategyImpl
determineQuantity, getQuantity, setQuantity
 
Methods inherited from class edu.cuny.cat.trader.strategy.AbstractStrategy
getAgent, initialize, modifyShout, protoClone, reset, setAgent
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.cuny.cat.trader.strategy.Strategy
determineQuantity, modifyShout, setAgent
 
Methods inherited from interface edu.cuny.obj.Prototypeable
protoClone
 
Methods inherited from interface edu.cuny.obj.Resetable
reset
 

Field Detail

learner

protected edu.cuny.ai.learning.MimicryLearner learner

currentPrice

protected double currentPrice

lastShout

protected Shout lastShout

scaling

protected double scaling
A parameter used to scale the randomly drawn price adjustment perturbation values.


lastShoutAccepted

protected boolean lastShoutAccepted

lastShoutPrice

protected double lastShoutPrice

initialMarginDistribution

protected cern.jet.random.AbstractContinousDistribution initialMarginDistribution

relativePerterbationDistribution

protected cern.jet.random.AbstractContinousDistribution relativePerterbationDistribution

absolutePerterbationDistribution

protected cern.jet.random.AbstractContinousDistribution absolutePerterbationDistribution

P_DEF_BASE

public static final java.lang.String P_DEF_BASE
See Also:
Constant Field Values

P_SCALING

public static final java.lang.String P_SCALING
See Also:
Constant Field Values

P_LEARNER

public static final java.lang.String P_LEARNER
See Also:
Constant Field Values
Constructor Detail

MomentumStrategy

public MomentumStrategy()

MomentumStrategy

public MomentumStrategy(AbstractTradingAgent agent)
Method Detail

setup

public void setup(edu.cuny.config.param.ParameterDatabase parameters,
                  edu.cuny.config.param.Parameter base)
Specified by:
setup in interface edu.cuny.config.param.Parameterizable
Overrides:
setup in class FixedQuantityStrategyImpl

modifyShout

public boolean modifyShout(Shout.MutableShout shout)
Description copied from class: AbstractStrategy
Modify the price and quantity of the given shout according to this strategy.

Overrides:
modifyShout in class FixedQuantityStrategyImpl
Returns:
false if no shout is to be placed at this time

requiresAuctionHistory

public boolean requiresAuctionHistory()
Specified by:
requiresAuctionHistory in interface Strategy
Overrides:
requiresAuctionHistory in class AbstractStrategy

eventOccurred

public void eventOccurred(AuctionEvent event)
Specified by:
eventOccurred in interface AuctionEventListener
Overrides:
eventOccurred in class AdaptiveStrategyImpl

initMargin

protected void initMargin()

processLastShout

protected void processLastShout(Shout lastShout)

shoutPosted

protected void shoutPosted(ShoutPostedEvent event)

transactionPosted

protected void transactionPosted(TransactionPostedEvent event)

processDayClosed

protected void processDayClosed()
if there is a shout placed as the last activity, since no more shout or transaction is coming, this last shout needs to be processed just as other shouts with following shouts were done.


setLearner

public void setLearner(edu.cuny.ai.learning.Learner learner)
Specified by:
setLearner in interface AdaptiveStrategy

getLearner

public edu.cuny.ai.learning.Learner getLearner()
Specified by:
getLearner in interface AdaptiveStrategy

setMargin

public void setMargin(double margin)

getCurrentPrice

public double getCurrentPrice()

getLastShout

public Shout getLastShout()

isLastShoutAccepted

public boolean isLastShoutAccepted()

setScaling

public void setScaling(double scaling)

getScaling

public double getScaling()

calculatePrice

protected double calculatePrice(double margin)

targetMargin

protected double targetMargin(double targetPrice)

adjustMargin

protected void adjustMargin(double targetMargin)

perterb

protected double perterb(double price)

adjustMargin

protected abstract void adjustMargin()

toString

public java.lang.String toString()
Overrides:
toString in class FixedQuantityStrategyImpl