market_history_record(price highest_bid = price(),
                       price lowest_ask = price(),
                       share_type volume = 0,
                       fc::optional<price> recent_average_price = fc::optional<price>())
   : highest_bid(highest_bid),
     lowest_ask(lowest_ask),
     volume(volume),
     recent_average_price(recent_average_price)
 {}
 market_history_record(price highest_bid = price(),
                       price lowest_ask = price(),
                       price opening_price = price(),
                       price closing_price = price(),
                       share_type volume = 0)
   : highest_bid(highest_bid),
     lowest_ask(lowest_ask),
     opening_price(opening_price),
     closing_price(closing_price),
     volume(volume)
 {}
int StaticHashTableBuilder::calcBestModulus (){
	int bestPrice  = price (1);
	int bestMod    = 1;
	for (size_t i = 2; i < 3 * mHashes.size(); i++){
		int p = price (i);
		if (p < bestPrice){
			bestPrice = p;
			bestMod   = i;
		}
	}
	return bestMod;
}
int main(int argc, char **argv) {
  parse_args(argc, argv);

  float res = price(n);
  printf("Price is: %f\n", res);

  for (int i = 0; i < runs; i++) {
    start_run();
    res = price(n);
    end_run();
    printf("Price is: %f\n", res);
  }
}
void KEquityPriceUpdateDlg::storePrices()
{
  // update the new prices into the equities

  MyMoneyFile* file = MyMoneyFile::instance();
  QList<MyMoneySecurity> equities = file->securityList();

  QTreeWidgetItem* item = 0;
  MyMoneyFileTransaction ft;
  QString name;

  try {
    for (int i = 0; i < lvEquityList->invisibleRootItem()->childCount(); ++i) {
      item = lvEquityList->invisibleRootItem()->child(i);
      // turn on signals before we modify the last entry in the list
      MyMoneyFile::instance()->blockSignals(i < lvEquityList->invisibleRootItem()->childCount() - 1);

      MyMoneyMoney rate(item->text(PRICE_COL));
      if (!rate.isZero()) {
        QString id = item->text(ID_COL).toUtf8();

        // if the ID has a space, then this is TWO ID's, so it's a currency quote
        if (QString(id).contains(" ")) {
          QStringList ids = id.split(' ', QString::SkipEmptyParts);
          QString fromid = ids[0].toUtf8();
          QString toid = ids[1].toUtf8();
          name = QString("%1 --> %2").arg(fromid).arg(toid);
          MyMoneyPrice price(fromid, toid, QDate().fromString(item->text(DATE_COL), Qt::ISODate), rate, item->text(SOURCE_COL));
          file->addPrice(price);
        } else
          // otherwise, it's a security quote
        {
          MyMoneySecurity security = MyMoneyFile::instance()->security(id);
          name = security.name();
          MyMoneyPrice price(id, security.tradingCurrency(), QDate().fromString(item->text(DATE_COL), Qt::ISODate), rate, item->text(SOURCE_COL));

          // TODO (Ace) Better handling of the case where there is already a price
          // for this date.  Currently, it just overrides the old value.  Really it
          // should check to see if the price is the same and prompt the user.
          MyMoneyFile::instance()->addPrice(price);
        }

      }
    }
    ft.commit();

  } catch (const MyMoneyException &) {
    qDebug("Unable to add price information for %s", qPrintable(name));
  }
}
Beispiel #6
0
double MUPD::calc_mu_per_d(
        const SharedMember<Consumer::Differentiable> &con,
        Member::Lock &lock,
        id_t mkt_id,
        const allocation &alloc,
        const Bundle &b) const {

    if (mkt_id == 0)
        return con->d(b, money);

    auto sim = simulation();
    auto mkt = sim->market(mkt_id);
    lock.add(mkt);

    double mu = 0.0;
    // Add together all of the marginal utilities weighted by the output level, since the market may
    // produce more than one good, and quantities may not equal 1.
    for (auto g : mkt->output_unit)
        mu += g.second * con->d(b, g.first);

    double q = alloc.quantity.count(mkt_id) ? alloc.quantity.at(mkt_id) : 0;
    auto pricing = mkt->price(q);

    lock.remove(mkt);

    if (!pricing.feasible) {
        throw market_exhausted_error(mkt_id);
    }

    return mu / pricing.marginal * price_ratio(mkt);
}
Beispiel #7
0
int main()
{
  typedef float T;
  double t(0),v(0);
  {
    std::vector<T> price     (128000);
    std::vector<T> strike    (128000);
    std::vector<T> rate      (128000);
    std::vector<T> time      (128000);
    std::vector<T> volatility(128000);
    std::vector<T> call      (128000);
    std::vector<T> put       (128000);

    std::fill(price.begin(),price.end(),1.);
    std::fill(strike.begin(),strike.end(),1.);
    std::fill(rate.begin(),rate.end(),1.);
    std::fill(time.begin(),time.end(),1.);
    std::fill(volatility.begin(),volatility.end(),1.);

    std::cout << "std::vector\n";
    for(int k=0;k<100;++k)
    {
      nt2::tic();
      for(std::size_t i=0;i<price.size();++i)
      blackscholes( price[i], strike[i] , rate[i] , time[i] , volatility[i]
                  , call[i] , put[i]
                  );
      t += nt2::toc(false);
    }
    std::cout << t/100 << "\n";
  }

  v = call();
  std::cout << "Speed-up: " << t/v << "\n";
}
Beispiel #8
0
function run()
{
	vars Price = series(price());
	vars Trend = series(LowPass(Price,1000));
	
	Stop = 100*PIP;
	TakeProfit = 100*PIP;
	if(valley(Trend)) {
		//plotPriceProfile(50,0);
		enterLong();
	} else if(peak(Trend)) {
		//plotPriceProfile(50,PMINUS);
		enterShort();
	}

	PlotWidth = 1000;
	PlotHeight1 = 320;
	PlotScale = 4;
	
	//plotDay(Equity,PDIFF); 
	//plotWeek(Equity,PDIFF); 
	//plotMonth(Equity,PDIFF); 
	//plotYear(Equity,PDIFF); 
	plotTradeProfile(50);
}
Beispiel #9
0
void MainWindow::populateStore()
{

    int row = 0;
    int i = 0;
    for(auto item : store) {
        QString name(item.first.c_str());
        QString price(QString::number(item.second));
        QPushButton *button = new QPushButton(name);
        QLabel *label = new QLabel("$"+price);
        button->setObjectName(name);
        label->setObjectName(price);
        shopSignalMapper->setMapping(button, name);
        connect(button, SIGNAL(clicked()), shopSignalMapper, SLOT(map()));
        label->setAlignment(Qt::AlignCenter);
        ui->shopLayout->addWidget(button, row, i, Qt::AlignCenter);
        ui->shopLayout->addWidget(label, row+1, i, Qt::AlignCenter);
        QSize widgetSize(50, 50);
        button->setFixedSize(widgetSize);
        label->setFixedSize(widgetSize);
        i++;
        if(i == 9) {
            i = 0;
            row += 2;
        }
    }
}
Beispiel #10
0
function run()
{
	BarPeriod = 240;	// 4 hour bars
	
// calculate the buy/sell signal
	vars Price = series(price());
	vars DomPeriod = series(DominantPeriod(Price,30));
	var LowPeriod = LowPass(DomPeriod,500);
	vars HP = series(HighPass(Price,LowPeriod));
	vars Signal = series(Fisher(HP,500));
	var Threshold = 1.0;

// buy and sell
	Stop = 4*ATR(100);
	Trail = 4*ATR(100);
	if(crossUnder(Signal,-Threshold))
		enterLong(); 
	else if(crossOver(Signal,Threshold))
		enterShort();

// plot signals and thresholds
	plot("DominantPeriod",LowPeriod,NEW,BLUE);
	plot("Signal",Signal[0],NEW,RED);
	plot("Threshold1",Threshold,0,BLACK);
	plot("Threshold2",-Threshold,0,BLACK);
	PlotWidth = 600;
	PlotHeight1 = 300;
} 
Beispiel #11
0
void Contract::GetContractRow( PyPackedRow* into )
{
    into->SetField( "contractID",			new PyInt(		contractID() ) );
    into->SetField( "issuerID",				new PyInt(		issuerID() ) );
    into->SetField( "issuerCorpID",			new PyInt(		issuerCorpID() ) );
    into->SetField( "type",					new PyInt(		type() ) );
    into->SetField( "availability",			new PyInt(		avail() ) );
    into->SetField( "assigneeID",			new PyInt(		assigneeID() ) );
    into->SetField( "numDays",				new PyInt(		0 ) );
    into->SetField( "startStationID",		new PyInt(		startStationID() ) );
    into->SetField( "endStationID",			new PyInt(		endStationID() ) );
    into->SetField( "startSolarSystemID",   new PyInt(		startSolarSystemID() ) );
    into->SetField( "endSolarSystemID",		new PyInt(		endSolarSystemID() ) );
    into->SetField( "startRegionID",		new PyInt(		startRegionID() ) );
    into->SetField( "endRegionID",			new PyInt(		endRegionID() ) );
    into->SetField( "price",				new PyFloat(	price() ) );
    into->SetField( "reward",				new PyFloat(	reward() ) );
    into->SetField( "collateral",			new PyFloat(	collateral() ) );
    into->SetField( "title",				new PyWString(	title().c_str(), title().length() ) );
    into->SetField( "description",			new PyWString(	description().c_str(), description().length() ) );
    into->SetField( "forCorp",				new PyBool(		forCorp() ) );
    into->SetField( "status",				new PyInt(		status() ) );
    into->SetField( "acceptorID",			new PyInt(		acceptorID() ) );
    into->SetField( "dateIssued",			new PyLong(		dateIssued() ) );
    into->SetField( "dateExpired",			new PyLong(		dateExpired() ) );
    into->SetField( "dateAccepted",			new PyLong(		dateAccepted() ) );
    into->SetField( "dateCompleted",		new PyLong(		dateCompleted() ) );
    into->SetField( "volume",				new PyFloat(	volume() ) );
    into->SetField( "issuerAllianceID",		new PyInt(		issuerAllianceID() ) );
    into->SetField( "issuerWalletKey",		new PyInt(		issuerWalletKey() ) );
    into->SetField( "acceptorWalletKey",	new PyInt(		0 ) );
    into->SetField( "crateID",				new PyInt(		0 ) );
}
Beispiel #12
0
 // Copy Constructor
 Good::Good(const Good& other) {
   upc(other._upc);
   name(other._name);
   price(other._price);
   qtyNeeded(other._qtyNeeded);
   taxed(other._taxed);
   quantity(other._quantity);
 }
