My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package dk.bettingai.trader.pricepriceslope

import org.junit._
import Assert._
import org.slf4j.LoggerFactory
import java.util.Random
import java.io.File
import dk.bettingai.tradingoptimiser._
import dk.bettingai.tradingoptimiser.ICoevolutionHillClimbing._
import dk.bettingai.marketsimulator.betex.PriceUtil._

/**Run trader implementation, full random mutate only.
*
* @author korzekwad
*
* Set more memory and active jmx:
* -Xmx512m
* -Dcom.sun.management.jmxremote
*
* bestSoFar=Solution [trader=PriceSlopeTrader [id=trader869, backSlope=-0.04, laySlope=-0.02, maxPrice=3.2], expectedProfit=141.8728123260652, matchedBetsNum=11080.0],
* 50 markets, 23/02/2011 09:51:02 INFO dk.bettingai.tradingoptimiser.CoevolutionHillClimbing$ - Iter number=156, bestSoFar=Solution [trader=PriceSlopeTrader [id=trader778, backSlope=-0.03, laySlope=-0.05, maxPrice=3.25], expectedProfit=195.72460059023436, matchedBetsNum=12751.0], currentBest=Solution [trader=PriceSlopeTrader [id=trader778, backSlope=-0.03, laySlope=-0.05, maxPrice=3.25], expectedProfit=195.72460059023436, matchedBetsNum=12751.0]
* 275 markets, 24/02/2011 08:31:54 INFO dk.bettingai.tradingoptimiser.CoevolutionHillClimbing$ - Iter number=76, bestSoFar=Solution [trader=PriceSlopeTrader [id=trader43, backSlope=-0.02, laySlope=-0.01, maxPrice=1.81], expectedProfit=106.75496311563737, matchedBetsNum=6450.0], currentBest=Solution [trader=PriceSlopeTrader [id=trader377, backSlope=0.01, laySlope=0.01, maxPrice=1.22], expectedProfit=0.0, matchedBetsNum=0.0]
* 275 markets 25/02/2011 07:08:27 INFO dk.bettingai.tradingoptimiser.CoevolutionHillClimbing$ - Iter number=73, bestSoFar=Solution [trader=PriceSlopeTrader [id=trader304, backSlope=-0.04, laySlope=-0.04, maxPrice=1.77], expectedProfit=138.8839350498075, matchedBetsNum=6266.0], currentBest=Solution [trader=PriceSlopeTrader [id=trader366, backSlope=0.01, laySlope=-0.03, maxPrice=1.05], expectedProfit=0.0, matchedBetsNum=0.0]
* 275 markets 25/02/2011 07:08:27 INFO dk.bettingai.tradingoptimiser.CoevolutionHillClimbing$ - Iter number=?, bestSoFar=Solution [trader=PriceSlopeTrader [id=trader?, backSlope=-0.03, laySlope=-+0.02, maxPrice=4.3, maxNumOfWinners=13], expectedProfit=190, matchedBetsNum=50000.0]
* 275 markets 27/02/2011 07:22:28 INFO dk.bettingai.tradingoptimiser.CoevolutionHillClimbing$ - Iter number=106, bestSoFar=Solution [trader=PriceSlopeTrader [id=trader100, backSlope=-0.04, laySlope=-0.04, maxPrice=1.78,numOfRunners=5], expectedProfit=215.44786786476382, matchedBetsNum=4126.0], currentBest=Solution [trader=PriceSlopeTrader [id=trader530, backSlope=0.0, laySlope=-0.01, maxPrice=1.16,numOfRunners=10], expectedProfit=0.0, matchedBetsNum=0.0]
* 50 markets 01/03/2011 11:19:49 INFO dk.bettingai.tradingoptimiser.CoevolutionHillClimbing$ - Iter number=829, bestSoFar=Solution [trader=PriceSlopeTrader [id=trader820, backSlope=-0.05, laySlope=-0.03, maxPrice=3.75,mxNumOfRunners=6,minProfitLoss=-62.0,minTradedVolume=405.0], expectedProfit=9.600873255130312, matchedBetsNum=282.0], currentBest=Solution [trader=PriceSlopeTrader [id=trader4144, backSlope=-0.04, laySlope=-0.03, maxPrice=1.46,mxNumOfRunners=11,minProfitLoss=-1.0,minTradedVolume=917.0], expectedProfit=0.062050340423681453, matchedBetsNum=2.0]
* 275 markets 03/03/2011 23:24:14 INFO dk.bettingai.tradingoptimiser.CoevolutionHillClimbing$ - Iter number=100, bestSoFar=Solution [trader=PricePriceSlopeTrader [id=trader22, backSlope=-0.05, laySlope=-0.04, maxPrice=1.77,mxNumOfRunners=19,minProfitLoss=-91.0,minTradedVolume=178.0], expectedProfit=13.032986027794397, matchedBetsNum=1655.0], currentBest=Solution [trader=PricePriceSlopeTrader [id=trader500, backSlope=0.03, laySlope=0.0, maxPrice=1.07,mxNumOfRunners=5,minProfitLoss=-31.0,minTradedVolume=673.0], expectedProfit=0.0, matchedBetsNum=0.0]
* 50 markets 04/03/2011 08:37:57 INFO dk.bettingai.tradingoptimiser.CoevolutionHillClimbing$ - Iter number=347, bestSoFar=Solution [trader=PricePriceSlopeTrader [id=trader1127, backSlope=-0.03, laySlope=-0.03, maxPrice=3.45,mxNumOfRunners=6,minProfitLoss=-79.0,minTradedVolume=167.0], expectedProfit=11.973669978370275, matchedBetsNum=647.0], currentBest=Solution [trader=PricePriceSlopeTrader [id=trader1736, backSlope=0.04, laySlope=0.02, maxPrice=1.75,mxNumOfRunners=11,minProfitLoss=-60.0,minTradedVolume=548.0], expectedProfit=0.06534685785395755, matchedBetsNum=91.0]
*
*/
class PricePriceSlopeTraderRandomTest {

private val log = LoggerFactory.getLogger(getClass)

val baseTrader = PricePriceSlopeTrader("baseTrader", -0.21, 0.21, 5,20,-10,10)

private val populationSize = 5
private val generationNum = 5

private val rand = new Random(System.currentTimeMillis)

@Test
def testTwoMarkets {

log.info("Initial trader=" + baseTrader)

var lastTraderId = 1
def nextTraderId = { lastTraderId += 1; lastTraderId }

// val marketDataDir = "c:/daniel/marketdata"
val marketDataDir = "./src/test/resources/two_hr_10mins_before_inplay"

/**Full random mutate only.*/
val mutate = (solution: Solution[PricePriceSlopeTrader]) => {
val backPriceSlopeSignal = ((rand.nextInt(11) - 5) * 0.01)
val layPriceSlopeSignal = ((rand.nextInt(11) - 5) * 0.01)
val maxPrice = priceUp(1 / rand.nextDouble)
val maxNumOfRunners = 3 + rand.nextInt(20)
val minProfitLoss = rand.nextInt(100) - 100
val minTradedVolume = rand.nextInt(1000)
val trader = PricePriceSlopeTrader("trader" + nextTraderId, backPriceSlopeSignal, layPriceSlopeSignal, maxPrice,maxNumOfRunners,minProfitLoss,minTradedVolume)
trader
}
val bestSolution = CoevolutionHillClimbing.optimise(marketDataDir, baseTrader, mutate, populationSize, generationNum)

log.info("Best solution=" + bestSolution)
}

}

Change log

r266 by daniel.korzekwa on Mar 4, 2011   Diff
[maven-release-plugin]  copy for tag
betting-ai-1.3
Go to: 
Project members, sign in to write a code review

Older revisions

r264 by daniel.korzekwa on Mar 4, 2011   Diff
Pre-release, update README.TXT
r260 by daniel.korzekwa on Mar 1, 2011   Diff
DONE:
 Issue 78 :       Create Simulator
companion and add a factory method to
initialise default Simulator
 Issue 78 :       Create Simulator
...
r259 by daniel.korzekwa on Feb 27, 2011   Diff
 Issue 91 :       Performance
improvement - run markets simulation
in parallel.
All revisions of this file

File info

Size: 5875 bytes, 69 lines
Powered by Google Project Hosting