Chilkat Examples

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

Visual FoxPro Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
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
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(Visual FoxPro) ETrade v1 View Portfolio

Get portfolio information for a selected brokerage account.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

LOCAL loHttp
LOCAL loJson
LOCAL lnSuccess
LOCAL lcRespStr
LOCAL lnStatusCode
LOCAL loXml
LOCAL lcTagPath
LOCAL lnAccountId
LOCAL i
LOCAL lnCount_i
LOCAL lcPositionId
LOCAL lnExpiryDay
LOCAL lnExpiryMonth
LOCAL lnExpiryYear
LOCAL lcSecurityType
LOCAL lnStrikePrice
LOCAL lcSymbol
LOCAL lcSymbolDescription
LOCAL lnDateAcquired
LOCAL lnPricePaid
LOCAL lnCommissions
LOCAL lnOtherFees
LOCAL lnQuantity
LOCAL lcPositionIndicator
LOCAL lcPositionType
LOCAL lcDaysGain
LOCAL lcDaysGainPct
LOCAL lcMarketValue
LOCAL lnTotalCost
LOCAL lcTotalGain
LOCAL lnTotalGainPct
LOCAL lcPctOfPortfolio
LOCAL lnCostPerShare
LOCAL lnTodayCommissions
LOCAL lnTodayFees
LOCAL lnTodayPricePaid
LOCAL lnTodayQuantity
LOCAL lcAdjPrevClose
LOCAL lcChange
LOCAL lcChangePct
LOCAL lcLastTrade
LOCAL lnLastTradeTime
LOCAL lcQuoteStatus
LOCAL lnVolume
LOCAL lcLotsDetails
LOCAL lcQuoteDetails
LOCAL lnTotalPages

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

loHttp = CreateObject('Chilkat_9_5_0.Http')

loHttp.OAuth1 = 1
loHttp.OAuthVerifier = ""
loHttp.OAuthConsumerKey = "ETRADE_CONSUMER_KEY"
loHttp.OAuthConsumerSecret = "ETRADE_CONSUMER_SECRET"

* Load the access token previously obtained via the OAuth1 3-Legged Authorization examples Step1 and Step2.
loJson = CreateObject('Chilkat_9_5_0.JsonObject')
lnSuccess = loJson.LoadFile("qa_data/tokens/etrade.json")
IF (lnSuccess <> 1) THEN
    ? "Failed to load OAuth1 token"
    RELEASE loHttp
    RELEASE loJson
    CANCEL
ENDIF

loHttp.OAuthToken = loJson.StringOf("oauth_token")
loHttp.OAuthTokenSecret = loJson.StringOf("oauth_token_secret")

* See the ETrade v1 API documentation HERE.

loHttp.SetUrlVar("accountIdKey","vsnhtF7d9jXxBy6HyaAC4vQ")
lcRespStr = loHttp.QuickGetStr("https://apisb.etrade.com/v1/accounts/{$accountIdKey}/portfolio")
IF (loHttp.LastMethodSuccess <> 1) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loJson
    CANCEL
ENDIF

* A 200 status code indicates success.
lnStatusCode = loHttp.LastStatus
? "statusCode = " + STR(lnStatusCode)

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

* A sample XML response is shown below...

loXml = CreateObject('Chilkat_9_5_0.Xml')
loXml.LoadXml(lcRespStr)

