void Exchange_Cryptsy::secondSlot()
{
	static int infoCounter=0;
	if(userInfoTime.elapsed()>(lastInfoReceived?10000:1000)&&!isReplayPending(202))
	{
		userInfoTime.restart();
		sendToApi(202,baseValues.currentPair.currRequestPair+"/money/info",true,baseValues.httpSplitPackets);
	}

	if(!tickerOnly&&!isReplayPending(204))sendToApi(204,baseValues.currentPair.currRequestPair+"/money/orders",true,baseValues.httpSplitPackets);

	if(depthEnabled&&(forceDepthLoad||/*infoCounter==3&&*/!isReplayPending(111)))
	{
		emit depthRequested();
		sendToApi(111,baseValues.currentPair.currRequestPair+"/money/depth/fetch",false,baseValues.httpSplitPackets);
		forceDepthLoad=false;
	}

	if(!isReplayPending(101))sendToApi(101,baseValues.currentPair.currRequestPair+"/money/order/lag",false,baseValues.httpSplitPackets);
	if((infoCounter==1)&&!isReplayPending(103))sendToApi(103,baseValues.currentPair.currRequestPair+"/money/ticker",false,baseValues.httpSplitPackets);
	if(!isReplayPending(104))sendToApi(104,baseValues.currentPair.currRequestPair+"/money/ticker_fast",false,baseValues.httpSplitPackets);

	if(!isReplayPending(109))sendToApi(109,baseValues.currentPair.currRequestPair+"/money/trades/fetch?since="+lastTradesDateCache,false,baseValues.httpSplitPackets);
	if(lastHistory.isEmpty())
		if(!isReplayPending(208))sendToApi(208,"money/wallet/history",true,baseValues.httpSplitPackets,"&currency=BTC");
	if(!baseValues.httpSplitPackets&&ShibeHttp)ShibeHttp->prepareDataSend();

	if(++infoCounter>9)
	{
		infoCounter=0;
		quint32 syncNonce=(static_cast<quint32>(time(NULL))-1371854884)*10;
		if(privateNonce<syncNonce)privateNonce=syncNonce;
	}
	Exchange::secondSlot();
}
Beispiel #2
0
void Exchange_BitCurex::secondSlot()
{
    static int sendCounter=0;
    switch(sendCounter)
    {
    case 0:
        if(!isReplayPending(103))sendToApi(103,baseValues.currentPair.currBStrLow.toLatin1()+"/ticker",false);
        break;
    case 1:
        if(!isReplayPending(202))sendToApi(202,"balance/",true,"nonce="+QByteArray::number(++privateNonce));
        break;
    case 2:
        if(!isReplayPending(109))sendToApi(109,baseValues.currentPair.currBStrLow.toLatin1()+'/'+QByteArray::number(lastTradesDate)+"/trades",false);
        break;
    case 3:
        if(!tickerOnly&&!isReplayPending(204))sendToApi(204,"offers/",true,"nonce="+QByteArray::number(++privateNonce));
        break;
    case 4:
        if(isDepthEnabled()&&(forceDepthLoad||!isReplayPending(111)))
        {
            emit depthRequested();
            sendToApi(111,baseValues.currentPair.currBStrLow.toLatin1()+"/"+baseValues.depthCountLimitStr+"/orderbook",false);
            forceDepthLoad=false;
        }
        break;
    case 5:
        if(lastHistory.isEmpty())getHistory(false);
        break;
    default: break;
    }
    if(sendCounter++>=5)sendCounter=0;

	Exchange::secondSlot();
}
void Exchange_Bitfinex::secondSlot()
{
    static int sendCounter=0;
    switch(sendCounter)
    {
    case 0:
        if(!isReplayPending(103))sendToApi(103,"ticker/"+baseValues.currentPair.currRequestPair,false,true);
        break;
    case 1:
        if(!isReplayPending(202))sendToApi(202,"balances",true,true);
        break;
    case 2:
        if(!isReplayPending(109))sendToApi(109,"trades/"+baseValues.currentPair.currRequestPair+"?timestamp="+lastTradesDateCache+"&limit_trades=200"/*astTradesDateCache*/,false,true);
        break;
    case 3:
        if(!tickerOnly&&!isReplayPending(204))sendToApi(204,"orders",true,true);
        break;
    case 4:
        if(isDepthEnabled()&&(forceDepthLoad||!isReplayPending(111)))
        {
            emit depthRequested();
            sendToApi(111,"book/"+baseValues.currentPair.currRequestPair+"?limit_bids="+baseValues.depthCountLimitStr+"&limit_asks="+baseValues.depthCountLimitStr,false,true);
            forceDepthLoad=false;
        }
        break;
    case 5:
        if(lastHistory.isEmpty())
            if(!isReplayPending(208))sendToApi(208,"mytrades",true,true,", \"symbol\": \""+baseValues.currentPair.currRequestPair+"\", \"timestamp\": "+historyLastTimestamp+", \"limit_trades\": 200");
        break;
    default: break;
    }
    if(sendCounter++>=5)sendCounter=0;

	Exchange::secondSlot();
}
void Exchange_Bitstamp::secondSlot()
{
	static int infoCounter=0;
	switch(infoCounter)
	{
	case 0: if(!tickerOnly&&!isReplayPending(204))sendToApi(204,"open_orders/",true,true); break;
	case 1: if(!isReplayPending(202))sendToApi(202,"balance/",true,true); break;
	case 2: if(!isReplayPending(103))sendToApi(103,"ticker/",false,true); break;
	case 3: if(!isReplayPending(109))sendToApi(109,"transactions/",false,true); break;
	case 4: if(lastHistory.isEmpty()&&!isReplayPending(208))sendToApi(208,"user_transactions/",true,true); break;
	default: break;
	}

	if(depthEnabled)
	{
		if(forceDepthLoad||/*infoCounter==5&&*/!isReplayPending(111))
		{
			emit depthRequested();
			sendToApi(111,"order_book/",false,true);
			forceDepthLoad=false;
		}
	}

	if(++infoCounter>4)
	{
		infoCounter=0;
		quint32 syncNonce=(static_cast<quint32>(time(NULL))-1371854884)*10;
		if(privateNonce<syncNonce)privateNonce=syncNonce;
	}

	Exchange::secondSlot();
}
void Exchange_BTCChina::secondSlot()
{
	static int infoCounter=0;
	switch(infoCounter)
	{
	case 0: if(!tickerOnly&&!isReplayPending(204))sendToApi(204,"getOrders",true,true,"true,\"ALL\""); break;
	case 1: if(!isReplayPending(202))sendToApi(202,"getAccountInfo",true,true); break;
	case 2: if(lastHistory.isEmpty()&&!isReplayPending(208))
			{
				if(historyLastDate.isEmpty())
					sendToApi(208,"getTransactions",true,true,"\"all\",100");
				else
                    sendToApi(208,"getTransactions",true,true,"\"all\",1000,0,"+historyLastDate);
			}
			break;
	default: break;
	}

	if(isDepthEnabled()&&(forceDepthLoad||/*infoCounter==3&&*/!isReplayPending(111)))
	{
		if(!isReplayPending(111))
		{
			emit depthRequested();
			sendToApi(111,"getMarketDepth2",true,true,baseValues.depthCountLimitStr+",\""+baseValues.currentPair.currRequestPair+"\"");
		}
		forceDepthLoad=false;
	}

	if(!isReplayPending(103))sendToApi(103,"ticker?market="+baseValues.currentPair.currRequestPair,false,true);//

    if(infoCounter==3&&!isReplayPending(109))
	{
		if(!lastFetchTid.isEmpty())historyLastTradesRequest="historydata?market="+baseValues.currentPair.currRequestPair+"&since="+lastFetchTid;
        else historyLastTradesRequest="historydata?market="+baseValues.currentPair.currRequestPair;
        sendToApi(109,historyLastTradesRequest,false,true);
	}

	if(infoCounter++==3)
	{
		infoCounter=0;
	}

	Exchange::secondSlot();
}
void Exchange_BitMarket::secondSlot()
{
    static int sendCounter=0;
    switch(sendCounter)
    {
    case 0:
        if(!isReplayPending(103))sendToApi(103,"ticker.json",false,true);
        break;
    case 1:
        if(!isReplayPending(202))sendToApi(202,"info",true,true);
        break;
    case 2:
        if(!isReplayPending(109))sendToApi(109,"trades.json?since="+lastTradesTid,false,true);
        break;
    case 3:
        if(!tickerOnly&&!isReplayPending(204))sendToApi(204,"orders&market="+baseValues.currentPair.symbol.toLatin1(),true,true);
        break;
    case 4:
        if(isDepthEnabled()&&(forceDepthLoad||!isReplayPending(111)))
        {
            emit depthRequested();
            sendToApi(111,"orderbook.json",false,true);
            forceDepthLoad=false;
        }
        break;
    case 5:
        if(lastHistory.isEmpty())getHistory(false);
        break;
    default: break;
    }
    if(sendCounter++>=5)sendCounter=0;

    static int nonceCounter=0;
    if(++nonceCounter>9)
	{
        nonceCounter=0;
        quint32 syncNonce=(TimeSync::getTimeT()-1371854884)*10;
		if(privateNonce<syncNonce)privateNonce=syncNonce;
	}
	Exchange::secondSlot();
}
Beispiel #7
0
	tickerOnly=tickOnly;
	if(!tickerOnly)
	{
        connect(mainClass,SIGNAL(apiBuy(QString, double, double)),this,SLOT(buy(QString, double, double)));
        connect(mainClass,SIGNAL(apiSell(QString, double, double)),this,SLOT(sell(QString, double, double)));
        connect(mainClass,SIGNAL(cancelOrderByOid(QString, QByteArray)),this,SLOT(cancelOrder(QString, QByteArray)));
        connect(mainClass,SIGNAL(getHistory(bool)),this,SLOT(getHistory(bool)));

        connect(this,SIGNAL(orderBookChanged(QString, QList<OrderItem> *)),mainClass,SLOT(orderBookChanged(QString, QList<OrderItem> *)));
		connect(this,SIGNAL(historyChanged(QList<HistoryItem>*)),mainClass,SLOT(historyChanged(QList<HistoryItem>*)));
        connect(this,SIGNAL(orderCanceled(QString, QByteArray)),mainClass,SLOT(orderCanceled(QString, QByteArray)));
		connect(this,SIGNAL(ordersIsEmpty()),mainClass,SLOT(ordersIsEmpty()));
	}

	connect(this,SIGNAL(depthRequested()),mainClass,SLOT(depthRequested()));
	connect(this,SIGNAL(depthRequestReceived()),mainClass,SLOT(depthRequestReceived()));
    connect(this,SIGNAL(depthSubmitOrders(QString, QList<DepthItem> *, QList<DepthItem> *)),mainClass,SLOT(depthSubmitOrders(QString, QList<DepthItem> *, QList<DepthItem> *)));
    connect(this,SIGNAL(depthFirstOrder(QString, double,double,bool)),mainClass,SLOT(depthFirstOrder(QString, double,double,bool)));
	connect(this,SIGNAL(showErrorMessage(QString)),mainClass,SLOT(showErrorMessage(QString)));

    connect(this,SIGNAL(availableAmountChanged(QString, double)),mainClass,SLOT(availableAmountChanged(QString, double)));
	connect(mainClass,SIGNAL(clearValues()),this,SLOT(clearValues()));
	connect(mainClass,SIGNAL(reloadDepth()),this,SLOT(reloadDepth()));

    connect(this,SIGNAL(accVolumeChanged(double)),mainClass->ui.accountVolume,SLOT(setValue(double)));
    connect(this,SIGNAL(accFeeChanged(QString, double)),mainClass,SLOT(accFeeChanged(QString,double)));
    connect(this,SIGNAL(accBtcBalanceChanged(QString, double)),mainClass,SLOT(accBtcBalanceChanged(QString, double)));
    connect(this,SIGNAL(accUsdBalanceChanged(QString, double)),mainClass,SLOT(accUsdBalanceChanged(QString, double)));

    connect(this,SIGNAL(loginChanged(QString)),mainClass,SLOT(loginChanged(QString)));