void TradeForm::onGotTrade(const BfTradeData& trade) { QVariantMap vItem; vItem.insert("symbol", trade.symbol().c_str()); vItem.insert("exchange", trade.exchange().c_str()); vItem.insert("direction", CtpUtils::formatDirection(trade.direction())); vItem.insert("offset", CtpUtils::formatOffset(trade.offset())); vItem.insert("price", trade.price()); vItem.insert("volume", trade.volume()); vItem.insert("tradeDate", trade.tradedate().c_str()); vItem.insert("tradeTime", trade.tradetime().c_str()); vItem.insert("tradeId", trade.tradeid().c_str()); vItem.insert("bfOrderId", trade.bforderid().c_str()); //根据id找到对应的行,然后用列的text来在map里面取值设置到item里面= int row = ui->tableWidget->rowCount(); ui->tableWidget->insertRow(row); for (int i = 0; i < table_col_.count(); i++) { QVariant raw_val = vItem.value(table_col_.at(i)); QString str_val = raw_val.toString(); if (raw_val.type() == QMetaType::Double || raw_val.type() == QMetaType::Float) { str_val = QString().sprintf("%6.3f", raw_val.toDouble()); } QTableWidgetItem* item = new QTableWidgetItem(str_val); ui->tableWidget->setItem(row, i, item); } }
void DbService::dbInit() { leveldb::WriteOptions options; leveldb::WriteBatch batch; if (1) { // key: order+ // key: order= BfOrderData bfNullOrder; std::string key = "order+"; std::string val = bfNullOrder.SerializeAsString(); batch.Put(key, val); key = "order="; val = bfNullOrder.SerializeAsString(); batch.Put(key, val); } if (1) { // key: trade+ // key: trade= BfTradeData bfNullTrade; std::string key = "trade+"; std::string val = bfNullTrade.SerializeAsString(); batch.Put(key, val); key = "trade="; val = bfNullTrade.SerializeAsString(); batch.Put(key, val); } db_->Write(options, &batch); }
void DbService::dbInit() { leveldb::WriteOptions options; leveldb::WriteBatch batch; if (1) { // key: gateway+ // key: gateway= BfGatewayData bfNullGateway; std::string key = "gateway+"; std::string val = bfNullGateway.SerializeAsString(); batch.Put(key, val); key = "gateway="; val = bfNullGateway.SerializeAsString(); batch.Put(key, val); } if (1) { // key: model+ // key: model= BfModelData bfNullModel; std::string key = "model+"; std::string val = bfNullModel.SerializeAsString(); batch.Put(key, val); key = "model="; val = bfNullModel.SerializeAsString(); batch.Put(key, val); } if (1) { // key: robot+ // key: robot= BfRobotData bfNullRobot; std::string key = "robot+"; std::string val = bfNullRobot.SerializeAsString(); batch.Put(key, val); key = "robot="; val = bfNullRobot.SerializeAsString(); batch.Put(key, val); } if (1) { // key: order+ // key: order= BfOrderData bfNullOrder; std::string key = "order+"; std::string val = bfNullOrder.SerializeAsString(); batch.Put(key, val); key = "order="; val = bfNullOrder.SerializeAsString(); batch.Put(key, val); } if (1) { // key: trade+ // key: trade= BfTradeData bfNullTrade; std::string key = "trade+"; std::string val = bfNullTrade.SerializeAsString(); batch.Put(key, val); key = "trade="; val = bfNullTrade.SerializeAsString(); batch.Put(key, val); } if (1) { // key: orderex+ // key: orderex= BfOrderExData bfNullOrderEx; std::string key = "orderex+"; std::string val = bfNullOrderEx.SerializeAsString(); batch.Put(key, val); key = "orderex="; val = bfNullOrderEx.SerializeAsString(); batch.Put(key, val); } db_->Write(options, &batch); }