Beispiel #13
0
 Good::Good(const char* u, const char* n, double p, int q, bool t) {
   upc(u);
   name(n);
   price(p);
   qtyNeeded(q);
   taxed(t);
   quantity(0);
 }
int main(void){
	int rep = 0;
	for (scanf("%d", &rep); rep > 0; --rep){
		double x;
		scanf("%lf", &x);
		printf("f(%.2lf) = %.2lf\n", x, price(x));
	}
	return 0;
}
void makePrice(const QString& _currencyid, const QDate& _date, const MyMoneyMoney& _price )
{
  MyMoneyFileTransaction ft;
  MyMoneyFile* file = MyMoneyFile::instance();
  MyMoneySecurity curr = file->currency(_currencyid);
  MyMoneyPrice price(_currencyid, file->baseCurrency().id(), _date, _price, "test");
  file->addPrice(price);
  ft.commit();
}
Beispiel #16
0
  // operator=
   Item& Item::operator=(const Item& RO){
      upc(RO._upc);
      name(RO._name);
      price(RO._price);
      quantity(RO._quantity);
      taxed(RO._taxed);
      qtyNeeded(RO._qtyNeeded);

      return *this;
   }
Beispiel #17
0
function run()
{
	NumYears = 2;
	BarPeriod = 1440;
	PlotWidth = 800;
	PlotHeight1 = 300;
	ColorUp = ColorDn = 0; // don't plot a real price curve
	set(PLOTNOW);
	
	asset("EUR/USD");
	plot("Price",price(),0,RED);	
	
	vars Random = series(0);
	if(Bar == 1)
		Random[0] = price();
	else
		Random[0] = Random[1] + 0.01*random();
	plot("Random",Random[0],0,BLUE);	
}
Beispiel #18
0
		Product::Product(const char* s, const char* n, double x, int i, bool tax) {
				//	Copies the SKU into the corresponding member variable up to MAX_SKU_LEN characters. 
				//still hae to implement  as just does (strcpy(x,y)) right now
				sku(s);
				name(n);
				price(x);
				qtyNeeded(i);
				quantity(0);
				taxed(tax);
		}
