当前位置: 首页>>代码示例>>C++>>正文


C++ TestClient::Subscribe方法代码示例

本文整理汇总了C++中TestClient::Subscribe方法的典型用法代码示例。如果您正苦于以下问题:C++ TestClient::Subscribe方法的具体用法?C++ TestClient::Subscribe怎么用?C++ TestClient::Subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestClient的用法示例。


在下文中一共展示了TestClient::Subscribe方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Basics

static void __stdcall Basics()
{
	// we need this line here in order to create windows from the cfix 
	// console application that runs our tests
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
		return;

	// setup our objects
	TLServer_WM s;
	s.Start();
	TestClient c;
	TestClient c2;
	char* sym = "TST";
	int size = 200;
	double price = 100;
	TLMarketBasket mb;
	mb.Add(sym);
	c.Subscribe(mb);

	// initial tests
	CFIX_ASSERT(c.ticks+c.fills+c.orders==0);

	// Tick test
	TLTick k;
	symcp(k.sym,sym);
	//k.sym = sym;
	k.trade = price;
	k.size = size;
	s.SrvGotTick(k); // send tick
	CFIX_ASSERT(c.ticks==1); 
	// test output
	// cout<<strcat(c.lasttick.sym,k.sym)<<endl;
	CFIX_ASSERT(isstrsame(c.lasttick.sym,k.sym));
	CFIX_ASSERT(c.lasttick.trade==k.trade);
	// make sure ticks were not copied to other clients
	CFIX_ASSERT(c.ticks!=c2.ticks);

	// Fill test
	TLTrade f;
	f.symbol = sym;
	f.xprice = price;
	f.xsize = size;
	f.xdate = 20081220;
	f.xtime = 1556;
	f.side = true;
	s.SrvGotFill(f);
	CFIX_ASSERT(c.fills==1);
	CFIX_ASSERT(c.lastfill.symbol==f.symbol);
	CFIX_ASSERT(c.lastfill.xprice==f.xprice);
	// make sure fills were copiedto other clients
	CFIX_ASSERT(c.fills==c2.fills);

	// Order test
	TLOrder o;
	o.symbol = sym;
	o.price = price;
	o.size = size;
	s.SrvGotOrder(o);
	CFIX_ASSERT(c.orders==1);
	CFIX_ASSERT(c.lastorder.symbol==o.symbol);
	CFIX_ASSERT(c.lastorder.price==o.price);
	// make sure orders were copied to other clients
	CFIX_ASSERT(c.orders==c2.orders);

	// performance test ticks

	// reset ticks
	c.ticks = 0;
	// get random ticks
	const int MAXTICKS = 1000;
	vector<TLTick> ticks;
	for (int i = 0; i<MAXTICKS; i++)
	{
		TLTick k;
		symcp(k.sym,sym);
		k.size = size;
		k.trade = rand();
		ticks.push_back(k);
	}
	// start timer
	unsigned long start = GetTickCount();
	// send ticks to clients
	for (unsigned int i =0; i<ticks.size(); i++)
		s.SrvGotTick(ticks[i]);
	// stop timer
	unsigned long stop = GetTickCount();
	// elapased time
	int elap = (stop - start);
	// ticks per second
	int rate = (MAXTICKS / elap)*1000;
	CFIX_LOG(L"Performance elap (ms): %i",elap);
	CFIX_LOG(L"Performance (ticks/sec): %i",rate);
	// make sure it took reasonable time
	CFIX_ASSERT(elap<200);


	
}
开发者ID:firememory,项目名称:TradeLinkProj,代码行数:98,代码来源:TestTLWM.cpp


注:本文中的TestClient::Subscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。