Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

VB.NET Web API Examples

Primary Categories

ABN AMRO
AWS Translate
Activix CRM
Adyen
Amazon DynamoDB
Amazon MWS
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bitfinex v2 REST
Bluzone
CallRail
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
Jira
Lightspeed

MYOB
Magento
MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
Rabobank
SOAP finkok.com
Shippo
Shopify
SimpleTexting
Square
Stripe
SugarCRM
Trello
Twilio
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
WhatsApp
WiX
WooCommerce
Xero
Yousign
_Miscellaneous_
eBay
effectconnect

 

 

 

(VB.NET) ETrade List Orders

Gets the order details for a selected brokerage account based on the search criteria provided.

For more information, see https://apisb.etrade.com/docs/api/order/api-order-v1.html#/definition/getOrders

Chilkat .NET Downloads

Chilkat .NET Assemblies

Chilkat for .NET Core

Chilkat for Mono

' This requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

Dim http As New Chilkat.Http

http.OAuth1 = True
http.OAuthVerifier = ""
http.OAuthConsumerKey = "ETRADE_CONSUMER_KEY"
http.OAuthConsumerSecret = "ETRADE_CONSUMER_SECRET"

' Load the access token previously obtained via the OAuth1 Authorization
Dim jsonToken As New Chilkat.JsonObject
Dim success As Boolean = jsonToken.LoadFile("qa_data/tokens/etrade.json")
If (success <> True) Then
    Debug.WriteLine("Failed to load OAuth1 token")
    Exit Sub
End If


http.OAuthToken = jsonToken.StringOf("oauth_token")
http.OAuthTokenSecret = jsonToken.StringOf("oauth_token_secret")

Dim sandboxUrl As String = "https://apisb.etrade.com/v1/accounts/{$accountIdKey}/orders"
Dim liveUrl As String = "https://api.etrade.com/v1/accounts/{$accountIdKey}/orders"

http.SetUrlVar("accountIdKey","6_Dpy0rmuQ9cu9IbTfvF2A")

Dim resp As Chilkat.HttpResponse = http.QuickGetObj(sandboxUrl)
If (http.LastMethodSuccess <> True) Then
    Debug.WriteLine(http.LastErrorText)
    Exit Sub
End If


' Make sure a successful response was received.
If (resp.StatusCode > 200) Then
    Debug.WriteLine(resp.StatusLine)
    Debug.WriteLine(resp.Header)
    Debug.WriteLine(resp.BodyStr)
    Exit Sub
End If


' Sample XML response:

' Use this online tool to generate parsing code from sample XML: 
' Generate Parsing Code from XML