Beispiel #19
0
int main()
{
  double r, t, a;
  
  printf("Input the radius ");
  scanf("%lf", &r);

  printf("Input the thickness ");
  scanf("%lf", &t);
  
  printf("gold   %f\n", price(1324.0, 19.3, r, t));

  printf("silver %f\n", price(17.76, 10.5, r, t));

  printf("copper %f\n", price(0.2211, 8.93, r, t));

  
  return 0;
}
Beispiel #20
0
// plot price difference profile
void plotPriceProfile(int bars,int type)
{
	if(!is(TESTMODE)) return; // [Test] only
	if(!bars) bars = 50;
	set(PLOTNOW+PEEK); // peek in the future 
	var vProfit;
	int count;
	for(count = 1; count < bars; count++) 
	{
		if(type&PDIFF) 
			vProfit = (price(-count-1)-price(-count))/PIP;
		else
			vProfit = (price(-count-1)-price(-1))/PIP;
		if(type&PMINUS) 
			vProfit = -vProfit;
		plotBar("Price",count,count,vProfit,NEW|AVG|BARS|LBL2,COLOR_AVG);
		plotBar("StdDev",count,0,vProfit/4,DEV|BARS,COLOR_DEV);
	}
}
int MealModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 3)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 3;
    }
#ifndef QT_NO_PROPERTIES
    else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            *reinterpret_cast< QString*>(_v) = type();
            break;
        case 1:
            *reinterpret_cast< QString*>(_v) = name();
            break;
        case 2:
            *reinterpret_cast< QString*>(_v) = price();
            break;
        }
        _id -= 3;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            settype(*reinterpret_cast< QString*>(_v));
            break;
        case 1:
            setname(*reinterpret_cast< QString*>(_v));
            break;
        case 2:
            setprice(*reinterpret_cast< QString*>(_v));
            break;
        }
        _id -= 3;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 3;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Beispiel #22
