finance_dev 0.9.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- finance_dev/__init__.py +18 -0
- finance_dev/_hooks/__init__.py +7 -0
- finance_dev/_hooks/clientcredentials.py +319 -0
- finance_dev/_hooks/oauth2scopes.py +50 -0
- finance_dev/_hooks/registration.py +13 -0
- finance_dev/_hooks/sdkhooks.py +82 -0
- finance_dev/_hooks/types.py +125 -0
- finance_dev/_version.py +16 -0
- finance_dev/accounts.py +797 -0
- finance_dev/alternativedata.py +4830 -0
- finance_dev/analytics.py +3757 -0
- finance_dev/basesdk.py +393 -0
- finance_dev/calendar.py +1523 -0
- finance_dev/chart.py +1881 -0
- finance_dev/company.py +1105 -0
- finance_dev/corporateactions.py +1795 -0
- finance_dev/economy.py +1153 -0
- finance_dev/errors/__init__.py +94 -0
- finance_dev/errors/apierror.py +41 -0
- finance_dev/errors/authenticationerrorenvelope.py +43 -0
- finance_dev/errors/badrequest.py +34 -0
- finance_dev/errors/errorenvelope.py +42 -0
- finance_dev/errors/errorresponse.py +45 -0
- finance_dev/errors/financedevapierror.py +31 -0
- finance_dev/errors/forbidden.py +34 -0
- finance_dev/errors/internalservererror.py +35 -0
- finance_dev/errors/no_response_error.py +18 -0
- finance_dev/errors/notfound.py +34 -0
- finance_dev/errors/orderhistorybadrequest.py +35 -0
- finance_dev/errors/predorderserrorenvelope.py +42 -0
- finance_dev/errors/responsevalidationerror.py +28 -0
- finance_dev/errors/unauthorized.py +34 -0
- finance_dev/estimates.py +1906 -0
- finance_dev/etf.py +1108 -0
- finance_dev/filings.py +586 -0
- finance_dev/financials.py +4079 -0
- finance_dev/history.py +477 -0
- finance_dev/httpclient.py +126 -0
- finance_dev/indices.py +2308 -0
- finance_dev/logos.py +692 -0
- finance_dev/market.py +1825 -0
- finance_dev/markets.py +952 -0
- finance_dev/models/__init__.py +4568 -0
- finance_dev/models/accountbalancev2.py +340 -0
- finance_dev/models/accountitem.py +78 -0
- finance_dev/models/accountposition.py +147 -0
- finance_dev/models/aggregatetechnicalindicatorsresponse.py +192 -0
- finance_dev/models/analystinsightitem.py +161 -0
- finance_dev/models/analystinsightsresponse.py +39 -0
- finance_dev/models/apperror.py +123 -0
- finance_dev/models/authenticationerrordetail.py +58 -0
- finance_dev/models/bankbranchesresponse.py +96 -0
- finance_dev/models/basicfinancials.py +243 -0
- finance_dev/models/bullbearanalysisresponse.py +150 -0
- finance_dev/models/cancelorderop.py +40 -0
- finance_dev/models/cancelordrequest_union.py +287 -0
- finance_dev/models/cancelordresponse.py +115 -0
- finance_dev/models/cashflowstatement.py +290 -0
- finance_dev/models/cashflowstatementsresponse.py +61 -0
- finance_dev/models/chartbars.py +111 -0
- finance_dev/models/chartconfig.py +81 -0
- finance_dev/models/chartresolution.py +46 -0
- finance_dev/models/companyesgresponse.py +408 -0
- finance_dev/models/companyexecutive.py +70 -0
- finance_dev/models/companyexecutiveresponse.py +39 -0
- finance_dev/models/companypeersresponse.py +38 -0
- finance_dev/models/companypresentationresponse.py +96 -0
- finance_dev/models/companyprofile.py +255 -0
- finance_dev/models/conferencecallsresponse.py +169 -0
- finance_dev/models/congressionaltradingresponse.py +138 -0
- finance_dev/models/covid19uscasesresponse.py +79 -0
- finance_dev/models/createconfigwatchlistop.py +40 -0
- finance_dev/models/createwatchlistrequest.py +43 -0
- finance_dev/models/dailymarketsummaryresponse.py +73 -0
- finance_dev/models/deleteconfigwatchlistbyidop.py +53 -0
- finance_dev/models/dividenditem.py +125 -0
- finance_dev/models/dividendsresponse.py +61 -0
- finance_dev/models/earningrelease.py +291 -0
- finance_dev/models/earningscallliveresponse.py +103 -0
- finance_dev/models/earningsqualityscoreresponse.py +140 -0
- finance_dev/models/earningssurprisesresponse.py +125 -0
- finance_dev/models/ebitdaestimatesresponse.py +176 -0
- finance_dev/models/ebitestimatesresponse.py +176 -0
- finance_dev/models/economicscalendarevent.py +160 -0
- finance_dev/models/economicsindicator.py +87 -0
- finance_dev/models/epsestimatesresponse.py +176 -0
- finance_dev/models/equitydetailsdto.py +569 -0
- finance_dev/models/errorcode.py +48 -0
- finance_dev/models/etblistresponse.py +43 -0
- finance_dev/models/etbsearchrequest.py +21 -0
- finance_dev/models/etbsearchresponse.py +43 -0
- finance_dev/models/etfcountryallocationresponse.py +113 -0
- finance_dev/models/etfholdingsresponse.py +163 -0
- finance_dev/models/etfprofileresponse.py +234 -0
- finance_dev/models/etfsectorallocationresponse.py +113 -0
- finance_dev/models/exchangecode.py +90 -0
- finance_dev/models/fdaadvisorycommitteecalendarresponse.py +88 -0
- finance_dev/models/filingsimilarityrecord.py +115 -0
- finance_dev/models/filingssimilarityindexdatawrapper.py +52 -0
- finance_dev/models/filingssimilarityindexresponse.py +42 -0
- finance_dev/models/financialratiosresponse.py +252 -0
- finance_dev/models/financialsreporteddatawrapper.py +49 -0
- finance_dev/models/financialsreportedresponse.py +42 -0
- finance_dev/models/financialsrevenuebreakdowndatawrapper.py +49 -0
- finance_dev/models/financialsrevenuebreakdownresponse.py +42 -0
- finance_dev/models/financialsstatementsdatawrapper.py +44 -0
- finance_dev/models/financialsstatementsresponse.py +42 -0
- finance_dev/models/financialstatement.py +171 -0
- finance_dev/models/financialstatementtype.py +14 -0
- finance_dev/models/getaccountbalanceop.py +53 -0
- finance_dev/models/getaccountpositionsop.py +53 -0
- finance_dev/models/getaccountsresponse.py +22 -0
- finance_dev/models/getaggregatetechnicalindicatorsop.py +94 -0
- finance_dev/models/getanalystinsightsop.py +164 -0
- finance_dev/models/getbankbranchesop.py +53 -0
- finance_dev/models/getbaseeventop.py +87 -0
- finance_dev/models/getbullbearanalysisop.py +91 -0
- finance_dev/models/getcashflowstatementsop.py +564 -0
- finance_dev/models/getchartconfigop.py +40 -0
- finance_dev/models/getcharthistoryop.py +122 -0
- finance_dev/models/getcharttimeop.py +39 -0
- finance_dev/models/getcompanyesgop.py +53 -0
- finance_dev/models/getcompanyexecutivesop.py +56 -0
- finance_dev/models/getcompanymetricsop.py +68 -0
- finance_dev/models/getcompanypeersop.py +53 -0
- finance_dev/models/getcompanypresentationop.py +56 -0
- finance_dev/models/getcompanyprofileop.py +86 -0
- finance_dev/models/getconferencecallsop.py +111 -0
- finance_dev/models/getconfigwatchlistbyidop.py +53 -0
- finance_dev/models/getconfigwatchlistsop.py +40 -0
- finance_dev/models/getcongressionaltradingop.py +73 -0
- finance_dev/models/getcovid19uscasesop.py +43 -0
- finance_dev/models/getdailymarketsummaryop.py +92 -0
- finance_dev/models/getdividendsop.py +294 -0
- finance_dev/models/getearningscalendarop.py +87 -0
- finance_dev/models/getearningscallliveop.py +91 -0
- finance_dev/models/getearningsqualityscoreop.py +81 -0
- finance_dev/models/getearningssurprisesop.py +80 -0
- finance_dev/models/getebitdaestimatesop.py +91 -0
- finance_dev/models/getebitestimatesop.py +88 -0
- finance_dev/models/geteconomicscalendarop.py +92 -0
- finance_dev/models/geteconomicscalendarresponse.py +56 -0
- finance_dev/models/getepsestimatesop.py +88 -0
- finance_dev/models/getequitydetailsop.py +56 -0
- finance_dev/models/getequitydetailsresponse.py +45 -0
- finance_dev/models/getetblistop.py +40 -0
- finance_dev/models/getetfcountryallocationop.py +80 -0
- finance_dev/models/getetfholdingsop.py +96 -0
- finance_dev/models/getetfprofileop.py +77 -0
- finance_dev/models/getetfsectorallocationop.py +80 -0
- finance_dev/models/geteventcontractsop.py +87 -0
- finance_dev/models/getfdaadvisorycommitteecalendarop.py +47 -0
- finance_dev/models/getfilingssimilarityindexop.py +102 -0
- finance_dev/models/getfinancialratiosop.py +612 -0
- finance_dev/models/getfinancialstatementsop.py +117 -0
- finance_dev/models/getfundownershipop.py +77 -0
- finance_dev/models/gethistoricaldataop.py +61 -0
- finance_dev/models/gethistoricalesgop.py +53 -0
- finance_dev/models/gethistorybatchop.py +74 -0
- finance_dev/models/gethistoryop.py +123 -0
- finance_dev/models/getincomestatementsop.py +564 -0
- finance_dev/models/getindexbarop.py +140 -0
- finance_dev/models/getindexbarsop.py +149 -0
- finance_dev/models/getindexchartbarsop.py +178 -0
- finance_dev/models/getindexrealtimevaluesop.py +94 -0
- finance_dev/models/getinflationexpectationsop.py +157 -0
- finance_dev/models/getinflationop.py +154 -0
- finance_dev/models/getinsidertransactionsop.py +90 -0
- finance_dev/models/getinstitutionalownershipop.py +99 -0
- finance_dev/models/getinstitutionalportfolioop.py +75 -0
- finance_dev/models/getinvestmentthemeop.py +68 -0
- finance_dev/models/getipocalendarop.py +63 -0
- finance_dev/models/getlobbyingop.py +70 -0
- finance_dev/models/getmarketbreadthop.py +40 -0
- finance_dev/models/getmarketholidaysop.py +65 -0
- finance_dev/models/getmarketstatusop.py +65 -0
- finance_dev/models/getmergersandacquisitionsop.py +113 -0
- finance_dev/models/getnetinflowop.py +40 -0
- finance_dev/models/getnewsbyidop.py +73 -0
- finance_dev/models/getnewsop.py +98 -0
- finance_dev/models/getnewssentimentop.py +53 -0
- finance_dev/models/getoptionchainsnapshotop.py +244 -0
- finance_dev/models/getoptioncontractsnapshotop.py +69 -0
- finance_dev/models/getoptiondetailsop.py +56 -0
- finance_dev/models/getoptiondetailsresponse.py +45 -0
- finance_dev/models/getoptionlasttradeop.py +56 -0
- finance_dev/models/getoptionopencloseop.py +66 -0
- finance_dev/models/getoptionpreviousdayop.py +56 -0
- finance_dev/models/getoptionquotesop.py +177 -0
- finance_dev/models/getoptionsactivityop.py +111 -0
- finance_dev/models/getoptionsetfstopvolumeop.py +70 -0
- finance_dev/models/getoptionsstockstopgainersop.py +70 -0
- finance_dev/models/getoptionsstockstopvolumeop.py +70 -0
- finance_dev/models/getoptionsunusualactivityop.py +100 -0
- finance_dev/models/getoptiontradesop.py +177 -0
- finance_dev/models/getordersv2response.py +66 -0
- finance_dev/models/getownershipdataop.py +77 -0
- finance_dev/models/getpositionsresponse.py +39 -0
- finance_dev/models/getpredictionorderop.py +88 -0
- finance_dev/models/getpricetargetop.py +53 -0
- finance_dev/models/getquotesop.py +53 -0
- finance_dev/models/getratingsop.py +164 -0
- finance_dev/models/getratingsresponse.py +39 -0
- finance_dev/models/getreportedfinancialsop.py +127 -0
- finance_dev/models/getrevenuebreakdownop.py +85 -0
- finance_dev/models/getrevenueestimatesop.py +91 -0
- finance_dev/models/getsecfilingsop.py +113 -0
- finance_dev/models/getsectortickersop.py +124 -0
- finance_dev/models/getsectorwisechangeop.py +84 -0
- finance_dev/models/getshortinterestop.py +334 -0
- finance_dev/models/getshortvolumeop.py +333 -0
- finance_dev/models/getsocialsentimentop.py +90 -0
- finance_dev/models/getspinoffsop.py +112 -0
- finance_dev/models/getstockaggregatesop.py +174 -0
- finance_dev/models/getstocklastquoteop.py +56 -0
- finance_dev/models/getstocklasttradeop.py +56 -0
- finance_dev/models/getstockopencloseop.py +90 -0
- finance_dev/models/getstockpreviousdayop.py +80 -0
- finance_dev/models/getstockquotesop.py +177 -0
- finance_dev/models/getstocksnapshotsop.py +82 -0
- finance_dev/models/getstocksplitsop.py +243 -0
- finance_dev/models/getstocktradesop.py +177 -0
- finance_dev/models/getsupplychainop.py +53 -0
- finance_dev/models/getsupportresistancelevelsop.py +90 -0
- finance_dev/models/getsymbolinfoop.py +53 -0
- finance_dev/models/gettechnicalindicatorop.py +172 -0
- finance_dev/models/gettechnicalpatternsop.py +88 -0
- finance_dev/models/gettenderoffersop.py +112 -0
- finance_dev/models/gettickhistoryop.py +104 -0
- finance_dev/models/gettopgainersop.py +78 -0
- finance_dev/models/gettoplosersop.py +78 -0
- finance_dev/models/gettopmostactiveop.py +78 -0
- finance_dev/models/gettranscriptop.py +53 -0
- finance_dev/models/gettreasuryyieldsop.py +157 -0
- finance_dev/models/getunifiedsnapshotop.py +223 -0
- finance_dev/models/getupgradesdowngradesop.py +91 -0
- finance_dev/models/getusaspendingop.py +70 -0
- finance_dev/models/getuseraccountsop.py +40 -0
- finance_dev/models/getusptopatentsop.py +70 -0
- finance_dev/models/getvisaapplicationsop.py +73 -0
- finance_dev/models/historicalesgresponse.py +439 -0
- finance_dev/models/httpmetadata.py +24 -0
- finance_dev/models/incomestatement.py +296 -0
- finance_dev/models/incomestatementsresponse.py +61 -0
- finance_dev/models/indexbarresponse.py +194 -0
- finance_dev/models/indexbarsresponse.py +123 -0
- finance_dev/models/indexchartbarsresponse.py +213 -0
- finance_dev/models/indexgroupsresponse.py +78 -0
- finance_dev/models/indexlistresponse.py +95 -0
- finance_dev/models/indexsearchresponse.py +93 -0
- finance_dev/models/indicesbygroupresponse.py +93 -0
- finance_dev/models/indicesidentifiertype.py +28 -0
- finance_dev/models/indicesrealtimeindexinfo.py +67 -0
- finance_dev/models/indicesrealtimeindexvalue.py +157 -0
- finance_dev/models/indicesrealtimevaluesitem.py +80 -0
- finance_dev/models/indicesrealtimevaluesresponse.py +42 -0
- finance_dev/models/inflationexpectationsresponse.py +140 -0
- finance_dev/models/inflationresponse.py +132 -0
- finance_dev/models/insidertransaction.py +97 -0
- finance_dev/models/insidertransactionsresponse.py +39 -0
- finance_dev/models/institutionalholding.py +77 -0
- finance_dev/models/institutionalownershipresponse.py +39 -0
- finance_dev/models/institutionalportfolioresponse.py +39 -0
- finance_dev/models/investmentthemeid.py +35 -0
- finance_dev/models/investmentthemeresponse.py +80 -0
- finance_dev/models/ipocalendarresponse.py +39 -0
- finance_dev/models/ipoitem.py +93 -0
- finance_dev/models/listactiveordersop.py +87 -0
- finance_dev/models/listcategoriesop.py +79 -0
- finance_dev/models/listindexgroupsop.py +40 -0
- finance_dev/models/listindicesbygroupop.py +58 -0
- finance_dev/models/listindicesop.py +91 -0
- finance_dev/models/listoptioncontractsop.py +66 -0
- finance_dev/models/listoptionexpirydatesop.py +56 -0
- finance_dev/models/listorderhistoryop.py +139 -0
- finance_dev/models/listpredictionordersop.py +134 -0
- finance_dev/models/listtranscriptsop.py +53 -0
- finance_dev/models/lobbyingresponse.py +166 -0
- finance_dev/models/logosearchresponse.py +152 -0
- finance_dev/models/logosyncresponse.py +277 -0
- finance_dev/models/marketbreadth.py +97 -0
- finance_dev/models/marketbreadthresponse.py +44 -0
- finance_dev/models/marketholiday.py +56 -0
- finance_dev/models/marketholidayresponse.py +39 -0
- finance_dev/models/marketstatus.py +67 -0
- finance_dev/models/mergersandacquisitionsresponse.py +186 -0
- finance_dev/models/metricseriespoint.py +43 -0
- finance_dev/models/netinflow.py +81 -0
- finance_dev/models/netinflowresponse.py +44 -0
- finance_dev/models/newsitem.py +102 -0
- finance_dev/models/newslistresponse.py +128 -0
- finance_dev/models/newssentimentresponse.py +176 -0
- finance_dev/models/newstypeenum.py +16 -0
- finance_dev/models/optionchainsnapshotresponse.py +64 -0
- finance_dev/models/optioncontractsnapshotresponse.py +64 -0
- finance_dev/models/optioncontractsnapshotrow.py +164 -0
- finance_dev/models/optioncontractsresponse.py +131 -0
- finance_dev/models/optiondetailsdto.py +72 -0
- finance_dev/models/optionexpirydatesresponse.py +53 -0
- finance_dev/models/optionlasttraderesponse.py +169 -0
- finance_dev/models/optionopencloseresponse.py +97 -0
- finance_dev/models/optionpreviousdayresponse.py +89 -0
- finance_dev/models/optionquotesresponse.py +138 -0
- finance_dev/models/optionsactivityresponse.py +265 -0
- finance_dev/models/optionsnapshotcontractdetails.py +85 -0
- finance_dev/models/optionsnapshotdaybar.py +107 -0
- finance_dev/models/optionsnapshotgreeks.py +67 -0
- finance_dev/models/optionsnapshotlastquote.py +116 -0
- finance_dev/models/optionsnapshotlasttrade.py +102 -0
- finance_dev/models/optionsnapshotunderlying.py +86 -0
- finance_dev/models/optionsscreeneritem.py +151 -0
- finance_dev/models/optionsunusualactivityresponse.py +62 -0
- finance_dev/models/optionsunusualactivitytrade.py +103 -0
- finance_dev/models/optiontradesresponse.py +132 -0
- finance_dev/models/orderrequesttimeinforceenum.py +29 -0
- finance_dev/models/ordersideenum.py +20 -0
- finance_dev/models/ordertypeenum.py +20 -0
- finance_dev/models/ordleg.py +162 -0
- finance_dev/models/ordresponse.py +202 -0
- finance_dev/models/ownershipdataresponse.py +39 -0
- finance_dev/models/ownershiprecord.py +74 -0
- finance_dev/models/placeorderop.py +40 -0
- finance_dev/models/placeordrequest_union.py +335 -0
- finance_dev/models/placepredictionorderop.py +114 -0
- finance_dev/models/predmdbaseevent.py +62 -0
- finance_dev/models/predmdbaseeventhit.py +53 -0
- finance_dev/models/predmdbaseeventsearchresult.py +46 -0
- finance_dev/models/predmdbaseeventwithevents.py +32 -0
- finance_dev/models/predmdbatchhistoryrequest.py +16 -0
- finance_dev/models/predmdbatchhistoryresponse.py +16 -0
- finance_dev/models/predmdcategory.py +48 -0
- finance_dev/models/predmdcontract.py +177 -0
- finance_dev/models/predmdcontracthit.py +157 -0
- finance_dev/models/predmdcontractsearchresult.py +46 -0
- finance_dev/models/predmdevent.py +136 -0
- finance_dev/models/predmdeventhit.py +73 -0
- finance_dev/models/predmdeventsearchresult.py +46 -0
- finance_dev/models/predmdeventwithcontracts.py +22 -0
- finance_dev/models/predmdhistoryrequest.py +59 -0
- finance_dev/models/predmdhistoryresponse.py +53 -0
- finance_dev/models/predmdtick.py +53 -0
- finance_dev/models/predordersapperror.py +78 -0
- finance_dev/models/predordersorder.py +267 -0
- finance_dev/models/predordersorderdetail.py +26 -0
- finance_dev/models/predordersorderpage.py +45 -0
- finance_dev/models/predordersorderreport.py +88 -0
- finance_dev/models/predordersplaceorderrequest.py +159 -0
- finance_dev/models/previeworderop.py +40 -0
- finance_dev/models/previeworderresponse.py +127 -0
- finance_dev/models/pricetargetresponse.py +89 -0
- finance_dev/models/quotedata.py +49 -0
- finance_dev/models/quotesresponse.py +62 -0
- finance_dev/models/quotevalues.py +114 -0
- finance_dev/models/rating.py +193 -0
- finance_dev/models/ratingsaccuracy.py +242 -0
- finance_dev/models/replaceconfigwatchlistsop.py +40 -0
- finance_dev/models/replaceorderop.py +40 -0
- finance_dev/models/replaceordrequest_union.py +367 -0
- finance_dev/models/replaceordresponse.py +144 -0
- finance_dev/models/reportedbsitem.py +53 -0
- finance_dev/models/reportedfiling.py +110 -0
- finance_dev/models/reportedreport.py +39 -0
- finance_dev/models/reportingfrequency.py +16 -0
- finance_dev/models/revenuebreakdownaxis.py +52 -0
- finance_dev/models/revenuebreakdowndatapoint.py +58 -0
- finance_dev/models/revenuebreakdownentry.py +51 -0
- finance_dev/models/revenuebreakdowninner.py +75 -0
- finance_dev/models/revenueestimatesresponse.py +176 -0
- finance_dev/models/screenclause.py +70 -0
- finance_dev/models/screengroup.py +75 -0
- finance_dev/models/searchetbsymbolsop.py +40 -0
- finance_dev/models/searchindicesop.py +55 -0
- finance_dev/models/searchlogosop.py +158 -0
- finance_dev/models/searchmarketsymbolsop.py +80 -0
- finance_dev/models/searchop.py +232 -0
- finance_dev/models/searchsymbolitem.py +76 -0
- finance_dev/models/searchsymbolresponseitem.py +71 -0
- finance_dev/models/searchsymbolsop.py +77 -0
- finance_dev/models/secfiling.py +91 -0
- finance_dev/models/secfilingsresponse.py +39 -0
- finance_dev/models/sectoravgchange.py +50 -0
- finance_dev/models/security.py +59 -0
- finance_dev/models/securitytypeenum.py +16 -0
- finance_dev/models/shortinterestresponse.py +126 -0
- finance_dev/models/shortvolumeresponse.py +198 -0
- finance_dev/models/socialsentimentresponse.py +124 -0
- finance_dev/models/sortorderenum.py +13 -0
- finance_dev/models/spinoffsresponse.py +136 -0
- finance_dev/models/stockaggregatesresponse.py +92 -0
- finance_dev/models/stocklastquoteresponse.py +175 -0
- finance_dev/models/stocklasttraderesponse.py +169 -0
- finance_dev/models/stockohlcbar.py +85 -0
- finance_dev/models/stockopencloseresponse.py +109 -0
- finance_dev/models/stockpreviousdayresponse.py +86 -0
- finance_dev/models/stockquotesresponse.py +170 -0
- finance_dev/models/stockscreenerop.py +144 -0
- finance_dev/models/stockscreenerrequest.py +131 -0
- finance_dev/models/stockscreenerresponse.py +197 -0
- finance_dev/models/stocksnapshotsresponse.py +454 -0
- finance_dev/models/stocksplitsresponse.py +144 -0
- finance_dev/models/stocktradesresponse.py +164 -0
- finance_dev/models/supplychainresponse.py +158 -0
- finance_dev/models/supportresistancelevelsresponse.py +68 -0
- finance_dev/models/symboldetails.py +119 -0
- finance_dev/models/symbolerror.py +43 -0
- finance_dev/models/symbolinfo.py +183 -0
- finance_dev/models/synclogosop.py +146 -0
- finance_dev/models/technicalindicatorresponse.py +43 -0
- finance_dev/models/technicalindicatortype.py +21 -0
- finance_dev/models/technicalpatternsresponse.py +249 -0
- finance_dev/models/tenderofferidentifiertype.py +26 -0
- finance_dev/models/tenderoffersresponse.py +548 -0
- finance_dev/models/tickchartbars.py +104 -0
- finance_dev/models/tickresolution.py +20 -0
- finance_dev/models/timeinforceenum.py +26 -0
- finance_dev/models/tradeorderlegv2.py +164 -0
- finance_dev/models/tradeorderv2.py +434 -0
- finance_dev/models/transcriptresponse.py +162 -0
- finance_dev/models/transcriptsresponse.py +89 -0
- finance_dev/models/treasuryyieldsresponse.py +160 -0
- finance_dev/models/unifiedsnapshotresponse.py +308 -0
- finance_dev/models/updateconfigwatchlistbyidop.py +65 -0
- finance_dev/models/updatewatchlistrequest_union.py +134 -0
- finance_dev/models/upgradesdowngradesresponse.py +98 -0
- finance_dev/models/usaspendingresponse.py +222 -0
- finance_dev/models/usptopatentsresponse.py +134 -0
- finance_dev/models/visaapplicationsresponse.py +228 -0
- finance_dev/models/watchlist.py +68 -0
- finance_dev/models/watchlistrequest.py +43 -0
- finance_dev/models/watchlistresponse.py +44 -0
- finance_dev/news_sdk.py +829 -0
- finance_dev/options.py +3443 -0
- finance_dev/orders.py +1907 -0
- finance_dev/ownership.py +1386 -0
- finance_dev/predictions.py +29 -0
- finance_dev/predictions_orders.py +852 -0
- finance_dev/py.typed +1 -0
- finance_dev/sdk.py +347 -0
- finance_dev/sdkconfiguration.py +50 -0
- finance_dev/signals.py +338 -0
- finance_dev/stocks.py +3131 -0
- finance_dev/technicalanalysis_sdk.py +1137 -0
- finance_dev/types/__init__.py +25 -0
- finance_dev/types/base64fileinput.py +44 -0
- finance_dev/types/basemodel.py +78 -0
- finance_dev/utils/__init__.py +181 -0
- finance_dev/utils/annotations.py +80 -0
- finance_dev/utils/datetimes.py +42 -0
- finance_dev/utils/dynamic_imports.py +55 -0
- finance_dev/utils/enums.py +135 -0
- finance_dev/utils/eventstreaming.py +327 -0
- finance_dev/utils/forms.py +240 -0
- finance_dev/utils/headers.py +137 -0
- finance_dev/utils/logger.py +23 -0
- finance_dev/utils/metadata.py +120 -0
- finance_dev/utils/queryparams.py +218 -0
- finance_dev/utils/requestbodies.py +68 -0
- finance_dev/utils/retries.py +373 -0
- finance_dev/utils/security.py +199 -0
- finance_dev/utils/serializers.py +327 -0
- finance_dev/utils/unmarshal_json_response.py +39 -0
- finance_dev/utils/url.py +155 -0
- finance_dev/utils/values.py +143 -0
- finance_dev/watchlist_sdk.py +1583 -0
- finance_dev/websocket/__init__.py +57 -0
- finance_dev/websocket/account.py +5 -0
- finance_dev/websocket/auth.py +124 -0
- finance_dev/websocket/chart.py +5 -0
- finance_dev/websocket/codec.py +66 -0
- finance_dev/websocket/config.py +52 -0
- finance_dev/websocket/errors.py +54 -0
- finance_dev/websocket/market.py +5 -0
- finance_dev/websocket/models/__init__.py +52 -0
- finance_dev/websocket/models/account.py +60 -0
- finance_dev/websocket/models/chart.py +44 -0
- finance_dev/websocket/models/common.py +85 -0
- finance_dev/websocket/models/market.py +113 -0
- finance_dev/websocket/resources.py +327 -0
- finance_dev/websocket/sdk.py +13 -0
- finance_dev/websocket/transport/async_connection.py +493 -0
- finance_dev/websocket/transport/base.py +78 -0
- finance_dev/websocket/transport/sync_connection.py +470 -0
- finance_dev-0.9.0.dist-info/METADATA +913 -0
- finance_dev-0.9.0.dist-info/RECORD +486 -0
- finance_dev-0.9.0.dist-info/WHEEL +5 -0
- finance_dev-0.9.0.dist-info/top_level.txt +1 -0
finance_dev/orders.py
ADDED
|
@@ -0,0 +1,1907 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
# @generated-id: dcd1fd2968f6
|
|
3
|
+
|
|
4
|
+
from .basesdk import BaseSDK
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from finance_dev import errors, models, utils
|
|
7
|
+
from finance_dev._hooks import HookContext
|
|
8
|
+
from finance_dev.types import BaseModel, OptionalNullable, UNSET
|
|
9
|
+
from finance_dev.utils.unmarshal_json_response import unmarshal_json_response
|
|
10
|
+
from jsonpath import JSONPath
|
|
11
|
+
from typing import Any, Dict, List, Mapping, Optional, Union, cast
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Orders(BaseSDK):
|
|
15
|
+
def place_order(
|
|
16
|
+
self,
|
|
17
|
+
*,
|
|
18
|
+
request: Union[
|
|
19
|
+
models.PlaceOrdRequestUnion, models.PlaceOrdRequestUnionTypedDict
|
|
20
|
+
],
|
|
21
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
22
|
+
server_url: Optional[str] = None,
|
|
23
|
+
timeout_ms: Optional[int] = None,
|
|
24
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
25
|
+
) -> models.PlaceOrderResponse:
|
|
26
|
+
r"""Place an order
|
|
27
|
+
|
|
28
|
+
Place an equity or option order. The order type is automatically determined:
|
|
29
|
+
- No `legs` array = Equity order
|
|
30
|
+
- 1 leg in `legs` array = Single-leg option order
|
|
31
|
+
- 2-4 legs in `legs` array = Multi-leg option order
|
|
32
|
+
|
|
33
|
+
Option and multi-leg orders only support `DAY` and `GTC` for `timeInForce`.
|
|
34
|
+
|
|
35
|
+
If you send an OSI option symbol in `symbol` and omit `legs`, the backend derives a single option leg automatically.
|
|
36
|
+
|
|
37
|
+
Price precision validation:
|
|
38
|
+
- `LIMIT` validates `price`
|
|
39
|
+
- `STOP` validates `stopPrice`
|
|
40
|
+
- `STOP_LIMIT` validates both
|
|
41
|
+
- Decimal inputs support up to 5 digits after the decimal point.
|
|
42
|
+
|
|
43
|
+
If set, this operation will use `client_id` from the global security.
|
|
44
|
+
|
|
45
|
+
:param request: The request object to send.
|
|
46
|
+
:param retries: Override the default retry configuration for this method
|
|
47
|
+
:param server_url: Override the default server URL for this method
|
|
48
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
49
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
50
|
+
"""
|
|
51
|
+
base_url = None
|
|
52
|
+
url_variables = None
|
|
53
|
+
if timeout_ms is None:
|
|
54
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
55
|
+
|
|
56
|
+
if timeout_ms is None:
|
|
57
|
+
timeout_ms = 30000
|
|
58
|
+
|
|
59
|
+
if server_url is not None:
|
|
60
|
+
base_url = server_url
|
|
61
|
+
else:
|
|
62
|
+
base_url = self._get_url(base_url, url_variables)
|
|
63
|
+
|
|
64
|
+
if not isinstance(request, BaseModel):
|
|
65
|
+
request = utils.unmarshal(request, models.PlaceOrdRequestUnion)
|
|
66
|
+
request = cast(models.PlaceOrdRequestUnion, request)
|
|
67
|
+
|
|
68
|
+
req = self._build_request(
|
|
69
|
+
method="POST",
|
|
70
|
+
path="/v1/orders",
|
|
71
|
+
base_url=base_url,
|
|
72
|
+
url_variables=url_variables,
|
|
73
|
+
request=request,
|
|
74
|
+
request_body_required=True,
|
|
75
|
+
request_has_path_params=False,
|
|
76
|
+
request_has_query_params=True,
|
|
77
|
+
user_agent_header="user-agent",
|
|
78
|
+
accept_header_value="application/json",
|
|
79
|
+
http_headers=http_headers,
|
|
80
|
+
security=self.sdk_configuration.security,
|
|
81
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
82
|
+
request, False, False, "json", models.PlaceOrdRequestUnion
|
|
83
|
+
),
|
|
84
|
+
allow_empty_value=None,
|
|
85
|
+
allowed_fields=["client_id"],
|
|
86
|
+
timeout_ms=timeout_ms,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
if retries == UNSET:
|
|
90
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
91
|
+
retries = self.sdk_configuration.retry_config
|
|
92
|
+
|
|
93
|
+
retry_config = None
|
|
94
|
+
if isinstance(retries, utils.RetryConfig):
|
|
95
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
96
|
+
|
|
97
|
+
http_res = self.do_request(
|
|
98
|
+
hook_ctx=HookContext(
|
|
99
|
+
config=self.sdk_configuration,
|
|
100
|
+
base_url=base_url or "",
|
|
101
|
+
operation_id="placeOrder",
|
|
102
|
+
oauth2_scopes=["order:execution"],
|
|
103
|
+
security_source=self.sdk_configuration.security,
|
|
104
|
+
tags=["Orders"],
|
|
105
|
+
extensions=None,
|
|
106
|
+
),
|
|
107
|
+
request=req,
|
|
108
|
+
is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
|
|
109
|
+
retry_config=retry_config,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
response_data: Any = None
|
|
113
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
114
|
+
return models.PlaceOrderResponse(
|
|
115
|
+
ord_response=unmarshal_json_response(
|
|
116
|
+
Optional[models.OrdResponse], http_res
|
|
117
|
+
),
|
|
118
|
+
http_meta=models.HTTPMetadata(request=req, response=http_res),
|
|
119
|
+
)
|
|
120
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
121
|
+
response_data = unmarshal_json_response(errors.BadRequestUnion, http_res)
|
|
122
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
123
|
+
request=req, response=http_res
|
|
124
|
+
)
|
|
125
|
+
raise errors.BadRequest(response_data, http_res)
|
|
126
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
127
|
+
response_data = unmarshal_json_response(errors.UnauthorizedUnion, http_res)
|
|
128
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
129
|
+
request=req, response=http_res
|
|
130
|
+
)
|
|
131
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
132
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
133
|
+
response_data = unmarshal_json_response(errors.ForbiddenUnion, http_res)
|
|
134
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
135
|
+
request=req, response=http_res
|
|
136
|
+
)
|
|
137
|
+
raise errors.Forbidden(response_data, http_res)
|
|
138
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
139
|
+
response_data = unmarshal_json_response(errors.NotFoundUnion, http_res)
|
|
140
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
141
|
+
request=req, response=http_res
|
|
142
|
+
)
|
|
143
|
+
raise errors.NotFound(response_data, http_res)
|
|
144
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
145
|
+
response_data = unmarshal_json_response(
|
|
146
|
+
errors.InternalServerErrorUnion, http_res
|
|
147
|
+
)
|
|
148
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
149
|
+
request=req, response=http_res
|
|
150
|
+
)
|
|
151
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
152
|
+
if utils.match_response(http_res, ["503", "504"], "application/json"):
|
|
153
|
+
response_data = unmarshal_json_response(
|
|
154
|
+
errors.AuthenticationErrorEnvelopeData, http_res
|
|
155
|
+
)
|
|
156
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
157
|
+
request=req, response=http_res
|
|
158
|
+
)
|
|
159
|
+
raise errors.AuthenticationErrorEnvelope(response_data, http_res)
|
|
160
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
161
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
162
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
163
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
164
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
165
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
166
|
+
|
|
167
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
168
|
+
|
|
169
|
+
async def place_order_async(
|
|
170
|
+
self,
|
|
171
|
+
*,
|
|
172
|
+
request: Union[
|
|
173
|
+
models.PlaceOrdRequestUnion, models.PlaceOrdRequestUnionTypedDict
|
|
174
|
+
],
|
|
175
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
176
|
+
server_url: Optional[str] = None,
|
|
177
|
+
timeout_ms: Optional[int] = None,
|
|
178
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
179
|
+
) -> models.PlaceOrderResponse:
|
|
180
|
+
r"""Place an order
|
|
181
|
+
|
|
182
|
+
Place an equity or option order. The order type is automatically determined:
|
|
183
|
+
- No `legs` array = Equity order
|
|
184
|
+
- 1 leg in `legs` array = Single-leg option order
|
|
185
|
+
- 2-4 legs in `legs` array = Multi-leg option order
|
|
186
|
+
|
|
187
|
+
Option and multi-leg orders only support `DAY` and `GTC` for `timeInForce`.
|
|
188
|
+
|
|
189
|
+
If you send an OSI option symbol in `symbol` and omit `legs`, the backend derives a single option leg automatically.
|
|
190
|
+
|
|
191
|
+
Price precision validation:
|
|
192
|
+
- `LIMIT` validates `price`
|
|
193
|
+
- `STOP` validates `stopPrice`
|
|
194
|
+
- `STOP_LIMIT` validates both
|
|
195
|
+
- Decimal inputs support up to 5 digits after the decimal point.
|
|
196
|
+
|
|
197
|
+
If set, this operation will use `client_id` from the global security.
|
|
198
|
+
|
|
199
|
+
:param request: The request object to send.
|
|
200
|
+
:param retries: Override the default retry configuration for this method
|
|
201
|
+
:param server_url: Override the default server URL for this method
|
|
202
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
203
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
204
|
+
"""
|
|
205
|
+
base_url = None
|
|
206
|
+
url_variables = None
|
|
207
|
+
if timeout_ms is None:
|
|
208
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
209
|
+
|
|
210
|
+
if timeout_ms is None:
|
|
211
|
+
timeout_ms = 30000
|
|
212
|
+
|
|
213
|
+
if server_url is not None:
|
|
214
|
+
base_url = server_url
|
|
215
|
+
else:
|
|
216
|
+
base_url = self._get_url(base_url, url_variables)
|
|
217
|
+
|
|
218
|
+
if not isinstance(request, BaseModel):
|
|
219
|
+
request = utils.unmarshal(request, models.PlaceOrdRequestUnion)
|
|
220
|
+
request = cast(models.PlaceOrdRequestUnion, request)
|
|
221
|
+
|
|
222
|
+
req = self._build_request_async(
|
|
223
|
+
method="POST",
|
|
224
|
+
path="/v1/orders",
|
|
225
|
+
base_url=base_url,
|
|
226
|
+
url_variables=url_variables,
|
|
227
|
+
request=request,
|
|
228
|
+
request_body_required=True,
|
|
229
|
+
request_has_path_params=False,
|
|
230
|
+
request_has_query_params=True,
|
|
231
|
+
user_agent_header="user-agent",
|
|
232
|
+
accept_header_value="application/json",
|
|
233
|
+
http_headers=http_headers,
|
|
234
|
+
security=self.sdk_configuration.security,
|
|
235
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
236
|
+
request, False, False, "json", models.PlaceOrdRequestUnion
|
|
237
|
+
),
|
|
238
|
+
allow_empty_value=None,
|
|
239
|
+
allowed_fields=["client_id"],
|
|
240
|
+
timeout_ms=timeout_ms,
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
if retries == UNSET:
|
|
244
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
245
|
+
retries = self.sdk_configuration.retry_config
|
|
246
|
+
|
|
247
|
+
retry_config = None
|
|
248
|
+
if isinstance(retries, utils.RetryConfig):
|
|
249
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
250
|
+
|
|
251
|
+
http_res = await self.do_request_async(
|
|
252
|
+
hook_ctx=HookContext(
|
|
253
|
+
config=self.sdk_configuration,
|
|
254
|
+
base_url=base_url or "",
|
|
255
|
+
operation_id="placeOrder",
|
|
256
|
+
oauth2_scopes=["order:execution"],
|
|
257
|
+
security_source=self.sdk_configuration.security,
|
|
258
|
+
tags=["Orders"],
|
|
259
|
+
extensions=None,
|
|
260
|
+
),
|
|
261
|
+
request=req,
|
|
262
|
+
is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
|
|
263
|
+
retry_config=retry_config,
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
response_data: Any = None
|
|
267
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
268
|
+
return models.PlaceOrderResponse(
|
|
269
|
+
ord_response=unmarshal_json_response(
|
|
270
|
+
Optional[models.OrdResponse], http_res
|
|
271
|
+
),
|
|
272
|
+
http_meta=models.HTTPMetadata(request=req, response=http_res),
|
|
273
|
+
)
|
|
274
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
275
|
+
response_data = unmarshal_json_response(errors.BadRequestUnion, http_res)
|
|
276
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
277
|
+
request=req, response=http_res
|
|
278
|
+
)
|
|
279
|
+
raise errors.BadRequest(response_data, http_res)
|
|
280
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
281
|
+
response_data = unmarshal_json_response(errors.UnauthorizedUnion, http_res)
|
|
282
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
283
|
+
request=req, response=http_res
|
|
284
|
+
)
|
|
285
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
286
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
287
|
+
response_data = unmarshal_json_response(errors.ForbiddenUnion, http_res)
|
|
288
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
289
|
+
request=req, response=http_res
|
|
290
|
+
)
|
|
291
|
+
raise errors.Forbidden(response_data, http_res)
|
|
292
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
293
|
+
response_data = unmarshal_json_response(errors.NotFoundUnion, http_res)
|
|
294
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
295
|
+
request=req, response=http_res
|
|
296
|
+
)
|
|
297
|
+
raise errors.NotFound(response_data, http_res)
|
|
298
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
299
|
+
response_data = unmarshal_json_response(
|
|
300
|
+
errors.InternalServerErrorUnion, http_res
|
|
301
|
+
)
|
|
302
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
303
|
+
request=req, response=http_res
|
|
304
|
+
)
|
|
305
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
306
|
+
if utils.match_response(http_res, ["503", "504"], "application/json"):
|
|
307
|
+
response_data = unmarshal_json_response(
|
|
308
|
+
errors.AuthenticationErrorEnvelopeData, http_res
|
|
309
|
+
)
|
|
310
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
311
|
+
request=req, response=http_res
|
|
312
|
+
)
|
|
313
|
+
raise errors.AuthenticationErrorEnvelope(response_data, http_res)
|
|
314
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
315
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
316
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
317
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
318
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
319
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
320
|
+
|
|
321
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
322
|
+
|
|
323
|
+
def cancel_order(
|
|
324
|
+
self,
|
|
325
|
+
*,
|
|
326
|
+
request: Union[
|
|
327
|
+
models.CancelOrdRequestUnion, models.CancelOrdRequestUnionTypedDict
|
|
328
|
+
],
|
|
329
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
330
|
+
server_url: Optional[str] = None,
|
|
331
|
+
timeout_ms: Optional[int] = None,
|
|
332
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
333
|
+
) -> models.CancelOrderResponse:
|
|
334
|
+
r"""Cancel an order
|
|
335
|
+
|
|
336
|
+
Cancel an existing order by original client order ID. For option cancels, you can provide the option fields directly or send an OSI option symbol in `symbol` and let the backend derive the option instrument fields.
|
|
337
|
+
|
|
338
|
+
If set, this operation will use `client_id` from the global security.
|
|
339
|
+
|
|
340
|
+
:param request: The request object to send.
|
|
341
|
+
:param retries: Override the default retry configuration for this method
|
|
342
|
+
:param server_url: Override the default server URL for this method
|
|
343
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
344
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
345
|
+
"""
|
|
346
|
+
base_url = None
|
|
347
|
+
url_variables = None
|
|
348
|
+
if timeout_ms is None:
|
|
349
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
350
|
+
|
|
351
|
+
if timeout_ms is None:
|
|
352
|
+
timeout_ms = 30000
|
|
353
|
+
|
|
354
|
+
if server_url is not None:
|
|
355
|
+
base_url = server_url
|
|
356
|
+
else:
|
|
357
|
+
base_url = self._get_url(base_url, url_variables)
|
|
358
|
+
|
|
359
|
+
if not isinstance(request, BaseModel):
|
|
360
|
+
request = utils.unmarshal(request, models.CancelOrdRequestUnion)
|
|
361
|
+
request = cast(models.CancelOrdRequestUnion, request)
|
|
362
|
+
|
|
363
|
+
req = self._build_request(
|
|
364
|
+
method="POST",
|
|
365
|
+
path="/v1/orders/cancel",
|
|
366
|
+
base_url=base_url,
|
|
367
|
+
url_variables=url_variables,
|
|
368
|
+
request=request,
|
|
369
|
+
request_body_required=True,
|
|
370
|
+
request_has_path_params=False,
|
|
371
|
+
request_has_query_params=True,
|
|
372
|
+
user_agent_header="user-agent",
|
|
373
|
+
accept_header_value="application/json",
|
|
374
|
+
http_headers=http_headers,
|
|
375
|
+
security=self.sdk_configuration.security,
|
|
376
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
377
|
+
request, False, False, "json", models.CancelOrdRequestUnion
|
|
378
|
+
),
|
|
379
|
+
allow_empty_value=None,
|
|
380
|
+
allowed_fields=["client_id"],
|
|
381
|
+
timeout_ms=timeout_ms,
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
if retries == UNSET:
|
|
385
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
386
|
+
retries = self.sdk_configuration.retry_config
|
|
387
|
+
|
|
388
|
+
retry_config = None
|
|
389
|
+
if isinstance(retries, utils.RetryConfig):
|
|
390
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
391
|
+
|
|
392
|
+
http_res = self.do_request(
|
|
393
|
+
hook_ctx=HookContext(
|
|
394
|
+
config=self.sdk_configuration,
|
|
395
|
+
base_url=base_url or "",
|
|
396
|
+
operation_id="cancelOrder",
|
|
397
|
+
oauth2_scopes=["order:execution"],
|
|
398
|
+
security_source=self.sdk_configuration.security,
|
|
399
|
+
tags=["Orders"],
|
|
400
|
+
extensions=None,
|
|
401
|
+
),
|
|
402
|
+
request=req,
|
|
403
|
+
is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
|
|
404
|
+
retry_config=retry_config,
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
response_data: Any = None
|
|
408
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
409
|
+
return models.CancelOrderResponse(
|
|
410
|
+
cancel_ord_response=unmarshal_json_response(
|
|
411
|
+
Optional[models.CancelOrdResponse], http_res
|
|
412
|
+
),
|
|
413
|
+
http_meta=models.HTTPMetadata(request=req, response=http_res),
|
|
414
|
+
)
|
|
415
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
416
|
+
response_data = unmarshal_json_response(errors.BadRequestUnion, http_res)
|
|
417
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
418
|
+
request=req, response=http_res
|
|
419
|
+
)
|
|
420
|
+
raise errors.BadRequest(response_data, http_res)
|
|
421
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
422
|
+
response_data = unmarshal_json_response(errors.UnauthorizedUnion, http_res)
|
|
423
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
424
|
+
request=req, response=http_res
|
|
425
|
+
)
|
|
426
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
427
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
428
|
+
response_data = unmarshal_json_response(errors.ForbiddenUnion, http_res)
|
|
429
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
430
|
+
request=req, response=http_res
|
|
431
|
+
)
|
|
432
|
+
raise errors.Forbidden(response_data, http_res)
|
|
433
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
434
|
+
response_data = unmarshal_json_response(errors.NotFoundUnion, http_res)
|
|
435
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
436
|
+
request=req, response=http_res
|
|
437
|
+
)
|
|
438
|
+
raise errors.NotFound(response_data, http_res)
|
|
439
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
440
|
+
response_data = unmarshal_json_response(
|
|
441
|
+
errors.InternalServerErrorUnion, http_res
|
|
442
|
+
)
|
|
443
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
444
|
+
request=req, response=http_res
|
|
445
|
+
)
|
|
446
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
447
|
+
if utils.match_response(http_res, ["503", "504"], "application/json"):
|
|
448
|
+
response_data = unmarshal_json_response(
|
|
449
|
+
errors.AuthenticationErrorEnvelopeData, http_res
|
|
450
|
+
)
|
|
451
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
452
|
+
request=req, response=http_res
|
|
453
|
+
)
|
|
454
|
+
raise errors.AuthenticationErrorEnvelope(response_data, http_res)
|
|
455
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
456
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
457
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
458
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
459
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
460
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
461
|
+
|
|
462
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
463
|
+
|
|
464
|
+
async def cancel_order_async(
|
|
465
|
+
self,
|
|
466
|
+
*,
|
|
467
|
+
request: Union[
|
|
468
|
+
models.CancelOrdRequestUnion, models.CancelOrdRequestUnionTypedDict
|
|
469
|
+
],
|
|
470
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
471
|
+
server_url: Optional[str] = None,
|
|
472
|
+
timeout_ms: Optional[int] = None,
|
|
473
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
474
|
+
) -> models.CancelOrderResponse:
|
|
475
|
+
r"""Cancel an order
|
|
476
|
+
|
|
477
|
+
Cancel an existing order by original client order ID. For option cancels, you can provide the option fields directly or send an OSI option symbol in `symbol` and let the backend derive the option instrument fields.
|
|
478
|
+
|
|
479
|
+
If set, this operation will use `client_id` from the global security.
|
|
480
|
+
|
|
481
|
+
:param request: The request object to send.
|
|
482
|
+
:param retries: Override the default retry configuration for this method
|
|
483
|
+
:param server_url: Override the default server URL for this method
|
|
484
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
485
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
486
|
+
"""
|
|
487
|
+
base_url = None
|
|
488
|
+
url_variables = None
|
|
489
|
+
if timeout_ms is None:
|
|
490
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
491
|
+
|
|
492
|
+
if timeout_ms is None:
|
|
493
|
+
timeout_ms = 30000
|
|
494
|
+
|
|
495
|
+
if server_url is not None:
|
|
496
|
+
base_url = server_url
|
|
497
|
+
else:
|
|
498
|
+
base_url = self._get_url(base_url, url_variables)
|
|
499
|
+
|
|
500
|
+
if not isinstance(request, BaseModel):
|
|
501
|
+
request = utils.unmarshal(request, models.CancelOrdRequestUnion)
|
|
502
|
+
request = cast(models.CancelOrdRequestUnion, request)
|
|
503
|
+
|
|
504
|
+
req = self._build_request_async(
|
|
505
|
+
method="POST",
|
|
506
|
+
path="/v1/orders/cancel",
|
|
507
|
+
base_url=base_url,
|
|
508
|
+
url_variables=url_variables,
|
|
509
|
+
request=request,
|
|
510
|
+
request_body_required=True,
|
|
511
|
+
request_has_path_params=False,
|
|
512
|
+
request_has_query_params=True,
|
|
513
|
+
user_agent_header="user-agent",
|
|
514
|
+
accept_header_value="application/json",
|
|
515
|
+
http_headers=http_headers,
|
|
516
|
+
security=self.sdk_configuration.security,
|
|
517
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
518
|
+
request, False, False, "json", models.CancelOrdRequestUnion
|
|
519
|
+
),
|
|
520
|
+
allow_empty_value=None,
|
|
521
|
+
allowed_fields=["client_id"],
|
|
522
|
+
timeout_ms=timeout_ms,
|
|
523
|
+
)
|
|
524
|
+
|
|
525
|
+
if retries == UNSET:
|
|
526
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
527
|
+
retries = self.sdk_configuration.retry_config
|
|
528
|
+
|
|
529
|
+
retry_config = None
|
|
530
|
+
if isinstance(retries, utils.RetryConfig):
|
|
531
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
532
|
+
|
|
533
|
+
http_res = await self.do_request_async(
|
|
534
|
+
hook_ctx=HookContext(
|
|
535
|
+
config=self.sdk_configuration,
|
|
536
|
+
base_url=base_url or "",
|
|
537
|
+
operation_id="cancelOrder",
|
|
538
|
+
oauth2_scopes=["order:execution"],
|
|
539
|
+
security_source=self.sdk_configuration.security,
|
|
540
|
+
tags=["Orders"],
|
|
541
|
+
extensions=None,
|
|
542
|
+
),
|
|
543
|
+
request=req,
|
|
544
|
+
is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
|
|
545
|
+
retry_config=retry_config,
|
|
546
|
+
)
|
|
547
|
+
|
|
548
|
+
response_data: Any = None
|
|
549
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
550
|
+
return models.CancelOrderResponse(
|
|
551
|
+
cancel_ord_response=unmarshal_json_response(
|
|
552
|
+
Optional[models.CancelOrdResponse], http_res
|
|
553
|
+
),
|
|
554
|
+
http_meta=models.HTTPMetadata(request=req, response=http_res),
|
|
555
|
+
)
|
|
556
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
557
|
+
response_data = unmarshal_json_response(errors.BadRequestUnion, http_res)
|
|
558
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
559
|
+
request=req, response=http_res
|
|
560
|
+
)
|
|
561
|
+
raise errors.BadRequest(response_data, http_res)
|
|
562
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
563
|
+
response_data = unmarshal_json_response(errors.UnauthorizedUnion, http_res)
|
|
564
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
565
|
+
request=req, response=http_res
|
|
566
|
+
)
|
|
567
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
568
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
569
|
+
response_data = unmarshal_json_response(errors.ForbiddenUnion, http_res)
|
|
570
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
571
|
+
request=req, response=http_res
|
|
572
|
+
)
|
|
573
|
+
raise errors.Forbidden(response_data, http_res)
|
|
574
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
575
|
+
response_data = unmarshal_json_response(errors.NotFoundUnion, http_res)
|
|
576
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
577
|
+
request=req, response=http_res
|
|
578
|
+
)
|
|
579
|
+
raise errors.NotFound(response_data, http_res)
|
|
580
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
581
|
+
response_data = unmarshal_json_response(
|
|
582
|
+
errors.InternalServerErrorUnion, http_res
|
|
583
|
+
)
|
|
584
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
585
|
+
request=req, response=http_res
|
|
586
|
+
)
|
|
587
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
588
|
+
if utils.match_response(http_res, ["503", "504"], "application/json"):
|
|
589
|
+
response_data = unmarshal_json_response(
|
|
590
|
+
errors.AuthenticationErrorEnvelopeData, http_res
|
|
591
|
+
)
|
|
592
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
593
|
+
request=req, response=http_res
|
|
594
|
+
)
|
|
595
|
+
raise errors.AuthenticationErrorEnvelope(response_data, http_res)
|
|
596
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
597
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
598
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
599
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
600
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
601
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
602
|
+
|
|
603
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
604
|
+
|
|
605
|
+
def preview_order(
|
|
606
|
+
self,
|
|
607
|
+
*,
|
|
608
|
+
request: Union[
|
|
609
|
+
models.PlaceOrdRequestUnion, models.PlaceOrdRequestUnionTypedDict
|
|
610
|
+
],
|
|
611
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
612
|
+
server_url: Optional[str] = None,
|
|
613
|
+
timeout_ms: Optional[int] = None,
|
|
614
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
615
|
+
) -> models.PreviewOrderResponseResponse:
|
|
616
|
+
r"""Preview order
|
|
617
|
+
|
|
618
|
+
Preview an order to calculate estimated cost, fees, buying power impact, and option requirements before placing. Uses the same request body as Place Order (PlaceOrdRequest), including the same option `timeInForce` restrictions, OSI-symbol support, and price-precision validation.
|
|
619
|
+
|
|
620
|
+
If set, this operation will use `client_id` from the global security.
|
|
621
|
+
|
|
622
|
+
:param request: The request object to send.
|
|
623
|
+
:param retries: Override the default retry configuration for this method
|
|
624
|
+
:param server_url: Override the default server URL for this method
|
|
625
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
626
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
627
|
+
"""
|
|
628
|
+
base_url = None
|
|
629
|
+
url_variables = None
|
|
630
|
+
if timeout_ms is None:
|
|
631
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
632
|
+
|
|
633
|
+
if timeout_ms is None:
|
|
634
|
+
timeout_ms = 30000
|
|
635
|
+
|
|
636
|
+
if server_url is not None:
|
|
637
|
+
base_url = server_url
|
|
638
|
+
else:
|
|
639
|
+
base_url = self._get_url(base_url, url_variables)
|
|
640
|
+
|
|
641
|
+
if not isinstance(request, BaseModel):
|
|
642
|
+
request = utils.unmarshal(request, models.PlaceOrdRequestUnion)
|
|
643
|
+
request = cast(models.PlaceOrdRequestUnion, request)
|
|
644
|
+
|
|
645
|
+
req = self._build_request(
|
|
646
|
+
method="POST",
|
|
647
|
+
path="/v1/orders/preview",
|
|
648
|
+
base_url=base_url,
|
|
649
|
+
url_variables=url_variables,
|
|
650
|
+
request=request,
|
|
651
|
+
request_body_required=True,
|
|
652
|
+
request_has_path_params=False,
|
|
653
|
+
request_has_query_params=True,
|
|
654
|
+
user_agent_header="user-agent",
|
|
655
|
+
accept_header_value="application/json",
|
|
656
|
+
http_headers=http_headers,
|
|
657
|
+
security=self.sdk_configuration.security,
|
|
658
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
659
|
+
request, False, False, "json", models.PlaceOrdRequestUnion
|
|
660
|
+
),
|
|
661
|
+
allow_empty_value=None,
|
|
662
|
+
allowed_fields=["client_id"],
|
|
663
|
+
timeout_ms=timeout_ms,
|
|
664
|
+
)
|
|
665
|
+
|
|
666
|
+
if retries == UNSET:
|
|
667
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
668
|
+
retries = self.sdk_configuration.retry_config
|
|
669
|
+
else:
|
|
670
|
+
retries = utils.RetryConfig(
|
|
671
|
+
"backoff", utils.BackoffStrategy(500, 8000, 1.5, 60000), True
|
|
672
|
+
)
|
|
673
|
+
|
|
674
|
+
retry_config = None
|
|
675
|
+
if isinstance(retries, utils.RetryConfig):
|
|
676
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
677
|
+
|
|
678
|
+
http_res = self.do_request(
|
|
679
|
+
hook_ctx=HookContext(
|
|
680
|
+
config=self.sdk_configuration,
|
|
681
|
+
base_url=base_url or "",
|
|
682
|
+
operation_id="previewOrder",
|
|
683
|
+
oauth2_scopes=["order:execution"],
|
|
684
|
+
security_source=self.sdk_configuration.security,
|
|
685
|
+
tags=["Orders"],
|
|
686
|
+
extensions=None,
|
|
687
|
+
),
|
|
688
|
+
request=req,
|
|
689
|
+
is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
|
|
690
|
+
retry_config=retry_config,
|
|
691
|
+
)
|
|
692
|
+
|
|
693
|
+
response_data: Any = None
|
|
694
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
695
|
+
return models.PreviewOrderResponseResponse(
|
|
696
|
+
preview_order_response=unmarshal_json_response(
|
|
697
|
+
Optional[models.PreviewOrderResponse], http_res
|
|
698
|
+
),
|
|
699
|
+
http_meta=models.HTTPMetadata(request=req, response=http_res),
|
|
700
|
+
)
|
|
701
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
702
|
+
response_data = unmarshal_json_response(errors.BadRequestUnion, http_res)
|
|
703
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
704
|
+
request=req, response=http_res
|
|
705
|
+
)
|
|
706
|
+
raise errors.BadRequest(response_data, http_res)
|
|
707
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
708
|
+
response_data = unmarshal_json_response(errors.UnauthorizedUnion, http_res)
|
|
709
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
710
|
+
request=req, response=http_res
|
|
711
|
+
)
|
|
712
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
713
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
714
|
+
response_data = unmarshal_json_response(errors.ForbiddenUnion, http_res)
|
|
715
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
716
|
+
request=req, response=http_res
|
|
717
|
+
)
|
|
718
|
+
raise errors.Forbidden(response_data, http_res)
|
|
719
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
720
|
+
response_data = unmarshal_json_response(errors.NotFoundUnion, http_res)
|
|
721
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
722
|
+
request=req, response=http_res
|
|
723
|
+
)
|
|
724
|
+
raise errors.NotFound(response_data, http_res)
|
|
725
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
726
|
+
response_data = unmarshal_json_response(
|
|
727
|
+
errors.InternalServerErrorUnion, http_res
|
|
728
|
+
)
|
|
729
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
730
|
+
request=req, response=http_res
|
|
731
|
+
)
|
|
732
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
733
|
+
if utils.match_response(http_res, ["503", "504"], "application/json"):
|
|
734
|
+
response_data = unmarshal_json_response(
|
|
735
|
+
errors.AuthenticationErrorEnvelopeData, http_res
|
|
736
|
+
)
|
|
737
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
738
|
+
request=req, response=http_res
|
|
739
|
+
)
|
|
740
|
+
raise errors.AuthenticationErrorEnvelope(response_data, http_res)
|
|
741
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
742
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
743
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
744
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
745
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
746
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
747
|
+
|
|
748
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
749
|
+
|
|
750
|
+
async def preview_order_async(
|
|
751
|
+
self,
|
|
752
|
+
*,
|
|
753
|
+
request: Union[
|
|
754
|
+
models.PlaceOrdRequestUnion, models.PlaceOrdRequestUnionTypedDict
|
|
755
|
+
],
|
|
756
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
757
|
+
server_url: Optional[str] = None,
|
|
758
|
+
timeout_ms: Optional[int] = None,
|
|
759
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
760
|
+
) -> models.PreviewOrderResponseResponse:
|
|
761
|
+
r"""Preview order
|
|
762
|
+
|
|
763
|
+
Preview an order to calculate estimated cost, fees, buying power impact, and option requirements before placing. Uses the same request body as Place Order (PlaceOrdRequest), including the same option `timeInForce` restrictions, OSI-symbol support, and price-precision validation.
|
|
764
|
+
|
|
765
|
+
If set, this operation will use `client_id` from the global security.
|
|
766
|
+
|
|
767
|
+
:param request: The request object to send.
|
|
768
|
+
:param retries: Override the default retry configuration for this method
|
|
769
|
+
:param server_url: Override the default server URL for this method
|
|
770
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
771
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
772
|
+
"""
|
|
773
|
+
base_url = None
|
|
774
|
+
url_variables = None
|
|
775
|
+
if timeout_ms is None:
|
|
776
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
777
|
+
|
|
778
|
+
if timeout_ms is None:
|
|
779
|
+
timeout_ms = 30000
|
|
780
|
+
|
|
781
|
+
if server_url is not None:
|
|
782
|
+
base_url = server_url
|
|
783
|
+
else:
|
|
784
|
+
base_url = self._get_url(base_url, url_variables)
|
|
785
|
+
|
|
786
|
+
if not isinstance(request, BaseModel):
|
|
787
|
+
request = utils.unmarshal(request, models.PlaceOrdRequestUnion)
|
|
788
|
+
request = cast(models.PlaceOrdRequestUnion, request)
|
|
789
|
+
|
|
790
|
+
req = self._build_request_async(
|
|
791
|
+
method="POST",
|
|
792
|
+
path="/v1/orders/preview",
|
|
793
|
+
base_url=base_url,
|
|
794
|
+
url_variables=url_variables,
|
|
795
|
+
request=request,
|
|
796
|
+
request_body_required=True,
|
|
797
|
+
request_has_path_params=False,
|
|
798
|
+
request_has_query_params=True,
|
|
799
|
+
user_agent_header="user-agent",
|
|
800
|
+
accept_header_value="application/json",
|
|
801
|
+
http_headers=http_headers,
|
|
802
|
+
security=self.sdk_configuration.security,
|
|
803
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
804
|
+
request, False, False, "json", models.PlaceOrdRequestUnion
|
|
805
|
+
),
|
|
806
|
+
allow_empty_value=None,
|
|
807
|
+
allowed_fields=["client_id"],
|
|
808
|
+
timeout_ms=timeout_ms,
|
|
809
|
+
)
|
|
810
|
+
|
|
811
|
+
if retries == UNSET:
|
|
812
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
813
|
+
retries = self.sdk_configuration.retry_config
|
|
814
|
+
else:
|
|
815
|
+
retries = utils.RetryConfig(
|
|
816
|
+
"backoff", utils.BackoffStrategy(500, 8000, 1.5, 60000), True
|
|
817
|
+
)
|
|
818
|
+
|
|
819
|
+
retry_config = None
|
|
820
|
+
if isinstance(retries, utils.RetryConfig):
|
|
821
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
822
|
+
|
|
823
|
+
http_res = await self.do_request_async(
|
|
824
|
+
hook_ctx=HookContext(
|
|
825
|
+
config=self.sdk_configuration,
|
|
826
|
+
base_url=base_url or "",
|
|
827
|
+
operation_id="previewOrder",
|
|
828
|
+
oauth2_scopes=["order:execution"],
|
|
829
|
+
security_source=self.sdk_configuration.security,
|
|
830
|
+
tags=["Orders"],
|
|
831
|
+
extensions=None,
|
|
832
|
+
),
|
|
833
|
+
request=req,
|
|
834
|
+
is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
|
|
835
|
+
retry_config=retry_config,
|
|
836
|
+
)
|
|
837
|
+
|
|
838
|
+
response_data: Any = None
|
|
839
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
840
|
+
return models.PreviewOrderResponseResponse(
|
|
841
|
+
preview_order_response=unmarshal_json_response(
|
|
842
|
+
Optional[models.PreviewOrderResponse], http_res
|
|
843
|
+
),
|
|
844
|
+
http_meta=models.HTTPMetadata(request=req, response=http_res),
|
|
845
|
+
)
|
|
846
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
847
|
+
response_data = unmarshal_json_response(errors.BadRequestUnion, http_res)
|
|
848
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
849
|
+
request=req, response=http_res
|
|
850
|
+
)
|
|
851
|
+
raise errors.BadRequest(response_data, http_res)
|
|
852
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
853
|
+
response_data = unmarshal_json_response(errors.UnauthorizedUnion, http_res)
|
|
854
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
855
|
+
request=req, response=http_res
|
|
856
|
+
)
|
|
857
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
858
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
859
|
+
response_data = unmarshal_json_response(errors.ForbiddenUnion, http_res)
|
|
860
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
861
|
+
request=req, response=http_res
|
|
862
|
+
)
|
|
863
|
+
raise errors.Forbidden(response_data, http_res)
|
|
864
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
865
|
+
response_data = unmarshal_json_response(errors.NotFoundUnion, http_res)
|
|
866
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
867
|
+
request=req, response=http_res
|
|
868
|
+
)
|
|
869
|
+
raise errors.NotFound(response_data, http_res)
|
|
870
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
871
|
+
response_data = unmarshal_json_response(
|
|
872
|
+
errors.InternalServerErrorUnion, http_res
|
|
873
|
+
)
|
|
874
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
875
|
+
request=req, response=http_res
|
|
876
|
+
)
|
|
877
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
878
|
+
if utils.match_response(http_res, ["503", "504"], "application/json"):
|
|
879
|
+
response_data = unmarshal_json_response(
|
|
880
|
+
errors.AuthenticationErrorEnvelopeData, http_res
|
|
881
|
+
)
|
|
882
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
883
|
+
request=req, response=http_res
|
|
884
|
+
)
|
|
885
|
+
raise errors.AuthenticationErrorEnvelope(response_data, http_res)
|
|
886
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
887
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
888
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
889
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
890
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
891
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
892
|
+
|
|
893
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
894
|
+
|
|
895
|
+
def replace_order(
|
|
896
|
+
self,
|
|
897
|
+
*,
|
|
898
|
+
request: Union[
|
|
899
|
+
models.ReplaceOrdRequestUnion, models.ReplaceOrdRequestUnionTypedDict
|
|
900
|
+
],
|
|
901
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
902
|
+
server_url: Optional[str] = None,
|
|
903
|
+
timeout_ms: Optional[int] = None,
|
|
904
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
905
|
+
) -> models.ReplaceOrderResponse:
|
|
906
|
+
r"""Replace an order
|
|
907
|
+
|
|
908
|
+
Replace/modify an existing order (change quantity, price, or time in force). **ID cycling:** a successful replace returns a new `clOrdId`. Use that new ID as `origClOrdId` for any further replaces of this order — the previous ID is no longer valid once replaced.
|
|
909
|
+
|
|
910
|
+
For single-leg options, you can send the option fields directly, put them inside the single leg, or send an OSI option symbol in `symbol` and let the backend derive the instrument. Multi-leg replaces must pass `legs` explicitly.
|
|
911
|
+
|
|
912
|
+
Price precision validation:
|
|
913
|
+
- `LIMIT` validates `price`
|
|
914
|
+
- `STOP` validates `stopPrice`
|
|
915
|
+
- `STOP_LIMIT` validates both
|
|
916
|
+
- Decimal inputs support up to 5 digits after the decimal point.
|
|
917
|
+
|
|
918
|
+
If set, this operation will use `client_id` from the global security.
|
|
919
|
+
|
|
920
|
+
:param request: The request object to send.
|
|
921
|
+
:param retries: Override the default retry configuration for this method
|
|
922
|
+
:param server_url: Override the default server URL for this method
|
|
923
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
924
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
925
|
+
"""
|
|
926
|
+
base_url = None
|
|
927
|
+
url_variables = None
|
|
928
|
+
if timeout_ms is None:
|
|
929
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
930
|
+
|
|
931
|
+
if timeout_ms is None:
|
|
932
|
+
timeout_ms = 30000
|
|
933
|
+
|
|
934
|
+
if server_url is not None:
|
|
935
|
+
base_url = server_url
|
|
936
|
+
else:
|
|
937
|
+
base_url = self._get_url(base_url, url_variables)
|
|
938
|
+
|
|
939
|
+
if not isinstance(request, BaseModel):
|
|
940
|
+
request = utils.unmarshal(request, models.ReplaceOrdRequestUnion)
|
|
941
|
+
request = cast(models.ReplaceOrdRequestUnion, request)
|
|
942
|
+
|
|
943
|
+
req = self._build_request(
|
|
944
|
+
method="POST",
|
|
945
|
+
path="/v1/orders/replace",
|
|
946
|
+
base_url=base_url,
|
|
947
|
+
url_variables=url_variables,
|
|
948
|
+
request=request,
|
|
949
|
+
request_body_required=True,
|
|
950
|
+
request_has_path_params=False,
|
|
951
|
+
request_has_query_params=True,
|
|
952
|
+
user_agent_header="user-agent",
|
|
953
|
+
accept_header_value="application/json",
|
|
954
|
+
http_headers=http_headers,
|
|
955
|
+
security=self.sdk_configuration.security,
|
|
956
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
957
|
+
request, False, False, "json", models.ReplaceOrdRequestUnion
|
|
958
|
+
),
|
|
959
|
+
allow_empty_value=None,
|
|
960
|
+
allowed_fields=["client_id"],
|
|
961
|
+
timeout_ms=timeout_ms,
|
|
962
|
+
)
|
|
963
|
+
|
|
964
|
+
if retries == UNSET:
|
|
965
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
966
|
+
retries = self.sdk_configuration.retry_config
|
|
967
|
+
|
|
968
|
+
retry_config = None
|
|
969
|
+
if isinstance(retries, utils.RetryConfig):
|
|
970
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
971
|
+
|
|
972
|
+
http_res = self.do_request(
|
|
973
|
+
hook_ctx=HookContext(
|
|
974
|
+
config=self.sdk_configuration,
|
|
975
|
+
base_url=base_url or "",
|
|
976
|
+
operation_id="replaceOrder",
|
|
977
|
+
oauth2_scopes=["order:execution"],
|
|
978
|
+
security_source=self.sdk_configuration.security,
|
|
979
|
+
tags=["Orders"],
|
|
980
|
+
extensions=None,
|
|
981
|
+
),
|
|
982
|
+
request=req,
|
|
983
|
+
is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
|
|
984
|
+
retry_config=retry_config,
|
|
985
|
+
)
|
|
986
|
+
|
|
987
|
+
response_data: Any = None
|
|
988
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
989
|
+
return models.ReplaceOrderResponse(
|
|
990
|
+
replace_ord_response=unmarshal_json_response(
|
|
991
|
+
Optional[models.ReplaceOrdResponse], http_res
|
|
992
|
+
),
|
|
993
|
+
http_meta=models.HTTPMetadata(request=req, response=http_res),
|
|
994
|
+
)
|
|
995
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
996
|
+
response_data = unmarshal_json_response(errors.BadRequestUnion, http_res)
|
|
997
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
998
|
+
request=req, response=http_res
|
|
999
|
+
)
|
|
1000
|
+
raise errors.BadRequest(response_data, http_res)
|
|
1001
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
1002
|
+
response_data = unmarshal_json_response(errors.UnauthorizedUnion, http_res)
|
|
1003
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1004
|
+
request=req, response=http_res
|
|
1005
|
+
)
|
|
1006
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
1007
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
1008
|
+
response_data = unmarshal_json_response(errors.ForbiddenUnion, http_res)
|
|
1009
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1010
|
+
request=req, response=http_res
|
|
1011
|
+
)
|
|
1012
|
+
raise errors.Forbidden(response_data, http_res)
|
|
1013
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
1014
|
+
response_data = unmarshal_json_response(errors.NotFoundUnion, http_res)
|
|
1015
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1016
|
+
request=req, response=http_res
|
|
1017
|
+
)
|
|
1018
|
+
raise errors.NotFound(response_data, http_res)
|
|
1019
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
1020
|
+
response_data = unmarshal_json_response(
|
|
1021
|
+
errors.InternalServerErrorUnion, http_res
|
|
1022
|
+
)
|
|
1023
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1024
|
+
request=req, response=http_res
|
|
1025
|
+
)
|
|
1026
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
1027
|
+
if utils.match_response(http_res, ["503", "504"], "application/json"):
|
|
1028
|
+
response_data = unmarshal_json_response(
|
|
1029
|
+
errors.AuthenticationErrorEnvelopeData, http_res
|
|
1030
|
+
)
|
|
1031
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1032
|
+
request=req, response=http_res
|
|
1033
|
+
)
|
|
1034
|
+
raise errors.AuthenticationErrorEnvelope(response_data, http_res)
|
|
1035
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1036
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1037
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1038
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1039
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1040
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1041
|
+
|
|
1042
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
1043
|
+
|
|
1044
|
+
async def replace_order_async(
|
|
1045
|
+
self,
|
|
1046
|
+
*,
|
|
1047
|
+
request: Union[
|
|
1048
|
+
models.ReplaceOrdRequestUnion, models.ReplaceOrdRequestUnionTypedDict
|
|
1049
|
+
],
|
|
1050
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1051
|
+
server_url: Optional[str] = None,
|
|
1052
|
+
timeout_ms: Optional[int] = None,
|
|
1053
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1054
|
+
) -> models.ReplaceOrderResponse:
|
|
1055
|
+
r"""Replace an order
|
|
1056
|
+
|
|
1057
|
+
Replace/modify an existing order (change quantity, price, or time in force). **ID cycling:** a successful replace returns a new `clOrdId`. Use that new ID as `origClOrdId` for any further replaces of this order — the previous ID is no longer valid once replaced.
|
|
1058
|
+
|
|
1059
|
+
For single-leg options, you can send the option fields directly, put them inside the single leg, or send an OSI option symbol in `symbol` and let the backend derive the instrument. Multi-leg replaces must pass `legs` explicitly.
|
|
1060
|
+
|
|
1061
|
+
Price precision validation:
|
|
1062
|
+
- `LIMIT` validates `price`
|
|
1063
|
+
- `STOP` validates `stopPrice`
|
|
1064
|
+
- `STOP_LIMIT` validates both
|
|
1065
|
+
- Decimal inputs support up to 5 digits after the decimal point.
|
|
1066
|
+
|
|
1067
|
+
If set, this operation will use `client_id` from the global security.
|
|
1068
|
+
|
|
1069
|
+
:param request: The request object to send.
|
|
1070
|
+
:param retries: Override the default retry configuration for this method
|
|
1071
|
+
:param server_url: Override the default server URL for this method
|
|
1072
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1073
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1074
|
+
"""
|
|
1075
|
+
base_url = None
|
|
1076
|
+
url_variables = None
|
|
1077
|
+
if timeout_ms is None:
|
|
1078
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1079
|
+
|
|
1080
|
+
if timeout_ms is None:
|
|
1081
|
+
timeout_ms = 30000
|
|
1082
|
+
|
|
1083
|
+
if server_url is not None:
|
|
1084
|
+
base_url = server_url
|
|
1085
|
+
else:
|
|
1086
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1087
|
+
|
|
1088
|
+
if not isinstance(request, BaseModel):
|
|
1089
|
+
request = utils.unmarshal(request, models.ReplaceOrdRequestUnion)
|
|
1090
|
+
request = cast(models.ReplaceOrdRequestUnion, request)
|
|
1091
|
+
|
|
1092
|
+
req = self._build_request_async(
|
|
1093
|
+
method="POST",
|
|
1094
|
+
path="/v1/orders/replace",
|
|
1095
|
+
base_url=base_url,
|
|
1096
|
+
url_variables=url_variables,
|
|
1097
|
+
request=request,
|
|
1098
|
+
request_body_required=True,
|
|
1099
|
+
request_has_path_params=False,
|
|
1100
|
+
request_has_query_params=True,
|
|
1101
|
+
user_agent_header="user-agent",
|
|
1102
|
+
accept_header_value="application/json",
|
|
1103
|
+
http_headers=http_headers,
|
|
1104
|
+
security=self.sdk_configuration.security,
|
|
1105
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1106
|
+
request, False, False, "json", models.ReplaceOrdRequestUnion
|
|
1107
|
+
),
|
|
1108
|
+
allow_empty_value=None,
|
|
1109
|
+
allowed_fields=["client_id"],
|
|
1110
|
+
timeout_ms=timeout_ms,
|
|
1111
|
+
)
|
|
1112
|
+
|
|
1113
|
+
if retries == UNSET:
|
|
1114
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1115
|
+
retries = self.sdk_configuration.retry_config
|
|
1116
|
+
|
|
1117
|
+
retry_config = None
|
|
1118
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1119
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1120
|
+
|
|
1121
|
+
http_res = await self.do_request_async(
|
|
1122
|
+
hook_ctx=HookContext(
|
|
1123
|
+
config=self.sdk_configuration,
|
|
1124
|
+
base_url=base_url or "",
|
|
1125
|
+
operation_id="replaceOrder",
|
|
1126
|
+
oauth2_scopes=["order:execution"],
|
|
1127
|
+
security_source=self.sdk_configuration.security,
|
|
1128
|
+
tags=["Orders"],
|
|
1129
|
+
extensions=None,
|
|
1130
|
+
),
|
|
1131
|
+
request=req,
|
|
1132
|
+
is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
|
|
1133
|
+
retry_config=retry_config,
|
|
1134
|
+
)
|
|
1135
|
+
|
|
1136
|
+
response_data: Any = None
|
|
1137
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1138
|
+
return models.ReplaceOrderResponse(
|
|
1139
|
+
replace_ord_response=unmarshal_json_response(
|
|
1140
|
+
Optional[models.ReplaceOrdResponse], http_res
|
|
1141
|
+
),
|
|
1142
|
+
http_meta=models.HTTPMetadata(request=req, response=http_res),
|
|
1143
|
+
)
|
|
1144
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
1145
|
+
response_data = unmarshal_json_response(errors.BadRequestUnion, http_res)
|
|
1146
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1147
|
+
request=req, response=http_res
|
|
1148
|
+
)
|
|
1149
|
+
raise errors.BadRequest(response_data, http_res)
|
|
1150
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
1151
|
+
response_data = unmarshal_json_response(errors.UnauthorizedUnion, http_res)
|
|
1152
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1153
|
+
request=req, response=http_res
|
|
1154
|
+
)
|
|
1155
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
1156
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
1157
|
+
response_data = unmarshal_json_response(errors.ForbiddenUnion, http_res)
|
|
1158
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1159
|
+
request=req, response=http_res
|
|
1160
|
+
)
|
|
1161
|
+
raise errors.Forbidden(response_data, http_res)
|
|
1162
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
1163
|
+
response_data = unmarshal_json_response(errors.NotFoundUnion, http_res)
|
|
1164
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1165
|
+
request=req, response=http_res
|
|
1166
|
+
)
|
|
1167
|
+
raise errors.NotFound(response_data, http_res)
|
|
1168
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
1169
|
+
response_data = unmarshal_json_response(
|
|
1170
|
+
errors.InternalServerErrorUnion, http_res
|
|
1171
|
+
)
|
|
1172
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1173
|
+
request=req, response=http_res
|
|
1174
|
+
)
|
|
1175
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
1176
|
+
if utils.match_response(http_res, ["503", "504"], "application/json"):
|
|
1177
|
+
response_data = unmarshal_json_response(
|
|
1178
|
+
errors.AuthenticationErrorEnvelopeData, http_res
|
|
1179
|
+
)
|
|
1180
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1181
|
+
request=req, response=http_res
|
|
1182
|
+
)
|
|
1183
|
+
raise errors.AuthenticationErrorEnvelope(response_data, http_res)
|
|
1184
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1185
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1186
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1187
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1188
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1189
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1190
|
+
|
|
1191
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
1192
|
+
|
|
1193
|
+
def list_active_orders(
|
|
1194
|
+
self,
|
|
1195
|
+
*,
|
|
1196
|
+
id: str,
|
|
1197
|
+
limit: Optional[int] = 50,
|
|
1198
|
+
cursor: Optional[int] = 0,
|
|
1199
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1200
|
+
server_url: Optional[str] = None,
|
|
1201
|
+
timeout_ms: Optional[int] = None,
|
|
1202
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1203
|
+
) -> Optional[models.ListActiveOrdersResponse]:
|
|
1204
|
+
r"""List active orders (v2)
|
|
1205
|
+
|
|
1206
|
+
Returns active orders (open orders plus today's terminal activity) from the orders v2 cache only. There is no database fallback.
|
|
1207
|
+
|
|
1208
|
+
Pagination uses an opaque int64 cursor: omit cursor or send 0 for the first page, then send nextCursor; 0 means exhausted. Each order uses the same domain shape as WebSocket account updates.
|
|
1209
|
+
|
|
1210
|
+
If set, this operation will use `client_id` from the global security.
|
|
1211
|
+
|
|
1212
|
+
:param id: Account ID whose active orders you want to read. Use the account identifier from the user's account list or trading setup.
|
|
1213
|
+
:param limit: Maximum number of orders to return in this page. Use smaller values for UI lists and larger values for back-office exports. Default is 50; maximum is 500.
|
|
1214
|
+
:param cursor: Opaque pagination cursor. Send `0` (or omit) for the first page; pass the previous response's `nextCursor` for subsequent pages. Stop when `nextCursor` is `0`.
|
|
1215
|
+
:param retries: Override the default retry configuration for this method
|
|
1216
|
+
:param server_url: Override the default server URL for this method
|
|
1217
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1218
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1219
|
+
"""
|
|
1220
|
+
base_url = None
|
|
1221
|
+
url_variables = None
|
|
1222
|
+
if timeout_ms is None:
|
|
1223
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1224
|
+
|
|
1225
|
+
if timeout_ms is None:
|
|
1226
|
+
timeout_ms = 30000
|
|
1227
|
+
|
|
1228
|
+
if server_url is not None:
|
|
1229
|
+
base_url = server_url
|
|
1230
|
+
else:
|
|
1231
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1232
|
+
|
|
1233
|
+
request = models.ListActiveOrdersRequest(
|
|
1234
|
+
id=id,
|
|
1235
|
+
limit=limit,
|
|
1236
|
+
cursor=cursor,
|
|
1237
|
+
)
|
|
1238
|
+
|
|
1239
|
+
req = self._build_request(
|
|
1240
|
+
method="GET",
|
|
1241
|
+
path="/v2/accounts/{id}/orders",
|
|
1242
|
+
base_url=base_url,
|
|
1243
|
+
url_variables=url_variables,
|
|
1244
|
+
request=request,
|
|
1245
|
+
request_body_required=False,
|
|
1246
|
+
request_has_path_params=True,
|
|
1247
|
+
request_has_query_params=True,
|
|
1248
|
+
user_agent_header="user-agent",
|
|
1249
|
+
accept_header_value="application/json",
|
|
1250
|
+
http_headers=http_headers,
|
|
1251
|
+
security=self.sdk_configuration.security,
|
|
1252
|
+
allow_empty_value=None,
|
|
1253
|
+
allowed_fields=["client_id"],
|
|
1254
|
+
timeout_ms=timeout_ms,
|
|
1255
|
+
)
|
|
1256
|
+
|
|
1257
|
+
if retries == UNSET:
|
|
1258
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1259
|
+
retries = self.sdk_configuration.retry_config
|
|
1260
|
+
else:
|
|
1261
|
+
retries = utils.RetryConfig(
|
|
1262
|
+
"backoff", utils.BackoffStrategy(500, 8000, 1.5, 60000), True
|
|
1263
|
+
)
|
|
1264
|
+
|
|
1265
|
+
retry_config = None
|
|
1266
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1267
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1268
|
+
|
|
1269
|
+
http_res = self.do_request(
|
|
1270
|
+
hook_ctx=HookContext(
|
|
1271
|
+
config=self.sdk_configuration,
|
|
1272
|
+
base_url=base_url or "",
|
|
1273
|
+
operation_id="listActiveOrders",
|
|
1274
|
+
oauth2_scopes=["order:information"],
|
|
1275
|
+
security_source=self.sdk_configuration.security,
|
|
1276
|
+
tags=["Orders"],
|
|
1277
|
+
extensions=None,
|
|
1278
|
+
),
|
|
1279
|
+
request=req,
|
|
1280
|
+
is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
|
|
1281
|
+
retry_config=retry_config,
|
|
1282
|
+
)
|
|
1283
|
+
|
|
1284
|
+
def next_func() -> Optional[models.ListActiveOrdersResponse]:
|
|
1285
|
+
body = utils.unmarshal_json(http_res.text, Union[Dict[Any, Any], List[Any]])
|
|
1286
|
+
next_cursor = JSONPath("$.nextCursor").parse(body)
|
|
1287
|
+
|
|
1288
|
+
if len(next_cursor) == 0:
|
|
1289
|
+
return None
|
|
1290
|
+
|
|
1291
|
+
next_cursor = next_cursor[0]
|
|
1292
|
+
if next_cursor is None or str(next_cursor).strip() == "":
|
|
1293
|
+
return None
|
|
1294
|
+
results = JSONPath("$.orders").parse(body)
|
|
1295
|
+
if len(results) == 0 or len(results[0]) == 0:
|
|
1296
|
+
return None
|
|
1297
|
+
limit_ = request.limit if isinstance(request.limit, int) else 50
|
|
1298
|
+
if len(results[0]) < limit_:
|
|
1299
|
+
return None
|
|
1300
|
+
|
|
1301
|
+
return self.list_active_orders(
|
|
1302
|
+
id=id,
|
|
1303
|
+
limit=limit,
|
|
1304
|
+
cursor=next_cursor,
|
|
1305
|
+
retries=retries,
|
|
1306
|
+
server_url=server_url,
|
|
1307
|
+
timeout_ms=timeout_ms,
|
|
1308
|
+
http_headers=http_headers,
|
|
1309
|
+
)
|
|
1310
|
+
|
|
1311
|
+
response_data: Any = None
|
|
1312
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1313
|
+
return models.ListActiveOrdersResponse(
|
|
1314
|
+
get_orders_v2_response=unmarshal_json_response(
|
|
1315
|
+
Optional[models.GetOrdersV2Response], http_res
|
|
1316
|
+
),
|
|
1317
|
+
http_meta=models.HTTPMetadata(request=req, response=http_res),
|
|
1318
|
+
next=next_func,
|
|
1319
|
+
)
|
|
1320
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
1321
|
+
response_data = unmarshal_json_response(errors.BadRequestUnion, http_res)
|
|
1322
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1323
|
+
request=req, response=http_res
|
|
1324
|
+
)
|
|
1325
|
+
raise errors.BadRequest(response_data, http_res)
|
|
1326
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
1327
|
+
response_data = unmarshal_json_response(errors.UnauthorizedUnion, http_res)
|
|
1328
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1329
|
+
request=req, response=http_res
|
|
1330
|
+
)
|
|
1331
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
1332
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
1333
|
+
response_data = unmarshal_json_response(errors.ForbiddenUnion, http_res)
|
|
1334
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1335
|
+
request=req, response=http_res
|
|
1336
|
+
)
|
|
1337
|
+
raise errors.Forbidden(response_data, http_res)
|
|
1338
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
1339
|
+
response_data = unmarshal_json_response(errors.NotFoundUnion, http_res)
|
|
1340
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1341
|
+
request=req, response=http_res
|
|
1342
|
+
)
|
|
1343
|
+
raise errors.NotFound(response_data, http_res)
|
|
1344
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
1345
|
+
response_data = unmarshal_json_response(
|
|
1346
|
+
errors.InternalServerErrorUnion, http_res
|
|
1347
|
+
)
|
|
1348
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1349
|
+
request=req, response=http_res
|
|
1350
|
+
)
|
|
1351
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
1352
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1353
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1354
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1355
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1356
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1357
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1358
|
+
|
|
1359
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
1360
|
+
|
|
1361
|
+
async def list_active_orders_async(
|
|
1362
|
+
self,
|
|
1363
|
+
*,
|
|
1364
|
+
id: str,
|
|
1365
|
+
limit: Optional[int] = 50,
|
|
1366
|
+
cursor: Optional[int] = 0,
|
|
1367
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1368
|
+
server_url: Optional[str] = None,
|
|
1369
|
+
timeout_ms: Optional[int] = None,
|
|
1370
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1371
|
+
) -> Optional[models.ListActiveOrdersResponse]:
|
|
1372
|
+
r"""List active orders (v2)
|
|
1373
|
+
|
|
1374
|
+
Returns active orders (open orders plus today's terminal activity) from the orders v2 cache only. There is no database fallback.
|
|
1375
|
+
|
|
1376
|
+
Pagination uses an opaque int64 cursor: omit cursor or send 0 for the first page, then send nextCursor; 0 means exhausted. Each order uses the same domain shape as WebSocket account updates.
|
|
1377
|
+
|
|
1378
|
+
If set, this operation will use `client_id` from the global security.
|
|
1379
|
+
|
|
1380
|
+
:param id: Account ID whose active orders you want to read. Use the account identifier from the user's account list or trading setup.
|
|
1381
|
+
:param limit: Maximum number of orders to return in this page. Use smaller values for UI lists and larger values for back-office exports. Default is 50; maximum is 500.
|
|
1382
|
+
:param cursor: Opaque pagination cursor. Send `0` (or omit) for the first page; pass the previous response's `nextCursor` for subsequent pages. Stop when `nextCursor` is `0`.
|
|
1383
|
+
:param retries: Override the default retry configuration for this method
|
|
1384
|
+
:param server_url: Override the default server URL for this method
|
|
1385
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1386
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1387
|
+
"""
|
|
1388
|
+
base_url = None
|
|
1389
|
+
url_variables = None
|
|
1390
|
+
if timeout_ms is None:
|
|
1391
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1392
|
+
|
|
1393
|
+
if timeout_ms is None:
|
|
1394
|
+
timeout_ms = 30000
|
|
1395
|
+
|
|
1396
|
+
if server_url is not None:
|
|
1397
|
+
base_url = server_url
|
|
1398
|
+
else:
|
|
1399
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1400
|
+
|
|
1401
|
+
request = models.ListActiveOrdersRequest(
|
|
1402
|
+
id=id,
|
|
1403
|
+
limit=limit,
|
|
1404
|
+
cursor=cursor,
|
|
1405
|
+
)
|
|
1406
|
+
|
|
1407
|
+
req = self._build_request_async(
|
|
1408
|
+
method="GET",
|
|
1409
|
+
path="/v2/accounts/{id}/orders",
|
|
1410
|
+
base_url=base_url,
|
|
1411
|
+
url_variables=url_variables,
|
|
1412
|
+
request=request,
|
|
1413
|
+
request_body_required=False,
|
|
1414
|
+
request_has_path_params=True,
|
|
1415
|
+
request_has_query_params=True,
|
|
1416
|
+
user_agent_header="user-agent",
|
|
1417
|
+
accept_header_value="application/json",
|
|
1418
|
+
http_headers=http_headers,
|
|
1419
|
+
security=self.sdk_configuration.security,
|
|
1420
|
+
allow_empty_value=None,
|
|
1421
|
+
allowed_fields=["client_id"],
|
|
1422
|
+
timeout_ms=timeout_ms,
|
|
1423
|
+
)
|
|
1424
|
+
|
|
1425
|
+
if retries == UNSET:
|
|
1426
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1427
|
+
retries = self.sdk_configuration.retry_config
|
|
1428
|
+
else:
|
|
1429
|
+
retries = utils.RetryConfig(
|
|
1430
|
+
"backoff", utils.BackoffStrategy(500, 8000, 1.5, 60000), True
|
|
1431
|
+
)
|
|
1432
|
+
|
|
1433
|
+
retry_config = None
|
|
1434
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1435
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1436
|
+
|
|
1437
|
+
http_res = await self.do_request_async(
|
|
1438
|
+
hook_ctx=HookContext(
|
|
1439
|
+
config=self.sdk_configuration,
|
|
1440
|
+
base_url=base_url or "",
|
|
1441
|
+
operation_id="listActiveOrders",
|
|
1442
|
+
oauth2_scopes=["order:information"],
|
|
1443
|
+
security_source=self.sdk_configuration.security,
|
|
1444
|
+
tags=["Orders"],
|
|
1445
|
+
extensions=None,
|
|
1446
|
+
),
|
|
1447
|
+
request=req,
|
|
1448
|
+
is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
|
|
1449
|
+
retry_config=retry_config,
|
|
1450
|
+
)
|
|
1451
|
+
|
|
1452
|
+
def next_func() -> Optional[models.ListActiveOrdersResponse]:
|
|
1453
|
+
body = utils.unmarshal_json(http_res.text, Union[Dict[Any, Any], List[Any]])
|
|
1454
|
+
next_cursor = JSONPath("$.nextCursor").parse(body)
|
|
1455
|
+
|
|
1456
|
+
if len(next_cursor) == 0:
|
|
1457
|
+
return None
|
|
1458
|
+
|
|
1459
|
+
next_cursor = next_cursor[0]
|
|
1460
|
+
if next_cursor is None or str(next_cursor).strip() == "":
|
|
1461
|
+
return None
|
|
1462
|
+
results = JSONPath("$.orders").parse(body)
|
|
1463
|
+
if len(results) == 0 or len(results[0]) == 0:
|
|
1464
|
+
return None
|
|
1465
|
+
limit_ = request.limit if isinstance(request.limit, int) else 50
|
|
1466
|
+
if len(results[0]) < limit_:
|
|
1467
|
+
return None
|
|
1468
|
+
|
|
1469
|
+
return self.list_active_orders(
|
|
1470
|
+
id=id,
|
|
1471
|
+
limit=limit,
|
|
1472
|
+
cursor=next_cursor,
|
|
1473
|
+
retries=retries,
|
|
1474
|
+
server_url=server_url,
|
|
1475
|
+
timeout_ms=timeout_ms,
|
|
1476
|
+
http_headers=http_headers,
|
|
1477
|
+
)
|
|
1478
|
+
|
|
1479
|
+
response_data: Any = None
|
|
1480
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1481
|
+
return models.ListActiveOrdersResponse(
|
|
1482
|
+
get_orders_v2_response=unmarshal_json_response(
|
|
1483
|
+
Optional[models.GetOrdersV2Response], http_res
|
|
1484
|
+
),
|
|
1485
|
+
http_meta=models.HTTPMetadata(request=req, response=http_res),
|
|
1486
|
+
next=next_func,
|
|
1487
|
+
)
|
|
1488
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
1489
|
+
response_data = unmarshal_json_response(errors.BadRequestUnion, http_res)
|
|
1490
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1491
|
+
request=req, response=http_res
|
|
1492
|
+
)
|
|
1493
|
+
raise errors.BadRequest(response_data, http_res)
|
|
1494
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
1495
|
+
response_data = unmarshal_json_response(errors.UnauthorizedUnion, http_res)
|
|
1496
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1497
|
+
request=req, response=http_res
|
|
1498
|
+
)
|
|
1499
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
1500
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
1501
|
+
response_data = unmarshal_json_response(errors.ForbiddenUnion, http_res)
|
|
1502
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1503
|
+
request=req, response=http_res
|
|
1504
|
+
)
|
|
1505
|
+
raise errors.Forbidden(response_data, http_res)
|
|
1506
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
1507
|
+
response_data = unmarshal_json_response(errors.NotFoundUnion, http_res)
|
|
1508
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1509
|
+
request=req, response=http_res
|
|
1510
|
+
)
|
|
1511
|
+
raise errors.NotFound(response_data, http_res)
|
|
1512
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
1513
|
+
response_data = unmarshal_json_response(
|
|
1514
|
+
errors.InternalServerErrorUnion, http_res
|
|
1515
|
+
)
|
|
1516
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1517
|
+
request=req, response=http_res
|
|
1518
|
+
)
|
|
1519
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
1520
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1521
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1522
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1523
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1524
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1525
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1526
|
+
|
|
1527
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
1528
|
+
|
|
1529
|
+
def list_order_history(
|
|
1530
|
+
self,
|
|
1531
|
+
*,
|
|
1532
|
+
id: str,
|
|
1533
|
+
from_: datetime,
|
|
1534
|
+
to: Optional[datetime] = None,
|
|
1535
|
+
order_by: Optional[models.OrderBy] = models.OrderBy.DESC,
|
|
1536
|
+
exclude_today: Optional[bool] = False,
|
|
1537
|
+
limit: Optional[int] = 50,
|
|
1538
|
+
cursor: Optional[int] = 0,
|
|
1539
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1540
|
+
server_url: Optional[str] = None,
|
|
1541
|
+
timeout_ms: Optional[int] = None,
|
|
1542
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1543
|
+
) -> Optional[models.ListOrderHistoryResponse]:
|
|
1544
|
+
r"""List order history (v2)
|
|
1545
|
+
|
|
1546
|
+
Date-range query against **PostgreSQL** only (no `source` parameter). `from` is required; `to` defaults to the current time truncated to the minute (UTC). The server caps the window at **90 days**.
|
|
1547
|
+
|
|
1548
|
+
Results are ordered and filtered by `order_created_at` (keyset pagination uses the row `id` for correctness). Rows with `SUPERSEDED` status and rows with `failed_flag = true` are excluded.
|
|
1549
|
+
|
|
1550
|
+
Set `exclude_today=true` to narrow `to` to just before midnight **America/New_York**, omitting today's activity (already returned by **GET /v2/accounts/{id}/orders**).
|
|
1551
|
+
|
|
1552
|
+
**Pagination:** Same opaque `int64` cursor contract as active orders when reading from DB — `cursor=0` first, then `nextCursor`; `0` means exhausted.
|
|
1553
|
+
|
|
1554
|
+
If set, this operation will use `client_id` from the global security.
|
|
1555
|
+
|
|
1556
|
+
:param id: Account ID whose historical orders you want to read.
|
|
1557
|
+
:param from_: Start of the history window, inclusive. Enter an RFC 3339 timestamp with timezone, for example `2026-04-01T00:00:00Z`.
|
|
1558
|
+
:param to: End of the history window, inclusive. Omit it to use the current time. The total range from `from` cannot exceed 90 days.
|
|
1559
|
+
:param order_by: Sort direction by `order_created_at`. Defaults to `desc` (newest first). Use `asc` for chronological exports.
|
|
1560
|
+
:param exclude_today: Set to `true` when you want historical orders only and do not want today's activity duplicated with the active-orders endpoint.
|
|
1561
|
+
:param limit: Maximum number of historical orders to return in this page. Default is 50; maximum is 500.
|
|
1562
|
+
:param cursor: Opaque pagination cursor for the database history walk. Send `0` (or omit) for the first page; pass the previous `nextCursor` until it returns `0`.
|
|
1563
|
+
:param retries: Override the default retry configuration for this method
|
|
1564
|
+
:param server_url: Override the default server URL for this method
|
|
1565
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1566
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1567
|
+
"""
|
|
1568
|
+
base_url = None
|
|
1569
|
+
url_variables = None
|
|
1570
|
+
if timeout_ms is None:
|
|
1571
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1572
|
+
|
|
1573
|
+
if timeout_ms is None:
|
|
1574
|
+
timeout_ms = 30000
|
|
1575
|
+
|
|
1576
|
+
if server_url is not None:
|
|
1577
|
+
base_url = server_url
|
|
1578
|
+
else:
|
|
1579
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1580
|
+
|
|
1581
|
+
request = models.ListOrderHistoryRequest(
|
|
1582
|
+
id=id,
|
|
1583
|
+
from_=from_,
|
|
1584
|
+
to=to,
|
|
1585
|
+
order_by=order_by,
|
|
1586
|
+
exclude_today=exclude_today,
|
|
1587
|
+
limit=limit,
|
|
1588
|
+
cursor=cursor,
|
|
1589
|
+
)
|
|
1590
|
+
|
|
1591
|
+
req = self._build_request(
|
|
1592
|
+
method="GET",
|
|
1593
|
+
path="/v2/accounts/{id}/orders/history",
|
|
1594
|
+
base_url=base_url,
|
|
1595
|
+
url_variables=url_variables,
|
|
1596
|
+
request=request,
|
|
1597
|
+
request_body_required=False,
|
|
1598
|
+
request_has_path_params=True,
|
|
1599
|
+
request_has_query_params=True,
|
|
1600
|
+
user_agent_header="user-agent",
|
|
1601
|
+
accept_header_value="application/json",
|
|
1602
|
+
http_headers=http_headers,
|
|
1603
|
+
security=self.sdk_configuration.security,
|
|
1604
|
+
allow_empty_value=None,
|
|
1605
|
+
allowed_fields=["client_id"],
|
|
1606
|
+
timeout_ms=timeout_ms,
|
|
1607
|
+
)
|
|
1608
|
+
|
|
1609
|
+
if retries == UNSET:
|
|
1610
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1611
|
+
retries = self.sdk_configuration.retry_config
|
|
1612
|
+
else:
|
|
1613
|
+
retries = utils.RetryConfig(
|
|
1614
|
+
"backoff", utils.BackoffStrategy(500, 8000, 1.5, 60000), True
|
|
1615
|
+
)
|
|
1616
|
+
|
|
1617
|
+
retry_config = None
|
|
1618
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1619
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1620
|
+
|
|
1621
|
+
http_res = self.do_request(
|
|
1622
|
+
hook_ctx=HookContext(
|
|
1623
|
+
config=self.sdk_configuration,
|
|
1624
|
+
base_url=base_url or "",
|
|
1625
|
+
operation_id="listOrderHistory",
|
|
1626
|
+
oauth2_scopes=["order:information"],
|
|
1627
|
+
security_source=self.sdk_configuration.security,
|
|
1628
|
+
tags=["Orders"],
|
|
1629
|
+
extensions=None,
|
|
1630
|
+
),
|
|
1631
|
+
request=req,
|
|
1632
|
+
is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
|
|
1633
|
+
retry_config=retry_config,
|
|
1634
|
+
)
|
|
1635
|
+
|
|
1636
|
+
def next_func() -> Optional[models.ListOrderHistoryResponse]:
|
|
1637
|
+
body = utils.unmarshal_json(http_res.text, Union[Dict[Any, Any], List[Any]])
|
|
1638
|
+
next_cursor = JSONPath("$.nextCursor").parse(body)
|
|
1639
|
+
|
|
1640
|
+
if len(next_cursor) == 0:
|
|
1641
|
+
return None
|
|
1642
|
+
|
|
1643
|
+
next_cursor = next_cursor[0]
|
|
1644
|
+
if next_cursor is None or str(next_cursor).strip() == "":
|
|
1645
|
+
return None
|
|
1646
|
+
results = JSONPath("$.orders").parse(body)
|
|
1647
|
+
if len(results) == 0 or len(results[0]) == 0:
|
|
1648
|
+
return None
|
|
1649
|
+
limit_ = request.limit if isinstance(request.limit, int) else 50
|
|
1650
|
+
if len(results[0]) < limit_:
|
|
1651
|
+
return None
|
|
1652
|
+
|
|
1653
|
+
return self.list_order_history(
|
|
1654
|
+
id=id,
|
|
1655
|
+
from_=from_,
|
|
1656
|
+
to=to,
|
|
1657
|
+
order_by=order_by,
|
|
1658
|
+
exclude_today=exclude_today,
|
|
1659
|
+
limit=limit,
|
|
1660
|
+
cursor=next_cursor,
|
|
1661
|
+
retries=retries,
|
|
1662
|
+
server_url=server_url,
|
|
1663
|
+
timeout_ms=timeout_ms,
|
|
1664
|
+
http_headers=http_headers,
|
|
1665
|
+
)
|
|
1666
|
+
|
|
1667
|
+
response_data: Any = None
|
|
1668
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1669
|
+
return models.ListOrderHistoryResponse(
|
|
1670
|
+
get_orders_v2_response=unmarshal_json_response(
|
|
1671
|
+
Optional[models.GetOrdersV2Response], http_res
|
|
1672
|
+
),
|
|
1673
|
+
http_meta=models.HTTPMetadata(request=req, response=http_res),
|
|
1674
|
+
next=next_func,
|
|
1675
|
+
)
|
|
1676
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
1677
|
+
response_data = unmarshal_json_response(
|
|
1678
|
+
errors.OrderHistoryBadRequestUnion, http_res
|
|
1679
|
+
)
|
|
1680
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1681
|
+
request=req, response=http_res
|
|
1682
|
+
)
|
|
1683
|
+
raise errors.OrderHistoryBadRequest(response_data, http_res)
|
|
1684
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
1685
|
+
response_data = unmarshal_json_response(errors.UnauthorizedUnion, http_res)
|
|
1686
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1687
|
+
request=req, response=http_res
|
|
1688
|
+
)
|
|
1689
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
1690
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
1691
|
+
response_data = unmarshal_json_response(errors.ForbiddenUnion, http_res)
|
|
1692
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1693
|
+
request=req, response=http_res
|
|
1694
|
+
)
|
|
1695
|
+
raise errors.Forbidden(response_data, http_res)
|
|
1696
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
1697
|
+
response_data = unmarshal_json_response(errors.NotFoundUnion, http_res)
|
|
1698
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1699
|
+
request=req, response=http_res
|
|
1700
|
+
)
|
|
1701
|
+
raise errors.NotFound(response_data, http_res)
|
|
1702
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
1703
|
+
response_data = unmarshal_json_response(
|
|
1704
|
+
errors.InternalServerErrorUnion, http_res
|
|
1705
|
+
)
|
|
1706
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1707
|
+
request=req, response=http_res
|
|
1708
|
+
)
|
|
1709
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
1710
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1711
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1712
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1713
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1714
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1715
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1716
|
+
|
|
1717
|
+
raise errors.APIError("Unexpected response received", http_res)
|
|
1718
|
+
|
|
1719
|
+
async def list_order_history_async(
|
|
1720
|
+
self,
|
|
1721
|
+
*,
|
|
1722
|
+
id: str,
|
|
1723
|
+
from_: datetime,
|
|
1724
|
+
to: Optional[datetime] = None,
|
|
1725
|
+
order_by: Optional[models.OrderBy] = models.OrderBy.DESC,
|
|
1726
|
+
exclude_today: Optional[bool] = False,
|
|
1727
|
+
limit: Optional[int] = 50,
|
|
1728
|
+
cursor: Optional[int] = 0,
|
|
1729
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1730
|
+
server_url: Optional[str] = None,
|
|
1731
|
+
timeout_ms: Optional[int] = None,
|
|
1732
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1733
|
+
) -> Optional[models.ListOrderHistoryResponse]:
|
|
1734
|
+
r"""List order history (v2)
|
|
1735
|
+
|
|
1736
|
+
Date-range query against **PostgreSQL** only (no `source` parameter). `from` is required; `to` defaults to the current time truncated to the minute (UTC). The server caps the window at **90 days**.
|
|
1737
|
+
|
|
1738
|
+
Results are ordered and filtered by `order_created_at` (keyset pagination uses the row `id` for correctness). Rows with `SUPERSEDED` status and rows with `failed_flag = true` are excluded.
|
|
1739
|
+
|
|
1740
|
+
Set `exclude_today=true` to narrow `to` to just before midnight **America/New_York**, omitting today's activity (already returned by **GET /v2/accounts/{id}/orders**).
|
|
1741
|
+
|
|
1742
|
+
**Pagination:** Same opaque `int64` cursor contract as active orders when reading from DB — `cursor=0` first, then `nextCursor`; `0` means exhausted.
|
|
1743
|
+
|
|
1744
|
+
If set, this operation will use `client_id` from the global security.
|
|
1745
|
+
|
|
1746
|
+
:param id: Account ID whose historical orders you want to read.
|
|
1747
|
+
:param from_: Start of the history window, inclusive. Enter an RFC 3339 timestamp with timezone, for example `2026-04-01T00:00:00Z`.
|
|
1748
|
+
:param to: End of the history window, inclusive. Omit it to use the current time. The total range from `from` cannot exceed 90 days.
|
|
1749
|
+
:param order_by: Sort direction by `order_created_at`. Defaults to `desc` (newest first). Use `asc` for chronological exports.
|
|
1750
|
+
:param exclude_today: Set to `true` when you want historical orders only and do not want today's activity duplicated with the active-orders endpoint.
|
|
1751
|
+
:param limit: Maximum number of historical orders to return in this page. Default is 50; maximum is 500.
|
|
1752
|
+
:param cursor: Opaque pagination cursor for the database history walk. Send `0` (or omit) for the first page; pass the previous `nextCursor` until it returns `0`.
|
|
1753
|
+
:param retries: Override the default retry configuration for this method
|
|
1754
|
+
:param server_url: Override the default server URL for this method
|
|
1755
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1756
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1757
|
+
"""
|
|
1758
|
+
base_url = None
|
|
1759
|
+
url_variables = None
|
|
1760
|
+
if timeout_ms is None:
|
|
1761
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1762
|
+
|
|
1763
|
+
if timeout_ms is None:
|
|
1764
|
+
timeout_ms = 30000
|
|
1765
|
+
|
|
1766
|
+
if server_url is not None:
|
|
1767
|
+
base_url = server_url
|
|
1768
|
+
else:
|
|
1769
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1770
|
+
|
|
1771
|
+
request = models.ListOrderHistoryRequest(
|
|
1772
|
+
id=id,
|
|
1773
|
+
from_=from_,
|
|
1774
|
+
to=to,
|
|
1775
|
+
order_by=order_by,
|
|
1776
|
+
exclude_today=exclude_today,
|
|
1777
|
+
limit=limit,
|
|
1778
|
+
cursor=cursor,
|
|
1779
|
+
)
|
|
1780
|
+
|
|
1781
|
+
req = self._build_request_async(
|
|
1782
|
+
method="GET",
|
|
1783
|
+
path="/v2/accounts/{id}/orders/history",
|
|
1784
|
+
base_url=base_url,
|
|
1785
|
+
url_variables=url_variables,
|
|
1786
|
+
request=request,
|
|
1787
|
+
request_body_required=False,
|
|
1788
|
+
request_has_path_params=True,
|
|
1789
|
+
request_has_query_params=True,
|
|
1790
|
+
user_agent_header="user-agent",
|
|
1791
|
+
accept_header_value="application/json",
|
|
1792
|
+
http_headers=http_headers,
|
|
1793
|
+
security=self.sdk_configuration.security,
|
|
1794
|
+
allow_empty_value=None,
|
|
1795
|
+
allowed_fields=["client_id"],
|
|
1796
|
+
timeout_ms=timeout_ms,
|
|
1797
|
+
)
|
|
1798
|
+
|
|
1799
|
+
if retries == UNSET:
|
|
1800
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1801
|
+
retries = self.sdk_configuration.retry_config
|
|
1802
|
+
else:
|
|
1803
|
+
retries = utils.RetryConfig(
|
|
1804
|
+
"backoff", utils.BackoffStrategy(500, 8000, 1.5, 60000), True
|
|
1805
|
+
)
|
|
1806
|
+
|
|
1807
|
+
retry_config = None
|
|
1808
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1809
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1810
|
+
|
|
1811
|
+
http_res = await self.do_request_async(
|
|
1812
|
+
hook_ctx=HookContext(
|
|
1813
|
+
config=self.sdk_configuration,
|
|
1814
|
+
base_url=base_url or "",
|
|
1815
|
+
operation_id="listOrderHistory",
|
|
1816
|
+
oauth2_scopes=["order:information"],
|
|
1817
|
+
security_source=self.sdk_configuration.security,
|
|
1818
|
+
tags=["Orders"],
|
|
1819
|
+
extensions=None,
|
|
1820
|
+
),
|
|
1821
|
+
request=req,
|
|
1822
|
+
is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
|
|
1823
|
+
retry_config=retry_config,
|
|
1824
|
+
)
|
|
1825
|
+
|
|
1826
|
+
def next_func() -> Optional[models.ListOrderHistoryResponse]:
|
|
1827
|
+
body = utils.unmarshal_json(http_res.text, Union[Dict[Any, Any], List[Any]])
|
|
1828
|
+
next_cursor = JSONPath("$.nextCursor").parse(body)
|
|
1829
|
+
|
|
1830
|
+
if len(next_cursor) == 0:
|
|
1831
|
+
return None
|
|
1832
|
+
|
|
1833
|
+
next_cursor = next_cursor[0]
|
|
1834
|
+
if next_cursor is None or str(next_cursor).strip() == "":
|
|
1835
|
+
return None
|
|
1836
|
+
results = JSONPath("$.orders").parse(body)
|
|
1837
|
+
if len(results) == 0 or len(results[0]) == 0:
|
|
1838
|
+
return None
|
|
1839
|
+
limit_ = request.limit if isinstance(request.limit, int) else 50
|
|
1840
|
+
if len(results[0]) < limit_:
|
|
1841
|
+
return None
|
|
1842
|
+
|
|
1843
|
+
return self.list_order_history(
|
|
1844
|
+
id=id,
|
|
1845
|
+
from_=from_,
|
|
1846
|
+
to=to,
|
|
1847
|
+
order_by=order_by,
|
|
1848
|
+
exclude_today=exclude_today,
|
|
1849
|
+
limit=limit,
|
|
1850
|
+
cursor=next_cursor,
|
|
1851
|
+
retries=retries,
|
|
1852
|
+
server_url=server_url,
|
|
1853
|
+
timeout_ms=timeout_ms,
|
|
1854
|
+
http_headers=http_headers,
|
|
1855
|
+
)
|
|
1856
|
+
|
|
1857
|
+
response_data: Any = None
|
|
1858
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1859
|
+
return models.ListOrderHistoryResponse(
|
|
1860
|
+
get_orders_v2_response=unmarshal_json_response(
|
|
1861
|
+
Optional[models.GetOrdersV2Response], http_res
|
|
1862
|
+
),
|
|
1863
|
+
http_meta=models.HTTPMetadata(request=req, response=http_res),
|
|
1864
|
+
next=next_func,
|
|
1865
|
+
)
|
|
1866
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
1867
|
+
response_data = unmarshal_json_response(
|
|
1868
|
+
errors.OrderHistoryBadRequestUnion, http_res
|
|
1869
|
+
)
|
|
1870
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1871
|
+
request=req, response=http_res
|
|
1872
|
+
)
|
|
1873
|
+
raise errors.OrderHistoryBadRequest(response_data, http_res)
|
|
1874
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
1875
|
+
response_data = unmarshal_json_response(errors.UnauthorizedUnion, http_res)
|
|
1876
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1877
|
+
request=req, response=http_res
|
|
1878
|
+
)
|
|
1879
|
+
raise errors.Unauthorized(response_data, http_res)
|
|
1880
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
1881
|
+
response_data = unmarshal_json_response(errors.ForbiddenUnion, http_res)
|
|
1882
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1883
|
+
request=req, response=http_res
|
|
1884
|
+
)
|
|
1885
|
+
raise errors.Forbidden(response_data, http_res)
|
|
1886
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
1887
|
+
response_data = unmarshal_json_response(errors.NotFoundUnion, http_res)
|
|
1888
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1889
|
+
request=req, response=http_res
|
|
1890
|
+
)
|
|
1891
|
+
raise errors.NotFound(response_data, http_res)
|
|
1892
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
1893
|
+
response_data = unmarshal_json_response(
|
|
1894
|
+
errors.InternalServerErrorUnion, http_res
|
|
1895
|
+
)
|
|
1896
|
+
response_data.http_meta = models.HTTPMetadata(
|
|
1897
|
+
request=req, response=http_res
|
|
1898
|
+
)
|
|
1899
|
+
raise errors.InternalServerError(response_data, http_res)
|
|
1900
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1901
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1902
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1903
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1904
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1905
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
|
1906
|
+
|
|
1907
|
+
raise errors.APIError("Unexpected response received", http_res)
|