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
(DataFlex) ETrade v1 View PortfolioGet portfolio information for a selected brokerage account.
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Handle hoJson Boolean iSuccess String sRespStr Integer iStatusCode Handle hoXml String sTagPath Integer iAccountId Integer i Integer iCount_i String sPositionId Integer iExpiryDay Integer iExpiryMonth Integer iExpiryYear String sSecurityType Integer iStrikePrice String sSymbol String sSymbolDescription Integer iDateAcquired Integer iPricePaid Integer iCommissions Integer iOtherFees Integer iQuantity String sPositionIndicator String sPositionType String sDaysGain String sDaysGainPct String sMarketValue Integer iTotalCost String sTotalGain Integer iTotalGainPct String sPctOfPortfolio Integer iCostPerShare Integer iTodayCommissions Integer iTodayFees Integer iTodayPricePaid Integer iTodayQuantity String sAdjPrevClose String sChange String sChangePct String sLastTrade Integer iLastTradeTime String sQuoteStatus Integer iVolume String sLotsDetails String sQuoteDetails Integer iTotalPages String sTemp1 Boolean bTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End Set ComOAuth1 Of hoHttp To True Set ComOAuthVerifier Of hoHttp To "" Set ComOAuthConsumerKey Of hoHttp To "ETRADE_CONSUMER_KEY" Set ComOAuthConsumerSecret Of hoHttp To "ETRADE_CONSUMER_SECRET" // Load the access token previously obtained via the OAuth1 3-Legged Authorization examples Step1 and Step2. Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComLoadFile Of hoJson "qa_data/tokens/etrade.json" To iSuccess If (iSuccess <> True) Begin Showln "Failed to load OAuth1 token" Procedure_Return End Get ComStringOf Of hoJson "oauth_token" To sTemp1 Set ComOAuthToken Of hoHttp To sTemp1 Get ComStringOf Of hoJson "oauth_token_secret" To sTemp1 Set ComOAuthTokenSecret Of hoHttp To sTemp1 // See the ETrade v1 API documentation HERE. Get ComSetUrlVar Of hoHttp "accountIdKey" "vsnhtF7d9jXxBy6HyaAC4vQ" To iSuccess Get ComQuickGetStr Of hoHttp "https://apisb.etrade.com/v1/accounts/{$accountIdKey}/portfolio" To sRespStr Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End // A 200 status code indicates success. Get ComLastStatus Of hoHttp To iStatusCode Showln "statusCode = " iStatusCode // Use the following online tool to generate parsing code from sample XML: // Generate Parsing Code from XML // A sample XML response is shown below... Get Create (RefClass(cComChilkatXml)) To hoXml If (Not(IsComObjectCreated(hoXml))) Begin Send CreateComObject of hoXml End Get ComLoadXml Of hoXml sRespStr To iSuccess Get ComGetChildIntValue Of hoXml "AccountPortfolio|accountId" To iAccountId Move 0 To i Get ComNumChildrenHavingTag Of hoXml "AccountPortfolio|Position" To iCount_i While (i < iCount_i) Set ComI Of hoXml To i Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|positionId" To sPositionId Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|Product|expiryDay" To iExpiryDay Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|Product|expiryMonth" To iExpiryMonth Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|Product|expiryYear" To iExpiryYear Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|Product|securityType" To sSecurityType Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|Product|strikePrice" To iStrikePrice Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|Product|symbol" To sSymbol Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|symbolDescription" To sSymbolDescription Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|dateAcquired" To iDateAcquired Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|pricePaid" To iPricePaid Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|commissions" To iCommissions Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|otherFees" To iOtherFees Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|quantity" To iQuantity Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|positionIndicator" To sPositionIndicator Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|positionType" To sPositionType Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|daysGain" To sDaysGain Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|daysGainPct" To sDaysGainPct Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|marketValue" To sMarketValue Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|totalCost" To iTotalCost Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|totalGain" To sTotalGain Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|totalGainPct" To iTotalGainPct Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|pctOfPortfolio" To sPctOfPortfolio Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|costPerShare" To iCostPerShare Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|todayCommissions" To iTodayCommissions Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|todayFees" To iTodayFees Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|todayPricePaid" To iTodayPricePaid Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|todayQuantity" To iTodayQuantity Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|adjPrevClose" To sAdjPrevClose Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|Quick|change" To sChange Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|Quick|changePct" To sChangePct Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|Quick|lastTrade" To sLastTrade Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|Quick|lastTradeTime" To iLastTradeTime Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|Quick|quoteStatus" To sQuoteStatus Get ComGetChildIntValue Of hoXml "AccountPortfolio|Position[i]|Quick|volume" To iVolume Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|lotsDetails" To sLotsDetails Get ComGetChildContent Of hoXml "AccountPortfolio|Position[i]|quoteDetails" To sQuoteDetails Move (i + 1) To i Loop Get ComGetChildIntValue Of hoXml "AccountPortfolio|totalPages" To iTotalPages // <?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> End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.