void Sav5::pkm(std::shared_ptr<PKX> pk, u8 box, u8 slot, bool applyTrade) { transfer(pk); if (applyTrade) { trade(pk); } std::copy(pk->rawData(), pk->rawData() + 136, data + boxOffset(box, slot)); }
void talk_function::mission_reward( npc &p ) { const mission *miss = p.chatbin.mission_selected; if( miss == nullptr ) { debugmsg( "Called mission_reward with null mission" ); return; } int mission_value = miss->get_value(); p.op_of_u.owed += mission_value; trade( p, 0, _( "Reward" ) ); }
void mainwindow::on_start_all_clicked() { int date_open=find_first_date(ui->trainFrom->date()),date_close=find_last_date(ui->trainTo->date()); // multy-threading starts here!1!!111 QFutureWatcher<void> *m_futureWatcher= new QFutureWatcher<void>(); QFuture <void>future=QtConcurrent::run(this,&mainwindow::learn,date_open,date_close); connect(m_futureWatcher, SIGNAL(finished()),this, SLOT(trade())); m_futureWatcher->setFuture(future); // multy-threading ends here!!11111 }
void IBSymbol::BuildTrade() { //if ( !m_bLastTimeStampFound && m_bLastFound && m_bLastSizeFound ) { // std::cout << m_sSymbolName << " Trade is weird" << std::endl; //} //if ( m_bLastTimeStampFound && m_bLastFound && m_bLastSizeFound ) { if ( m_bLastFound && m_bLastSizeFound ) { Trade trade( ou::TimeSource::Instance().External(), m_dblLast, m_nLastSize ); //std::cout << "T:" << trade.m_dt << " " << trade.m_nTradeSize << "@" << trade.m_dblTrade << std::endl; m_OnTrade( trade ); //m_bLastTimeStampFound = m_bLastFound = m_bLastSizeFound = false; m_bLastFound = m_bLastSizeFound = false; } }
bool pay_npc( npc &np, int cost ) { if( np.op_of_u.owed >= cost ) { np.op_of_u.owed -= cost; return true; } if( g->u.cash + static_cast<unsigned long>( np.op_of_u.owed ) >= static_cast<unsigned long> ( cost ) ) { g->u.cash -= cost - np.op_of_u.owed; np.op_of_u.owed = 0; return true; } return trade( np, -cost, _( "Pay:" ) ); }
void OrderMatcher::matchOrders(TradeList& tradeList, OrderList& buyList, OrderList& sellList, Decimal price) { if (verbose) cout << endl << "Matching orders..." << endl; if (buyList.size() == 0 || sellList.size() == 0) return; Order buyOrder = buyList.front(); Order sellOrder = sellList.front(); bool finished = false; while (!finished && buyOrder.getPrice() >= price && sellOrder.getPrice() <= price) { uint32_t amount = std::min(buyOrder.getAmount(), sellOrder.getAmount()); Trade trade(amount, price, buyOrder, sellOrder); tradeList.push_back(trade); buyOrder.decreaseAmount(amount); sellOrder.decreaseAmount(amount); if (buyOrder.getAmount() == 0) { buyList.pop_front(); if (buyList.size() > 0) buyOrder = buyList.front(); else finished = true; } if (sellOrder.getAmount() == 0) { sellList.pop_front(); if (sellList.size() > 0) sellOrder = sellList.front(); else finished = true; } } }
void AIPlayer::makeTurn(Game * g){ int randPick = rand() % 4; if(randPick==0 && this->myHand.getSize()<7){ //take int r= rand() % g->market().getSize(); take(g, r); } else if(randPick==1){ //trade trade(g); //CHECK ONCE ALEX IS DONE } else if(randPick==2){ //sell one } else if(randPick==3){ //&& check is valid to sell mult){ //sell multiple } else{ std::cout<<"Error in picking a move"<<std::endl; } }
void TradesRecord::saveTrade(string ref, double priceIn, double pricePredicted, int volume, string position) { Trade trade(ref, priceIn, pricePredicted, volume, position); _trades->push_back(trade); _count++; }
// Export connection-related stuff. void export_connect() { enum_<LOGMODE>("LOGMODE") .value("NONE", NONE) .value("SCREEN", SCREEN) .value("DISK", DISK) .value("SYSLOG", SYSLOG); // class_<Common, boost::noncopyable> common("Common", no_init); { // common.def("logError", &simplify_log_function<Common::logError>); // common.def("logInfo", &simplify_log_function<Common::logInfo>); // common.def("logDebug", &simplify_log_function<Common::logDebug>); // common.def("logWarning", &simplify_log_function<Common::logWarning>); // common.def("log", &Common::log); // common.def("setLogMode", &Common::setLogMode); // common.def("setLogFilename", &Common::setLogFilename); } class_<FXClient> client("FXClient"); { client.add_property("version", &FXClient::version); client.def("login", &FXClient::login); client.def("logout", &FXClient::logout); client.def("isLoggedIn", &FXClient::isLoggedIn); client.def("setTimeout", &FXClient::setTimeout); // client.add_property("timeout", &FXClient::timeout); // (Removed because redundant and confusing.) client.def("setLogfile", &FXClient::setLogfile); client.def("getWithRateThread", &FXClient::getWithRateThread); client.def("setWithRateThread", &FXClient::setWithRateThread); client.add_property("withRateThread", &FXClient::getWithRateThread, &FXClient::setWithRateThread); client.def("getWithKeepAliveThread", &FXClient::getWithKeepAliveThread); client.def("setWithKeepAliveThread", &FXClient::setWithKeepAliveThread); client.add_property("withKeepAliveThread", &FXClient::getWithKeepAliveThread, &FXClient::setWithKeepAliveThread); client.def("getWithLoadableKey", &FXClient::getWithLoadableKey); client.def("setWithLoadableKey", &FXClient::setWithLoadableKey); client.add_property("withLoadableKey", &FXClient::getWithLoadableKey, &FXClient::setWithLoadableKey); client.def("getServerTime", &FXClient::getServerTime); // Note: I'm assuming that we don't have to manage the lifespan of the // returned user object here. client.def("getUser", &FXClient::getUser, return_value_policy<reference_existing_object>()); client.def("getRateTable", &FXClient::getRateTable, return_value_policy<reference_existing_object>()); // We don't need to export this, there are several substitute elsewhere. // static DateString timestampToString(time_t stamp) } class_<FXGame, bases<FXClient> > game("FXGame"); class_<FXTrade, bases<FXClient> > trade("FXTrade"); class_<User> user("User", no_init); { user.add_property("userId", &User::userId); user.add_property("createDate", &User::createDate); user.add_property("name", &User::name); user.add_property("email", &User::email); user.add_property("address", &User::address); user.add_property("telephone", &User::telephone); const char*(User::*user_getprofile)() const = &User::profile; void(User::*user_setprofile)(char*) = &User::profile; user.add_property("profile", user_getprofile, user_setprofile); user.def("getAccounts", User__getAccounts); user.def("getAccountWithId", &User::getAccountWithId, return_value_policy<reference_existing_object>()); } class_<Account> account("Account", no_init); { account.def("__str__", &Account__str__); account.add_property("accountId", &Account::accountId); account.add_property("accountName", &Account::accountName); account.add_property("createDate", &Account::createDate); account.add_property("homeCurrency", &Account::homeCurrency); account.add_property("marginRate", &Account::marginRate); account.add_property("balance", &Account::balance); account.def("realizedPL", &Account::realizedPL); account.def("unrealizedPL", &Account::unrealizedPL); account.def("marginUsed", &Account::marginUsed); account.def("marginAvailable", &Account::marginAvailable); account.add_property("profile", Account__profile); account.def("eventManager", &OanPy::Account__eventManager); // return_value_policy<manage_new_object>()); // Order execution. void (Account::*execute_limit)(LimitOrder& anorder) = &Account::execute; account.def("execute", Account__execute_market); account.def("execute", execute_limit); // Order close. MarketOrder (Account::*close_market)(const MarketOrder&) = &Account::close; void (Account::*close_limit)(const LimitOrder&) = &Account::close; void (Account::*close_position)(const char*) = &Account::close; account.def("close", close_market); account.def("close", close_limit); account.def("close", close_position); // Order modify. void (Account::*modify_market)(const MarketOrder&) = &Account::modify; void (Account::*modify_limit)(const LimitOrder&) = &Account::modify; account.def("modify", modify_market); account.def("modify", modify_limit); // Access to orders and positions. account.def("getTrades", Account__getTrades); account.def("getTradeWithId", &Account::getTradeWithId); account.def("getOrders", Account__getOrders); account.def("getOrderWithId", &Account::getOrderWithId); account.def("getPositions", Account__getPositions); account.def("getPosition", &Account::getPosition); account.def("getTransactions", Account__getTransactions); account.def("getTransactionWithId", &Account::getTransactionWithId); } }
void doReadBody(MktDataGlobalHeaderMsg* header, char* msgType){ switch(*msgType){ case 'N': case 'M': case 'X': case 'G': case 'H': case 'J': { boost::asio::async_read(_socket, boost::asio::buffer(_data, sizeof(MktDataOrderMsg)), [this, &header, &msgType](boost::system::error_code ec, std::size_t length) { if(!ec){ MktDataOrderMsg* body = new MktDataOrderMsg; memcpy((void*)body, (void*)_data, sizeof(MktDataOrderMsg)); Order::SharedPtr order(new SimpleOrder(*header, *msgType, *body)); { std::string str; try{ LatencyChecker<> lc(str); _orderBookManager.addOrder(order); }catch(const std::runtime_error& err){ std::cout << " Exception " << err.what() << std::endl; } order->toString(str); _orderBookManager.printOrderBookForSymbol(str, body->_toeknNo); _logger.log(std::move(str)); } delete body; doReadHeader(); }else{ std::cout << "Exception comes - Socket Closed. " << std::endl; _socket.close(); } }); } break; case 'T': case 'K': { boost::asio::async_read(_socket, boost::asio::buffer(_data, sizeof(MktDataTradeMsg)), [this, &header, &msgType](boost::system::error_code ec, std::size_t length) { if(!ec){ MktDataTradeMsg* body = new MktDataTradeMsg; memcpy((void*)body, (void*)_data, sizeof(MktDataTradeMsg)); Trade::SharedPtr trade(new SimpleTrade(*header, *msgType, *body)); { std::string str; try{ LatencyChecker<> lc(str); _orderBookManager.addTrade(trade); }catch(const std::runtime_error& err){ std::cout << " Exception " << err.what() << std::endl; } trade->toString(str); _orderBookManager.printOrderBookForSymbol(str, body->_toeknNo); _logger.log(std::move(str)); } delete body; doReadHeader(); }else{ std::cout << "Exception comes - Socket Closed. " << std::endl; _socket.close(); } }); } break; default: std::cout << " Error: Unknown Packet comes.... " << std::endl; break; } }
void mainwindow::on_start_trade_clicked() { trade(); }
void talk_function::start_trade(game *g, npc *p) { int trade_amount = p->op_of_u.owed; p->op_of_u.owed = 0; trade(g, p, trade_amount, _("Trade")); }
void talk_function::mission_reward(game *g, npc *p) { int trade_amount = p->op_of_u.owed; p->op_of_u.owed = 0; trade(g, p, trade_amount, _("Reward")); }
void TradingCycle::run() { trade(); emit my_finished(this); quit(); }
void talk_function::start_trade( npc &p ) { trade( p, 0, _( "Trade" ) ); }