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

Incorrect order placement success report #7

Open
SteelRaven opened this issue Jul 3, 2017 · 2 comments
Open

Incorrect order placement success report #7

SteelRaven opened this issue Jul 3, 2017 · 2 comments

Comments

@SteelRaven
Copy link

SteelRaven commented Jul 3, 2017

When you try to place two orders in opposite directions which can be matched at the same time, both of them are reported as accepted, but only one is really added to the order book.

Code

#include "participant_strategy.h"
#include <vector>

using namespace hftbattle;

namespace {

class UserStrategy : public ParticipantStrategy {
public:
  explicit UserStrategy(const JsonValue& /*config*/): go_(true) { }

  void trading_book_update(const OrderBook& order_book) override {
    if(!go_){
      return;
    }

    Price middle_price = order_book.middle_price();

    for (Dir dir : {BID, ASK}) {
      if(add_limit_order(dir, middle_price, 1)){
        SCREEN() << "PLACED " << middle_price << ' ' << dir << ' ' << 1;
      }
    }

    go_ = false;
  }

  void execution_report_update(const ExecutionReport& execution_report) override {
    SCREEN() << execution_report.price() << ' ' << execution_report.dir() << ' ' << execution_report.amount();
  }

private:
  bool go_;

};

}  // namespace

REGISTER_CONTEST_STRATEGY(UserStrategy, strange_strategy)

Output

Config was successfully validated
00:00:00.000000 SCREEN[market_events_deserializer] Reading HFTBI-9.16 data file 1 / 5                : /home/phoenix/hftbattle/data/20160902/HFTBI-9.16/market_events_0.bin
00:00:00.000000 SCREEN[royal_manager] {
   "day" : "2016.09.02",
   "log_level" : "fatal",
   "strategy_id" : 0
}

09:15:01.381000 SCREEN[participant_strategy_68591408] PLACED 176228 0 1
09:15:01.381000 SCREEN[participant_strategy_68591408] PLACED 176228 1 1
09:15:01.763000 SCREEN[participant_strategy_68591408] 176228 0 1
09:22:59.175000 SCREEN[market_events_deserializer] Reading HFTBI-9.16 data file 2 / 5                : /home/phoenix/hftbattle/data/20160902/HFTBI-9.16/market_events_1.bin
09:36:09.607000 SCREEN[market_events_deserializer] Reading HFTBI-9.16 data file 3 / 5                : /home/phoenix/hftbattle/data/20160902/HFTBI-9.16/market_events_2.bin
09:59:08.732000 SCREEN[market_events_deserializer] Reading HFTBI-9.16 data file 4 / 5                : /home/phoenix/hftbattle/data/20160902/HFTBI-9.16/market_events_3.bin
10:38:39.368000 SCREEN[market_events_deserializer] Reading HFTBI-9.16 data file 5 / 5                : /home/phoenix/hftbattle/data/20160902/HFTBI-9.16/market_events_4.bin
11:25:34.122000 SCREEN[strategy:strange] finished platform_strategy
11:25:34.122000 SCREEN[strategy:strange] HFTBI-9.16 : res = -11; pos = 1; total_fee = 8
11:25:34.122000 SCREEN[strategy:strange] res sum: -11
11:25:34.122000 SCREEN[royal_manager] Our deals count: 1
11:25:34.122000 SCREEN[royal_manager] Our deals volume: 1
11:25:34.122000 SCREEN[royal_manager] Transactions count: 2
11:25:34.122000 SCREEN[royal_manager] Adds count: 2
11:25:34.122000 SCREEN[royal_manager] Dels count: 0
@salikhov-kamil
Copy link

add_limit_order doesn't check possible self-cross
there are several reasons for that, among them roundtrip - order is actually added after some time after add_order call, and it is very hard to predict what security state will be in future

@SteelRaven
Copy link
Author

It might be useful to have some notes about this kind of behavior in documentation.

Besides, is my understanding correct and participants orders doesn't cause a call to trading_book_update after a roundtrip, if this is the case it might also be useful to have this in documentation.

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