int main(int argc, char** argv) { purchase input1,input2,input3; float sales_tax; /* UNIT TESTS - HARD CODED INPUT */ /* For Input 1 */ input1.books.price.push_back(12.49); input1.music.price.push_back(14.99); input1.choc.price.push_back(0.85); /* For input 2 */ input2.choc_imp.price.push_back(10.00); input2.perf_imp.price.push_back(47.50); /* For input 3 */ input3.perf_imp.price.push_back(27.99); input3.perf.price.push_back(18.99); input3.pills.price.push_back(9.75); input3.choc_imp.price.push_back(11.25); for(unsigned int i=1;i<=3;i++) { cout<<"Output "<<i<<" : "; if(i==1) { sales_tax = CalTax(&input1); Price(&input1,sales_tax); } else if(i==2) { sales_tax = CalTax(&input2); Price(&input2,sales_tax); } else if(i==3) { sales_tax = CalTax(&input3); Price(&input3,sales_tax); } } return 0; }
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); }
int Category::find() { // qDebug() << "find category"; QString query = QString("SELECT id, priceID FROM categories WHERE " "teamID = %1 AND techID = %2 AND typeID = %3 AND homeID = %4 AND line = %5;") .arg(teamID).arg(techID).arg(typeID).arg(homeID).arg(line); // qDebug() << query; QSqlQuery *q = new QSqlQuery(query, App::theApp()->db()); q->exec(); if (q->size() == 0) { // нет этой категории, создаем категорию... if (!create()) return -1; // Создали, находим (рекурсивно) return find(); } q->first(); int id = q->value("id").toInt(); int priceID = q->value("priceID").toInt(); price = Price(priceID); // qDebug() << "find category. ID = " << id << " priceID = " << priceID; return id; }
PriceColumn::PriceColumn(Table* t, const QString& n, int digits) : TextColumn(t, n, 0, Qt::AlignRight) { fixed number = pow(10.0, digits) - 1.0; QString text = valcon.format(Price(number)); width = t->fontMetrics().width(text); checkWidth(); }
//Price mesher vector<double>PutOption::Price(const EuropeanOption & obj,vector<double> Mesh) const//price for a range { vector<double> temp; for (int i=0; i<Mesh.size();i++) { double opt = Price(Mesh[i]); temp.push_back(opt); } return temp; }
Category::Category() { // qDebug() << "clear category. ID = " << ID; teamID = 0; techID = 0; typeID = 0; homeID = 0; line = 0; ID = 0; price = Price(); // qDebug() << "clear category. ID = " << ID; }
QVariant PartDistributorProxyModel::data(const QModelIndex &proxyIndex, int role) const { if(!proxyIndex.isValid()) return QVariant(); int column = proxyIndex.column(); if(column == PartDistributorTableModel2::ColumnUnitPrice){ if(role == Qt::DisplayRole || role == Qt::EditRole){ QVariant value = sourceModel()->index(proxyIndex.row(), PartDistributorTableModel2::ColumnUnitPrice).data(); QVariant currency = sourceModel()->index(proxyIndex.row(), PartDistributorTableModel2::ColumnCurrency).data(); if(value.isValid()){ return QVariant::fromValue(Price(value.toDouble(), currency.toString())); } } } return QIdentityProxyModel::data(proxyIndex, role); }
vector<double>PutOption::Price(vector<double> Mesh, double param) const { if (param == optdata.sig_() || param == optdata.T_()) { vector<double> temp; for (int i=0; i<Mesh.size();i++) { double opt = Price(Mesh[i]); temp.push_back(opt); } return temp; } }
int main() { int n, i; double p[Max_size]; scanf("%d", &n); for (i=0; i<n; i++) scanf("%lf", &p[i]); Price(n, p); for (i=0; i<n; i++) printf("%.2f ", p[i]); printf("\n"); return 0; }
Price UnpaidDocumentTVModel::getUnpaidPurchaseDocumentsValue() { QString warehouseId = QString::number(ApplicationManager::getInstance()->getWarehouseId()); QSqlQuery *query = new QSqlQuery(Database::getInstance().db); query->prepare("SELECT SUM(total) AS value " "FROM purchase_documents " "WHERE is_active = true AND is_paid = false " + notOnTimeFilter + "AND purchase_documents.warehouse = " + warehouseId); query->exec(); query->first(); double value = query->value(0).toDouble(); delete query; return Price(value); }
void TSSWRealizedVolatility::PostUpdate( void ) { double result( 0.0 ); if ( 1.0 == m_dblP ) { result = m_dblSum / m_n; } else { if ( 2.0 == m_dblP ) { result = std::sqrt( m_dblSum / m_n ); } else { result = std::pow( m_dblSum / m_n, 1.0 / m_dblP ); } } Prices::Append( Price( m_dt, result * m_dblScaleFactor ) ); }
Price CurrentInventoryGroupsTVModel::getValue() { QString warehouseId = QString::number(ApplicationManager::getInstance()->getWarehouse()->getId()); QSqlQuery *query = new QSqlQuery(Database::getInstance().db); query->prepare("SELECT SUM(quantity*price_mag_net) AS value " "FROM goods, wh_goods " "WHERE wh_goods.is_active = true AND type = 1 " "AND wh_goods.good = goods.id_good AND wh_goods.warehouse = " + warehouseId); query->exec(); query->first(); double value = query->value(0).toDouble(); delete query; return Price(value); }
SimplePropertySet<string, double> propertylist() { SimplePropertySet<string, double> result; result.add (Property<string, double> ("Option Value", Price() ) ); result.add (Property<string, double> ("Delta",Delta() ) ); result.add (Property<string, double> ("Gamma",Gamma() ) ); result.add (Property<string, double> ("Vega",Vega() ) ); result.add (Property<string, double> ("Vega",Theta() ) ); result.add (Property<string, double> ("Rho",Rho() ) ); result.add (Property<string, double> ("Cost of Carry",Coc() ) ); // Cost of carry cout << "counbt " << result.Count(); return result; }
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); }
floating TSecurity::MarketValueY( floating anominal, const TDate& asettle, floating aytm ) const { return MarketValue( anominal, asettle, Price(asettle,aytm) ); }
void Goods::setPriceGross(int priceType, double priceValue) { prices->replace(priceType + Price::GROSS, Price(priceValue)); }
void Goods::setPriceNet(int priceType, double priceValue) { prices->replace(priceType + Price::NET, Price(priceValue)); }
int main(void) { char choice; int product_number, product_type, product_quantity; double product_cost, product_price; double price, cost, profit, total_price, total_cost, total_profit; /*sums */ double sum_price = 0; double sum_cost = 0; int sum_quantity = 0; do{ /* User data entry*/ printf("%s\n\n", NAME); printf("Enter the product number:"); scanf("%d%*c", &product_number); printf("Enter the product type:"); scanf("%d%*c", &product_type); printf("Enter the quantity:"); scanf("%d%*c", &product_quantity); printf("Enter cost:"); scanf("%lf%*c", &product_cost); printf("Enter the price:"); scanf("%lf%*c", &product_price); /* Single product display */ printf("\nThe product number is ------ %04d\n", product_number); printf("The product type is ------ %d\n", product_type); printf("The quantity is ------ %d\n", product_quantity); printf("The cost is ------ $%.2lf\n", product_cost); printf("The price is ------ $%.2lf\n", product_price); /* Running total of all entries */ sum_price += product_price; sum_cost += product_cost; sum_quantity+=1; /*Business logic functions */ price = Price(product_quantity , product_price); cost = Cost(product_cost , product_quantity); profit = Profit(price, cost); /* Single product business display */ printf("Total product price ------ $%4.2lf\n", price); printf("Total product cost ------ $%4.2lf\n", cost); printf("Total product profit ------ $%4.2lf\n", profit); printf("Would you like to continue? (type Y/N)\n"); scanf(" %c%*c", &choice); } while(toupper(choice)=='Y'); /*Finally calculations for business logic */ total_price = Price(sum_quantity, sum_price); total_cost = Cost(sum_cost, sum_quantity); total_profit = Profit(total_price, total_cost); /* Summations of Products */ printf("Total count of all products -> %d\n", sum_quantity); printf("Total of all prices ------ %4.2lf\n", total_price); printf("Total of all costs ------ $%4.2lf\n", total_cost); printf("Total profit ------ $ %4.2lf\n", total_profit); return 0; }
Vector<double> graph( string& sensitivity_type, string& property, Vector<double> parameter_range) { curr = &T; // Default x axis is time T if (property == "r") curr = &r; if (property == "sig") curr = &sig; if (property == "K") curr = &K; if (property == "T") curr = &T; if (property == "U") curr = &U; if (property == "b") curr = &b; // Save the value in the 'current' property double memento = (*curr)(); Vector<double> result (parameter_range.Size(), parameter_range.MinIndex()); if (sensitivity_type == "Price") { for (int i = parameter_range.MinIndex(); i <= parameter_range.MaxIndex(); i++) { (*curr)(parameter_range[i]); result[i] = Price(); } } if (sensitivity_type == "Delta") { for (int i = parameter_range.MinIndex(); i <= parameter_range.MaxIndex(); i++) { (*curr)(parameter_range[i]); result[i] = Delta(); } } if (sensitivity_type == "Gamma") { for (int i = parameter_range.MinIndex(); i <= parameter_range.MaxIndex(); i++) { (*curr)(parameter_range[i]); result[i] = Gamma(); } } if (sensitivity_type == "Vega") { for (int i = parameter_range.MinIndex(); i <= parameter_range.MaxIndex(); i++) { (*curr)(parameter_range[i]); result[i] = Vega(); } } if (sensitivity_type == "Theta") { for (int i = parameter_range.MinIndex(); i <= parameter_range.MaxIndex(); i++) { (*curr)(parameter_range[i]); result[i] = Theta(); } } if (sensitivity_type == "Rho") { for (int i = parameter_range.MinIndex(); i <= parameter_range.MaxIndex(); i++) { (*curr)(parameter_range[i]); result[i] = Rho(); } } if (sensitivity_type == "Coc") { for (int i = parameter_range.MinIndex(); i <= parameter_range.MaxIndex(); i++) { (*curr)(parameter_range[i]); result[i] = Coc(); } } // Now restore the old value of the property (*curr)(memento); return result; }
void TSReturns::Append( const Price& price ) { price_t price_ = std::log( price.Value() ); if ( m_bFirstAppend ) m_bFirstAppend = false; else Prices::Append( Price( price.DateTime(), price_ - m_priceLast ) ); m_priceLast = price_; }
void TSReturns::Append( const Trade& trade ) { price_t price_ = std::log( trade.Price() ); if ( m_bFirstAppend ) m_bFirstAppend = false; else Prices::Append( Price( trade.DateTime(), price_ - m_priceLast ) ); m_priceLast = price_; }
//Delta approximation double PutOption::PutDelta_approx(double h) const //h sets the boundaries -h and h { double temp= Price(optdata.U_()+h) -Price(optdata.U_()-h); // return temp/(2*h); }
void TSReturns::Append( const Bar& bar ) { price_t price_ = std::log( bar.Close() ); if ( m_bFirstAppend ) m_bFirstAppend = false; else Prices::Append( Price( bar.DateTime(), price_ - m_priceLast ) ); m_priceLast = price_; }
void TSReturns::Append( const Quote& quote ) { price_t price_ = std::log( quote.LogarithmicMidPointA() ); if ( m_bFirstAppend ) m_bFirstAppend = false; else Prices::Append( Price( quote.DateTime(), price_ - m_priceLast ) ); m_priceLast = price_; }
//Approximate gamma using divided differences double PutOption::Putgamma_approx(double h) const { double temp= Price(optdata.U_()+h) - (2*Price(optdata.U_()))+ Price(optdata.U_()-h); //estimate gamma return temp/(h*h); }