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

trade: add pool constructor options #33

Merged
merged 1 commit into from
Apr 2, 2018
Merged

Conversation

yerden
Copy link
Contributor

@yerden yerden commented Mar 28, 2018

Changes:

  • downgrade OrderPool to interface;
  • add OrderPoolMatcher class;
  • introduce OrderMatcher optional parameter for TradingPool and HistoryPool constructors.

These changes don't violate current API and allow to reduce boilerplate code in case of defining TradingPool and HistoryPool since matching criteria for both are often identical. It can also be useful when defining pools as RAII objects. For example:

class MagicAndBuyMatcher: public OrderMatcher
  {
private:
   int               m_magic;
public:
                     MagicAndBuyMatcher(int m):m_magic(m){}
   virtual bool      matches() const {return Order::MagicNumber()==m_magic && Order::Type()==OP_BUY;}
  };
...
// elsewhere
   MagicAndBuyMatcher myMatcher(1337);
   TradingPool tp(&myMatcher);
   HistoryPool hp(&myMatcher);
   foreachorder(tp) {
   ...
   }

Changes:
* downgrade OrderPool to interface;
* add OrderPoolMatcher class;
* introduce OrderMatcher optional parameter for TradingPool and HistoryPool constructors.
@dingmaotu dingmaotu merged commit 3c09910 into dingmaotu:master Apr 2, 2018
@yerden yerden deleted the orderpool branch April 2, 2018 16:42
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

Successfully merging this pull request may close these issues.

2 participants