lnAccountId = loXml.GetChildIntValue("AccountPortfolio|accountId")
i = 0
lnCount_i = loXml.NumChildrenHavingTag("AccountPortfolio|Position")
DO WHILE i < lnCount_i
    loXml.I = i
    lcPositionId = loXml.GetChildContent("AccountPortfolio|Position[i]|positionId")
    lnExpiryDay = loXml.GetChildIntValue("AccountPortfolio|Position[i]|Product|expiryDay")
    lnExpiryMonth = loXml.GetChildIntValue("AccountPortfolio|Position[i]|Product|expiryMonth")
    lnExpiryYear = loXml.GetChildIntValue("AccountPortfolio|Position[i]|Product|expiryYear")
    lcSecurityType = loXml.GetChildContent("AccountPortfolio|Position[i]|Product|securityType")
    lnStrikePrice = loXml.GetChildIntValue("AccountPortfolio|Position[i]|Product|strikePrice")
    lcSymbol = loXml.GetChildContent("AccountPortfolio|Position[i]|Product|symbol")
    lcSymbolDescription = loXml.GetChildContent("AccountPortfolio|Position[i]|symbolDescription")
    lnDateAcquired = loXml.GetChildIntValue("AccountPortfolio|Position[i]|dateAcquired")
    lnPricePaid = loXml.GetChildIntValue("AccountPortfolio|Position[i]|pricePaid")
    lnCommissions = loXml.GetChildIntValue("AccountPortfolio|Position[i]|commissions")
    lnOtherFees = loXml.GetChildIntValue("AccountPortfolio|Position[i]|otherFees")
    lnQuantity = loXml.GetChildIntValue("AccountPortfolio|Position[i]|quantity")
    lcPositionIndicator = loXml.GetChildContent("AccountPortfolio|Position[i]|positionIndicator")
    lcPositionType = loXml.GetChildContent("AccountPortfolio|Position[i]|positionType")
    lcDaysGain = loXml.GetChildContent("AccountPortfolio|Position[i]|daysGain")
    lcDaysGainPct = loXml.GetChildContent("AccountPortfolio|Position[i]|daysGainPct")
    lcMarketValue = loXml.GetChildContent("AccountPortfolio|Position[i]|marketValue")
    lnTotalCost = loXml.GetChildIntValue("AccountPortfolio|Position[i]|totalCost")
    lcTotalGain = loXml.GetChildContent("AccountPortfolio|Position[i]|totalGain")
    lnTotalGainPct = loXml.GetChildIntValue("AccountPortfolio|Position[i]|totalGainPct")
    lcPctOfPortfolio = loXml.GetChildContent("AccountPortfolio|Position[i]|pctOfPortfolio")
    lnCostPerShare = loXml.GetChildIntValue("AccountPortfolio|Position[i]|costPerShare")
    lnTodayCommissions = loXml.GetChildIntValue("AccountPortfolio|Position[i]|todayCommissions")
    lnTodayFees = loXml.GetChildIntValue("AccountPortfolio|Position[i]|todayFees")
    lnTodayPricePaid = loXml.GetChildIntValue("AccountPortfolio|Position[i]|todayPricePaid")
    lnTodayQuantity = loXml.GetChildIntValue("AccountPortfolio|Position[i]|todayQuantity")
    lcAdjPrevClose = loXml.GetChildContent("AccountPortfolio|Position[i]|adjPrevClose")
    lcChange = loXml.GetChildContent("AccountPortfolio|Position[i]|Quick|change")
    lcChangePct = loXml.GetChildContent("AccountPortfolio|Position[i]|Quick|changePct")
    lcLastTrade = loXml.GetChildContent("AccountPortfolio|Position[i]|Quick|lastTrade")
    lnLastTradeTime = loXml.GetChildIntValue("AccountPortfolio|Position[i]|Quick|lastTradeTime")
    lcQuoteStatus = loXml.GetChildContent("AccountPortfolio|Position[i]|Quick|quoteStatus")
    lnVolume = loXml.GetChildIntValue("AccountPortfolio|Position[i]|Quick|volume")
    lcLotsDetails = loXml.GetChildContent("AccountPortfolio|Position[i]|lotsDetails")
    lcQuoteDetails = loXml.GetChildContent("AccountPortfolio|Position[i]|quoteDetails")
    i = i + 1
ENDDO
lnTotalPages = loXml.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>

RELEASE loHttp
RELEASE loJson
RELEASE loXml


 

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