Hi guys, I have a question about the Anvil API. Basically, I'm writing a program which keeps track of orders sent and which can automatically cancel them if certain conditions arise. So I'm using the B_SendOrder method in the API, kinda like this:
unsigned int SendOrder(...)
{
...
Order* orderSent;
B_SendOrder(stockHandle, side, destination, size, visibilityMode, visibleSize, price,
&stopPrice, &descretionaryPrice, seconds, proactive, principalOrAgency,
superMontageAlgorithm, oversellHandling, destinationExchange, &orderSent);
return orderSent->GetId();
}
void CancelOrder(unsigned int orderID)
{
Observable* account = B_GetCurrentAccount();
// Question: Why does this return null?
//Order* order = B_FindOrder(orderID, account);
// Do this instead
Order* order = B_FindOrder(orderID, NULL);
if (order != NULL)
{
order->Cancel();
}
}
In simulation mode, the numbers I am getting back from SendOrder are quite a bit larger than are entered in Anvil itself; in fact I have to set some code to subtract from 2147483648 in simulation mode to get a valid order ID for cancelling. This works okay but is hokey.
The real problem is, when in real mode, the numbers I am getting back from SendOrder have no clearly defined relationship with the order numbers entered into Anvil. I would do similarly to what I said above (subtracting from a large number) but there's no way to know exactly what the mapping or difference is, because it changes (presumably because other people are making orders in the system).
To further explain, basically I want to write code like this:
void mymethod()
{
unsigned int orderID = SendOrder("SBUX", 100, true, 15.00, 86400);
CancelOrder(orderID);
}
But this doesn't work because my orderID ends up being wrong.
Also, in CancelOrder above, why does B_FindOrder return null when I use the current account as an argument?
Thanks a lot,
Hexar