' <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
' <OrdersResponse>
'     <marker>12345678999</marker>
'     <next>https://api.sit.etrade.com/accounts/E5Nd4LJBsEi_UyHm4Vio9g/orders?marker=12345678999</next>
'     <Order>
'         <orderId>479</orderId>
'         <details>https://api.etrade.com/accounts/E5Nd4LJBsEi_UyHm4Vio9g/orders/479</details>
'         <orderType>OPTN</orderType>
'         <OrderDetail>
'             <placedTime>123453456</placedTime>
'             <orderValue>123.0000</orderValue>
'             <status>OPEN</status>
'             <orderTerm>GOOD_FOR_DAY</orderTerm>
'             <priceType>LIMIT</priceType>
'             <limitPrice>1.5</limitPrice>
'             <stopPrice>0</stopPrice>
'             <marketSession>REGULAR</marketSession>
'             <allOrNone>false</allOrNone>
'             <Instrument>
'                 <Product>
'                     <symbol>RIMM</symbol>
'                     <securityType>OPTN</securityType>
'                     <callPut>CALL</callPut>
'                     <expiryYear>2012</expiryYear>
'                     <expiryMonth>3</expiryMonth>
'                     <expiryDay>9</expiryDay>
'                     <strikePrice>12</strikePrice>
'                 </Product>
'                 <symbolDescription>RESEARCH IN MOTION LTD COM</symbolDescription>
'                 <orderAction>BUY_OPEN</orderAction>
'                 <quantityType>QUANTITY</quantityType>
'                 <orderedQuantity>5</orderedQuantity>
'                 <filledQuantity>5</filledQuantity>
'                 <averageExecutionPrice>0</averageExecutionPrice>
'                 <estimatedCommission>9.99</estimatedCommission>
'                 <estimatedFees>0</estimatedFees>
'             </Instrument>
'             <netPrice>0</netPrice>
'             <netBid>0</netBid>
'             <netAsk>0</netAsk>
'             <gcd>0</gcd>
'             <ratio/>
'         </OrderDetail>
'     </Order>
'     <Order>
'         <orderId>477</orderId>
'         <details>https://api.etrade.com/accounts/E5Nd4LJBsEi_UyHm4Vio9g/orders/477</details>
'         <orderType>ONE_CANCELS_ALL</orderType>
'         <totalOrderValue>209.99</totalOrderValue>
'         <totalCommission>10.74</totalCommission>
'         <OrderDetail>
'             <orderNumber>1</orderNumber>
'             <placedTime>1331699203122</placedTime>
'             <orderValue>123.0000</orderValue>
'             <status>OPEN</status>
'             <orderTerm>GOOD_FOR_DAY</orderTerm>
'             <priceType>LIMIT</priceType>
'             <limitPrice>2</limitPrice>
'             <stopPrice>0</stopPrice>
'             <marketSession>REGULAR</marketSession>
'             <bracketedLimitPrice>2</bracketedLimitPrice>
'             <initialStopPrice>2</initialStopPrice>
'             <allOrNone>false</allOrNone>
'             <Instrument>
'                 <Product>
'                     <symbol>ETFC</symbol>
'                     <securityType>EQ</securityType>
'                 </Product>
'                 <symbolDescription>ETRADE Financials</symbolDescription>
'                 <orderAction>BUY</orderAction>
'                 <quantityType>QUANTITY</quantityType>
'                 <orderedQuantity>100</orderedQuantity>
'                 <filledQuantity>0</filledQuantity>
'                 <averageExecutionPrice>0</averageExecutionPrice>
'                 <estimatedCommission>9.99</estimatedCommission>
'                 <estimatedFees>0</estimatedFees>
'             </Instrument>
'             <netPrice>0</netPrice>
'             <netBid>0</netBid>
'             <netAsk>0</netAsk>
'             <gcd>0</gcd>
'             <ratio/>
'         </OrderDetail>
'         <OrderDetail>
'             <orderNumber>2</orderNumber>
'             <placedTime>1331699203</placedTime>
'             <orderValue>231.0000</orderValue>
'             <status>OPEN</status>
'             <orderTerm>GOOD_FOR_DAY</orderTerm>
'             <priceType>LIMIT</priceType>
'             <limitPrice>0.5</limitPrice>
'             <stopPrice>0</stopPrice>
'             <marketSession>REGULAR</marketSession>
'             <initialStopPrice>0.5</initialStopPrice>
'             <allOrNone>false</allOrNone>
'             <Instrument>
'                 <Product>
'                     <symbol>MON</symbol>
'                     <securityType>OPTN</securityType>
'                     <callPut>CALL</callPut>
'                     <expiryYear>2012</expiryYear>
'                     <expiryMonth>4</expiryMonth>
'                     <expiryDay>21</expiryDay>
'                     <strikePrice>85</strikePrice>
'                 </Product>
'                 <symbolDescription>MON Mar 9 '12 $85 Call</symbolDescription>
'                 <orderAction>BUY_OPEN</orderAction>
'                 <quantityType>QUANTITY</quantityType>
'                 <orderedQuantity>1</orderedQuantity>
'                 <filledQuantity>0</filledQuantity>
'                 <averageExecutionPrice>0</averageExecutionPrice>
'                 <estimatedCommission>9.99</estimatedCommission>
'                 <estimatedFees>0</estimatedFees>
'             </Instrument>
'             <netPrice>0</netPrice>
'             <netBid>0</netBid>
'             <netAsk>0</netAsk>
'             <gcd>0</gcd>
'             <ratio/>
'         </OrderDetail>
'     </Order>
'     <Order>
'         <orderId>475</orderId>
'         <details>https://api.etrade.com/accounts/E5Nd4LJBsEi_UyHm4Vio9g/orders/475</details>
'         <orderType>SPREADS</orderType>
'         <OrderDetail>
'             <placedTime>1331742953</placedTime>
'             <executedTime>1331742955432</executedTime>
'             <orderValue>4445.99</orderValue>
'             <status>EXECUTED</status>
'             <orderTerm>GOOD_FOR_DAY</orderTerm>
'             <priceType>NET_DEBIT</priceType>
'             <limitPrice>1.5</limitPrice>
'             <stopPrice>0</stopPrice>
'             <marketSession>REGULAR</marketSession>
'             <allOrNone>false</allOrNone>
'             <Instrument>
'                 <Product>
'                     <symbol>REE</symbol>
'                     <securityType>OPTN</securityType>
'                     <callPut>CALL</callPut>
'                     <expiryYear>2012</expiryYear>
'                     <expiryMonth>7</expiryMonth>
'                     <expiryDay>21</expiryDay>
'                     <strikePrice>7</strikePrice>
'                 </Product>
'                 <symbolDescription>REE Jul 21 '12 $7 Call</symbolDescription>
'                 <orderAction>BUY_OPEN</orderAction>
'                 <quantityType>QUANTITY</quantityType>
'                 <orderedQuantity>2</orderedQuantity>
'                 <filledQuantity>2</filledQuantity>
'                 <averageExecutionPrice>1.5</averageExecutionPrice>
'                 <estimatedCommission>7.24</estimatedCommission>
'                 <estimatedFees>0</estimatedFees>
'             </Instrument>
'             <Instrument>
'                 <Product>
'                     <symbol>REE</symbol>
'                     <securityType>OPTN</securityType>
'                     <callPut>PUT</callPut>
'                     <expiryYear>2013</expiryYear>
'                     <expiryMonth>1</expiryMonth>
'                     <expiryDay>19</expiryDay>
'                     <strikePrice>12.50</strikePrice>
'                 </Product>
'                 <symbolDescription>REE Jan 19 '13 $12.50 Put</symbolDescription>
'                 <orderAction>BUY_OPEN</orderAction>
'                 <quantityType>QUANTITY</quantityType>
'                 <orderedQuantity>2</orderedQuantity>
'                 <filledQuantity>2</filledQuantity>
'                 <averageExecutionPrice>1.5</averageExecutionPrice>
'                 <estimatedCommission>7.24</estimatedCommission>
'                 <estimatedFees>0</estimatedFees>
'             </Instrument>
'             <netPrice>0</netPrice>
'             <netBid>0</netBid>
'             <netAsk>0</netAsk>
'             <gcd>0</gcd>
'             <ratio/>
'         </OrderDetail>
'     </Order>
' </OrdersResponse>
' 

