def Dependency(ctx): liqVol = mathutils.product(mathutils.rnd.expovariate(.1), mathutils.constant(2)) ctx.volumeStep = 70 return [ ctx.makeTrader_A( strategy.LiquidityProvider(defaultValue=50., volumeDistr=liqVol), "LiquidityProvider_A"), ctx.makeTrader_B( strategy.LiquidityProvider(defaultValue=150., volumeDistr=liqVol), "LiquidityProvider_B"), ctx.makeTrader_A(strategy.Dependency(ctx.book_B, factor=2), "A dependent on B"), ctx.makeTrader_B(strategy.Dependency(ctx.book_A, factor=.5), "B dependent on A"), ctx.makeTrader_A(strategy.DependencyEx(ctx.book_B, factor=2), "A dependent on B ex"), ctx.makeTrader_B(strategy.DependencyEx(ctx.book_A, factor=.5), "B dependent on A ex") ]
def LiquidityProviderSideEx(side = Side.Sell, orderFactory = order.LimitFactory, defaultValue = 100., creationIntervalDistr = mathutils.rnd.expovariate(1.), priceDistr = mathutils.rnd.lognormvariate(0., .1), volumeDistr = mathutils.rnd.expovariate(1.)): orderBook = orderbook.OfTrader() r = Generic(eventGen = scheduler.Timer(creationIntervalDistr), volumeFunc = volumeDistr, sideFunc = ConstantSide(side), orderFactory= order.AdaptLimit(orderFactory, mathutils.product( SafeSidePrice(orderBook, side, defaultValue), priceDistr))) return r
def Arbitrage(ctx): liqVol = mathutils.product(mathutils.rnd.expovariate(.1), mathutils.constant(2)) ctx.volumeStep = 70 return [ ctx.makeTrader_A( strategy.LiquidityProvider(defaultValue=50., volumeDistr=liqVol), "LiquidityProvider_A"), ctx.makeTrader_B( strategy.LiquidityProvider(defaultValue=150., volumeDistr=liqVol), "LiquidityProvider_B"), ctx.makeMultiAssetTrader([ctx.remote_A, ctx.remote_B], strategy.Arbitrage(), "Arbitrager") ]