Esempio n. 1
0
char getPI(TLOrder o)
{
    if (o.isLimit() && o.isStop())
        return PRICE_INDICATOR_STOPLIMIT;
    else if (o.isLimit())
        return PRICE_INDICATOR_LIMIT;
    else if (o.isStop())
        return PRICE_INDICATOR_STOP;
    return PRICE_INDICATOR_MARKET;

}
Esempio n. 2
0
static void __stdcall Basics()
{
	const CString sym = "LVS";
	const double x = 10;
	const int s = 200;
	TLOrder o;
	CFIX_ASSERT(!o.isFilled());
	CFIX_ASSERT(!o.isValid());
	o.symbol = sym;
	o.size = s;
	CFIX_ASSERT(o.isMarket());
	o.price = x;
	CFIX_ASSERT(o.isLimit());
	o.stop = x;
	CFIX_ASSERT(o.isStop());
}
Esempio n. 3
0
	int TWS_TLServer::SendOrder(TLOrder o)
	{
		// check our order
		if (o.symbol=="") return UNKNOWN_SYMBOL;
		if (!o.isValid()) return INVALID_ORDERSIZE;


		// create broker-specific objects here
		Order* order(new Order);
		order->auxPrice = o.isTrail() ? o.trail : o.stop;
		order->lmtPrice = o.price;
		order->orderType = (o.isStop()) ? "STP" : (o.isLimit() ? "LMT" : (o.isTrail() ? "TRAIL" : "MKT"));
		order->totalQuantity = (long)o.size;
		order->action = (o.side) ? "BUY" : "SELL";
		order->account = o.account;
		order->tif = o.TIF;
		order->outsideRth = true;
		order->orderId = newOrder(o.id,o.account);
		order->transmit = true;

		Contract* contract(new Contract);
		contract->symbol = o.symbol;
		contract->localSymbol = o.localsymbol!="" ? o.localsymbol : o.symbol;
		if (o.exchange=="")
			o.exchange = "SMART";
		contract->exchange = o.exchange;
		contract->secType = o.security;
		contract->currency = o.currency;

		// get the TWS session associated with our account
		EClient* client;
		if (o.account=="") // if no account specified, get default
			client = m_link[this->validlinkids[0]];
		else // otherwise get the session our account is logged into
			client	= GetOrderSink(o.account);

		// place our order
		if (client!=NULL)
			client->placeOrder(order->orderId,*contract,*order);

		delete order;
		delete contract;

		return OK;
	}
Esempio n. 4
0
long LS_TLWM::gettype(TLOrder o)
{
    long type = o.isStop() ? L_OrderType::STOP :
                ( o.isLimit() ? L_OrderType::LIMIT : L_OrderType::MARKET);

    if ((o.TIF=="DAY")
            || (o.TIF=="IOC")
            || (o.TIF=="GTC")
            || (o.TIF==""))
        return type;

    if (o.TIF=="MOC")
        return L_OrderType::MOC;
    else if ((o.TIF=="LOO") || (o.TIF=="OPG"))
        return L_OrderType::LOO;
    else if (o.TIF=="LOC")
        return L_OrderType::LOC;
    else if (o.TIF=="MOO")
        return L_OrderType::MOO;

    return type;
}