コード例 #1
0
ファイル: Strategy.cpp プロジェクト: ctppanda/ctp_candlestick
    void DoubleMAStrategy::Run()
    {
        if (fast_ma->Count() <= 1 || slow_ma->Count() <= 1)
            return;

        double fv1 = fast_ma->get(1);
        double fv0 = fast_ma->get(0);
        double sv1 = slow_ma->get(1);
        double sv0 = slow_ma->get(0);

        if (fv1 < sv1 && fv0 > sv0)
        {
            cout << "Up Cross" << endl;
            SendOrder(inst, Order::Buy, 1, LastPrice());
        }

        if (fv1 > sv1 && fv0 < sv0)
        {
            cout << "Down Cross" << endl;
            SendOrder(inst, Order::Sell, 1, LastPrice());
        }
    }
コード例 #2
0
ファイル: remotectrl.c プロジェクト: Lichanglu/ENC-1260
/*LCD display char*/
static int __SendData(int fd, unsigned char *pdata, int nLen, int nFlag)
{
	int nLength = nLen + 4;
	unsigned char send[300];
	int ret;

	if((nFlag & FLAG_CENTER) == FLAG_CENTER) {
		if(MAX_DISPLAY_CHAR > nLen) {
			SendOrder(fd, FLAG_SETCURSOR, (MAX_DISPLAY_CHAR - nLen) / 2 + (((nFlag & FLAG_NEWLINE) == FLAG_NEWLINE) ? TWO_LINE_POS : ONE_LINE_POS));
		} else {
			SendOrder(fd, FLAG_SETCURSOR, (((nFlag & FLAG_NEWLINE) == FLAG_NEWLINE) ? TWO_LINE_POS : ONE_LINE_POS));
		}
	} else if((nFlag & FLAG_LEFT) == FLAG_LEFT) {
		SendOrder(fd, FLAG_SETCURSOR, (((nFlag & FLAG_NEWLINE) == FLAG_NEWLINE) ? TWO_LINE_POS : ONE_LINE_POS));
	} else if((nFlag & FLAG_RIGHT) == FLAG_RIGHT) {
		if(16 > nLen) {
			SendOrder(fd, FLAG_SETCURSOR, MAX_DISPLAY_CHAR - nLen + (((nFlag & FLAG_NEWLINE) == FLAG_NEWLINE) ? TWO_LINE_POS : ONE_LINE_POS));
		} else {
			SendOrder(fd, FLAG_SETCURSOR, (((nFlag & FLAG_NEWLINE) == FLAG_NEWLINE) ? TWO_LINE_POS : ONE_LINE_POS));
		}
	}

	memset(send, 0, nLength);
	send[0] = 0xF8;
	send[1] = 0x03;
	memcpy(send + 2, pdata, nLen);
	send[nLen + 2] = 0xA0;

	ret = SendDataToCom(fd, send, nLength);

	if(ret == -1) {
		DEBUG(DL_ERROR, "SendData()::SendDataToCom() send error!!!\n");
		return (ret);
	}

	return (ret);
}
コード例 #3
0
void KSingleIVIDLeg::SendOrder(const tbricks::Volume& volume, const tbricks::Price& price, const tbricks::Side& side)
{
	TBDEBUG("-KSingleIVIDLeg::SendOrder()");
	tbricks::Order::Options options;	
	SendOrder(volume, price, side, options);
}
コード例 #4
0
/* Called when the Sell button is pressed
 */
void CSubmitOrderDialog::OnSellButton()
{
	SendOrder("Sell");
}
コード例 #5
0
/* Called when the Buy button is pressed
 */
