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

Visual FoxPro Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
Mastercard

MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Visual FoxPro) ETrade List Orders

Gets the order details for a selected brokerage account based on the search criteria provided.

For more information, see https://apisb.etrade.com/docs/api/order/api-order-v1.html#/definition/getOrders

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

LOCAL loHttp
LOCAL loJsonToken
LOCAL lnSuccess
LOCAL lcSandboxUrl
LOCAL lcLiveUrl
LOCAL loResp
LOCAL loXml
LOCAL lnOrderId
LOCAL lcDetails
LOCAL lcOrderType
LOCAL j
LOCAL lnCount_j
LOCAL lcPlacedTime
LOCAL lcOrderValue
LOCAL lcStatus
LOCAL lcOrderTerm
LOCAL lcPriceType
LOCAL lcLimitPrice
LOCAL lnStopPrice
LOCAL lcMarketSession
LOCAL lcAllOrNone
LOCAL k
LOCAL lnCount_k
LOCAL lcSymbol
LOCAL lcSecurityType
LOCAL lcCallPut
LOCAL lnExpiryYear
LOCAL lnExpiryMonth
LOCAL lnExpiryDay
LOCAL lcStrikePrice
LOCAL lcSymbolDescription
LOCAL lcOrderAction
LOCAL lcQuantityType
LOCAL lnOrderedQuantity
LOCAL lnFilledQuantity
LOCAL lcAverageExecutionPrice
LOCAL lcEstimatedCommission
LOCAL lnEstimatedFees
LOCAL lnNetPrice
LOCAL lnNetBid
LOCAL lnNetAsk
LOCAL lnGcd
LOCAL lnOrderNumber
LOCAL lnBracketedLimitPrice
LOCAL lcInitialStopPrice
LOCAL lcExecutedTime
LOCAL lcTotalOrderValue
LOCAL lcTotalCommission
LOCAL lcMarker
LOCAL lcNext
LOCAL i
LOCAL lnCount_i

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

