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
(PowerBuilder) ETrade v1 View PortfolioGet portfolio information for a selected brokerage account.
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 integer i integer li_Count_i string ls_PositionId integer li_ExpiryDay integer li_ExpiryMonth integer li_ExpiryYear string ls_SecurityType integer li_StrikePrice string ls_Symbol string ls_SymbolDescription integer li_DateAcquired integer li_PricePaid integer li_Commissions integer li_OtherFees integer li_Quantity string ls_PositionIndicator string ls_PositionType string ls_DaysGain string ls_DaysGainPct string ls_MarketValue integer li_TotalCost string ls_TotalGain integer li_TotalGainPct string ls_PctOfPortfolio integer li_CostPerShare integer li_TodayCommissions integer li_TodayFees integer li_TodayPricePaid integer li_TodayQuantity string ls_AdjPrevClose string ls_Change string ls_ChangePct string ls_LastTrade integer li_LastTradeTime string ls_QuoteStatus integer li_Volume string ls_LotsDetails string ls_QuoteDetails integer li_TotalPages // 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") ls_RespStr = loo_Http.QuickGetStr("https://apisb.etrade.com/v1/accounts/{$accountIdKey}/portfolio") 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("AccountPortfolio|accountId") i = 0 li_Count_i = loo_Xml.NumChildrenHavingTag("AccountPortfolio|Position") do while i < li_Count_i loo_Xml.I = i ls_PositionId = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|positionId") li_ExpiryDay = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|Product|expiryDay") li_ExpiryMonth = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|Product|expiryMonth") li_ExpiryYear = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|Product|expiryYear") ls_SecurityType = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|Product|securityType") li_StrikePrice = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|Product|strikePrice") ls_Symbol = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|Product|symbol") ls_SymbolDescription = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|symbolDescription") li_DateAcquired = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|dateAcquired") li_PricePaid = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|pricePaid") li_Commissions = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|commissions") li_OtherFees = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|otherFees") li_Quantity = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|quantity") ls_PositionIndicator = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|positionIndicator") ls_PositionType = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|positionType") ls_DaysGain = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|daysGain") ls_DaysGainPct = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|daysGainPct") ls_MarketValue = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|marketValue") li_TotalCost = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|totalCost") ls_TotalGain = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|totalGain") li_TotalGainPct = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|totalGainPct") ls_PctOfPortfolio = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|pctOfPortfolio") li_CostPerShare = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|costPerShare") li_TodayCommissions = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|todayCommissions") li_TodayFees = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|todayFees") li_TodayPricePaid = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|todayPricePaid") li_TodayQuantity = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|todayQuantity") ls_AdjPrevClose = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|adjPrevClose") ls_Change = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|Quick|change") ls_ChangePct = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|Quick|changePct") ls_LastTrade = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|Quick|lastTrade") li_LastTradeTime = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|Quick|lastTradeTime") ls_QuoteStatus = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|Quick|quoteStatus") li_Volume = loo_Xml.GetChildIntValue("AccountPortfolio|Position[i]|Quick|volume") ls_LotsDetails = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|lotsDetails") ls_QuoteDetails = loo_Xml.GetChildContent("AccountPortfolio|Position[i]|quoteDetails") i = i + 1 loop li_TotalPages = loo_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> destroy loo_Http destroy loo_Json destroy loo_Xml |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.