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 UWP/WinRT Examples

Web API Categories

ASN.1
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(VB.NET UWP/WinRT) ETrade v1 View Portfolio

Get portfolio information for a selected brokerage account.

Chilkat Universal Windows Platform (UWP) / WinRT Downloads

Chilkat for the Universal Windows Platform (UWP)

' This example 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 3-Legged Authorization examples Step1 and Step2.
Dim json As New Chilkat.JsonObject
Dim success As Boolean = json.LoadFile("qa_data/tokens/etrade.json")
If (success <> True) Then
    Debug.WriteLine("Failed to load OAuth1 token")
    Exit Sub
End If


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

' See the ETrade v1 API documentation HERE.


http.SetUrlVar("accountIdKey","vsnhtF7d9jXxBy6HyaAC4vQ")
Dim respStr As String = Await http.QuickGetStrAsync("https://apisb.etrade.com/v1/accounts/{$accountIdKey}/portfolio")
If (http.LastMethodSuccess <> True) Then
    Debug.WriteLine(http.LastErrorText)
    Exit Sub
End If


' A 200 status code indicates success.
Dim statusCode As Integer = http.LastStatus
Debug.WriteLine("statusCode = " & statusCode)

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

' A sample XML response is shown below...

Dim xml As New Chilkat.Xml
xml.LoadXml(respStr)

Dim tagPath As String
Dim accountId As Integer
Dim i As Integer
Dim count_i As Integer
Dim positionId As String
Dim expiryDay As Integer
Dim expiryMonth As Integer
Dim expiryYear As Integer
Dim securityType As String
Dim strikePrice As Integer
Dim symbol As String
Dim symbolDescription As String
Dim dateAcquired As Integer
Dim pricePaid As Integer
Dim commissions As Integer
Dim otherFees As Integer
Dim quantity As Integer
Dim positionIndicator As String
Dim positionType As String
Dim daysGain As String
Dim daysGainPct As String
Dim marketValue As String
Dim totalCost As Integer
Dim totalGain As String
Dim totalGainPct As Integer
Dim pctOfPortfolio As String
Dim costPerShare As Integer
Dim todayCommissions As Integer
Dim todayFees As Integer
Dim todayPricePaid As Integer
Dim todayQuantity As Integer
Dim adjPrevClose As String
Dim change As String
Dim changePct As String
Dim lastTrade As String
Dim lastTradeTime As Integer
Dim quoteStatus As String
Dim volume As Integer
Dim lotsDetails As String
Dim quoteDetails As String
Dim totalPages As Integer

accountId = xml.GetChildIntValue("AccountPortfolio|accountId")
i = 0
count_i = xml.NumChildrenHavingTag("AccountPortfolio|Position")
While i < count_i
    xml.I = i
    positionId = xml.GetChildContent("AccountPortfolio|Position[i]|positionId")
    expiryDay = xml.GetChildIntValue("AccountPortfolio|Position[i]|Product|expiryDay")
    expiryMonth = xml.GetChildIntValue("AccountPortfolio|Position[i]|Product|expiryMonth")
    expiryYear = xml.GetChildIntValue("AccountPortfolio|Position[i]|Product|expiryYear")
    securityType = xml.GetChildContent("AccountPortfolio|Position[i]|Product|securityType")
    strikePrice = xml.GetChildIntValue("AccountPortfolio|Position[i]|Product|strikePrice")
    symbol = xml.GetChildContent("AccountPortfolio|Position[i]|Product|symbol")
    symbolDescription = xml.GetChildContent("AccountPortfolio|Position[i]|symbolDescription")
    dateAcquired = xml.GetChildIntValue("AccountPortfolio|Position[i]|dateAcquired")
    pricePaid = xml.GetChildIntValue("AccountPortfolio|Position[i]|pricePaid")
    commissions = xml.GetChildIntValue("AccountPortfolio|Position[i]|commissions")
    otherFees = xml.GetChildIntValue("AccountPortfolio|Position[i]|otherFees")
    quantity = xml.GetChildIntValue("AccountPortfolio|Position[i]|quantity")
    positionIndicator = xml.GetChildContent("AccountPortfolio|Position[i]|positionIndicator")
    positionType = xml.GetChildContent("AccountPortfolio|Position[i]|positionType")
    daysGain = xml.GetChildContent("AccountPortfolio|Position[i]|daysGain")
    daysGainPct = xml.GetChildContent("AccountPortfolio|Position[i]|daysGainPct")
    marketValue = xml.GetChildContent("AccountPortfolio|Position[i]|marketValue")
    totalCost = xml.GetChildIntValue("AccountPortfolio|Position[i]|totalCost")
    totalGain = xml.GetChildContent("AccountPortfolio|Position[i]|totalGain")
    totalGainPct = xml.GetChildIntValue("AccountPortfolio|Position[i]|totalGainPct")
    pctOfPortfolio = xml.GetChildContent("AccountPortfolio|Position[i]|pctOfPortfolio")
    costPerShare = xml.GetChildIntValue("AccountPortfolio|Position[i]|costPerShare")
    todayCommissions = xml.GetChildIntValue("AccountPortfolio|Position[i]|todayCommissions")
    todayFees = xml.GetChildIntValue("AccountPortfolio|Position[i]|todayFees")
    todayPricePaid = xml.GetChildIntValue("AccountPortfolio|Position[i]|todayPricePaid")
    todayQuantity = xml.GetChildIntValue("AccountPortfolio|Position[i]|todayQuantity")
    adjPrevClose = xml.GetChildContent("AccountPortfolio|Position[i]|adjPrevClose")
    change = xml.GetChildContent("AccountPortfolio|Position[i]|Quick|change")
    changePct = xml.GetChildContent("AccountPortfolio|Position[i]|Quick|changePct")
    lastTrade = xml.GetChildContent("AccountPortfolio|Position[i]|Quick|lastTrade")
    lastTradeTime = xml.GetChildIntValue("AccountPortfolio|Position[i]|Quick|lastTradeTime")
    quoteStatus = xml.GetChildContent("AccountPortfolio|Position[i]|Quick|quoteStatus")
    volume = xml.GetChildIntValue("AccountPortfolio|Position[i]|Quick|volume")
    lotsDetails = xml.GetChildContent("AccountPortfolio|Position[i]|lotsDetails")
    quoteDetails = xml.GetChildContent("AccountPortfolio|Position[i]|quoteDetails")
    i = i + 1