Dim xml As New Chilkat.Xml
xml.LoadXml(resp.BodyStr)
Debug.WriteLine(xml.GetXml())




Dim orderId As Integer
Dim details As String
Dim orderType As String
Dim j As Integer
Dim count_j As Integer
Dim placedTime As String
Dim orderValue As String
Dim status As String
Dim orderTerm As String
Dim priceType As String
Dim limitPrice As String
Dim stopPrice As Integer
Dim marketSession As String
Dim allOrNone As String
Dim k As Integer
Dim count_k As Integer
Dim symbol As String
Dim securityType As String
Dim callPut As String
Dim expiryYear As Integer
Dim expiryMonth As Integer
Dim expiryDay As Integer
Dim strikePrice As String
Dim symbolDescription As String
Dim orderAction As String
Dim quantityType As String
Dim orderedQuantity As Integer
Dim filledQuantity As Integer
Dim averageExecutionPrice As String
Dim estimatedCommission As String
Dim estimatedFees As Integer
Dim netPrice As Integer
Dim netBid As Integer
Dim netAsk As Integer
Dim gcd As Integer
Dim orderNumber As Integer
Dim bracketedLimitPrice As Integer
Dim initialStopPrice As String
Dim executedTime As String
Dim totalOrderValue As String
Dim totalCommission As String

