Roughly 1/10 runs I get a crash, fairly repeatable.
% go run example/backtesting/main.go
INFO[2021-05-22 13:39] [SETUP] Using paper wallet
INFO[2021-05-22 13:39] [SETUP] Initial Portfolio = 10000.000000 USDT
fatal error: concurrent map writes
goroutine 55 [running]:
runtime.throw(0x45f51b3, 0x15)
/usr/local/go/src/runtime/panic.go:1117 +0x72 fp=0xc000267ce0 sp=0xc000267cb0 pc=0x4039a12
runtime.mapassign_faststr(0x456fce0, 0xc0000a5710, 0x45eb910, 0x7, 0x0)
/usr/local/go/src/runtime/map_faststr.go:291 +0x3d8 fp=0xc000267d48 sp=0xc000267ce0 pc=0x40181d8
github.com/rodrigo-brito/ninjabot/pkg/plot.(*Chart).OnCandle(0xc00000e0d8, 0x45eb910, 0x7, 0x0, 0xed7f2d740, 0x0, 0x409a2c1eb851eb85, 0x409a0df5c28f5c29, 0x409a02851eb851ec, 0x409a340000000000, ...)
/Users/myusername/Documents/Projects/ninjabot/pkg/plot/chart.go:29 +0x67 fp=0xc000267da0 sp=0xc000267d48 pc=0x430ecc7
github.com/rodrigo-brito/ninjabot.CandleSubscriber.OnCandle-fm(0x45eb910, 0x7, 0x0, 0xed7f2d740, 0x0, 0x409a2c1eb851eb85, 0x409a0df5c28f5c29, 0x409a02851eb851ec, 0x409a340000000000, 0x40ccf7999999999a, ...)
/Users/myusername/Documents/Projects/ninjabot/ninjabot.go:37 +0x55 fp=0xc000267e18 sp=0xc000267da0 pc=0x43f3bd5
github.com/rodrigo-brito/ninjabot/pkg/exchange.(*DataFeedSubscription).Start.func1(0xc00002a740, 0xc0000363c0, 0xc00002a560, 0xb, 0xc0000207b0)
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/exchange.go:127 +0x278 fp=0xc000267fb8 sp=0xc000267e18 pc=0x43cf998
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1371 +0x1 fp=0xc000267fc0 sp=0xc000267fb8 pc=0x406f301
created by github.com/rodrigo-brito/ninjabot/pkg/exchange.(*DataFeedSubscription).Start
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/exchange.go:115 +0x139
goroutine 1 [semacquire]:
sync.runtime_Semacquire(0xc00002a748)
/usr/local/go/src/runtime/sema.go:56 +0x45
sync.(*WaitGroup).Wait(0xc00002a740)
/usr/local/go/src/sync/waitgroup.go:130 +0x65
github.com/rodrigo-brito/ninjabot/pkg/exchange.(*DataFeedSubscription).Start(0xc0000363c0)
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/exchange.go:137 +0x1a5
github.com/rodrigo-brito/ninjabot.(*NinjaBot).Run(0xc0001f50a0, 0x467d770, 0xc0000aa000, 0x2, 0x2)
/Users/myusername/Documents/Projects/ninjabot/ninjabot.go:185 +0x38f
main.main()
/Users/myusername/Documents/Projects/ninjabot/example/backtesting/main.go:75 +0x5b2
goroutine 9 [select]:
database/sql.(*DB).connectionOpener(0xc0000a61a0, 0x467d738, 0xc000036040)
/usr/local/go/src/database/sql/sql.go:1133 +0xb5
created by database/sql.OpenDB
/usr/local/go/src/database/sql/sql.go:740 +0x12a
goroutine 13 [chan receive]:
github.com/rodrigo-brito/ninjabot/pkg/order.(*Feed).Start.func1(0xc000020480, 0x45eb520, 0x7, 0xc000020540)
/Users/myusername/Documents/Projects/ninjabot/pkg/order/feed.go:54 +0x93
created by github.com/rodrigo-brito/ninjabot/pkg/order.(*Feed).Start
/Users/myusername/Documents/Projects/ninjabot/pkg/order/feed.go:53 +0xfe
goroutine 14 [chan receive]:
github.com/rodrigo-brito/ninjabot/pkg/order.(*Feed).Start.func1(0xc000020480, 0x45eb910, 0x7, 0xc000020560)
/Users/myusername/Documents/Projects/ninjabot/pkg/order/feed.go:54 +0x93
created by github.com/rodrigo-brito/ninjabot/pkg/order.(*Feed).Start
/Users/myusername/Documents/Projects/ninjabot/pkg/order/feed.go:53 +0xfe
goroutine 15 [chan receive]:
github.com/rodrigo-brito/ninjabot/pkg/order.(*Controller).Start.func1(0xc00007a190)
/Users/myusername/Documents/Projects/ninjabot/pkg/order/controller.go:142 +0x8d6
created by github.com/rodrigo-brito/ninjabot/pkg/order.(*Controller).Start
/Users/myusername/Documents/Projects/ninjabot/pkg/order/controller.go:141 +0x3f
goroutine 16 [chan send]:
github.com/rodrigo-brito/ninjabot/pkg/exchange.CSVFeed.CandlesSubscription.func1(0xc0000a5320, 0xc0000a5350, 0xc00002a6e0, 0xb, 0xc0000962a0)
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/csvfeed.go:205 +0xf9
created by github.com/rodrigo-brito/ninjabot/pkg/exchange.CSVFeed.CandlesSubscription
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/csvfeed.go:203 +0x15f
goroutine 50 [chan send]:
github.com/rodrigo-brito/ninjabot/pkg/exchange.CSVFeed.CandlesSubscription.func1(0xc0000a5320, 0xc0000a5350, 0xc00002a6f0, 0xb, 0xc000096360)
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/csvfeed.go:205 +0xf9
created by github.com/rodrigo-brito/ninjabot/pkg/exchange.CSVFeed.CandlesSubscription
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/csvfeed.go:203 +0x15f
goroutine 51 [chan send]:
github.com/rodrigo-brito/ninjabot/pkg/exchange.CSVFeed.CandlesSubscription.func1(0xc0000a5320, 0xc0000a5350, 0xc00002a700, 0xb, 0xc000096420)
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/csvfeed.go:205 +0xf9
created by github.com/rodrigo-brito/ninjabot/pkg/exchange.CSVFeed.CandlesSubscription
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/csvfeed.go:203 +0x15f
goroutine 52 [chan send]:
github.com/rodrigo-brito/ninjabot/pkg/exchange.CSVFeed.CandlesSubscription.func1(0xc0000a5320, 0xc0000a5350, 0xc00002a710, 0xb, 0xc0000964e0)
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/csvfeed.go:205 +0xf9
created by github.com/rodrigo-brito/ninjabot/pkg/exchange.CSVFeed.CandlesSubscription
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/csvfeed.go:203 +0x15f
goroutine 53 [chan send]:
github.com/rodrigo-brito/ninjabot/pkg/exchange.CSVFeed.CandlesSubscription.func1(0xc0000a5320, 0xc0000a5350, 0xc00002a720, 0xb, 0xc0000965a0)
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/csvfeed.go:205 +0xf9
created by github.com/rodrigo-brito/ninjabot/pkg/exchange.CSVFeed.CandlesSubscription
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/csvfeed.go:203 +0x15f
goroutine 54 [chan send]:
github.com/rodrigo-brito/ninjabot/pkg/exchange.CSVFeed.CandlesSubscription.func1(0xc0000a5320, 0xc0000a5350, 0xc00002a730, 0xb, 0xc000096660)
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/csvfeed.go:205 +0xf9
created by github.com/rodrigo-brito/ninjabot/pkg/exchange.CSVFeed.CandlesSubscription
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/csvfeed.go:203 +0x15f
goroutine 56 [runnable]:
github.com/markcheno/go-talib.ema(0xc00021e000, 0xcde, 0x1000, 0x15, 0x3fb745d1745d1746, 0xc000911500, 0xcde, 0xcde)
/Users/myusername/Documents/Projects/go/pkg/mod/github.com/markcheno/[email protected]/talib.go:127 +0xdd
github.com/markcheno/go-talib.Ema(...)
/Users/myusername/Documents/Projects/go/pkg/mod/github.com/markcheno/[email protected]/talib.go:141
github.com/rodrigo-brito/ninjabot/example.MyStrategy.Indicators(0xc00007e900)
/Users/myusername/Documents/Projects/ninjabot/example/strategy.go:25 +0x125
github.com/rodrigo-brito/ninjabot/pkg/strategy.(*Controller).OnCandle(0xc0000a5890, 0x45eb520, 0x7, 0x0, 0xed7fa1780, 0x0, 0x40ecf4b99999999a, 0x40ecd294cccccccd, 0x40ecafdeb851eb85, 0x40ed31f70a3d70a4, ...)
/Users/myusername/Documents/Projects/ninjabot/pkg/strategy/controller.go:54 +0x243
github.com/rodrigo-brito/ninjabot/pkg/exchange.(*DataFeedSubscription).Start.func1(0xc00002a740, 0xc0000363c0, 0xc00002a534, 0xb, 0xc000020780)
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/exchange.go:127 +0x278
created by github.com/rodrigo-brito/ninjabot/pkg/exchange.(*DataFeedSubscription).Start
/Users/myusername/Documents/Projects/ninjabot/pkg/exchange/exchange.go:115 +0x139
exit status 2