End While
totalPages = xml.GetChildIntValue("AccountPortfolio|totalPages")


' <?xml version="1.0" encoding="UTF-8"?>
' <PortfolioResponse>
'    <AccountPortfolio>
'       <accountId>83554788</accountId>
'       <Position>
'          <positionId>10087531</positionId>
'          <Product>
'             <expiryDay>0</expiryDay>
'             <expiryMonth>0</expiryMonth>
'             <expiryYear>0</expiryYear>
'             <securityType>EQ</securityType>
'             <strikePrice>0</strikePrice>
'             <symbol>A</symbol>
'          </Product>
'          <symbolDescription>A</symbolDescription>
'          <dateAcquired>-68400000</dateAcquired>
'          <pricePaid>0</pricePaid>
'          <commissions>0</commissions>
'          <otherFees>0</otherFees>
'          <quantity>-120</quantity>
'          <positionIndicator>TYPE2</positionIndicator>
'          <positionType>SHORT</positionType>
'          <daysGain>190.80</daysGain>
'          <daysGainPct>2.4472</daysGainPct>
'          <marketValue>-7605.60</marketValue>
'          <totalCost>0</totalCost>
'          <totalGain>-7605.60</totalGain>
'          <totalGainPct>0</totalGainPct>
'          <pctOfPortfolio>-0.0008</pctOfPortfolio>
'          <costPerShare>0</costPerShare>
'          <todayCommissions>0</todayCommissions>
'          <todayFees>0</todayFees>
'          <todayPricePaid>0</todayPricePaid>
'          <todayQuantity>0</todayQuantity>
'          <adjPrevClose>64.970000</adjPrevClose>
'          <Quick>
'             <change>-1.59</change>
'             <changePct>-2.4472</changePct>
'             <lastTrade>63.38</lastTrade>
'             <lastTradeTime>1529429280</lastTradeTime>
'             <quoteStatus>DELAYED</quoteStatus>
'             <volume>2431617</volume>
'          </Quick>
'          <lotsDetails>https://api.etrade.com/v1/accounts/JDIozUumZpHdgbIjMnAAHQ/portfolio/10087531</lotsDetails>
'          <quoteDetails>https://api.etrade.com/v1/market/quote/A</quoteDetails>
'       </Position>
'       <Position>
'          <positionId>140357348131</positionId>
'          <Product>
'             <expiryDay>0</expiryDay>
'             <expiryMonth>0</expiryMonth>
'             <expiryYear>0</expiryYear>
'             <securityType>EQ</securityType>
'             <strikePrice>0</strikePrice>
'             <symbol>TWTR</symbol>
'          </Product>
'          <symbolDescription>TWTR</symbolDescription>
'          <dateAcquired>-68400000</dateAcquired>
'          <pricePaid>0</pricePaid>
'          <commissions>0</commissions>
'          <otherFees>0</otherFees>
'          <quantity>3</quantity>
'          <positionIndicator>TYPE2</positionIndicator>
'          <positionType>LONG</positionType>
'          <daysGain>-3.915</daysGain>
'          <daysGainPct>-2.8369</daysGainPct>
'          <marketValue>134.085</marketValue>
'          <totalCost>0</totalCost>
'          <totalGain>134.085</totalGain>
'          <totalGainPct>0</totalGainPct>
'          <pctOfPortfolio>0.0235</pctOfPortfolio>
'          <costPerShare>0</costPerShare>
'          <todayCommissions>0</todayCommissions>
'          <todayFees>0</todayFees>
'          <todayPricePaid>0</todayPricePaid>
'          <todayQuantity>0</todayQuantity>
'          <adjPrevClose>46.000000</adjPrevClose>
'          <Quick>
'             <change>-1.305</change>
'             <changePct>-2.8369</changePct>
'             <lastTrade>44.695</lastTrade>
'             <lastTradeTime>1529429280</lastTradeTime>
'             <quoteStatus>DELAYED</quoteStatus>
'             <volume>26582141</volume>
'          </Quick>
'          <lotsDetails>https://api.etrade.com/v1/accounts/yIFaUoJ81qyAhgxLWRQ42g/portfolio/140357348131</lotsDetails>
'          <quoteDetails>https://api.etrade.com/v1/market/quote/TWTR</quoteDetails>
'       </Position>
'       <totalPages>1</totalPages>
'    </AccountPortfolio>
' </PortfolioResponse>

 

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