Dim marker As String = xml.GetChildContent("marker")
Dim next As String = xml.GetChildContent("next")
Dim i As Integer = 0
Dim count_i As Integer = xml.NumChildrenHavingTag("Order")
While i < count_i
    xml.I = i
    orderId = xml.GetChildIntValue("Order[i]|orderId")
    details = xml.GetChildContent("Order[i]|details")
    orderType = xml.GetChildContent("Order[i]|orderType")
    j = 0
    count_j = xml.NumChildrenHavingTag("Order[i]|OrderDetail")
    While j < count_j
        xml.J = j
        placedTime = xml.GetChildContent("Order[i]|OrderDetail[j]|placedTime")
        orderValue = xml.GetChildContent("Order[i]|OrderDetail[j]|orderValue")
        status = xml.GetChildContent("Order[i]|OrderDetail[j]|status")
        orderTerm = xml.GetChildContent("Order[i]|OrderDetail[j]|orderTerm")
        priceType = xml.GetChildContent("Order[i]|OrderDetail[j]|priceType")
        limitPrice = xml.GetChildContent("Order[i]|OrderDetail[j]|limitPrice")
        stopPrice = xml.GetChildIntValue("Order[i]|OrderDetail[j]|stopPrice")
        marketSession = xml.GetChildContent("Order[i]|OrderDetail[j]|marketSession")
        allOrNone = xml.GetChildContent("Order[i]|OrderDetail[j]|allOrNone")
        k = 0
        count_k = xml.NumChildrenHavingTag("Order[i]|OrderDetail[j]|Instrument")
        While k < count_k
            xml.K = k
            symbol = xml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|Product|symbol")
            securityType = xml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|Product|securityType")
            callPut = xml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|Product|callPut")
            expiryYear = xml.GetChildIntValue("Order[i]|OrderDetail[j]|Instrument[k]|Product|expiryYear")
            expiryMonth = xml.GetChildIntValue("Order[i]|OrderDetail[j]|Instrument[k]|Product|expiryMonth")
            expiryDay = xml.GetChildIntValue("Order[i]|OrderDetail[j]|Instrument[k]|Product|expiryDay")
            strikePrice = xml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|Product|strikePrice")
            symbolDescription = xml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|symbolDescription")
            orderAction = xml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|orderAction")
            quantityType = xml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|quantityType")
            orderedQuantity = xml.GetChildIntValue("Order[i]|OrderDetail[j]|Instrument[k]|orderedQuantity")
            filledQuantity = xml.GetChildIntValue("Order[i]|OrderDetail[j]|Instrument[k]|filledQuantity")
            averageExecutionPrice = xml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|averageExecutionPrice")
            estimatedCommission = xml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|estimatedCommission")
            estimatedFees = xml.GetChildIntValue("Order[i]|OrderDetail[j]|Instrument[k]|estimatedFees")
            k = k + 1
        End While
        netPrice = xml.GetChildIntValue("Order[i]|OrderDetail[j]|netPrice")
        netBid = xml.GetChildIntValue("Order[i]|OrderDetail[j]|netBid")
        netAsk = xml.GetChildIntValue("Order[i]|OrderDetail[j]|netAsk")
        gcd = xml.GetChildIntValue("Order[i]|OrderDetail[j]|gcd")
        orderNumber = xml.GetChildIntValue("Order[i]|OrderDetail[j]|orderNumber")
        bracketedLimitPrice = xml.GetChildIntValue("Order[i]|OrderDetail[j]|bracketedLimitPrice")
        initialStopPrice = xml.GetChildContent("Order[i]|OrderDetail[j]|initialStopPrice")
        executedTime = xml.GetChildContent("Order[i]|OrderDetail[j]|executedTime")
        j = j + 1
    End While
    totalOrderValue = xml.GetChildContent("Order[i]|totalOrderValue")
    totalCommission = xml.GetChildContent("Order[i]|totalCommission")
    i = i + 1
End While

Debug.WriteLine("Success.")

 

© 2000-2020 Chilkat Software, Inc. All Rights Reserved.