robaho / go-trader

financial exchange written in Go, designed for algorithmic trading tests
GNU General Public License v3.0
372 stars 75 forks source link

Run time exception: index out of range #16

Closed napoleon665 closed 1 month ago

napoleon665 commented 1 month ago

How to reproduce:

  1. Build the client, exchange and marketmaker
  2. Active them all and make sure the market maker is running.
  3. Submit a buy / sell request in the client example: sell IBM 10 100
  4. It will crash.
image

The exception occurring in exchange component

he available commands are: quit, sessions, book SYMBOL, watch SYMBOL, unwatch SYMBOL, list
Command?panic: runtime error: index out of range [0] with length 0

goroutine 12 [running]:
github.com/robaho/go-trader/internal/exchange.(*orderBook).remove(0x140002c20a0, {{0x10151a330, 0x14001936a00}, 0x140019399a0, {0xc19de4fdef746c18, 0xe5c7ff2d4ef, 0x101cc5c20}})
        /Users/monia/Documents/go-trader/internal/exchange/orderbook.go:175 +0x4f4
github.com/robaho/go-trader/internal/exchange.(*exchange).Quote(0x101cc5ca0, {0x10151a330, 0x14001936a80}, {0x10151a390, 0x140001eb380}, {0x45e2ee20?}, {0x5f5e100?}, {0x460913c0?}, {0x5f5e100?})
        /Users/monia/Documents/go-trader/internal/exchange/exchange.go:209 +0x184
github.com/robaho/go-trader/internal/exchange.(*myApplication).onMassQuote(0x101cc4e40, {{0x14001889500?}, 0x14001889560?, {0x14001889530?}, 0x14001889500?}, {{0x140000406fc, 0x7}, {0x1400001164d, 0x3}, {0x0, ...}, ...})
        /Users/monia/Documents/go-trader/internal/exchange/qfixapp.go:196 +0x274
github.com/robaho/go-trader/internal/exchange.init.0.Route.func4(0x140016dd7f8?, {{0x140000406fc, 0x7}, {0x1400001164d, 0x3}, {0x0, 0x0}, {0x0, 0x0}, {0x1400001160d, ...}, ...})
        /Users/monia/go/pkg/mod/github.com/quickfixgo/fix44@v0.1.0/massquote/MassQuote.generated.go:56 +0x54
github.com/quickfixgo/quickfix.MessageRouter.tryRoute({0x140016dd9b8?}, {0x14000057980, 0x7}, {0x101c7ab48, 0x1}, 0x14001889500, {{0x140000406fc, 0x7}, {0x1400001164d, 0x3}, ...})
        /Users/monia/go/pkg/mod/github.com/quickfixgo/quickfix@v0.9.0/message_router.go:98 +0x55c
github.com/quickfixgo/quickfix.MessageRouter.Route({0x14000057ad8?}, 0x14001889500, {{0x140000406fc, 0x7}, {0x1400001164d, 0x3}, {0x0, 0x0}, {0x0, 0x0}, ...})
        /Users/monia/go/pkg/mod/github.com/quickfixgo/quickfix@v0.9.0/message_router.go:67 +0x134
github.com/robaho/go-trader/internal/exchange.(*myApplication).FromApp(0x1014000057b78?, 0x100e733c0?, {{0x140000406fc, 0x7}, {0x1400001164d, 0x3}, {0x0, 0x0}, {0x0, 0x0}, ...})
        /Users/monia/Documents/go-trader/internal/exchange/qfixapp.go:75 +0x44
github.com/quickfixgo/quickfix.(*session).fromCallback(0x140001e8e00, 0x14001889500)
        /Users/monia/go/pkg/mod/github.com/quickfixgo/quickfix@v0.9.0/session.go:563 +0x2c8
github.com/quickfixgo/quickfix.(*session).verifySelect(0x140001e8e00, 0x14001889500, 0x1, 0x1)
        /Users/monia/go/pkg/mod/github.com/quickfixgo/quickfix@v0.9.0/session.go:550 +0xdc
github.com/quickfixgo/quickfix.(*session).verify(...)
        /Users/monia/go/pkg/mod/github.com/quickfixgo/quickfix@v0.9.0/session.go:504
github.com/quickfixgo/quickfix.inSession.FixMsgIn({{{}}}, 0x140001e8e00, 0x14001889500)
        /Users/monia/go/pkg/mod/github.com/quickfixgo/quickfix@v0.9.0/in_session.go:54 +0x19c
github.com/quickfixgo/quickfix.(*stateMachine).fixMsgIn(0x140001e8f00, 0x140001e8e00, 0x0?)
        /Users/monia/go/pkg/mod/github.com/quickfixgo/quickfix@v0.9.0/session_state.go:98 +0x34
github.com/quickfixgo/quickfix.(*stateMachine).Incoming(0x140001e8f00, 0x140001e8e00, {0x140017d6330?, {0x0?, 0x101cc5c20?, 0x101cc5c20?}})
        /Users/monia/go/pkg/mod/github.com/quickfixgo/quickfix@v0.9.0/session_state.go:91 +0x2c4
github.com/quickfixgo/quickfix.(*session).run(0x140001e8e00)
        /Users/monia/go/pkg/mod/github.com/quickfixgo/quickfix@v0.9.0/session.go:813 +0x2a0
github.com/quickfixgo/quickfix.(*Acceptor).Start.func1(0x0?)
        /Users/monia/go/pkg/mod/github.com/quickfixgo/quickfix@v0.9.0/acceptor.go:111 +0x24
created by github.com/quickfixgo/quickfix.(*Acceptor).Start in goroutine 1
        /Users/monia/go/pkg/mod/github.com/quickfixgo/quickfix@v0.9.0/acceptor.go:110 +0xbc0
monia@monias-MacBook-Pro go-trader % ./main
robaho commented 1 month ago

Yes, I noticed this today. You can use the earlier version before the orderList changes. I am pretty sure I have already fixed it but testing. It is not handling the fills properly. It should be fixed tonight.

robaho commented 1 month ago

btw, it is best to run the marketmaker in a different console session - otherwise the client UI gets all messed up.

napoleon665 commented 1 month ago

Yes, I noticed this today. You can use the earlier version before the orderList changes. I am pretty sure I have already fixed it but testing. It is not handling the fills properly. It should be fixed tonight.

Oh ok cool, im gonna try to fix it locally and then compare it to your fix. Thanks!

robaho commented 1 month ago

fixed in v1.3.1. It was related to the recent orderList changes.