void API2::Test2::Context::onMarketDataEvent(UNSIGNED_LONG symbolId) { API2::DATA_TYPES::RiskStatus risk; // DEBUG_MESSAGE(reqQryDebugLog(), __PRETTY_FUNCTION__ ); // DEBUG_FLUSH(reqQryDebugLog()); // reqQryMarketData(symbolId)->dump(); // return; if(_orderWrapper._isReset) { DEBUG_MESSAGE(reqQryDebugLog(), "Sending New Order"); if(!_orderWrapper.newOrder(risk,getPrice(),_userParams._qty)) { DEBUG_VARSHOW(reqQryDebugLog(), "Failed Sending New Order, Reason:", risk); DEBUG_FLUSH(reqQryDebugLog()); reqAddStrategyComment(API2::CONSTANTS::RSP_StrategyComment_RMS_FAILURE); reqTerminateStrategy(); } } else { switch(reqQryOrderStatus(_orderWrapper._orderId)) { case API2::CONSTANTS::RSP_OrderStatus_PENDING: return; case API2::CONSTANTS::RSP_OrderStatus_FILLED: case API2::CONSTANTS::RSP_OrderStatus_CANCELED: _orderWrapper.reset(); onMarketDataEvent(symbolId); return; case API2::CONSTANTS::RSP_OrderStatus_CONFIRMED: case API2::CONSTANTS::RSP_OrderStatus_PARTIALLY_FILLED: case API2::CONSTANTS::RSP_OrderStatus_REPLACED: if(_orderWrapper.replaceOrder(risk,getPrice(),_userParams._qty)){ DEBUG_MESSAGE(reqQryDebugLog(), "Sent Replace Order"); } else{ DEBUG_VARSHOW(reqQryDebugLog(), "Failed Replace Order, reason",risk); } } } DEBUG_FLUSH(reqQryDebugLog()); }
void SampleStrategy::onMarketDataEvent(UNSIGNED_LONG symbolId) { API2::DATA_TYPES::PRICE price = reqQryMarketData(symbolId)->getBidPrice(1); API2::DATA_TYPES::QTY qty = _instrument->getStaticData()->marketLot*100; if(_orderWrapper->getLastQuotedPrice() == price) return; #ifdef BENCHMARK_NEW_ORDERS HFT_Start_Timer_Define _orderWrapper->reset(); HFT_Record_Timer(_LNResetOrder); sendNewOrder(price,qty); return; #endif if(_orderWrapper->_isReset) { sendNewOrder(price,qty); } API2::DATA_TYPES::OrderStatus status = reqQryOrderStatus(_orderWrapper->_orderId); // DEBUG_VARSHOW(reqQryDebugLog(), "Order Status:", status); switch(status) { case API2::CONSTANTS::RSP_OrderStatus_FILLED: case API2::CONSTANTS::RSP_OrderStatus_FROZEN: case API2::CONSTANTS::RSP_OrderStatus_CANCELED: sendNewOrder(price,qty); break; case API2::CONSTANTS::RSP_OrderStatus_REPLACED: sendCancelOrder();break; case API2::CONSTANTS::RSP_OrderStatus_CONFIRMED: case API2::CONSTANTS::RSP_OrderStatus_PARTIALLY_FILLED: case API2::CONSTANTS::RSP_OrderStatus_REPLACE_REJECTED: case API2::CONSTANTS::RSP_OrderStatus_CANCEL_REJECTED: sendReplaceOrder(price);break; } }