Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

PowerBuilder Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
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
Misc
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
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(PowerBuilder) ETrade v1 Get Account Balances

Get account balances using the ETrade v1 API.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

integer li_rc
oleobject loo_Http
oleobject loo_Json
integer li_Success
string ls_RespStr
integer li_StatusCode
oleobject loo_Xml
string ls_TagPath
integer li_AccountId
string ls_AccountType
string ls_OptionLevel
string ls_AccountDescription
integer li_QuoteMode
string ls_DayTraderStatus
string ls_AccountMode
integer li_FundsForOpenOrdersCash
integer li_MoneyMktBalance
integer li_CashAvailableForInvestment
string ls_NetCash
string ls_CashBalance
integer li_SettledCashForInvestment
integer li_UnSettledCashForInvestment
integer li_FundsWithheldFromPurchasePower
integer li_FundsWithheldFromWithdrawal
integer li_MarginBuyingPower
string ls_CashBuyingPower
integer li_DtMarginBuyingPower
integer li_DtCashBuyingPower
integer li_ShortAdjustBalance
integer li_RegtEquity
integer li_RegtEquityPercent
integer li_AccountBalance
integer li_DtCashOpenOrderReserve
integer li_DtMarginOpenOrderReserve

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

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

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

// Load the access token previously obtained via the OAuth1 3-Legged Authorization examples Step1 and Step2.
loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

li_Success = loo_Json.LoadFile("qa_data/tokens/etrade.json")
if li_Success <> 1 then
    Write-Debug "Failed to load OAuth1 token"
    destroy loo_Http
    destroy loo_Json
    return
end if

loo_Http.OAuthToken = loo_Json.StringOf("oauth_token")
loo_Http.OAuthTokenSecret = loo_Json.StringOf("oauth_token_secret")

// See the ETrade v1 API documentation HERE.

loo_Http.SetUrlVar("accountIdKey","vsnhtF7d9jXxBy6HyaAC4vQ")
loo_Http.SetUrlVar("instType","BROKERAGE")
ls_RespStr = loo_Http.QuickGetStr("https://apisb.etrade.com/v1/accounts/{$accountIdKey}/balance?instType={$instType}&realTimeNAV=true")
if loo_Http.LastMethodSuccess <> 1 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Json
    return
end if

// A 200 status code indicates success.
li_StatusCode = loo_Http.LastStatus
Write-Debug "statusCode = " + string(li_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...

loo_Xml = create oleobject
// Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0
li_rc = loo_Xml.ConnectToNewObject("Chilkat.Xml")

loo_Xml.LoadXml(ls_RespStr)

li_AccountId = loo_Xml.GetChildIntValue("accountId")
ls_AccountType = loo_Xml.GetChildContent("accountType")
ls_OptionLevel = loo_Xml.GetChildContent("optionLevel")
ls_AccountDescription = loo_Xml.GetChildContent("accountDescription")
li_QuoteMode = loo_Xml.GetChildIntValue("quoteMode")
ls_DayTraderStatus = loo_Xml.GetChildContent("dayTraderStatus")
ls_AccountMode = loo_Xml.GetChildContent("accountMode")
li_FundsForOpenOrdersCash = loo_Xml.GetChildIntValue("Cash|fundsForOpenOrdersCash")
li_MoneyMktBalance = loo_Xml.GetChildIntValue("Cash|moneyMktBalance")
li_CashAvailableForInvestment = loo_Xml.GetChildIntValue("Computed|cashAvailableForInvestment")
ls_NetCash = loo_Xml.GetChildContent("Computed|netCash")
ls_CashBalance = loo_Xml.GetChildContent("Computed|cashBalance")
li_SettledCashForInvestment = loo_Xml.GetChildIntValue("Computed|settledCashForInvestment")
li_UnSettledCashForInvestment = loo_Xml.GetChildIntValue("Computed|unSettledCashForInvestment")
li_FundsWithheldFromPurchasePower = loo_Xml.GetChildIntValue("Computed|fundsWithheldFromPurchasePower")
li_FundsWithheldFromWithdrawal = loo_Xml.GetChildIntValue("Computed|fundsWithheldFromWithdrawal")
li_MarginBuyingPower = loo_Xml.GetChildIntValue("Computed|marginBuyingPower")
ls_CashBuyingPower = loo_Xml.GetChildContent("Computed|cashBuyingPower")
li_DtMarginBuyingPower = loo_Xml.GetChildIntValue("Computed|dtMarginBuyingPower")
li_DtCashBuyingPower = loo_Xml.GetChildIntValue("Computed|dtCashBuyingPower")
li_ShortAdjustBalance = loo_Xml.GetChildIntValue("Computed|shortAdjustBalance")
li_RegtEquity = loo_Xml.GetChildIntValue("Computed|regtEquity")
li_RegtEquityPercent = loo_Xml.GetChildIntValue("Computed|regtEquityPercent")
li_AccountBalance = loo_Xml.GetChildIntValue("Computed|accountBalance")
li_DtCashOpenOrderReserve = loo_Xml.GetChildIntValue("Margin|dtCashOpenOrderReserve")
li_DtMarginOpenOrderReserve = loo_Xml.GetChildIntValue("Margin|dtMarginOpenOrderReserve")

// <?xml version="1.0" encoding="UTF-8"?>
// <BalanceResponse>
//    <accountId>83564979</accountId>
//    <accountType>PDT_ACCOUNT</accountType>
//    <optionLevel>LEVEL_4</optionLevel>
//    <accountDescription>KRITHH TT</accountDescription>
//    <quoteMode>6</quoteMode>
//    <dayTraderStatus>PDT_MIN_EQUITY_RES_1XK</dayTraderStatus>
//    <accountMode>PDT ACCOUNT</accountMode>
//    <Cash>
//       <fundsForOpenOrdersCash>0</fundsForOpenOrdersCash>
//       <moneyMktBalance>0</moneyMktBalance>
//    </Cash>
//    <Computed>
//       <cashAvailableForInvestment>0</cashAvailableForInvestment>
//       <netCash>93921.44</netCash>
//       <cashBalance>93921.44</cashBalance>
//       <settledCashForInvestment>0</settledCashForInvestment>
//       <unSettledCashForInvestment>0</unSettledCashForInvestment>
//       <fundsWithheldFromPurchasePower>0</fundsWithheldFromPurchasePower>
//       <fundsWithheldFromWithdrawal>0</fundsWithheldFromWithdrawal>
//       <marginBuyingPower>0</marginBuyingPower>
//       <cashBuyingPower>93921.44</cashBuyingPower>
//       <dtMarginBuyingPower>0</dtMarginBuyingPower>
//       <dtCashBuyingPower>0</dtCashBuyingPower>
//       <shortAdjustBalance>0</shortAdjustBalance>
//       <regtEquity>0</regtEquity>
//       <regtEquityPercent>0</regtEquityPercent>
//       <accountBalance>0</accountBalance>
//    </Computed>
//    <Margin>
//       <dtCashOpenOrderReserve>0</dtCashOpenOrderReserve>
//       <dtMarginOpenOrderReserve>0</dtMarginOpenOrderReserve>
//    </Margin>
// </BalanceResponse>


destroy loo_Http
destroy loo_Json
destroy loo_Xml

 

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