0
int main( ) {
   const std::string xmltext(
      "<inventory title=\"OmniCorp Store #45x10^3\">"
	"<section name=\"health\">"
	  "<item upc=\"123456789\" stock=\"12\">"
	    "<name>Invisibility Cream</name>"
	    "<price>14.50</price>"
	    "<description>Makes you invisible</description>"
	  "</item>"
	  "<item upc=\"445322344\" stock=\"18\">"
	    "<name>Levitation Salve</name>"
	    "<price>23.99</price>"
	    "<description>Levitate yourself for up to 3 hours per application</description>"
	  "</item>"
	"</section>"
	"<section name=\"food\">"
	  "<item upc=\"485672034\" stock=\"653\">"
	    "<name>Blork and Freen Instameal</name>"
	    "<price>4.95</price>"
	    "<description>A tasty meal in a tablet; just add water</description>"
	  "</item>"
	  "<item upc=\"132957764\" stock=\"44\">"
	    "<name>Grob winglets</name>"
	    "<price>3.56</price>"
	    "<description>Tender winglets of Grob. Just add water</description>"
	  "</item>"
	"</section>"
      "</inventory>" ) ;
   std::string::size_type found = xmltext.find( "<item" , 0 ) ; //beginning of first item
   std::string::size_type foundnext = xmltext.find(  "</item>" , found + 5 ) ; //and its end
   std::cout << "The first item is\n" << xmltext.substr( found + 5 , foundnext - ( found + 5 ) ) << '\n' ;
   std::string::const_iterator start , end ;
   start = xmltext.begin( ) ;
   end = xmltext.end( ) ;
   boost::match_results<std::string::const_iterator> what ;
   boost::regex pricefind( "<price>(\\d+\\.?\\d+)</price>" ) ;//this regex finds the prices
   start = xmltext.begin( ) ;
   std::cout << "The prices are:\n" ;
   while ( boost::regex_search( start , end , what , pricefind ) ) {
      std::string price( what[ 1 ].first , what[ 1 ].second ) ;//find the first price
      std::cout << price << std::endl ;
      start = what[ 1 ].second ;                               //continue search after first price found
   }
   start = xmltext.begin( ) ;
   std::vector<std::string> names ;
   boost::regex namefind( "<name>(.+?)</name>" ) ;            //find characters, be greedy!
   while ( boost::regex_search ( start , end , what , namefind ) ) {
      std::string name ( what[ 1 ].first , what[ 1 ].second ) ;
      names.push_back( name ) ;
      start = what[ 1 ].second ;
   }
   std::cout << "The following name elements were found in the xml string:\n" ;
   std::copy( names.begin( ) , names.end( ) , std::ostream_iterator<std::string>( std::cout , "\n" )) ;
   return 0 ;
}
Beispiel #23
0
		//copy con
		Product::Product(const Product& other) {
				//
				sku(other.sku_);
				name(other.name_);
				price(other.price_);
				taxed(other.taxed_);
				quantity(other.quantity_);
				qtyNeeded(other.qtyNeeded_);
				

		}