loHttp = CreateObject('Chilkat_9_5_0.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
loJsonToken = CreateObject('Chilkat_9_5_0.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}/orders"
lcLiveUrl = "https://api.etrade.com/v1/accounts/{$accountIdKey}/orders"

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"?>
* <OrdersResponse>
*     <marker>12345678999</marker>
*     <next>https://api.sit.etrade.com/accounts/E5Nd4LJBsEi_UyHm4Vio9g/orders?marker=12345678999</next>
*     <Order>
*         <orderId>479</orderId>
*         <details>https://api.etrade.com/accounts/E5Nd4LJBsEi_UyHm4Vio9g/orders/479</details>
*         <orderType>OPTN</orderType>
*         <OrderDetail>
*             <placedTime>123453456</placedTime>
*             <orderValue>123.0000</orderValue>
*             <status>OPEN</status>
*             <orderTerm>GOOD_FOR_DAY</orderTerm>
*             <priceType>LIMIT</priceType>
*             <limitPrice>1.5</limitPrice>
*             <stopPrice>0</stopPrice>
*             <marketSession>REGULAR</marketSession>
*             <allOrNone>false</allOrNone>
*             <Instrument>
*                 <Product>
*                     <symbol>RIMM</symbol>
*                     <securityType>OPTN</securityType>
*                     <callPut>CALL</callPut>
*                     <expiryYear>2012</expiryYear>
*                     <expiryMonth>3</expiryMonth>
*                     <expiryDay>9</expiryDay>
*                     <strikePrice>12</strikePrice>
*                 </Product>
*                 <symbolDescription>RESEARCH IN MOTION LTD COM</symbolDescription>
*                 <orderAction>BUY_OPEN</orderAction>
*                 <quantityType>QUANTITY</quantityType>
*                 <orderedQuantity>5</orderedQuantity>
*                 <filledQuantity>5</filledQuantity>
*                 <averageExecutionPrice>0</averageExecutionPrice>
*                 <estimatedCommission>9.99</estimatedCommission>
*                 <estimatedFees>0</estimatedFees>
*             </Instrument>
*             <netPrice>0</netPrice>
*             <netBid>0</netBid>
*             <netAsk>0</netAsk>
*             <gcd>0</gcd>
*             <ratio/>
*         </OrderDetail>
*     </Order>
*     <Order>
*         <orderId>477</orderId>
*         <details>https://api.etrade.com/accounts/E5Nd4LJBsEi_UyHm4Vio9g/orders/477</details>
*         <orderType>ONE_CANCELS_ALL</orderType>
*         <totalOrderValue>209.99</totalOrderValue>
*         <totalCommission>10.74</totalCommission>
*         <OrderDetail>
*             <orderNumber>1</orderNumber>
*             <placedTime>1331699203122</placedTime>
*             <orderValue>123.0000</orderValue>
*             <status>OPEN</status>
*             <orderTerm>GOOD_FOR_DAY</orderTerm>
*             <priceType>LIMIT</priceType>
*             <limitPrice>2</limitPrice>
*             <stopPrice>0</stopPrice>
*             <marketSession>REGULAR</marketSession>
*             <bracketedLimitPrice>2</bracketedLimitPrice>
*             <initialStopPrice>2</initialStopPrice>
*             <allOrNone>false</allOrNone>
*             <Instrument>
*                 <Product>
*                     <symbol>ETFC</symbol>
*                     <securityType>EQ</securityType>
*                 </Product>
*                 <symbolDescription>ETRADE Financials</symbolDescription>
*                 <orderAction>BUY</orderAction>
*                 <quantityType>QUANTITY</quantityType>
*                 <orderedQuantity>100</orderedQuantity>
*                 <filledQuantity>0</filledQuantity>
*                 <averageExecutionPrice>0</averageExecutionPrice>
*                 <estimatedCommission>9.99</estimatedCommission>
*                 <estimatedFees>0</estimatedFees>
*             </Instrument>
*             <netPrice>0</netPrice>
*             <netBid>0</netBid>
*             <netAsk>0</netAsk>
*             <gcd>0</gcd>
*             <ratio/>
*         </OrderDetail>
*         <OrderDetail>
*             <orderNumber>2</orderNumber>
*             <placedTime>1331699203</placedTime>
*             <orderValue>231.0000</orderValue>
*             <status>OPEN</status>
*             <orderTerm>GOOD_FOR_DAY</orderTerm>
*             <priceType>LIMIT</priceType>
*             <limitPrice>0.5</limitPrice>
*             <stopPrice>0</stopPrice>
*             <marketSession>REGULAR</marketSession>
*             <initialStopPrice>0.5</initialStopPrice>
*             <allOrNone>false</allOrNone>
*             <Instrument>
*                 <Product>
*                     <symbol>MON</symbol>
*                     <securityType>OPTN</securityType>
*                     <callPut>CALL</callPut>
*                     <expiryYear>2012</expiryYear>
*                     <expiryMonth>4</expiryMonth>
*                     <expiryDay>21</expiryDay>
*                     <strikePrice>85</strikePrice>
*                 </Product>
*                 <symbolDescription>MON Mar 9 '12 $85 Call</symbolDescription>
*                 <orderAction>BUY_OPEN</orderAction>
*                 <quantityType>QUANTITY</quantityType>
*                 <orderedQuantity>1</orderedQuantity>
*                 <filledQuantity>0</filledQuantity>
*                 <averageExecutionPrice>0</averageExecutionPrice>
*                 <estimatedCommission>9.99</estimatedCommission>
*                 <estimatedFees>0</estimatedFees>
*             </Instrument>
*             <netPrice>0</netPrice>
*             <netBid>0</netBid>
*             <netAsk>0</netAsk>
*             <gcd>0</gcd>
*             <ratio/>
*         </OrderDetail>
*     </Order>
*     <Order>
*         <orderId>475</orderId>
*         <details>https://api.etrade.com/accounts/E5Nd4LJBsEi_UyHm4Vio9g/orders/475</details>
*         <orderType>SPREADS</orderType>
*         <OrderDetail>
*             <placedTime>1331742953</placedTime>
*             <executedTime>1331742955432</executedTime>
*             <orderValue>4445.99</orderValue>
*             <status>EXECUTED</status>
*             <orderTerm>GOOD_FOR_DAY</orderTerm>
*             <priceType>NET_DEBIT</priceType>
*             <limitPrice>1.5</limitPrice>
*             <stopPrice>0</stopPrice>
*             <marketSession>REGULAR</marketSession>
*             <allOrNone>false</allOrNone>
*             <Instrument>
*                 <Product>
*                     <symbol>REE</symbol>
*                     <securityType>OPTN</securityType>
*                     <callPut>CALL</callPut>
*                     <expiryYear>2012</expiryYear>
*                     <expiryMonth>7</expiryMonth>
*                     <expiryDay>21</expiryDay>
*                     <strikePrice>7</strikePrice>
*                 </Product>
*                 <symbolDescription>REE Jul 21 '12 $7 Call</symbolDescription>
*                 <orderAction>BUY_OPEN</orderAction>
*                 <quantityType>QUANTITY</quantityType>
*                 <orderedQuantity>2</orderedQuantity>
*                 <filledQuantity>2</filledQuantity>
*                 <averageExecutionPrice>1.5</averageExecutionPrice>
*                 <estimatedCommission>7.24</estimatedCommission>
*                 <estimatedFees>0</estimatedFees>
*             </Instrument>
*             <Instrument>
*                 <Product>
*                     <symbol>REE</symbol>
*                     <securityType>OPTN</securityType>
*                     <callPut>PUT</callPut>
*                     <expiryYear>2013</expiryYear>
*                     <expiryMonth>1</expiryMonth>
*                     <expiryDay>19</expiryDay>
*                     <strikePrice>12.50</strikePrice>
*                 </Product>
*                 <symbolDescription>REE Jan 19 '13 $12.50 Put</symbolDescription>
*                 <orderAction>BUY_OPEN</orderAction>
*                 <quantityType>QUANTITY</quantityType>
*                 <orderedQuantity>2</orderedQuantity>
*                 <filledQuantity>2</filledQuantity>
*                 <averageExecutionPrice>1.5</averageExecutionPrice>
*                 <estimatedCommission>7.24</estimatedCommission>
*                 <estimatedFees>0</estimatedFees>
*             </Instrument>
*             <netPrice>0</netPrice>
*             <netBid>0</netBid>
*             <netAsk>0</netAsk>
*             <gcd>0</gcd>
*             <ratio/>
*         </OrderDetail>
*     </Order>
* </OrdersResponse>
* 

loXml = CreateObject('Chilkat_9_5_0.Xml')
loXml.LoadXml(loResp.BodyStr)
? loXml.GetXml()

lcMarker = loXml.GetChildContent("marker")
lcNext = loXml.GetChildContent("next")
i = 0
lnCount_i = loXml.NumChildrenHavingTag("Order")
DO WHILE i < lnCount_i
    loXml.I = i
    lnOrderId = loXml.GetChildIntValue("Order[i]|orderId")
    lcDetails = loXml.GetChildContent("Order[i]|details")
    lcOrderType = loXml.GetChildContent("Order[i]|orderType")
    j = 0
    lnCount_j = loXml.NumChildrenHavingTag("Order[i]|OrderDetail")
    DO WHILE j < lnCount_j
        loXml.J = j
        lcPlacedTime = loXml.GetChildContent("Order[i]|OrderDetail[j]|placedTime")
        lcOrderValue = loXml.GetChildContent("Order[i]|OrderDetail[j]|orderValue")
        lcStatus = loXml.GetChildContent("Order[i]|OrderDetail[j]|status")
        lcOrderTerm = loXml.GetChildContent("Order[i]|OrderDetail[j]|orderTerm")
        lcPriceType = loXml.GetChildContent("Order[i]|OrderDetail[j]|priceType")
        lcLimitPrice = loXml.GetChildContent("Order[i]|OrderDetail[j]|limitPrice")
        lnStopPrice = loXml.GetChildIntValue("Order[i]|OrderDetail[j]|stopPrice")
        lcMarketSession = loXml.GetChildContent("Order[i]|OrderDetail[j]|marketSession")
        lcAllOrNone = loXml.GetChildContent("Order[i]|OrderDetail[j]|allOrNone")
        k = 0
        lnCount_k = loXml.NumChildrenHavingTag("Order[i]|OrderDetail[j]|Instrument")
        DO WHILE k < lnCount_k
            loXml.K = k
            lcSymbol = loXml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|Product|symbol")
            lcSecurityType = loXml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|Product|securityType")
            lcCallPut = loXml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|Product|callPut")
            lnExpiryYear = loXml.GetChildIntValue("Order[i]|OrderDetail[j]|Instrument[k]|Product|expiryYear")
            lnExpiryMonth = loXml.GetChildIntValue("Order[i]|OrderDetail[j]|Instrument[k]|Product|expiryMonth")
            lnExpiryDay = loXml.GetChildIntValue("Order[i]|OrderDetail[j]|Instrument[k]|Product|expiryDay")
            lcStrikePrice = loXml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|Product|strikePrice")
            lcSymbolDescription = loXml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|symbolDescription")
            lcOrderAction = loXml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|orderAction")
            lcQuantityType = loXml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|quantityType")
            lnOrderedQuantity = loXml.GetChildIntValue("Order[i]|OrderDetail[j]|Instrument[k]|orderedQuantity")
            lnFilledQuantity = loXml.GetChildIntValue("Order[i]|OrderDetail[j]|Instrument[k]|filledQuantity")
            lcAverageExecutionPrice = loXml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|averageExecutionPrice")
            lcEstimatedCommission = loXml.GetChildContent("Order[i]|OrderDetail[j]|Instrument[k]|estimatedCommission")
            lnEstimatedFees = loXml.GetChildIntValue("Order[i]|OrderDetail[j]|Instrument[k]|estimatedFees")
            k = k + 1
        ENDDO
        lnNetPrice = loXml.GetChildIntValue("Order[i]|OrderDetail[j]|netPrice")
        lnNetBid = loXml.GetChildIntValue("Order[i]|OrderDetail[j]|netBid")
        lnNetAsk = loXml.GetChildIntValue("Order[i]|OrderDetail[j]|netAsk")
        lnGcd = loXml.GetChildIntValue("Order[i]|OrderDetail[j]|gcd")
        lnOrderNumber = loXml.GetChildIntValue("Order[i]|OrderDetail[j]|orderNumber")
        lnBracketedLimitPrice = loXml.GetChildIntValue("Order[i]|OrderDetail[j]|bracketedLimitPrice")
        lcInitialStopPrice = loXml.GetChildContent("Order[i]|OrderDetail[j]|initialStopPrice")
        lcExecutedTime = loXml.GetChildContent("Order[i]|OrderDetail[j]|executedTime")
        j = j + 1
    ENDDO
    lcTotalOrderValue = loXml.GetChildContent("Order[i]|totalOrderValue")
    lcTotalCommission = loXml.GetChildContent("Order[i]|totalCommission")
    i = i + 1
ENDDO

? "Success."

RELEASE loHttp
RELEASE loJsonToken
RELEASE loXml


 

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