Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orderbook notifications are sent in different threads #39

Open
satyapravin opened this issue Oct 19, 2019 · 1 comment
Open

Orderbook notifications are sent in different threads #39

satyapravin opened this issue Oct 19, 2019 · 1 comment

Comments

@satyapravin
Copy link

The order book notifications are sent in different threads and this is a problem because you cannot process market data serially. For example if we receive an INSERT Action on orderbook it is sent on a new task and following UPDATE action is sent on a new task which defeats the purpose because you cannot guarantee that the UPDATE task will finish after INSERT task.

@Gdocal
Copy link

Gdocal commented May 23, 2020

BitmexApiSocketService.BitmexApiSocketProxyDataReceived method queue all message to threadpool.

 private void BitmexApiSocketProxyDataReceived(DataEventArgs args)
        {
            if (_actions.ContainsKey(args.TableName))
            {
                foreach (var subscription in _actions[args.TableName])
                {
                    var data = args.Data;
                    Task.Factory.StartNew(() => subscription.Execute(data, args.Action));
                }
            }
        }

we can just change it to

  private void BitmexApiSocketProxyDataReceived(DataEventArgs args)
        {
            if (_actions.ContainsKey(args.TableName))
            {
                foreach (var subscription in _actions[args.TableName])
                {
                    var data = args.Data;
                    subscription.Execute(data, args.Action);
                }
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants