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
(Visual FoxPro) ETrade View PortfolioGets portfolio information for the selected brokerage account. For more information, see https://apisb.etrade.com/docs/api/account/api-portfolio-v1.html
LOCAL loHttp LOCAL loJsonToken LOCAL lnSuccess LOCAL lcSandboxUrl LOCAL lcLiveUrl LOCAL loResp LOCAL loXml LOCAL lnAccountId LOCAL lnPositionId LOCAL lnExpiryDay LOCAL lnExpiryMonth LOCAL lnExpiryYear LOCAL lcSecurityType LOCAL lnStrikePrice LOCAL lcSymbol LOCAL lcSymbolDescription LOCAL lcDateAcquired LOCAL lcPricePaid LOCAL lcCommissions LOCAL lcOtherFees LOCAL lnQuantity LOCAL lcPositionIndicator LOCAL lcPositionType LOCAL lcDaysGain LOCAL lcDaysGainPct LOCAL lcMarketValue LOCAL lcTotalCost LOCAL lcTotalGain LOCAL lcTotalGainPct LOCAL lcPctOfPortfolio LOCAL lcCostPerShare LOCAL lnTodayCommissions LOCAL lnTodayFees LOCAL lnTodayPricePaid LOCAL lnTodayQuantity LOCAL lcChange LOCAL lcChangePct LOCAL lcLastTrade LOCAL lnLastTradeTime LOCAL lnVolume LOCAL lcLotsDetails LOCAL lcQuoteDetails LOCAL lnTotalPages LOCAL i LOCAL lnCount_i * This requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.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 Authorization * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJsonToken = CreateObject('Chilkat.JsonObject') lnSuccess = loJsonToken.LoadFile("qa_data/tokens/etrade.json") IF (lnSuccess <> 1) THEN ? "Failed to load OAuth1 token" RELEASE loHttp RELEASE loJsonToken CANCEL ENDIF loHttp.OAuthToken = loJsonToken.StringOf("oauth_token") loHttp.OAuthTokenSecret = loJsonToken.StringOf("oauth_token_secret") lcSandboxUrl = "https://apisb.etrade.com/v1/accounts/{$accountIdKey}/portfolio" lcLiveUrl = "https://api.etrade.com/v1/accounts/{$accountIdKey}/portfolio" loHttp.SetUrlVar("accountIdKey","6_Dpy0rmuQ9cu9IbTfvF2A") loResp = loHttp.QuickGetObj(lcSandboxUrl) IF (loHttp.LastMethodSuccess <> 1) THEN ? loHttp.LastErrorText RELEASE loHttp RELEASE loJsonToken CANCEL ENDIF * Make sure a successful response was received. IF (loResp.StatusCode > 200) THEN ? loResp.StatusLine ? loResp.Header ? loResp.BodyStr RELEASE loHttp RELEASE loJsonToken CANCEL ENDIF * Sample XML response: * Use this online tool to generate parsing code from sample XML: * Generate Parsing Code from XML * <?xml version="1.0" encoding="UTF-8" standalone="yes"?> * <PortfolioResponse> * <AccountPortfolio> * <accountId>83359700</accountId> * <Position> * <positionId>27005131</positionId> * <Product> * <expiryDay>0</expiryDay> * <expiryMonth>0</expiryMonth> * <expiryYear>0</expiryYear> * <securityType>EQ</securityType> * <strikePrice>0</strikePrice> * <symbol>BR</symbol> * </Product> * <symbolDescription>BR</symbolDescription> * <dateAcquired>-57600000</dateAcquired> * <pricePaid>0</pricePaid> * <commissions>0</commissions> * <otherFees>0</otherFees> * <quantity>10</quantity> * <positionIndicator>TYPE2</positionIndicator> * <positionType>LONG</positionType> * <daysGain>-2.7999</daysGain> * <daysGainPct>-1.3346</daysGainPct> * <marketValue>207</marketValue> * <totalCost>0</totalCost> * <totalGain>207</totalGain> * <totalGainPct>0</totalGainPct> * <pctOfPortfolio>0.0018</pctOfPortfolio> * <costPerShare>0</costPerShare> * <todayCommissions>0</todayCommissions> * <todayFees>0</todayFees> * <todayPricePaid>0</todayPricePaid> * <todayQuantity>0</todayQuantity> * <Quick> * <change>-0.28</change> * <changePct>-1.3346</changePct> * <lastTrade>20.70</lastTrade> * <lastTradeTime>1343160240</lastTradeTime> * <volume>431591</volume> * </Quick> * <lotsDetails>https://apisb.etrade.com/v1/accounts/E5Nd4LJBsEi_UyHm4Vio9g/portfolio/27005131</lotsDetails> * <quoteDetails>https://apisb.etrade.com/v1/market/quote/BR</quoteDetails> * </Position> * <Position> * <positionId>4709131</positionId> * <Product> * <expiryDay>0</expiryDay> * <expiryMonth>0</expiryMonth> * <expiryYear>0</expiryYear> * <securityType>EQ</securityType> * <strikePrice>0</strikePrice> * <symbol>GLD</symbol> * </Product> * <symbolDescription>GLD</symbolDescription> * <dateAcquired>1335250800000</dateAcquired> * <pricePaid>1</pricePaid> * <commissions>5</commissions> * <otherFees>0</otherFees> * <quantity>2</quantity> * <positionIndicator>TYPE1</positionIndicator> * <positionType>LONG</positionType> * <daysGain>0.9799</daysGain> * <daysGainPct>0.3201</daysGainPct> * <marketValue>307.04</marketValue> * <totalCost>7</totalCost> * <totalGain>300.04</totalGain> * <totalGainPct>4286.2857</totalGainPct> * <pctOfPortfolio>0.0028</pctOfPortfolio> * <costPerShare>3.5</costPerShare> * <todayCommissions>0</todayCommissions> * <todayFees>0</todayFees> * <todayPricePaid>0</todayPricePaid> * <todayQuantity>0</todayQuantity> * <Quick> * <change>0.49</change> * <changePct>0.3201</changePct> * <lastTrade>153.52</lastTrade> * <lastTradeTime>1343160000</lastTradeTime> * <volume>6510878</volume> * </Quick> * <lotsDetails>https://apisb.etrade.com/v1/accounts/E5Nd4LJBsEi_UyHm4Vio9g/portfolio/4709131</lotsDetails> * <quoteDetails>https://apisb.etrade.com/v1/market/quote/GLD</quoteDetails> * </Position> * <Position> * <positionId>4729131</positionId> * <Product> * <expiryDay>0</expiryDay> * <expiryMonth>0</expiryMonth> * <expiryYear>0</expiryYear> * <securityType>EQ</securityType> * <strikePrice>0</strikePrice> * <symbol>MSFT</symbol> * </Product> * <symbolDescription>MSFT</symbolDescription> * <dateAcquired>1335250800000</dateAcquired> * <pricePaid>1</pricePaid> * <commissions>5</commissions> * <otherFees>0</otherFees> * <quantity>1</quantity> * <positionIndicator>TYPE2</positionIndicator> * <positionType>LONG</positionType> * <daysGain>-0.13</daysGain> * <daysGainPct>-0.4439</daysGainPct> * <marketValue>29.1499</marketValue> * <totalCost>6</totalCost> * <totalGain>23.1499</totalGain> * <totalGainPct>385.8333</totalGainPct> * <pctOfPortfolio>0.0002</pctOfPortfolio> * <costPerShare>6</costPerShare> * <todayCommissions>0</todayCommissions> * <todayFees>0</todayFees> * <todayPricePaid>0</todayPricePaid> * <todayQuantity>0</todayQuantity> * <Quick> * <change>-0.13</change> * <changePct>-0.4439</changePct> * <lastTrade>29.15</lastTrade> * <lastTradeTime>1343160000</lastTradeTime> * <volume>47711254</volume> * </Quick> * <lotsDetails>https://apisb.etrade.com/v1/accounts/E5Nd4LJBsEi_UyHm4Vio9g/portfolio/4729131</lotsDetails> * <quoteDetails>https://apisb.etrade.com/v1/market/quote/MSFT</quoteDetails> * </Position> * <Position> * <positionId>23971131</positionId> * <Product> * <expiryDay>0</expiryDay> * <expiryMonth>0</expiryMonth> * <expiryYear>0</expiryYear> * <securityType>EQ</securityType> * <strikePrice>0</strikePrice> * <symbol>MSFT</symbol> * </Product> * <symbolDescription>MSFT</symbolDescription> * <dateAcquired>-57600000</dateAcquired> * <pricePaid>0</pricePaid> * <commissions>0</commissions> * <otherFees>0</otherFees> * <quantity>-10</quantity> * <positionIndicator>TYPE5</positionIndicator> * <positionType>SHORT</positionType> * <daysGain>1.30</daysGain> * <daysGainPct>-0.4439</daysGainPct> * <marketValue>-291.5</marketValue> * <totalCost>0</totalCost> * <totalGain>-291.5</totalGain> * <totalGainPct>0</totalGainPct> * <pctOfPortfolio>-0.0026</pctOfPortfolio> * <costPerShare>0</costPerShare> * <todayCommissions>0</todayCommissions> * <todayFees>0</todayFees> * <todayPricePaid>0</todayPricePaid> * <todayQuantity>0</todayQuantity> * <Quick> * <change>-0.13</change> * <changePct>-0.4439</changePct> * <lastTrade>29.15</lastTrade> * <lastTradeTime>1343160000</lastTradeTime> * <volume>47711254</volume> * </Quick> * <lotsDetails>https://apisb.etrade.com/v1/accounts/E5Nd4LJBsEi_UyHm4Vio9g/portfolio/23971131</lotsDetails> * <quoteDetails>https://apisb.etrade.com/v1/market/quote/MSFT</quoteDetails> * </Position> * <Position> * <positionId>4725131</positionId> * <Product> * <expiryDay>0</expiryDay> * <expiryMonth>0</expiryMonth> * <expiryYear>0</expiryYear> * <securityType>EQ</securityType> * <strikePrice>0</strikePrice> * <symbol>RBL</symbol> * </Product> * <symbolDescription>RBL</symbolDescription> * <dateAcquired>1335250800000</dateAcquired> * <pricePaid>1</pricePaid> * <commissions>5</commissions> * <otherFees>0</otherFees> * <quantity>2</quantity> * <positionIndicator>TYPE2</positionIndicator> * <positionType>LONG</positionType> * <daysGain>-0.52</daysGain> * <daysGainPct>-1.0252</daysGainPct> * <marketValue>50.20</marketValue> * <totalCost>7</totalCost> * <totalGain>43.20</totalGain> * <totalGainPct>617.1428</totalGainPct> * <pctOfPortfolio>0.0004</pctOfPortfolio> * <costPerShare>3.5</costPerShare> * <todayCommissions>0</todayCommissions> * <todayFees>0</todayFees> * <todayPricePaid>0</todayPricePaid> * <todayQuantity>0</todayQuantity> * <Quick> * <change>-0.26</change> * <changePct>-1.0252</changePct> * <lastTrade>25.10</lastTrade> * <lastTradeTime>1343159760</lastTradeTime> * <volume>11827</volume> * </Quick> * <lotsDetails>https://apisb.etrade.com/v1/accounts/E5Nd4LJBsEi_UyHm4Vio9g/portfolio/4725131</lotsDetails> * <quoteDetails>https://apisb.etrade.com/v1/market/quote/RBL</quoteDetails> * </Position> * <Position> * <positionId>20841131</positionId> * <Product> * <expiryDay>0</expiryDay> * <expiryMonth>0</expiryMonth> * <expiryYear>0</expiryYear> * <securityType>EQ</securityType> * <strikePrice>0</strikePrice> * <symbol>RPI</symbol> * </Product> * <symbolDescription>RPI</symbolDescription> * <dateAcquired>1335250800000</dateAcquired> * <pricePaid>7.5599</pricePaid> * <commissions>5</commissions> * <otherFees>45</otherFees> * <quantity>2</quantity> * <positionIndicator>TYPE2</positionIndicator> * <positionType>LONG</positionType> * <daysGain>0</daysGain> * <daysGainPct>0</daysGainPct> * <marketValue>2.8599</marketValue> * <totalCost>65.12</totalCost> * <totalGain>-62.2599</totalGain> * <totalGainPct>-95.6081</totalGainPct> * <pctOfPortfolio>0.00</pctOfPortfolio> * <costPerShare>32.56</costPerShare> * <todayCommissions>0</todayCommissions> * <todayFees>0</todayFees> * <todayPricePaid>0</todayPricePaid> * <todayQuantity>0</todayQuantity> * <Quick> * <change>0</change> * <changePct>0</changePct> * <lastTrade>1.43</lastTrade> * <lastTradeTime>1343150700</lastTradeTime> * <volume>1803</volume> * </Quick> * <lotsDetails>https://apisb.etrade.com/v1/accounts/E5Nd4LJBsEi_UyHm4Vio9g/portfolio/20841131</lotsDetails> * <quoteDetails>https://apisb.etrade.com/v1/market/quote/RPI</quoteDetails> * </Position> * <Position> * <positionId>4732131</positionId> * <Product> * <expiryDay>0</expiryDay> * <expiryMonth>0</expiryMonth> * <expiryYear>0</expiryYear> * <securityType>EQ</securityType> * <strikePrice>0</strikePrice> * <symbol>RXD</symbol> * </Product> * <symbolDescription>RXD</symbolDescription> * <dateAcquired>1335250800000</dateAcquired> * <pricePaid>1</pricePaid> * <commissions>2.99</commissions> * <otherFees>0.0099</otherFees> * <quantity>-3</quantity> * <positionIndicator>TYPE5</positionIndicator> * <positionType>SHORT</positionType> * <daysGain>-1.296</daysGain> * <daysGainPct>2.6799</daysGainPct> * <marketValue>-49.6559</marketValue> * <totalCost>0</totalCost> * <totalGain>-49.6559</totalGain> * <totalGainPct>-827.60</totalGainPct> * <pctOfPortfolio>-0.0004</pctOfPortfolio> * <costPerShare>0</costPerShare> * <todayCommissions>0</todayCommissions> * <todayFees>0</todayFees> * <todayPricePaid>0</todayPricePaid> * <todayQuantity>0</todayQuantity> * <Quick> * <change>0.432</change> * <changePct>2.6799</changePct> * <lastTrade>16.552</lastTrade> * <lastTradeTime>1343157480</lastTradeTime> * <volume>2200</volume> * </Quick> * <lotsDetails>https://apisb.etrade.com/v1/accounts/E5Nd4LJBsEi_UyHm4Vio9g/portfolio/4732131</lotsDetails> * <quoteDetails>https://apisb.etrade.com/v1/market/quote/RXD</quoteDetails> * </Position> * <totalPages>1</totalPages> * </AccountPortfolio> * </PortfolioResponse> * * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Xml') loXml = CreateObject('Chilkat.Xml') loXml.LoadXml(loResp.BodyStr) ? loXml.GetXml() lnAccountId = loXml.GetChildIntValue("AccountPortfolio|accountId") i = 0 lnCount_i = loXml.NumChildrenHavingTag("AccountPortfolio|Position") DO WHILE i < lnCount_i loXml.I = i lnPositionId = loXml.GetChildIntValue("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") lcDateAcquired = loXml.GetChildContent("AccountPortfolio|Position[i]|dateAcquired") lcPricePaid = loXml.GetChildContent("AccountPortfolio|Position[i]|pricePaid") lcCommissions = loXml.GetChildContent("AccountPortfolio|Position[i]|commissions") lcOtherFees = loXml.GetChildContent("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") lcTotalCost = loXml.GetChildContent("AccountPortfolio|Position[i]|totalCost") lcTotalGain = loXml.GetChildContent("AccountPortfolio|Position[i]|totalGain") lcTotalGainPct = loXml.GetChildContent("AccountPortfolio|Position[i]|totalGainPct") lcPctOfPortfolio = loXml.GetChildContent("AccountPortfolio|Position[i]|pctOfPortfolio") lcCostPerShare = loXml.GetChildContent("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") 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") 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") ? "Success." RELEASE loHttp RELEASE loJsonToken RELEASE loXml |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.