Friday, 22 October 2010

Market analysis with time line charts

In my last post I was writing about analysing trading strategies with a market simulator. This time I'd like to present a charts feature that makes it easier to analyse trading strategies. Before I start, a bit of information for those who read my blog for the first time.

The market simulator I'm referring to, allows for betfair market simulations that produce results very close to running trading strategies on real betfair markets. It's due to replaying market in a form of bet placement events on a real betting exchange engine.

Time line charts can present any data including standard metrics such as price, probability, traded volume, customer ifwin, customer expected liability, etc, as well as any transformation of those basic metrics, e.g. math functions such as derivativess, statistical, etc. I present below three chart examples. The first chart represents probability for all market runners during last 10 minutes before market is turned in play.


1. Probability for all market runners

Where as the second and third charts present market expected profit for two different trading strategies. As you can see, one of them generates profit, while the next one generates loss. 

 2. Market current expected for a market (profit)

  3. Market current expected for a market (loss)

One more thing worth to mention is a great flexibility that makes it possible to presents aggregated metrics across both time and many markets. What metrics are presented is up to a trader implementation class. Consider the trader implementation below:

def execute(eventTimestamp:Long,ctx: ITraderContext)= {
  if(bestPrices._2.price>2)
    ctc.placeBet(2,bestPrices._2.price,BACK,runnerId)
  ctx.addChartValues(ctx.risk.ifWin)
}

There is a method on a trader context named ctx.addChartValues(...), that adds timestamped metrics to be displayed on a chart after simulation is finished. Let say we want to present log(ifWin), then just call:

ctx.addChartValues(log(ctx.risk.ifWin))

References