void OkcoinApp::submitMarketOrder(const char *symbol, OrderSide side, double amount, const char *userId) { int ts = timestamp(); FIX44::NewOrderSingle message; message.set(Account(_publicKey + "," + _privateKey)); if (userId) message.set(ClOrdID(userId)); else message.set(ClOrdID("OkcoinOrder")); message.set(Price(amount)); message.set(OrderQty(amount)); message.set(OrdType(OrdType_MARKET)); message.set(Symbol(symbol)); message.set(Side(side == OrderBuy ? Side_BUY : Side_SELL)); message.set(TransactTime()); Session *session = Session::lookupSession(_sessionID); if (session) session->send(message); }
void FixProviderImpl::sendOrder(const FreeQuant::Order& order) { FIX44::NewOrderSingle message; message.set(FIX::ClOrdID(FreeQuant::createGuid())); FIX::Side side; if (order.side() == FreeQuant::Order::Buy) { side = FIX::Side_BUY; } else { side = FIX::Side_SELL; } message.set(side); FIX::OrdType type; switch (order.type()) { case FreeQuant::Order::Market: type = FIX::OrdType_MARKET; default: break; } }
void Application::onMessage( const FIX44::NewOrderSingle& message, const FIX::SessionID& sessionID ) { FIX::Symbol symbol; FIX::Side side; FIX::OrdType ordType; FIX::OrderQty orderQty; FIX::Price price; FIX::ClOrdID clOrdID; FIX::Account account; message.get( ordType ); if ( ordType != FIX::OrdType_LIMIT ) throw FIX::IncorrectTagValue( ordType.getField() ); message.get( symbol ); message.get( side ); message.get( orderQty ); message.get( price ); message.get( clOrdID ); FIX44::ExecutionReport executionReport = FIX44::ExecutionReport ( FIX::OrderID( genOrderID() ), FIX::ExecID( genExecID() ), FIX::ExecType( FIX::ExecType_FILL ), FIX::OrdStatus( FIX::OrdStatus_FILLED ), side, FIX::LeavesQty( 0 ), FIX::CumQty( orderQty ), FIX::AvgPx( price ) ); executionReport.set( clOrdID ); executionReport.set( symbol ); executionReport.set( orderQty ); executionReport.set( FIX::LastQty( orderQty ) ); executionReport.set( FIX::LastPx( price ) ); if( message.isSet(account) ) executionReport.setField( message.get(account) ); try { FIX::Session::sendToTarget( executionReport, sessionID ); } catch ( FIX::SessionNotFound& ) {} }
void HuobiApp::submitLimitOrder(const char *symbol, OrderSide side, double price, double amount, const char *userId) { int ts = timestamp(); FIX44::NewOrderSingle message; message.set(Account(_publicKey)); if (userId) message.set(ClOrdID(userId)); else message.set(ClOrdID("HuobiOrder")); message.set(Price(price)); message.set(MinQty(amount)); message.set(OrdType(OrdType_LIMIT)); message.set(Symbol(symbol)); message.set(Side(side == OrderBuy ? Side_BUY : Side_SELL)); message.set(TransactTime()); message.setField(IntField(957, ts)); message.setField(StringField(958, _publicKey)); char str[1024]; sprintf(str, "access_key=%s&amount=%s&coin_type=%d&created=%d&method=%s&price=%s&secret_key=%s", _publicKey.c_str(), float2str(amount).c_str(), getCoinType(symbol), ts, side == OrderBuy ? "buy" : "sell", float2str(price).c_str(), _privateKey.c_str()); message.setField(StringField(959, md5::MD5String(str, false))); Session *session = Session::lookupSession(_sessionID); if (session) session->send(message); }