Beispiel #24
0
 // Assignment Operator=
 Good& Good::operator=(const Good& other) {
   if (this != &other) {
     upc(other._upc);
     name(other._name);
     price(other._price);
     qtyNeeded(other._qtyNeeded);
     taxed(other._taxed);
     quantity(other._quantity);
   }
   return *this;
 }
Beispiel #25
0
// brute force optimization
function run(){  
	set(PARAMETERS);
  int PeriodsEMA1[4] = { 5, 10, 15, 20 };
  int PeriodsEMA2[3] = { 100, 150, 200 };  LookBack = 250;
  int Index = optimize(1,1,4*3,1) - 1;  int PeriodEMA1 = PeriodsEMA1[Index%4];
  int PeriodEMA2 = PeriodsEMA2[Index/4];    vars Price = series(price(0));
  vars EMA1 = series(EMA(Price,PeriodEMA1));
  vars EMA2 = series(EMA(Price,PeriodEMA2));    
  if(crossOver(EMA1,EMA2))
    enterLong();  
  else if(crossUnder(EMA1,EMA2))    
   enterShort();
 }
Beispiel #26
0
QVariant FruitItem::data(int role) const
{
	switch(role) {
		case NameRole:
			return name();
		case SizeRole:
			return size();
		case PriceRole:
			return price();
		default:
			return QVariant();
	}
}
Beispiel #27
0
std::string Pizza::toString() const
{
	std::string tmp(_name);
	tmp.append("(");
	for (ExtToppings::const_iterator it = _toppings.begin(); it != _toppings.end(); ++it)
	{
		tmp.append(it->toString());
	}
	tmp.append(" Price: ");
	tmp.append(Poco::NumberFormatter::format(price()/100.0, 2));
	tmp.append(")");
	return tmp;
}
Beispiel #28
0
		Product& Product::operator=(const Product& other) {
				//may not need to test this
				if (this != &other) {
						sku(other.sku_);
						name(other.name_);
						price(other.price_);
						taxed(other.taxed_);
						quantity(other.quantity_);
						qtyNeeded(other.qtyNeeded_);
				}
						return *this;
				
		}
Beispiel #29
0
double total(int args, ...){
	double total = 0;
	va_list ap;
	va_start(ap, args);

	int i;
	for(i = 0; i < args; i++){
		enum drink d = va_arg(ap, enum drink);
		total +=price(d);
	}
	va_end(ap);
	return total;
}
Beispiel #30
0
std::vector<sf::Vertex> price_demo(unsigned int seed, double drift, double vol, double time, double dt, double jump, double mean_jump_per_unit_time)
{
	const double start_price = 50.0;
	MC101::PriceSimulation price(start_price, drift, vol, dt, seed, jump, mean_jump_per_unit_time);

	std::vector<sf::Vertex> points;
	int count = static_cast<int>(time/dt);
	for(int i=0; i <= count+1; ++i)
	{
		auto point = sf::Vector2f(static_cast<float>(i*dt), static_cast<float>(price.update()));
		points.push_back(point);
	}
	return points;
}