Sunday, November 07, 2010

Streamster™ API Retrieval Methods

Once the SOAP object is created, Streamster API exposes a number of methods you can invoke to communicate with Streamster from your script or application. The following section explores available retrieval methods and related structures.

GetQuote
GetQuote method returns a "Quote" structure for a given instrument name. The Quote structure contains fields equivalent to columns in Rates windows in Streamster. GetQuote returns only fields available in Streamster - if you wish to retrieve any fields not currently shown in Streamster, you have to add them by clicking the Columns button.


Sample - PHP: The following sample retrieves a quote for EUR/USD, displays the "Last" field and then lists all available fields.

SOAP_SINGLE_ELEMENT_ARRAYS));

$quote = $api -> GetQuote("EUR/USD");

echo $quote -> Last . "\n";

foreach($quote as $field => $value) {
echo $field . " = " . $value . "\n";
}

?>

Sample - Visual Basic: The following sample retrieves a quote for EUR/USD, displays the "Last" field and then displays all other fields.

Dim api As StreamsterApi = New StreamsterApi

Dim q As Quote
q = api.GetQuote("EUR/USD")

Console.WriteLine("Last: " & q.Last)
Console.WriteLine("Bid: " & q.Bid)
Console.WriteLine("Offer: " & q.Offer)
Console.WriteLine("Change: " & q.Change)
Console.WriteLine("High: " & q.High)
Console.WriteLine("Low: " & q.Low)
Console.WriteLine("Open: " & q.Open)
Console.WriteLine("Close: " & q.Close)
Console.WriteLine("Time: " & q.Time)
Console.WriteLine("Currency: " & q.Currency)
Console.WriteLine("Yield: " & q.Yield)
Console.WriteLine("Ask: " & q.Ask)


GetOrders
GetOrders method returns an array of "Order" structures. This array corresponds directly to the Orders window in Streamster. Each Order structure in the returned array contains one order with its associated fields as displayed in Streamster. GetOrders returns an array of Order structures which contain only fields available in Streamster - if you wish to retrieve any fields not currently shown in Streamster's Orders window, you have to add them by clicking the Columns button.

Sample - PHP: The following sample retrieves all orders and lists them.

SOAP_SINGLE_ELEMENT_ARRAYS));

$r = $api -> GetOrders();
if(property_exists($r, "Order")) {
foreach($r -> Order as $n => $OrderInfo) {
echo "\tOrder " . $n . "\n";
foreach($OrderInfo as $field => $value) {
echo "\t\tField: " . $field . " = " . $value . "\n";
}
}
}

?>

Sample - Visual Basic: The following sample retrieves all orders and lists them.

Dim api As StreamsterApi = New StreamsterApi

Dim ao As Order()
Dim o As Order

ao = api.GetOrders()

For Each o In ao
Console.WriteLine("")
Console.WriteLine("Order:")

Console.WriteLine("OrderID: " & o.OrderID)
Console.WriteLine("Desk: " & o.Desk)
Console.WriteLine("Instrument: " & o.Instrument)
Console.WriteLine("Side: " & o.Side)
Console.WriteLine("Phase: " & o.Phase)
Console.WriteLine("PriceType: " & o.PriceType)
Console.WriteLine("Price: " & o.Price)
Console.WriteLine("ActiveQuantity: " & o.ActiveQuantity)
Console.WriteLine("TradedQuantity: " & o.TradedQuantity)
Console.WriteLine("ExitStopLoss: " & o.ExitStopLoss)
Console.WriteLine("ExitTarget: " & o.ExitTarget)
Console.WriteLine("Status: " & o.Status)
Console.WriteLine("PositionID: " & o.PositionID)
Console.WriteLine("Currency: " & o.Currency)
Console.WriteLine("Duration: " & o.Duration)
Console.WriteLine("DurationType: " & o.DurationType)
Console.WriteLine("Quantity: " & o.Quantity)
Console.WriteLine("QuantityType: " & o.QuantityType)
Console.WriteLine("Text: " & o.Text)
Console.WriteLine("Entered: " & o.Entered)
Next

GetTrades
GetTrades method returns an array of "Trade" structures. This array corresponds directly to the Trades window in Streamster. Each Trade structure in the returned array contains one trade with its associated fields as displayed in Streamster. GetTrades returns an array of Trade structures which contain only fields available in Streamster - if you wish to retrieve any fields not currently shown in Streamster's Trades window, you have to add them by clicking the Columns button.

Sample - PHP: The following sample retrieves all trades and lists them.

SOAP_SINGLE_ELEMENT_ARRAYS));

$r = $api -> GetTrades();
if(property_exists($r, "Trade")) {
foreach($r -> Trade as $n => $TradeInfo) {
echo "\tTrade " . $n . "\n";
foreach($TradeInfo as $field => $value) {
echo "\t\tField: " . $field . " = " . $value . "\n";
}
}
}

?>

Sample - Visual Basic: The following sample retrieves all trades and lists them.

Dim api As StreamsterApi = New StreamsterApi

Dim at As Trade()
Dim t As Trade

at = api.GetTrades()

For Each t In at
Console.WriteLine("")
Console.WriteLine("Trade:")

Console.WriteLine("TradeID: " & t.TradeID)
Console.WriteLine("Desk: " & t.Desk)
Console.WriteLine("Instrument: " & t.Instrument)
Console.WriteLine("Side: " & t.Side)
Console.WriteLine("Phase: " & t.Phase)
Console.WriteLine("Price: " & t.Price)
Console.WriteLine("Quantity: " & t.Quantity)
Console.WriteLine("Executed: " & t.Executed)
Console.WriteLine("Status: " & t.Status)
Console.WriteLine("Currency: " & t.Currency)
Console.WriteLine("Text: " & t.Text)
Console.WriteLine("OrderID: " & t.OrderID)
Next

No comments:

Post a Comment