void CSubmitOrderDialog::OnBuyButton() 
{
	SendOrder("Buy");	
}
コード例 #6
0
ファイル: remotectrl.c プロジェクト: Lichanglu/ENC-1260
/*LCD show infomation*/
void LCDShowInfo(int fd)
{
	char strTemp[200];

	switch(dwShowFlag) {
		case 0:			//encode Name
			SendOrder(fd, FLAG_CLR, 0);
			memset(strTemp, 0, sizeof(strTemp));
			ReadName(strTemp);
			SendData(fd, strTemp, FLAG_CENTER);
			ReadVerNo(strTemp);
			SendData(fd, strTemp, FLAG_CENTER | FLAG_NEWLINE);
			break;

		case 1:
			SendOrder(fd, FLAG_CLR, 0);
			memset(strTemp, 0, sizeof(strTemp));
			GetDeviceType(strTemp);
			SendData(fd, strTemp, FLAG_CENTER);
			ReadIPMaskaddr(strTemp, 0);  //IP
			SendData(fd, strTemp, FLAG_CENTER | FLAG_NEWLINE);
			break;

		case 2:
			SendOrder(fd, FLAG_CLR, 0);
			memset(strTemp, 0, sizeof(strTemp));
			ReadIPMaskaddr(strTemp, 1);  //NW
			SendData(fd, strTemp, FLAG_CENTER);
			ReadIPMaskaddr(strTemp, 2);  //GW
			SendData(fd, strTemp, FLAG_CENTER | FLAG_NEWLINE);
			break;

		case 3:
			SendOrder(fd, FLAG_CLR, 0);
			ReadVideoinfo(strTemp, 0, 1); // width
			SendData(fd, strTemp, FLAG_CENTER);
			ReadVideoinfo(strTemp, 0, 2); // height
			SendData(fd, strTemp, FLAG_CENTER | FLAG_NEWLINE);
			break;

		case 4:
			SendOrder(fd, FLAG_CLR, 0);
			ReadVideoinfo(strTemp, 1, 1);  //VBR or CBR
			SendData(fd, strTemp, FLAG_CENTER);
			ReadVideoinfo(strTemp, 1, 2); //quality or bitrate
			SendData(fd, strTemp, FLAG_CENTER | FLAG_NEWLINE);
			break;

		case 5:
			SendOrder(fd, FLAG_CLR, 0);
			ReadVideoinfo(strTemp, 2, 1);  //Audio samplerate
			SendData(fd, strTemp, FLAG_CENTER);
			ReadVideoinfo(strTemp, 2, 2); //Audio bitrate
			SendData(fd, strTemp, FLAG_CENTER | FLAG_NEWLINE);
			break;
	}

	dwShowFlag++;

	if(dwShowFlag > 5) {	//display
		dwShowFlag = 0;
	}
}
コード例 #7
0
ファイル: ClientGame.cpp プロジェクト: GameJam/thegrid
void ClientGame::OnMouseDown(int x, int y, int button)
{

    if (m_gameState == GameState_MainMenu)
    {
        return;
    }
    
    if (m_gameState != GameState_Playing)
    {
        return;
    }

    Vec2 location;
    if (m_notificationLog.OnMouseDown(x, y, button, location))
    {
        CenterMap(static_cast<int>(location.x), static_cast<int>(location.y));
        return;
    }

    if (button == 1)
    {

        ButtonId buttonId = GetButtonAtPoint(x, y);

        if (buttonId != ButtonId_None)
        {
            m_activeButton = buttonId;
            m_activeButtonDown = true;
            m_mapState = State_Button;

            Protocol::OrderPacket order;
            order.order = kButtonToOrder[buttonId];
            order.agentId = m_selectedAgent;
            SendOrder(order);
        }
        else if (y < m_ySize - yStatusBarSize)
        {
            bool hasSelection = (m_selectedAgent != -1);
            int agentUnderCursor = GetAgentUnderCursor(x, y);
            
            int xWorld, yWorld;
            ScreenToWorld(x, y, xWorld, yWorld);


            int stopUnderCursor = m_map.GetNearestStopForPoint( Vec2(static_cast<float>(xWorld), static_cast<float>(yWorld)) );

            if (agentUnderCursor == -1 && stopUnderCursor != -1 && m_selectedAgent != -1)
            {
                const Entity* selectedEntity = GetEntity(m_selectedAgent);
                if (selectedEntity != NULL)
                {
                    int fromStop = selectedEntity->Cast<AgentEntity>()->m_currentStop;
                    m_pathLength = m_map.GetPath(fromStop, stopUnderCursor, m_path);
                    if (m_pathLength > 1)
                    {
                        m_nextStop = 0;
                    }
                    else
                    {
                        m_pathLength = 0;
                        m_nextStop = -1;
                    }
                }
            }
            else if (m_selectedAgent != agentUnderCursor)
            {
                m_selectedAgent = agentUnderCursor;
                m_pathLength = 0;
                m_nextStop = -1;
            }

            UpdateActiveButtons();
        }

    }

    // Zoom.
    if (button == 4)
    {
        SetMapScale(1, x, y);
    }
    if (button == 5)
    {
        SetMapScale(2, x, y);
    }


    if (button == 2)
    {
        int blipX, blipY;
        ScreenToWorld(x, y, blipX, blipY);

    }

    if (button == 3)
    {
        if (y < m_ySize - yStatusBarSize)
        {
            // Pan with right mouse button.
            if (m_mapState == State_Idle)
            {
                m_mapState = State_Panning;
                m_stateX = x;
                m_stateY = y;
            }
        }
    }

}
コード例 #8
0
ファイル: TLServer_IP.cpp プロジェクト: Decatf/tradelink
	int TLServer_IP::ServiceMessage(int MessageType, CString msg)
	{
		switch (MessageType)
		{
			case ORDERCANCELREQUEST :
				return CancelRequest((long)atoi(msg.GetBuffer()));
			case ACCOUNTREQUEST :
				return AccountResponse(msg);
			case CLEARCLIENT :
				return ClearClient(msg);
			case CLEARSTOCKS :
				return ClearStocks(msg);
			case REGISTERSTOCK :
				{
				vector<CString> rec;
				gsplit(msg,CString("+"),rec);
				CString client = rec[0];
				vector<CString> hisstocks;
				// make sure client sent a basket, otherwise clear the basket
				if (rec.size()!=2) return ClearStocks(client);
				// get the basket
				gsplit(rec[1],CString(","),hisstocks);
				// make sure we have the client
				unsigned int cid = FindClient(client); 
				if (cid==-1) return CLIENTNOTREGISTERED; //client not registered
				// save the basket
				stocks[cid] = hisstocks; 
				D(CString(_T("Client ")+client+_T(" registered: ")+gjoin(hisstocks,",")));
				HeartBeat(client);
				return RegisterStocks(client);
				}
			case POSITIONREQUEST :
				{
				vector<CString> r;
				gsplit(msg,CString("+"),r);
				if (r.size()!=2) return UNKNOWN_MESSAGE;
				return PositionResponse(r[1],r[0]);
				}
			case REGISTERCLIENT :
				return RegisterClient(msg);
			case HEARTBEAT :
				return HeartBeat(msg);
			case BROKERNAME :
				return BrokerName();
			case SENDORDER :
				return SendOrder(TLOrder::Deserialize(msg));
			case FEATUREREQUEST:
				{
					// get features supported by child class
					std::vector<int> stub = GetFeatures();
					// append basic feature we provide as parent
					stub.push_back(REGISTERCLIENT);
					stub.push_back(HEARTBEAT);
					stub.push_back(CLEARSTOCKS);
					stub.push_back(CLEARCLIENT);
					stub.push_back(VERSION);
					// send entire feature set back to client
					TLSend(FEATURERESPONSE,SerializeIntVec(stub),msg);
					return OK;
				}
			case VERSION :
					return MinorVer;
		}

		return UnknownMessage(MessageType,msg);
	}