Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(AutoIt) ETrade v1 View PortfolioGet portfolio information for a selected brokerage account.
; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oHttp = ObjCreate("Chilkat_9_5_0.Http") $oHttp.OAuth1 = True $oHttp.OAuthVerifier = "" $oHttp.OAuthConsumerKey = "ETRADE_CONSUMER_KEY" $oHttp.OAuthConsumerSecret = "ETRADE_CONSUMER_SECRET" ; Load the access token previously obtained via the OAuth1 3-Legged Authorization examples Step1 and Step2. $oJson = ObjCreate("Chilkat_9_5_0.JsonObject") Local $bSuccess = $oJson.LoadFile("qa_data/tokens/etrade.json") If ($bSuccess <> True) Then ConsoleWrite("Failed to load OAuth1 token" & @CRLF) Exit EndIf $oHttp.OAuthToken = $oJson.StringOf("oauth_token") $oHttp.OAuthTokenSecret = $oJson.StringOf("oauth_token_secret") ; See the ETrade v1 API documentation HERE. $oHttp.SetUrlVar("accountIdKey","vsnhtF7d9jXxBy6HyaAC4vQ") Local $sRespStr = $oHttp.QuickGetStr("https://apisb.etrade.com/v1/accounts/{$accountIdKey}/portfolio") If ($oHttp.LastMethodSuccess <> True) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf ; A 200 status code indicates success. Local $iStatusCode = $oHttp.LastStatus ConsoleWrite("statusCode = " & $iStatusCode & @CRLF) ; Use the following online tool to generate parsing code from sample XML: ; Generate Parsing Code from XML ; A sample XML response is shown below... $oXml = ObjCreate("Chilkat_9_5_0.Xml") $oXml.LoadXml($sRespStr) Local $sTagPath Local $iAccountId Local $i Local $iCount_i Local $sPositionId Local $iExpiryDay Local $iExpiryMonth Local $iExpiryYear Local $securityType Local $iStrikePrice Local $symbol Local $symbolDescription Local $iDateAcquired Local $iPricePaid Local $iCommissions Local $iOtherFees Local $iQuantity Local $sPositionIndicator Local $sPositionType Local $sDaysGain Local $sDaysGainPct Local $sMarketValue Local $iTotalCost Local $sTotalGain Local $iTotalGainPct Local $sPctOfPortfolio Local $iCostPerShare Local $iTodayCommissions Local $iTodayFees Local $iTodayPricePaid Local $iTodayQuantity Local $sAdjPrevClose Local $sChange Local $sChangePct Local $sLastTrade Local $iLastTradeTime Local $sQuoteStatus Local $iVolume Local $sLotsDetails Local $sQuoteDetails Local $iTotalPages $iAccountId = $oXml.GetChildIntValue("AccountPortfolio|accountId") $i = 0 $iCount_i = $oXml.NumChildrenHavingTag("AccountPortfolio|Position") While $i < $iCount_i $oXml.I = $i $sPositionId = $oXml.GetChildContent("AccountPortfolio|Position[i]|positionId") $iExpiryDay = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|Product|expiryDay") $iExpiryMonth = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|Product|expiryMonth") $iExpiryYear = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|Product|expiryYear") $securityType = $oXml.GetChildContent("AccountPortfolio|Position[i]|Product|securityType") $iStrikePrice = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|Product|strikePrice") $symbol = $oXml.GetChildContent("AccountPortfolio|Position[i]|Product|symbol") $symbolDescription = $oXml.GetChildContent("AccountPortfolio|Position[i]|symbolDescription") $iDateAcquired = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|dateAcquired") $iPricePaid = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|pricePaid") $iCommissions = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|commissions") $iOtherFees = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|otherFees") $iQuantity = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|quantity") $sPositionIndicator = $oXml.GetChildContent("AccountPortfolio|Position[i]|positionIndicator") $sPositionType = $oXml.GetChildContent("AccountPortfolio|Position[i]|positionType") $sDaysGain = $oXml.GetChildContent("AccountPortfolio|Position[i]|daysGain") $sDaysGainPct = $oXml.GetChildContent("AccountPortfolio|Position[i]|daysGainPct") $sMarketValue = $oXml.GetChildContent("AccountPortfolio|Position[i]|marketValue") $iTotalCost = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|totalCost") $sTotalGain = $oXml.GetChildContent("AccountPortfolio|Position[i]|totalGain") $iTotalGainPct = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|totalGainPct") $sPctOfPortfolio = $oXml.GetChildContent("AccountPortfolio|Position[i]|pctOfPortfolio") $iCostPerShare = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|costPerShare") $iTodayCommissions = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|todayCommissions") $iTodayFees = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|todayFees") $iTodayPricePaid = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|todayPricePaid") $iTodayQuantity = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|todayQuantity") $sAdjPrevClose = $oXml.GetChildContent("AccountPortfolio|Position[i]|adjPrevClose") $sChange = $oXml.GetChildContent("AccountPortfolio|Position[i]|Quick|change") $sChangePct = $oXml.GetChildContent("AccountPortfolio|Position[i]|Quick|changePct") $sLastTrade = $oXml.GetChildContent("AccountPortfolio|Position[i]|Quick|lastTrade") $iLastTradeTime = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|Quick|lastTradeTime") $sQuoteStatus = $oXml.GetChildContent("AccountPortfolio|Position[i]|Quick|quoteStatus") $iVolume = $oXml.GetChildIntValue("AccountPortfolio|Position[i]|Quick|volume") $sLotsDetails = $oXml.GetChildContent("AccountPortfolio|Position[i]|lotsDetails") $sQuoteDetails = $oXml.GetChildContent("AccountPortfolio|Position[i]|quoteDetails") $i = $i + 1 Wend $iTotalPages = $oXml.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-2024 Chilkat Software, Inc. All Rights Reserved.