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

DataFlex 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
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

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
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
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

 

 

 

(DataFlex) 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

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Handle hoJsonToken
    Boolean iSuccess
    String sSandboxUrl
    String sLiveUrl
    Variant vResp
    Handle hoResp
    Handle hoXml
    Integer iOrderId
    String sDetails
    String sOrderType
    Integer j
    Integer iCount_j
    String sPlacedTime
    String sOrderValue
    String sStatus
    String sOrderTerm
    String sPriceType
    String sLimitPrice
    Integer iStopPrice
    String sMarketSession
    String sAllOrNone
    Integer k
    Integer iCount_k
    String sSymbol
    String sSecurityType
    String sCallPut
    Integer iExpiryYear
    Integer iExpiryMonth
    Integer iExpiryDay
    String sStrikePrice
    String sSymbolDescription
    String sOrderAction
    String sQuantityType
    Integer iOrderedQuantity
    Integer iFilledQuantity
    String sAverageExecutionPrice
    String sEstimatedCommission
    Integer iEstimatedFees
    Integer iNetPrice
    Integer iNetBid
    Integer iNetAsk
    Integer iGcd
    Integer iOrderNumber
    Integer iBracketedLimitPrice
    String sInitialStopPrice
    String sExecutedTime
    String sTotalOrderValue
    String sTotalCommission
    String sMarker
    String sNext
    Integer i
    Integer iCount_i
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

    // This 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 Authorization
    Get Create (RefClass(cComChilkatJsonObject)) To hoJsonToken
    If (Not(IsComObjectCreated(hoJsonToken))) Begin
        Send CreateComObject of hoJsonToken
    End
    Get ComLoadFile Of hoJsonToken "qa_data/tokens/etrade.json" To iSuccess
    If (iSuccess <> True) Begin
        Showln "Failed to load OAuth1 token"
        Procedure_Return
    End

    Get ComStringOf Of hoJsonToken "oauth_token" To sTemp1
    Set ComOAuthToken Of hoHttp To sTemp1
    Get ComStringOf Of hoJsonToken "oauth_token_secret" To sTemp1
    Set ComOAuthTokenSecret Of hoHttp To sTemp1

    Move "https://apisb.etrade.com/v1/accounts/{$accountIdKey}/orders" To sSandboxUrl
    Move "https://api.etrade.com/v1/accounts/{$accountIdKey}/orders" To sLiveUrl

    Get ComSetUrlVar Of hoHttp "accountIdKey" "6_Dpy0rmuQ9cu9IbTfvF2A" To iSuccess

    Get ComQuickGetObj Of hoHttp sSandboxUrl To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Make sure a successful response was received.
    Get ComStatusCode Of hoResp To iTemp1
    If (iTemp1 > 200) Begin
        Get ComStatusLine Of hoResp To sTemp1
        Showln sTemp1
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Get ComBodyStr Of hoResp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // 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>
    // 

    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End
    Get ComBodyStr Of hoResp To sTemp1
    Get ComLoadXml Of hoXml sTemp1 To iSuccess
    Get ComGetXml Of hoXml To sTemp1
    Showln sTemp1

    Get ComGetChildContent Of hoXml "marker" To sMarker
    Get ComGetChildContent Of hoXml "next" To sNext
    Move 0 To i
    Get ComNumChildrenHavingTag Of hoXml "Order" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoXml To i
        Get ComGetChildIntValue Of hoXml "Order[i]|orderId" To iOrderId
        Get ComGetChildContent Of hoXml "Order[i]|details" To sDetails
        Get ComGetChildContent Of hoXml "Order[i]|orderType" To sOrderType
        Move 0 To j
        Get ComNumChildrenHavingTag Of hoXml "Order[i]|OrderDetail" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoXml To j
            Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|placedTime" To sPlacedTime
            Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|orderValue" To sOrderValue
            Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|status" To sStatus
            Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|orderTerm" To sOrderTerm
            Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|priceType" To sPriceType
            Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|limitPrice" To sLimitPrice
            Get ComGetChildIntValue Of hoXml "Order[i]|OrderDetail[j]|stopPrice" To iStopPrice
            Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|marketSession" To sMarketSession
            Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|allOrNone" To sAllOrNone
            Move 0 To k
            Get ComNumChildrenHavingTag Of hoXml "Order[i]|OrderDetail[j]|Instrument" To iCount_k
            While (k < iCount_k)
                Set ComK Of hoXml To k
                Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|Product|symbol" To sSymbol
                Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|Product|securityType" To sSecurityType
                Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|Product|callPut" To sCallPut
                Get ComGetChildIntValue Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|Product|expiryYear" To iExpiryYear
                Get ComGetChildIntValue Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|Product|expiryMonth" To iExpiryMonth
                Get ComGetChildIntValue Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|Product|expiryDay" To iExpiryDay
                Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|Product|strikePrice" To sStrikePrice
                Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|symbolDescription" To sSymbolDescription
                Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|orderAction" To sOrderAction
                Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|quantityType" To sQuantityType
                Get ComGetChildIntValue Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|orderedQuantity" To iOrderedQuantity
                Get ComGetChildIntValue Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|filledQuantity" To iFilledQuantity
                Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|averageExecutionPrice" To sAverageExecutionPrice
                Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|estimatedCommission" To sEstimatedCommission
                Get ComGetChildIntValue Of hoXml "Order[i]|OrderDetail[j]|Instrument[k]|estimatedFees" To iEstimatedFees
                Move (k + 1) To k
            Loop

            Get ComGetChildIntValue Of hoXml "Order[i]|OrderDetail[j]|netPrice" To iNetPrice
            Get ComGetChildIntValue Of hoXml "Order[i]|OrderDetail[j]|netBid" To iNetBid
            Get ComGetChildIntValue Of hoXml "Order[i]|OrderDetail[j]|netAsk" To iNetAsk
            Get ComGetChildIntValue Of hoXml "Order[i]|OrderDetail[j]|gcd" To iGcd
            Get ComGetChildIntValue Of hoXml "Order[i]|OrderDetail[j]|orderNumber" To iOrderNumber
            Get ComGetChildIntValue Of hoXml "Order[i]|OrderDetail[j]|bracketedLimitPrice" To iBracketedLimitPrice
            Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|initialStopPrice" To sInitialStopPrice
            Get ComGetChildContent Of hoXml "Order[i]|OrderDetail[j]|executedTime" To sExecutedTime
            Move (j + 1) To j
        Loop

        Get ComGetChildContent Of hoXml "Order[i]|totalOrderValue" To sTotalOrderValue
        Get ComGetChildContent Of hoXml "Order[i]|totalCommission" To sTotalCommission
        Move (i + 1) To i
    Loop

    Showln "Success."


End_Procedure

 

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