From 5f9ca355b0db16f4aa7b176316bde12a1a94100b Mon Sep 17 00:00:00 2001 From: Borodinov Ilya Date: Fri, 7 Jun 2024 17:47:02 +0300 Subject: [PATCH] initial commit --- .devenv/profile | 1 + .devenv/run | 1 + .direnv/bin/nix-direnv-reload | 19 + .../27rg15w6bjjh2hkbdqajhvqd7b02v5cb-source | 1 + .../8kpx53qi52yhjai1vdw8zpa95iqa61bv-source | 1 + .../8sm7wycza5fl6lnsmw11sn4vqkvw4xyh-source | 1 + .../ah2qh833bkpxg8girwyl6vs30fkp1109-source | 1 + .../br885sqy62q1bblwi2bslcfg2193ly75-source | 1 + .../dlrwkbfzbag8f4xj2kbixalscj206j45-source | 1 + .../f2h5kmarn194yda41znm0r4ibwyg8z7i-source | 1 + .../g5v3sgqy6a0fsmas7mnapc196flrplix-source | 1 + .../gzf4zwcakda1nykn6h0avh45xhjhvsz4-source | 1 + .../hwsdv71bmaqvzbii5viryxc8slw4vr5v-source | 1 + .../i4ginw25yf2q0shnzvzjjwa58srbjhw7-source | 1 + .../i6yzq14z49ayjinw6v9v06kqz62akkay-source | 1 + .../ia8xy09wg9si4lbbxgzbyyg1n0qxg1vk-source | 1 + .../lhbcw63xdqclg2hrni4p7dc90nl996lk-source | 1 + .../lvg59dwzvw3q6l1kpf4mirnzv2fflmra-source | 1 + .../mhgnysbsr0yx44xlqvl7xymk8js22c7z-source | 1 + .../na7sykizsgkzh9i3wc8m8pz5xfqib2rv-source | 1 + .../qkig73szmrhgp0qhncxy5vb36lw2g3jj-source | 1 + .../r2ip1850igy8kciyaagw502s3c6ph1s4-source | 1 + .../s1cnnplqrk8w595dp9fb5cv84xj61lgx-source | 1 + .../v1wzqsqi3d9fhdl60n24sqhj7pr3yhin-source | 1 + .../vm4qsaala00i8q5js7i3am3w0m766k1d-source | 1 + .../vpddlysgdvzcqixkqgx49zyx2whhzpkb-source | 1 + .../vz580xz1w41n6m6x81mqgcrnp3y4cf41-source | 1 + .../y1nw9w1s0ly6442igksfq29v0cfbnmfd-source | 1 + .../yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source | 1 + .../z9wkyy0bbdjfvsmkkw16bmn56502hd1k-source | 1 + ...e-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa | 1 + ...5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc | 1938 ++++++ .envrc | 4 + .gitignore | 1 + .gitmodules | 3 + Cargo.lock | 1922 ++++++ Cargo.toml | 20 + README.md | 15 + README.ru.md | 15 + crates/algorithms/Cargo.toml | 9 + crates/algorithms/src/dev.rs | 48 + crates/algorithms/src/divergence.rs | 187 + crates/algorithms/src/lib.rs | 94 + crates/algorithms/src/ma.rs | 65 + crates/algorithms/src/obv.rs | 25 + crates/algorithms/src/rsi.rs | 35 + crates/alpaca_openapi/Cargo.toml | 9 + crates/alpaca_openapi/gen/broker/.gitignore | 3 + .../gen/broker/.openapi-generator-ignore | 23 + .../gen/broker/.openapi-generator/FILES | 212 + .../gen/broker/.openapi-generator/VERSION | 1 + crates/alpaca_openapi/gen/broker/.travis.yml | 1 + crates/alpaca_openapi/gen/broker/Cargo.toml | 19 + crates/alpaca_openapi/gen/broker/README.md | 199 + .../alpaca_openapi/gen/broker/docs/Account.md | 19 + .../gen/broker/docs/AccountConfigurations.md | 17 + .../gen/broker/docs/AccountCreationRequest.md | 16 + .../gen/broker/docs/AccountDocument.md | 15 + .../gen/broker/docs/AccountExtended.md | 29 + .../gen/broker/docs/AccountStatus.md | 31 + .../gen/broker/docs/AccountStatusEvent.md | 18 + .../gen/broker/docs/AccountType.md | 14 + .../gen/broker/docs/AccountUpdateRequest.md | 14 + .../gen/broker/docs/AccountsApi.md | 632 ++ .../gen/broker/docs/AchRelationship.md | 20 + .../gen/broker/docs/Activity.md | 28 + .../gen/broker/docs/ActivityItem.md | 25 + .../gen/broker/docs/ActivityType.md | 32 + .../gen/broker/docs/Agreement.md | 14 + .../gen/broker/docs/AgreementType.md | 15 + .../gen/broker/docs/Announcement.md | 25 + .../gen/broker/docs/AnnouncementCaSubType.md | 20 + .../gen/broker/docs/AnnouncementCaType.md | 15 + .../gen/broker/docs/ApplicationDocument.md | 15 + .../alpaca_openapi/gen/broker/docs/Asset.md | 24 + .../gen/broker/docs/AssetClass.md | 13 + .../gen/broker/docs/AssetsApi.md | 71 + .../docs/AuthorizeOAuthTokenResponse.md | 14 + crates/alpaca_openapi/gen/broker/docs/Bank.md | 24 + .../gen/broker/docs/BatchJournalRequest.md | 14 + .../docs/BatchJournalRequestEntriesInner.md | 12 + .../gen/broker/docs/BatchJournalResponse.md | 27 + .../gen/broker/docs/Calendar.md | 15 + .../gen/broker/docs/CalendarApi.md | 40 + .../alpaca_openapi/gen/broker/docs/Clock.md | 14 + .../gen/broker/docs/ClockApi.md | 36 + .../alpaca_openapi/gen/broker/docs/Contact.md | 16 + .../gen/broker/docs/CorporateActionsApi.md | 44 + .../docs/CreateAchRelationshipRequest.md | 16 + .../gen/broker/docs/CreateBankRequest.md | 19 + .../gen/broker/docs/CreateJournalRequest.md | 22 + .../gen/broker/docs/CreateOrderRequest.md | 26 + .../broker/docs/CreateOrderRequestStopLoss.md | 12 + .../docs/CreateOrderRequestTakeProfit.md | 11 + .../gen/broker/docs/CreateTransferRequest.md | 17 + .../gen/broker/docs/CreateWatchlistRequest.md | 12 + .../docs/CustodialAccountMinorIdentity.md | 20 + .../docs/DisclosureContextAnnotation.md | 19 + .../gen/broker/docs/Disclosures.md | 19 + .../gen/broker/docs/DocumentInner.md | 13 + .../gen/broker/docs/DocumentType.md | 17 + .../gen/broker/docs/DocumentUpload.md | 14 + .../gen/broker/docs/DocumentUploadRequest.md | 14 + .../gen/broker/docs/DocumentsApi.md | 105 + .../alpaca_openapi/gen/broker/docs/Error.md | 12 + .../gen/broker/docs/EventsApi.md | 144 + .../gen/broker/docs/Exchange.md | 20 + .../gen/broker/docs/FundingApi.md | 333 + .../gen/broker/docs/Identity.md | 26 + .../broker/docs/IssueOAuthTokenResponse.md | 13 + crates/alpaca_openapi/gen/broker/docs/Jnlc.md | 17 + crates/alpaca_openapi/gen/broker/docs/Jnls.md | 13 + .../alpaca_openapi/gen/broker/docs/Journal.md | 26 + .../gen/broker/docs/JournalData.md | 16 + .../gen/broker/docs/JournalEntryType.md | 13 + .../gen/broker/docs/JournalResource.md | 10 + .../gen/broker/docs/JournalStatus.md | 17 + .../gen/broker/docs/JournalStatusEvent.md | 16 + .../gen/broker/docs/JournalsApi.md | 171 + .../gen/broker/docs/KycResult.md | 14 + .../gen/broker/docs/NonTradeActivity.md | 17 + .../gen/broker/docs/OAuthApi.md | 104 + .../gen/broker/docs/OAuthTokenRequest.md | 15 + .../gen/broker/docs/OathClientResponse.md | 19 + .../alpaca_openapi/gen/broker/docs/Order.md | 43 + .../gen/broker/docs/OrderClass.md | 15 + .../gen/broker/docs/OrderClosedResponse.md | 13 + .../gen/broker/docs/OrderSide.md | 20 + .../gen/broker/docs/OrderStatus.md | 27 + .../gen/broker/docs/OrderType.md | 16 + .../gen/broker/docs/PortfolioHistory.md | 16 + .../gen/broker/docs/Position.md | 27 + .../gen/broker/docs/PositionClosedResponse.md | 13 + .../gen/broker/docs/TaxIdType.md | 49 + .../gen/broker/docs/TimeInForce.md | 17 + .../gen/broker/docs/TradeAccount.md | 49 + .../gen/broker/docs/TradeActivity.md | 20 + .../gen/broker/docs/TradeUpdateEvent.md | 17 + .../gen/broker/docs/TradeUpdateEventType.md | 27 + .../gen/broker/docs/TradingApi.md | 369 ++ .../gen/broker/docs/Transfer.md | 25 + .../gen/broker/docs/TransferData.md | 17 + .../gen/broker/docs/TransferDirection.md | 13 + .../gen/broker/docs/TransferResource.md | 23 + .../gen/broker/docs/TransferStatus.md | 20 + .../gen/broker/docs/TransferStatusEvent.md | 16 + .../gen/broker/docs/TransferTiming.md | 12 + .../gen/broker/docs/TransferType.md | 14 + .../gen/broker/docs/TrustedContact.md | 19 + .../gen/broker/docs/UntypedAchTransferData.md | 13 + .../gen/broker/docs/UntypedTransferData.md | 12 + .../broker/docs/UntypedWireTransferData.md | 14 + .../gen/broker/docs/UpdateOrderRequest.md | 16 + .../gen/broker/docs/Watchlist.md | 16 + .../gen/broker/docs/WatchlistApi.md | 168 + crates/alpaca_openapi/gen/broker/git_push.sh | 57 + .../gen/broker/src/apis/accounts_api.rs | 1778 +++++ .../gen/broker/src/apis/assets_api.rs | 182 + .../gen/broker/src/apis/calendar_api.rs | 100 + .../gen/broker/src/apis/clock_api.rs | 81 + .../gen/broker/src/apis/configuration.rs | 49 + .../broker/src/apis/corporate_actions_api.rs | 125 + .../gen/broker/src/apis/documents_api.rs | 282 + .../gen/broker/src/apis/events_api.rs | 428 ++ .../gen/broker/src/apis/funding_api.rs | 919 +++ .../gen/broker/src/apis/journals_api.rs | 471 ++ .../alpaca_openapi/gen/broker/src/apis/mod.rs | 108 + .../gen/broker/src/apis/o_auth_api.rs | 271 + .../gen/broker/src/apis/trading_api.rs | 1034 +++ .../gen/broker/src/apis/watchlist_api.rs | 445 ++ crates/alpaca_openapi/gen/broker/src/lib.rs | 12 + .../gen/broker/src/models/account.rs | 59 + .../src/models/account_configurations.rs | 89 + .../src/models/account_creation_request.rs | 48 + .../gen/broker/src/models/account_document.rs | 43 + .../gen/broker/src/models/account_extended.rs | 111 + .../gen/broker/src/models/account_status.rs | 90 + .../broker/src/models/account_status_event.rs | 59 + .../gen/broker/src/models/account_type.rs | 39 + .../src/models/account_update_request.rs | 34 + .../gen/broker/src/models/ach_relationship.rs | 101 + .../gen/broker/src/models/activity.rs | 121 + .../gen/broker/src/models/activity_item.rs | 110 + .../gen/broker/src/models/activity_type.rs | 93 + .../gen/broker/src/models/agreement.rs | 38 + .../gen/broker/src/models/agreement_type.rs | 42 + .../gen/broker/src/models/announcement.rs | 101 + .../src/models/announcement_ca_sub_type.rs | 57 + .../broker/src/models/announcement_ca_type.rs | 42 + .../broker/src/models/application_document.rs | 43 + .../gen/broker/src/models/asset.rs | 95 + .../gen/broker/src/models/asset_class.rs | 35 + .../models/authorize_o_auth_token_response.rs | 45 + .../gen/broker/src/models/bank.rs | 115 + .../src/models/batch_journal_request.rs | 56 + .../batch_journal_request_entries_inner.rs | 27 + .../src/models/batch_journal_response.rs | 112 + .../gen/broker/src/models/calendar.rs | 44 + .../gen/broker/src/models/clock.rs | 40 + .../gen/broker/src/models/contact.rs | 43 + .../models/create_ach_relationship_request.rs | 65 + .../broker/src/models/create_bank_request.rs | 78 + .../src/models/create_journal_request.rs | 87 + .../broker/src/models/create_order_request.rs | 87 + .../models/create_order_request_stop_loss.rs | 30 + .../create_order_request_take_profit.rs | 25 + .../src/models/create_transfer_request.rs | 59 + .../src/models/create_watchlist_request.rs | 29 + .../custodial_account_minor_identity.rs | 64 + .../models/disclosure_context_annotation.rs | 80 + .../gen/broker/src/models/disclosures.rs | 83 + .../gen/broker/src/models/document_inner.rs | 35 + .../gen/broker/src/models/document_type.rs | 48 + .../gen/broker/src/models/document_upload.rs | 40 + .../src/models/document_upload_request.rs | 40 + .../gen/broker/src/models/error.rs | 25 + .../gen/broker/src/models/exchange.rs | 57 + .../gen/broker/src/models/identity.rs | 119 + .../src/models/issue_o_auth_token_response.rs | 52 + .../gen/broker/src/models/jnlc.rs | 64 + .../gen/broker/src/models/jnls.rs | 32 + .../gen/broker/src/models/journal.rs | 107 + .../gen/broker/src/models/journal_data.rs | 47 + .../broker/src/models/journal_entry_type.rs | 36 + .../gen/broker/src/models/journal_resource.rs | 26 + .../gen/broker/src/models/journal_status.rs | 48 + .../broker/src/models/journal_status_event.rs | 52 + .../gen/broker/src/models/kyc_result.rs | 39 + .../gen/broker/src/models/mod.rs | 178 + .../broker/src/models/non_trade_activity.rs | 66 + .../broker/src/models/o_auth_token_request.rs | 50 + .../broker/src/models/oath_client_response.rs | 71 + .../gen/broker/src/models/order.rs | 201 + .../gen/broker/src/models/order_class.rs | 41 + .../src/models/order_closed_response.rs | 35 + .../gen/broker/src/models/order_side.rs | 57 + .../gen/broker/src/models/order_status.rs | 77 + .../gen/broker/src/models/order_type.rs | 44 + .../broker/src/models/portfolio_history.rs | 55 + .../gen/broker/src/models/position.rs | 121 + .../src/models/position_closed_response.rs | 35 + .../gen/broker/src/models/tax_id_type.rs | 144 + .../gen/broker/src/models/time_in_force.rs | 47 + .../gen/broker/src/models/trade_account.rs | 219 + .../gen/broker/src/models/trade_activity.rs | 74 + .../broker/src/models/trade_update_event.rs | 58 + .../src/models/trade_update_event_type.rs | 78 + .../gen/broker/src/models/transfer.rs | 97 + .../gen/broker/src/models/transfer_data.rs | 92 + .../broker/src/models/transfer_direction.rs | 36 + .../broker/src/models/transfer_resource.rs | 139 + .../gen/broker/src/models/transfer_status.rs | 57 + .../src/models/transfer_status_event.rs | 53 + .../gen/broker/src/models/transfer_timing.rs | 33 + .../gen/broker/src/models/transfer_type.rs | 39 + .../gen/broker/src/models/trusted_contact.rs | 58 + .../src/models/untyped_ach_transfer_data.rs | 49 + .../src/models/untyped_transfer_data.rs | 39 + .../src/models/untyped_wire_transfer_data.rs | 55 + .../broker/src/models/update_order_request.rs | 46 + .../gen/broker/src/models/watchlist.rs | 48 + crates/alpaca_openapi/gen/data/.gitignore | 3 + .../gen/data/.openapi-generator-ignore | 23 + .../gen/data/.openapi-generator/FILES | 64 + .../gen/data/.openapi-generator/VERSION | 1 + crates/alpaca_openapi/gen/data/.travis.yml | 1 + crates/alpaca_openapi/gen/data/Cargo.toml | 19 + crates/alpaca_openapi/gen/data/README.md | 103 + crates/alpaca_openapi/gen/data/docs/Bar.md | 19 + .../gen/data/docs/BarsResponse.md | 13 + .../gen/data/docs/CryptoPricingDataApiApi.md | 574 ++ .../gen/data/docs/CryptoSpreadsResponse.md | 11 + .../gen/data/docs/GetNewsResponse.md | 12 + .../gen/data/docs/LatestBarResponse.md | 12 + .../gen/data/docs/LatestMultiBarsResponse.md | 11 + .../data/docs/LatestMultiQuotesResponse.md | 11 + .../data/docs/LatestMultiTradesResponse.md | 11 + .../gen/data/docs/LatestMultiXbboResponse.md | 11 + .../gen/data/docs/LatestQuoteResponse.md | 12 + .../gen/data/docs/LatestTradeResponse.md | 12 + .../gen/data/docs/LatestXbboResponse.md | 12 + .../alpaca_openapi/gen/data/docs/LogoApi.md | 40 + .../gen/data/docs/MultiBarsResponse.md | 12 + .../gen/data/docs/MultiQuotesReponse.md | 12 + .../gen/data/docs/MultiTradesResponse.md | 12 + crates/alpaca_openapi/gen/data/docs/News.md | 21 + .../alpaca_openapi/gen/data/docs/NewsApi.md | 46 + .../alpaca_openapi/gen/data/docs/NewsImage.md | 12 + crates/alpaca_openapi/gen/data/docs/Quote.md | 20 + .../gen/data/docs/QuotesResponse.md | 13 + .../alpaca_openapi/gen/data/docs/Snapshot.md | 15 + .../gen/data/docs/StockPricingDataApiApi.md | 544 ++ crates/alpaca_openapi/gen/data/docs/Trade.md | 18 + .../gen/data/docs/TradesResponse.md | 13 + crates/alpaca_openapi/gen/data/docs/Xbbo.md | 17 + crates/alpaca_openapi/gen/data/git_push.sh | 57 + .../gen/data/src/apis/configuration.rs | 49 + .../src/apis/crypto_pricing_data_api_api.rs | 1847 ++++++ .../gen/data/src/apis/logo_api.rs | 113 + .../alpaca_openapi/gen/data/src/apis/mod.rs | 100 + .../gen/data/src/apis/news_api.rs | 149 + .../src/apis/stock_pricing_data_api_api.rs | 1761 +++++ crates/alpaca_openapi/gen/data/src/lib.rs | 12 + .../alpaca_openapi/gen/data/src/models/bar.rs | 76 + .../gen/data/src/models/bars_response.rs | 39 + .../src/models/crypto_spreads_response.rs | 25 + .../gen/data/src/models/get_news_response.rs | 29 + .../data/src/models/latest_bar_response.rs | 30 + .../src/models/latest_multi_bars_response.rs | 25 + .../models/latest_multi_quotes_response.rs | 27 + .../models/latest_multi_trades_response.rs | 27 + .../src/models/latest_multi_xbbo_response.rs | 25 + .../data/src/models/latest_quote_response.rs | 30 + .../data/src/models/latest_trade_response.rs | 31 + .../data/src/models/latest_xbbo_response.rs | 30 + .../alpaca_openapi/gen/data/src/models/mod.rs | 46 + .../data/src/models/multi_bars_response.rs | 35 + .../data/src/models/multi_quotes_reponse.rs | 38 + .../data/src/models/multi_trades_response.rs | 37 + .../gen/data/src/models/news.rs | 84 + .../gen/data/src/models/news_image.rs | 45 + .../gen/data/src/models/quote.rs | 64 + .../gen/data/src/models/quotes_response.rs | 38 + .../gen/data/src/models/snapshot.rs | 39 + .../gen/data/src/models/trade.rs | 56 + .../gen/data/src/models/trades_response.rs | 41 + .../gen/data/src/models/xbbo.rs | 52 + crates/alpaca_openapi/gen/oauth/.gitignore | 3 + .../gen/oauth/.openapi-generator-ignore | 23 + .../gen/oauth/.openapi-generator/FILES | 12 + .../gen/oauth/.openapi-generator/VERSION | 1 + crates/alpaca_openapi/gen/oauth/.travis.yml | 1 + crates/alpaca_openapi/gen/oauth/Cargo.toml | 18 + crates/alpaca_openapi/gen/oauth/README.md | 49 + .../gen/oauth/docs/StockPricingDataApiApi.md | 79 + crates/alpaca_openapi/gen/oauth/git_push.sh | 57 + .../gen/oauth/src/apis/configuration.rs | 49 + .../alpaca_openapi/gen/oauth/src/apis/mod.rs | 97 + .../src/apis/stock_pricing_data_api_api.rs | 219 + crates/alpaca_openapi/gen/oauth/src/lib.rs | 12 + .../gen/oauth/src/models/mod.rs | 1 + crates/alpaca_openapi/gen/trading/.gitignore | 3 + .../gen/trading/.openapi-generator-ignore | 23 + .../gen/trading/.openapi-generator/FILES | 82 + .../gen/trading/.openapi-generator/VERSION | 1 + crates/alpaca_openapi/gen/trading/.travis.yml | 1 + crates/alpaca_openapi/gen/trading/Cargo.toml | 19 + crates/alpaca_openapi/gen/trading/README.md | 103 + .../gen/trading/docs/Account.md | 36 + .../gen/trading/docs/AccountActivitiesApi.md | 82 + .../gen/trading/docs/AccountConfigurations.md | 17 + .../trading/docs/AccountConfigurationsApi.md | 67 + .../gen/trading/docs/AccountStatus.md | 18 + .../gen/trading/docs/AccountsApi.md | 36 + .../gen/trading/docs/ActivityType.md | 46 + .../docs/AddAssetToWatchlistRequest.md | 11 + .../gen/trading/docs/AssetClass.md | 13 + .../alpaca_openapi/gen/trading/docs/Assets.md | 21 + .../gen/trading/docs/Calendar.md | 15 + .../gen/trading/docs/CalendarApi.md | 40 + .../gen/trading/docs/CanceledOrderResponse.md | 12 + .../alpaca_openapi/gen/trading/docs/Clock.md | 14 + .../gen/trading/docs/ClockApi.md | 36 + .../gen/trading/docs/Exchange.md | 18 + .../GetAccountActivities200ResponseInner.md | 25 + ...ctivitiesByActivityType200ResponseInner.md | 12 + .../gen/trading/docs/NonTradeActivities.md | 17 + .../alpaca_openapi/gen/trading/docs/Order.md | 42 + .../gen/trading/docs/OrderClass.md | 16 + .../gen/trading/docs/OrderSide.md | 13 + .../gen/trading/docs/OrderStatus.md | 27 + .../gen/trading/docs/OrderType.md | 16 + .../gen/trading/docs/OrdersApi.md | 199 + .../gen/trading/docs/PatchOrderRequest.md | 16 + .../gen/trading/docs/PortfolioHistory.md | 16 + .../gen/trading/docs/PortfolioHistoryApi.md | 42 + .../gen/trading/docs/Position.md | 28 + .../gen/trading/docs/PositionClosedReponse.md | 13 + .../gen/trading/docs/PositionsApi.md | 131 + .../gen/trading/docs/TimeInForce.md | 17 + .../gen/trading/docs/TradingActivities.md | 22 + .../trading/docs/UpdateWatchlistRequest.md | 12 + .../gen/trading/docs/Watchlist.md | 16 + .../gen/trading/docs/WatchlistsApi.md | 351 + crates/alpaca_openapi/gen/trading/git_push.sh | 57 + .../src/apis/account_activities_api.rs | 286 + .../src/apis/account_configurations_api.rs | 185 + .../gen/trading/src/apis/accounts_api.rs | 92 + .../gen/trading/src/apis/calendar_api.rs | 111 + .../gen/trading/src/apis/clock_api.rs | 91 + .../gen/trading/src/apis/configuration.rs | 49 + .../gen/trading/src/apis/mod.rs | 105 + .../gen/trading/src/apis/orders_api.rs | 600 ++ .../trading/src/apis/portfolio_history_api.rs | 132 + .../gen/trading/src/apis/positions_api.rs | 379 ++ .../gen/trading/src/apis/watchlists_api.rs | 1016 +++ crates/alpaca_openapi/gen/trading/src/lib.rs | 12 + .../gen/trading/src/models/account.rs | 136 + .../src/models/account_configurations.rs | 73 + .../gen/trading/src/models/account_status.rs | 51 + .../gen/trading/src/models/activity_type.rs | 135 + .../models/add_asset_to_watchlist_request.rs | 26 + .../gen/trading/src/models/asset_class.rs | 36 + .../gen/trading/src/models/assets.rs | 92 + .../gen/trading/src/models/calendar.rs | 48 + .../src/models/canceled_order_response.rs | 32 + .../gen/trading/src/models/clock.rs | 38 + .../gen/trading/src/models/exchange.rs | 51 + ...t_account_activities_200_response_inner.rs | 96 + ...ies_by_activity_type_200_response_inner.rs | 40 + .../gen/trading/src/models/mod.rs | 54 + .../src/models/non_trade_activities.rs | 49 + .../gen/trading/src/models/order.rs | 210 + .../gen/trading/src/models/order_class.rs | 45 + .../gen/trading/src/models/order_side.rs | 36 + .../gen/trading/src/models/order_status.rs | 78 + .../gen/trading/src/models/order_type.rs | 45 + .../trading/src/models/patch_order_request.rs | 47 + .../trading/src/models/portfolio_history.rs | 46 + .../gen/trading/src/models/position.rs | 111 + .../src/models/position_closed_reponse.rs | 35 + .../gen/trading/src/models/time_in_force.rs | 48 + .../trading/src/models/trading_activities.rs | 82 + .../src/models/update_watchlist_request.rs | 30 + .../gen/trading/src/models/watchlist.rs | 52 + crates/alpaca_openapi/gen_alpaca.sh | 18 + crates/alpaca_openapi/openapi/README.md | 52 + .../openapi/broker/openapi.yaml | 5809 +++++++++++++++++ .../alpaca_openapi/openapi/data/openapi.yaml | 3016 +++++++++ .../alpaca_openapi/openapi/oauth/openapi.yaml | 129 + .../openapi/oauth/redirect/openapi.yaml | 63 + .../openapi/oauth/token/openapi.yaml | 74 + .../openapi/trading/openapi.yaml | 2071 ++++++ crates/alpaca_openapi/src/lib.rs | 3 + crates/sanetrade/.gitignore | 1 + crates/sanetrade/Cargo.toml | 17 + crates/sanetrade/src/lib.rs | 16 + crates/sanetrade/src/market_data.rs | 1 + crates/sanetrade/src/tinkoff.rs | 112 + crates/tinkoff_invest/Cargo.toml | 13 + crates/tinkoff_invest/build.rs | 19 + crates/tinkoff_invest/investapi | 1 + crates/tinkoff_invest/src/lib.rs | 4 + flake.lock | 597 ++ flake.nix | 79 + 445 files changed, 47288 insertions(+) create mode 120000 .devenv/profile create mode 120000 .devenv/run create mode 100755 .direnv/bin/nix-direnv-reload create mode 120000 .direnv/flake-inputs/27rg15w6bjjh2hkbdqajhvqd7b02v5cb-source create mode 120000 .direnv/flake-inputs/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source create mode 120000 .direnv/flake-inputs/8sm7wycza5fl6lnsmw11sn4vqkvw4xyh-source create mode 120000 .direnv/flake-inputs/ah2qh833bkpxg8girwyl6vs30fkp1109-source create mode 120000 .direnv/flake-inputs/br885sqy62q1bblwi2bslcfg2193ly75-source create mode 120000 .direnv/flake-inputs/dlrwkbfzbag8f4xj2kbixalscj206j45-source create mode 120000 .direnv/flake-inputs/f2h5kmarn194yda41znm0r4ibwyg8z7i-source create mode 120000 .direnv/flake-inputs/g5v3sgqy6a0fsmas7mnapc196flrplix-source create mode 120000 .direnv/flake-inputs/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source create mode 120000 .direnv/flake-inputs/hwsdv71bmaqvzbii5viryxc8slw4vr5v-source create mode 120000 .direnv/flake-inputs/i4ginw25yf2q0shnzvzjjwa58srbjhw7-source create mode 120000 .direnv/flake-inputs/i6yzq14z49ayjinw6v9v06kqz62akkay-source create mode 120000 .direnv/flake-inputs/ia8xy09wg9si4lbbxgzbyyg1n0qxg1vk-source create mode 120000 .direnv/flake-inputs/lhbcw63xdqclg2hrni4p7dc90nl996lk-source create mode 120000 .direnv/flake-inputs/lvg59dwzvw3q6l1kpf4mirnzv2fflmra-source create mode 120000 .direnv/flake-inputs/mhgnysbsr0yx44xlqvl7xymk8js22c7z-source create mode 120000 .direnv/flake-inputs/na7sykizsgkzh9i3wc8m8pz5xfqib2rv-source create mode 120000 .direnv/flake-inputs/qkig73szmrhgp0qhncxy5vb36lw2g3jj-source create mode 120000 .direnv/flake-inputs/r2ip1850igy8kciyaagw502s3c6ph1s4-source create mode 120000 .direnv/flake-inputs/s1cnnplqrk8w595dp9fb5cv84xj61lgx-source create mode 120000 .direnv/flake-inputs/v1wzqsqi3d9fhdl60n24sqhj7pr3yhin-source create mode 120000 .direnv/flake-inputs/vm4qsaala00i8q5js7i3am3w0m766k1d-source create mode 120000 .direnv/flake-inputs/vpddlysgdvzcqixkqgx49zyx2whhzpkb-source create mode 120000 .direnv/flake-inputs/vz580xz1w41n6m6x81mqgcrnp3y4cf41-source create mode 120000 .direnv/flake-inputs/y1nw9w1s0ly6442igksfq29v0cfbnmfd-source create mode 120000 .direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source create mode 120000 .direnv/flake-inputs/z9wkyy0bbdjfvsmkkw16bmn56502hd1k-source create mode 120000 .direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa create mode 100644 .direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 README.md create mode 100644 README.ru.md create mode 100644 crates/algorithms/Cargo.toml create mode 100644 crates/algorithms/src/dev.rs create mode 100644 crates/algorithms/src/divergence.rs create mode 100644 crates/algorithms/src/lib.rs create mode 100644 crates/algorithms/src/ma.rs create mode 100644 crates/algorithms/src/obv.rs create mode 100644 crates/algorithms/src/rsi.rs create mode 100644 crates/alpaca_openapi/Cargo.toml create mode 100644 crates/alpaca_openapi/gen/broker/.gitignore create mode 100644 crates/alpaca_openapi/gen/broker/.openapi-generator-ignore create mode 100644 crates/alpaca_openapi/gen/broker/.openapi-generator/FILES create mode 100644 crates/alpaca_openapi/gen/broker/.openapi-generator/VERSION create mode 100644 crates/alpaca_openapi/gen/broker/.travis.yml create mode 100644 crates/alpaca_openapi/gen/broker/Cargo.toml create mode 100644 crates/alpaca_openapi/gen/broker/README.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Account.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AccountConfigurations.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AccountCreationRequest.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AccountDocument.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AccountExtended.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AccountStatus.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AccountStatusEvent.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AccountType.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AccountUpdateRequest.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AccountsApi.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AchRelationship.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Activity.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/ActivityItem.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/ActivityType.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Agreement.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AgreementType.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Announcement.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AnnouncementCaSubType.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AnnouncementCaType.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/ApplicationDocument.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Asset.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AssetClass.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AssetsApi.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/AuthorizeOAuthTokenResponse.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Bank.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/BatchJournalRequest.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/BatchJournalRequestEntriesInner.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/BatchJournalResponse.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Calendar.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/CalendarApi.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Clock.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/ClockApi.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Contact.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/CorporateActionsApi.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/CreateAchRelationshipRequest.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/CreateBankRequest.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/CreateJournalRequest.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/CreateOrderRequest.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/CreateOrderRequestStopLoss.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/CreateOrderRequestTakeProfit.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/CreateTransferRequest.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/CreateWatchlistRequest.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/CustodialAccountMinorIdentity.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/DisclosureContextAnnotation.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Disclosures.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/DocumentInner.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/DocumentType.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/DocumentUpload.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/DocumentUploadRequest.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/DocumentsApi.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Error.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/EventsApi.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Exchange.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/FundingApi.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Identity.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/IssueOAuthTokenResponse.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Jnlc.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Jnls.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Journal.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/JournalData.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/JournalEntryType.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/JournalResource.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/JournalStatus.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/JournalStatusEvent.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/JournalsApi.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/KycResult.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/NonTradeActivity.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/OAuthApi.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/OAuthTokenRequest.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/OathClientResponse.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Order.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/OrderClass.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/OrderClosedResponse.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/OrderSide.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/OrderStatus.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/OrderType.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/PortfolioHistory.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Position.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/PositionClosedResponse.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TaxIdType.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TimeInForce.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TradeAccount.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TradeActivity.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TradeUpdateEvent.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TradeUpdateEventType.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TradingApi.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Transfer.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TransferData.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TransferDirection.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TransferResource.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TransferStatus.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TransferStatusEvent.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TransferTiming.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TransferType.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/TrustedContact.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/UntypedAchTransferData.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/UntypedTransferData.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/UntypedWireTransferData.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/UpdateOrderRequest.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/Watchlist.md create mode 100644 crates/alpaca_openapi/gen/broker/docs/WatchlistApi.md create mode 100644 crates/alpaca_openapi/gen/broker/git_push.sh create mode 100644 crates/alpaca_openapi/gen/broker/src/apis/accounts_api.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/apis/assets_api.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/apis/calendar_api.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/apis/clock_api.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/apis/configuration.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/apis/corporate_actions_api.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/apis/documents_api.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/apis/events_api.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/apis/funding_api.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/apis/journals_api.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/apis/mod.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/apis/o_auth_api.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/apis/trading_api.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/apis/watchlist_api.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/lib.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/account.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/account_configurations.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/account_creation_request.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/account_document.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/account_extended.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/account_status.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/account_status_event.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/account_type.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/account_update_request.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/ach_relationship.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/activity.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/activity_item.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/activity_type.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/agreement.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/agreement_type.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/announcement.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/announcement_ca_sub_type.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/announcement_ca_type.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/application_document.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/asset.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/asset_class.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/authorize_o_auth_token_response.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/bank.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/batch_journal_request.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/batch_journal_request_entries_inner.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/batch_journal_response.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/calendar.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/clock.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/contact.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/create_ach_relationship_request.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/create_bank_request.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/create_journal_request.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/create_order_request.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/create_order_request_stop_loss.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/create_order_request_take_profit.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/create_transfer_request.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/create_watchlist_request.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/custodial_account_minor_identity.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/disclosure_context_annotation.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/disclosures.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/document_inner.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/document_type.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/document_upload.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/document_upload_request.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/error.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/exchange.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/identity.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/issue_o_auth_token_response.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/jnlc.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/jnls.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/journal.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/journal_data.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/journal_entry_type.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/journal_resource.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/journal_status.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/journal_status_event.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/kyc_result.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/mod.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/non_trade_activity.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/o_auth_token_request.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/oath_client_response.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/order.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/order_class.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/order_closed_response.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/order_side.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/order_status.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/order_type.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/portfolio_history.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/position.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/position_closed_response.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/tax_id_type.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/time_in_force.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/trade_account.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/trade_activity.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/trade_update_event.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/trade_update_event_type.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/transfer.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/transfer_data.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/transfer_direction.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/transfer_resource.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/transfer_status.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/transfer_status_event.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/transfer_timing.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/transfer_type.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/trusted_contact.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/untyped_ach_transfer_data.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/untyped_transfer_data.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/untyped_wire_transfer_data.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/update_order_request.rs create mode 100644 crates/alpaca_openapi/gen/broker/src/models/watchlist.rs create mode 100644 crates/alpaca_openapi/gen/data/.gitignore create mode 100644 crates/alpaca_openapi/gen/data/.openapi-generator-ignore create mode 100644 crates/alpaca_openapi/gen/data/.openapi-generator/FILES create mode 100644 crates/alpaca_openapi/gen/data/.openapi-generator/VERSION create mode 100644 crates/alpaca_openapi/gen/data/.travis.yml create mode 100644 crates/alpaca_openapi/gen/data/Cargo.toml create mode 100644 crates/alpaca_openapi/gen/data/README.md create mode 100644 crates/alpaca_openapi/gen/data/docs/Bar.md create mode 100644 crates/alpaca_openapi/gen/data/docs/BarsResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/CryptoPricingDataApiApi.md create mode 100644 crates/alpaca_openapi/gen/data/docs/CryptoSpreadsResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/GetNewsResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/LatestBarResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/LatestMultiBarsResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/LatestMultiQuotesResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/LatestMultiTradesResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/LatestMultiXbboResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/LatestQuoteResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/LatestTradeResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/LatestXbboResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/LogoApi.md create mode 100644 crates/alpaca_openapi/gen/data/docs/MultiBarsResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/MultiQuotesReponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/MultiTradesResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/News.md create mode 100644 crates/alpaca_openapi/gen/data/docs/NewsApi.md create mode 100644 crates/alpaca_openapi/gen/data/docs/NewsImage.md create mode 100644 crates/alpaca_openapi/gen/data/docs/Quote.md create mode 100644 crates/alpaca_openapi/gen/data/docs/QuotesResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/Snapshot.md create mode 100644 crates/alpaca_openapi/gen/data/docs/StockPricingDataApiApi.md create mode 100644 crates/alpaca_openapi/gen/data/docs/Trade.md create mode 100644 crates/alpaca_openapi/gen/data/docs/TradesResponse.md create mode 100644 crates/alpaca_openapi/gen/data/docs/Xbbo.md create mode 100644 crates/alpaca_openapi/gen/data/git_push.sh create mode 100644 crates/alpaca_openapi/gen/data/src/apis/configuration.rs create mode 100644 crates/alpaca_openapi/gen/data/src/apis/crypto_pricing_data_api_api.rs create mode 100644 crates/alpaca_openapi/gen/data/src/apis/logo_api.rs create mode 100644 crates/alpaca_openapi/gen/data/src/apis/mod.rs create mode 100644 crates/alpaca_openapi/gen/data/src/apis/news_api.rs create mode 100644 crates/alpaca_openapi/gen/data/src/apis/stock_pricing_data_api_api.rs create mode 100644 crates/alpaca_openapi/gen/data/src/lib.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/bar.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/bars_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/crypto_spreads_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/get_news_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/latest_bar_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/latest_multi_bars_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/latest_multi_quotes_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/latest_multi_trades_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/latest_multi_xbbo_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/latest_quote_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/latest_trade_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/latest_xbbo_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/mod.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/multi_bars_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/multi_quotes_reponse.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/multi_trades_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/news.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/news_image.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/quote.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/quotes_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/snapshot.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/trade.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/trades_response.rs create mode 100644 crates/alpaca_openapi/gen/data/src/models/xbbo.rs create mode 100644 crates/alpaca_openapi/gen/oauth/.gitignore create mode 100644 crates/alpaca_openapi/gen/oauth/.openapi-generator-ignore create mode 100644 crates/alpaca_openapi/gen/oauth/.openapi-generator/FILES create mode 100644 crates/alpaca_openapi/gen/oauth/.openapi-generator/VERSION create mode 100644 crates/alpaca_openapi/gen/oauth/.travis.yml create mode 100644 crates/alpaca_openapi/gen/oauth/Cargo.toml create mode 100644 crates/alpaca_openapi/gen/oauth/README.md create mode 100644 crates/alpaca_openapi/gen/oauth/docs/StockPricingDataApiApi.md create mode 100644 crates/alpaca_openapi/gen/oauth/git_push.sh create mode 100644 crates/alpaca_openapi/gen/oauth/src/apis/configuration.rs create mode 100644 crates/alpaca_openapi/gen/oauth/src/apis/mod.rs create mode 100644 crates/alpaca_openapi/gen/oauth/src/apis/stock_pricing_data_api_api.rs create mode 100644 crates/alpaca_openapi/gen/oauth/src/lib.rs create mode 100644 crates/alpaca_openapi/gen/oauth/src/models/mod.rs create mode 100644 crates/alpaca_openapi/gen/trading/.gitignore create mode 100644 crates/alpaca_openapi/gen/trading/.openapi-generator-ignore create mode 100644 crates/alpaca_openapi/gen/trading/.openapi-generator/FILES create mode 100644 crates/alpaca_openapi/gen/trading/.openapi-generator/VERSION create mode 100644 crates/alpaca_openapi/gen/trading/.travis.yml create mode 100644 crates/alpaca_openapi/gen/trading/Cargo.toml create mode 100644 crates/alpaca_openapi/gen/trading/README.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/Account.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/AccountActivitiesApi.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/AccountConfigurations.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/AccountConfigurationsApi.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/AccountStatus.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/AccountsApi.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/ActivityType.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/AddAssetToWatchlistRequest.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/AssetClass.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/Assets.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/Calendar.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/CalendarApi.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/CanceledOrderResponse.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/Clock.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/ClockApi.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/Exchange.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/GetAccountActivities200ResponseInner.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/GetAccountActivitiesByActivityType200ResponseInner.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/NonTradeActivities.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/Order.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/OrderClass.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/OrderSide.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/OrderStatus.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/OrderType.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/OrdersApi.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/PatchOrderRequest.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/PortfolioHistory.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/PortfolioHistoryApi.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/Position.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/PositionClosedReponse.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/PositionsApi.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/TimeInForce.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/TradingActivities.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/UpdateWatchlistRequest.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/Watchlist.md create mode 100644 crates/alpaca_openapi/gen/trading/docs/WatchlistsApi.md create mode 100644 crates/alpaca_openapi/gen/trading/git_push.sh create mode 100644 crates/alpaca_openapi/gen/trading/src/apis/account_activities_api.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/apis/account_configurations_api.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/apis/accounts_api.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/apis/calendar_api.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/apis/clock_api.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/apis/configuration.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/apis/mod.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/apis/orders_api.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/apis/portfolio_history_api.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/apis/positions_api.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/apis/watchlists_api.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/lib.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/account.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/account_configurations.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/account_status.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/activity_type.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/add_asset_to_watchlist_request.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/asset_class.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/assets.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/calendar.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/canceled_order_response.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/clock.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/exchange.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/get_account_activities_200_response_inner.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/get_account_activities_by_activity_type_200_response_inner.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/mod.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/non_trade_activities.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/order.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/order_class.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/order_side.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/order_status.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/order_type.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/patch_order_request.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/portfolio_history.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/position.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/position_closed_reponse.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/time_in_force.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/trading_activities.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/update_watchlist_request.rs create mode 100644 crates/alpaca_openapi/gen/trading/src/models/watchlist.rs create mode 100755 crates/alpaca_openapi/gen_alpaca.sh create mode 100644 crates/alpaca_openapi/openapi/README.md create mode 100644 crates/alpaca_openapi/openapi/broker/openapi.yaml create mode 100644 crates/alpaca_openapi/openapi/data/openapi.yaml create mode 100644 crates/alpaca_openapi/openapi/oauth/openapi.yaml create mode 100644 crates/alpaca_openapi/openapi/oauth/redirect/openapi.yaml create mode 100644 crates/alpaca_openapi/openapi/oauth/token/openapi.yaml create mode 100644 crates/alpaca_openapi/openapi/trading/openapi.yaml create mode 100644 crates/alpaca_openapi/src/lib.rs create mode 100644 crates/sanetrade/.gitignore create mode 100644 crates/sanetrade/Cargo.toml create mode 100644 crates/sanetrade/src/lib.rs create mode 100644 crates/sanetrade/src/market_data.rs create mode 100644 crates/sanetrade/src/tinkoff.rs create mode 100644 crates/tinkoff_invest/Cargo.toml create mode 100644 crates/tinkoff_invest/build.rs create mode 160000 crates/tinkoff_invest/investapi create mode 100644 crates/tinkoff_invest/src/lib.rs create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.devenv/profile b/.devenv/profile new file mode 120000 index 0000000..ee0a088 --- /dev/null +++ b/.devenv/profile @@ -0,0 +1 @@ +/nix/store/ya15x5s5b8w1visadax2ffndw4fknkmb-devenv-profile \ No newline at end of file diff --git a/.devenv/run b/.devenv/run new file mode 120000 index 0000000..c61618d --- /dev/null +++ b/.devenv/run @@ -0,0 +1 @@ +/run/user/1000/devenv-503e649 \ No newline at end of file diff --git a/.direnv/bin/nix-direnv-reload b/.direnv/bin/nix-direnv-reload new file mode 100755 index 0000000..704b7d8 --- /dev/null +++ b/.direnv/bin/nix-direnv-reload @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -e +if [[ ! -d "/mnt/k/minky/trading/sdk" ]]; then + echo "Cannot find source directory; Did you move it?" + echo "(Looking for "/mnt/k/minky/trading/sdk")" + echo 'Cannot force reload with this script - use "direnv reload" manually and then try again' + exit 1 +fi + +# rebuild the cache forcefully +_nix_direnv_force_reload=1 direnv exec "/mnt/k/minky/trading/sdk" true + +# Update the mtime for .envrc. +# This will cause direnv to reload again - but without re-building. +touch "/mnt/k/minky/trading/sdk/.envrc" + +# Also update the timestamp of whatever profile_rc we have. +# This makes sure that we know we are up to date. +touch -r "/mnt/k/minky/trading/sdk/.envrc" "/mnt/k/minky/trading/sdk/.direnv"/*.rc diff --git a/.direnv/flake-inputs/27rg15w6bjjh2hkbdqajhvqd7b02v5cb-source b/.direnv/flake-inputs/27rg15w6bjjh2hkbdqajhvqd7b02v5cb-source new file mode 120000 index 0000000..3ea5c6e --- /dev/null +++ b/.direnv/flake-inputs/27rg15w6bjjh2hkbdqajhvqd7b02v5cb-source @@ -0,0 +1 @@ +/nix/store/27rg15w6bjjh2hkbdqajhvqd7b02v5cb-source \ No newline at end of file diff --git a/.direnv/flake-inputs/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source b/.direnv/flake-inputs/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source new file mode 120000 index 0000000..ec68f6a --- /dev/null +++ b/.direnv/flake-inputs/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source @@ -0,0 +1 @@ +/nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source \ No newline at end of file diff --git a/.direnv/flake-inputs/8sm7wycza5fl6lnsmw11sn4vqkvw4xyh-source b/.direnv/flake-inputs/8sm7wycza5fl6lnsmw11sn4vqkvw4xyh-source new file mode 120000 index 0000000..c2649c1 --- /dev/null +++ b/.direnv/flake-inputs/8sm7wycza5fl6lnsmw11sn4vqkvw4xyh-source @@ -0,0 +1 @@ +/nix/store/8sm7wycza5fl6lnsmw11sn4vqkvw4xyh-source \ No newline at end of file diff --git a/.direnv/flake-inputs/ah2qh833bkpxg8girwyl6vs30fkp1109-source b/.direnv/flake-inputs/ah2qh833bkpxg8girwyl6vs30fkp1109-source new file mode 120000 index 0000000..d0a84eb --- /dev/null +++ b/.direnv/flake-inputs/ah2qh833bkpxg8girwyl6vs30fkp1109-source @@ -0,0 +1 @@ +/nix/store/ah2qh833bkpxg8girwyl6vs30fkp1109-source \ No newline at end of file diff --git a/.direnv/flake-inputs/br885sqy62q1bblwi2bslcfg2193ly75-source b/.direnv/flake-inputs/br885sqy62q1bblwi2bslcfg2193ly75-source new file mode 120000 index 0000000..57c9cb9 --- /dev/null +++ b/.direnv/flake-inputs/br885sqy62q1bblwi2bslcfg2193ly75-source @@ -0,0 +1 @@ +/nix/store/br885sqy62q1bblwi2bslcfg2193ly75-source \ No newline at end of file diff --git a/.direnv/flake-inputs/dlrwkbfzbag8f4xj2kbixalscj206j45-source b/.direnv/flake-inputs/dlrwkbfzbag8f4xj2kbixalscj206j45-source new file mode 120000 index 0000000..6fc19ed --- /dev/null +++ b/.direnv/flake-inputs/dlrwkbfzbag8f4xj2kbixalscj206j45-source @@ -0,0 +1 @@ +/nix/store/dlrwkbfzbag8f4xj2kbixalscj206j45-source \ No newline at end of file diff --git a/.direnv/flake-inputs/f2h5kmarn194yda41znm0r4ibwyg8z7i-source b/.direnv/flake-inputs/f2h5kmarn194yda41znm0r4ibwyg8z7i-source new file mode 120000 index 0000000..ca09ed7 --- /dev/null +++ b/.direnv/flake-inputs/f2h5kmarn194yda41znm0r4ibwyg8z7i-source @@ -0,0 +1 @@ +/nix/store/f2h5kmarn194yda41znm0r4ibwyg8z7i-source \ No newline at end of file diff --git a/.direnv/flake-inputs/g5v3sgqy6a0fsmas7mnapc196flrplix-source b/.direnv/flake-inputs/g5v3sgqy6a0fsmas7mnapc196flrplix-source new file mode 120000 index 0000000..c425a39 --- /dev/null +++ b/.direnv/flake-inputs/g5v3sgqy6a0fsmas7mnapc196flrplix-source @@ -0,0 +1 @@ +/nix/store/g5v3sgqy6a0fsmas7mnapc196flrplix-source \ No newline at end of file diff --git a/.direnv/flake-inputs/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source b/.direnv/flake-inputs/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source new file mode 120000 index 0000000..5ee5200 --- /dev/null +++ b/.direnv/flake-inputs/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source @@ -0,0 +1 @@ +/nix/store/gzf4zwcakda1nykn6h0avh45xhjhvsz4-source \ No newline at end of file diff --git a/.direnv/flake-inputs/hwsdv71bmaqvzbii5viryxc8slw4vr5v-source b/.direnv/flake-inputs/hwsdv71bmaqvzbii5viryxc8slw4vr5v-source new file mode 120000 index 0000000..96bc5fa --- /dev/null +++ b/.direnv/flake-inputs/hwsdv71bmaqvzbii5viryxc8slw4vr5v-source @@ -0,0 +1 @@ +/nix/store/hwsdv71bmaqvzbii5viryxc8slw4vr5v-source \ No newline at end of file diff --git a/.direnv/flake-inputs/i4ginw25yf2q0shnzvzjjwa58srbjhw7-source b/.direnv/flake-inputs/i4ginw25yf2q0shnzvzjjwa58srbjhw7-source new file mode 120000 index 0000000..e3d1b64 --- /dev/null +++ b/.direnv/flake-inputs/i4ginw25yf2q0shnzvzjjwa58srbjhw7-source @@ -0,0 +1 @@ +/nix/store/i4ginw25yf2q0shnzvzjjwa58srbjhw7-source \ No newline at end of file diff --git a/.direnv/flake-inputs/i6yzq14z49ayjinw6v9v06kqz62akkay-source b/.direnv/flake-inputs/i6yzq14z49ayjinw6v9v06kqz62akkay-source new file mode 120000 index 0000000..2fcf585 --- /dev/null +++ b/.direnv/flake-inputs/i6yzq14z49ayjinw6v9v06kqz62akkay-source @@ -0,0 +1 @@ +/nix/store/i6yzq14z49ayjinw6v9v06kqz62akkay-source \ No newline at end of file diff --git a/.direnv/flake-inputs/ia8xy09wg9si4lbbxgzbyyg1n0qxg1vk-source b/.direnv/flake-inputs/ia8xy09wg9si4lbbxgzbyyg1n0qxg1vk-source new file mode 120000 index 0000000..979b69b --- /dev/null +++ b/.direnv/flake-inputs/ia8xy09wg9si4lbbxgzbyyg1n0qxg1vk-source @@ -0,0 +1 @@ +/nix/store/ia8xy09wg9si4lbbxgzbyyg1n0qxg1vk-source \ No newline at end of file diff --git a/.direnv/flake-inputs/lhbcw63xdqclg2hrni4p7dc90nl996lk-source b/.direnv/flake-inputs/lhbcw63xdqclg2hrni4p7dc90nl996lk-source new file mode 120000 index 0000000..7a82a69 --- /dev/null +++ b/.direnv/flake-inputs/lhbcw63xdqclg2hrni4p7dc90nl996lk-source @@ -0,0 +1 @@ +/nix/store/lhbcw63xdqclg2hrni4p7dc90nl996lk-source \ No newline at end of file diff --git a/.direnv/flake-inputs/lvg59dwzvw3q6l1kpf4mirnzv2fflmra-source b/.direnv/flake-inputs/lvg59dwzvw3q6l1kpf4mirnzv2fflmra-source new file mode 120000 index 0000000..afcf2c4 --- /dev/null +++ b/.direnv/flake-inputs/lvg59dwzvw3q6l1kpf4mirnzv2fflmra-source @@ -0,0 +1 @@ +/nix/store/lvg59dwzvw3q6l1kpf4mirnzv2fflmra-source \ No newline at end of file diff --git a/.direnv/flake-inputs/mhgnysbsr0yx44xlqvl7xymk8js22c7z-source b/.direnv/flake-inputs/mhgnysbsr0yx44xlqvl7xymk8js22c7z-source new file mode 120000 index 0000000..f628d3a --- /dev/null +++ b/.direnv/flake-inputs/mhgnysbsr0yx44xlqvl7xymk8js22c7z-source @@ -0,0 +1 @@ +/nix/store/mhgnysbsr0yx44xlqvl7xymk8js22c7z-source \ No newline at end of file diff --git a/.direnv/flake-inputs/na7sykizsgkzh9i3wc8m8pz5xfqib2rv-source b/.direnv/flake-inputs/na7sykizsgkzh9i3wc8m8pz5xfqib2rv-source new file mode 120000 index 0000000..9cfec12 --- /dev/null +++ b/.direnv/flake-inputs/na7sykizsgkzh9i3wc8m8pz5xfqib2rv-source @@ -0,0 +1 @@ +/nix/store/na7sykizsgkzh9i3wc8m8pz5xfqib2rv-source \ No newline at end of file diff --git a/.direnv/flake-inputs/qkig73szmrhgp0qhncxy5vb36lw2g3jj-source b/.direnv/flake-inputs/qkig73szmrhgp0qhncxy5vb36lw2g3jj-source new file mode 120000 index 0000000..f7b4153 --- /dev/null +++ b/.direnv/flake-inputs/qkig73szmrhgp0qhncxy5vb36lw2g3jj-source @@ -0,0 +1 @@ +/nix/store/qkig73szmrhgp0qhncxy5vb36lw2g3jj-source \ No newline at end of file diff --git a/.direnv/flake-inputs/r2ip1850igy8kciyaagw502s3c6ph1s4-source b/.direnv/flake-inputs/r2ip1850igy8kciyaagw502s3c6ph1s4-source new file mode 120000 index 0000000..b1dabc8 --- /dev/null +++ b/.direnv/flake-inputs/r2ip1850igy8kciyaagw502s3c6ph1s4-source @@ -0,0 +1 @@ +/nix/store/r2ip1850igy8kciyaagw502s3c6ph1s4-source \ No newline at end of file diff --git a/.direnv/flake-inputs/s1cnnplqrk8w595dp9fb5cv84xj61lgx-source b/.direnv/flake-inputs/s1cnnplqrk8w595dp9fb5cv84xj61lgx-source new file mode 120000 index 0000000..3dbdc0c --- /dev/null +++ b/.direnv/flake-inputs/s1cnnplqrk8w595dp9fb5cv84xj61lgx-source @@ -0,0 +1 @@ +/nix/store/s1cnnplqrk8w595dp9fb5cv84xj61lgx-source \ No newline at end of file diff --git a/.direnv/flake-inputs/v1wzqsqi3d9fhdl60n24sqhj7pr3yhin-source b/.direnv/flake-inputs/v1wzqsqi3d9fhdl60n24sqhj7pr3yhin-source new file mode 120000 index 0000000..92d8c93 --- /dev/null +++ b/.direnv/flake-inputs/v1wzqsqi3d9fhdl60n24sqhj7pr3yhin-source @@ -0,0 +1 @@ +/nix/store/v1wzqsqi3d9fhdl60n24sqhj7pr3yhin-source \ No newline at end of file diff --git a/.direnv/flake-inputs/vm4qsaala00i8q5js7i3am3w0m766k1d-source b/.direnv/flake-inputs/vm4qsaala00i8q5js7i3am3w0m766k1d-source new file mode 120000 index 0000000..c859f5d --- /dev/null +++ b/.direnv/flake-inputs/vm4qsaala00i8q5js7i3am3w0m766k1d-source @@ -0,0 +1 @@ +/nix/store/vm4qsaala00i8q5js7i3am3w0m766k1d-source \ No newline at end of file diff --git a/.direnv/flake-inputs/vpddlysgdvzcqixkqgx49zyx2whhzpkb-source b/.direnv/flake-inputs/vpddlysgdvzcqixkqgx49zyx2whhzpkb-source new file mode 120000 index 0000000..4598043 --- /dev/null +++ b/.direnv/flake-inputs/vpddlysgdvzcqixkqgx49zyx2whhzpkb-source @@ -0,0 +1 @@ +/nix/store/vpddlysgdvzcqixkqgx49zyx2whhzpkb-source \ No newline at end of file diff --git a/.direnv/flake-inputs/vz580xz1w41n6m6x81mqgcrnp3y4cf41-source b/.direnv/flake-inputs/vz580xz1w41n6m6x81mqgcrnp3y4cf41-source new file mode 120000 index 0000000..959439c --- /dev/null +++ b/.direnv/flake-inputs/vz580xz1w41n6m6x81mqgcrnp3y4cf41-source @@ -0,0 +1 @@ +/nix/store/vz580xz1w41n6m6x81mqgcrnp3y4cf41-source \ No newline at end of file diff --git a/.direnv/flake-inputs/y1nw9w1s0ly6442igksfq29v0cfbnmfd-source b/.direnv/flake-inputs/y1nw9w1s0ly6442igksfq29v0cfbnmfd-source new file mode 120000 index 0000000..2578dc5 --- /dev/null +++ b/.direnv/flake-inputs/y1nw9w1s0ly6442igksfq29v0cfbnmfd-source @@ -0,0 +1 @@ +/nix/store/y1nw9w1s0ly6442igksfq29v0cfbnmfd-source \ No newline at end of file diff --git a/.direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source b/.direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source new file mode 120000 index 0000000..f17959f --- /dev/null +++ b/.direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source @@ -0,0 +1 @@ +/nix/store/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source \ No newline at end of file diff --git a/.direnv/flake-inputs/z9wkyy0bbdjfvsmkkw16bmn56502hd1k-source b/.direnv/flake-inputs/z9wkyy0bbdjfvsmkkw16bmn56502hd1k-source new file mode 120000 index 0000000..46f1bf1 --- /dev/null +++ b/.direnv/flake-inputs/z9wkyy0bbdjfvsmkkw16bmn56502hd1k-source @@ -0,0 +1 @@ +/nix/store/z9wkyy0bbdjfvsmkkw16bmn56502hd1k-source \ No newline at end of file diff --git a/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa b/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa new file mode 120000 index 0000000..5f70e53 --- /dev/null +++ b/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa @@ -0,0 +1 @@ +/nix/store/6mjq6r4lpd0xpxg65v2nqyfh3dvb17xm-devenv-shell-env \ No newline at end of file diff --git a/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc b/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc new file mode 100644 index 0000000..1e34c0a --- /dev/null +++ b/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc @@ -0,0 +1,1938 @@ +unset shellHook +PATH=${PATH:-} +nix_saved_PATH="$PATH" +XDG_DATA_DIRS=${XDG_DATA_DIRS:-} +nix_saved_XDG_DATA_DIRS="$XDG_DATA_DIRS" +AR='ar' +export AR +AS='as' +export AS +BASH='/nix/store/h3bhzvz9ipglcybbcvkxvm4vg9lwvqg4-bash-5.2p26/bin/bash' +CC='gcc' +export CC +CONFIG_SHELL='/nix/store/h3bhzvz9ipglcybbcvkxvm4vg9lwvqg4-bash-5.2p26/bin/bash' +export CONFIG_SHELL +CXX='g++' +export CXX +DEVENV_DOTFILE='/mnt/k/minky/trading/sdk/.devenv' +export DEVENV_DOTFILE +DEVENV_PROFILE='/nix/store/ya15x5s5b8w1visadax2ffndw4fknkmb-devenv-profile' +export DEVENV_PROFILE +DEVENV_ROOT='/mnt/k/minky/trading/sdk' +export DEVENV_ROOT +DEVENV_RUNTIME='/run/user/1000/devenv-503e649' +export DEVENV_RUNTIME +DEVENV_STATE='/mnt/k/minky/trading/sdk/.devenv/state' +export DEVENV_STATE +HOSTTYPE='x86_64' +HOST_PATH='/nix/store/ddypgcb25zgi0gwvklxlzazjrh9s63dg-coreutils-9.5/bin:/nix/store/y21vimynf3h666dvi4z8abzphw8ibibj-findutils-4.9.0/bin:/nix/store/4crhxg3dmy1n16h55rk6banv5xssmsyp-diffutils-3.10/bin:/nix/store/4cps736z7in3d37qc801lwv9z0ib67ps-gnused-4.9/bin:/nix/store/wy37jk2hirzqzx0666w1849kjdgzdam6-gnugrep-3.11/bin:/nix/store/a2ffqcqzbp8k4fmkyhpjq2km0i9wr8d8-gawk-5.2.2/bin:/nix/store/4m4vnjdy44s4sb8hlv4qsph492zz3rly-gnutar-1.35/bin:/nix/store/hragmx5p3izmwinv4441hj5706sxy4xs-gzip-1.13/bin:/nix/store/5giwsjx504zrgzl7cjzxm0s1423wndif-bzip2-1.0.8-bin/bin:/nix/store/qwcdasr63dfp74g7djazx48fx9s28i7a-gnumake-4.4.1/bin:/nix/store/h3bhzvz9ipglcybbcvkxvm4vg9lwvqg4-bash-5.2p26/bin:/nix/store/lj804cdk0fcf9yhgqrvgaqv2dc3lmfgp-patch-2.7.6/bin:/nix/store/3iiml9pwff4y6zsis1gp4apbry1h1wfr-xz-5.4.6-bin/bin:/nix/store/kaiq352476xq7zb1p06yranc5j3jjlz2-file-5.45/bin' +export HOST_PATH +IFS=' +' +IN_NIX_SHELL='impure' +export IN_NIX_SHELL +LD='ld' +export LD +LD_LIBRARY_PATH='/nix/store/mil8a9jgadf9jjd4a9fw88l9kqxzdd49-pkg-config-wrapper-0.29.2/lib:/nix/store/dpgf3v45qli2irgvzhlm90q0i54iwsra-fontconfig-2.15.0-dev/lib:/nix/store/d9dj22m1qpvcqr4b2skxwh467a6hlrsb-freetype-2.13.2-dev/lib:/nix/store/8f10pxi30lvkdjrkzfw5gzz4rzia8163-openssl-3.0.13/lib:/nix/store/93hz6i770d2awc6g37xj35kp5avnd4gk-protobuf-24.4/lib:/nix/store/h0aal69rli3p604dmijx7mps1diwx4f3-libX11-1.8.9/lib:/nix/store/h0aal69rli3p604dmijx7mps1diwx4f3-libX11-1.8.9/lib:/nix/store/h6h29n0pv86n3r70fdcl2b96kpblffj5-libXcursor-1.2.2/lib:/nix/store/83fywhh4p1bw1df21kjkiqs4dq24f6j7-libXi-1.8.1/lib:/nix/store/nn8n0jxm4wsphi1xlvynjw72176kkdg1-libXrandr-1.5.4/lib:/nix/store/sx108j0la4slxp8cr15kyg8jjy79p3dn-libxkbcommon-1.7.0/lib:/nix/store/2kl8zy4yql419zsywn9q65hrp4fsjnj2-wayland-1.22.0/lib:/nix/store/h6yiakrrww2js0ngakgr6ddxdjjp60sn-vulkan-tools-1.3.280.0/lib:/nix/store/71m8cqhw5b7d2bz2971n2n5i5xc383kw-vulkan-headers-1.3.280.0/lib:/nix/store/g4z99lhm1whxz58vcqq2snxin0kvhzc2-vulkan-validation-layers-1.3.280.0/lib:/nix/store/7rs73b2461wcsqsg6lahxy6v5cl4kj9v-vulkan-loader-1.3.280.0/lib:/nix/store/8f64rn26nd0cyy0brblzyn064fmcmy79-systemd-minimal-libs-255.4/lib:/nix/store/yl9krrpgc5gzz0r7djyhrcikdvxrn42w-openapi-generator-cli-7.5.0/lib' +export LD_LIBRARY_PATH +LINENO='76' +MACHTYPE='x86_64-pc-linux-gnu' +NIX_BINTOOLS='/nix/store/m3gq2f6iwh3g67zrs27m7w82b37l8gf8-binutils-wrapper-2.41' +export NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu='1' +export NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_BUILD_CORES='16' +export NIX_BUILD_CORES +NIX_CC='/nix/store/md6hh4rrcrf99nssvcam3qaqs3skj086-gcc-wrapper-13.2.0' +export NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu='1' +export NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE=' -frandom-seed=6mjq6r4lpd -isystem /nix/store/dpgf3v45qli2irgvzhlm90q0i54iwsra-fontconfig-2.15.0-dev/include -isystem /nix/store/d9dj22m1qpvcqr4b2skxwh467a6hlrsb-freetype-2.13.2-dev/include -isystem /nix/store/wz1lmhhmvjxj2ipp2z5mvkydchhljggm-zlib-1.3.1-dev/include -isystem /nix/store/cz5vp8p8rzlq46qwsh6bxh3ymxs70skp-bzip2-1.0.8-dev/include -isystem /nix/store/9m1zwv61brcjjnc36qrwvx67xmcfqajm-brotli-1.1.0-dev/include -isystem /nix/store/997rri8chjh3blxpf5i3dn5c8nzq2y60-libpng-apng-1.6.43-dev/include -isystem /nix/store/0bp9inq3wd4car25n60idlfics6fajjv-openssl-3.0.13-dev/include -isystem /nix/store/93hz6i770d2awc6g37xj35kp5avnd4gk-protobuf-24.4/include -isystem /nix/store/i005wwms9cd45ha5hp8qb3mv797xcdmg-abseil-cpp-20240116.2/include -isystem /nix/store/vy0l2k4kh51w7hkqbnakyapgvsmgbwmb-libX11-1.8.9-dev/include -isystem /nix/store/9yjmpbn9x09b29plxvzq8p5wyvn15ap1-xorgproto-2024.1/include -isystem /nix/store/5b1kh5bgxb4y2wyjd9mza5781k0jgllh-libxcb-1.17.0-dev/include -isystem /nix/store/sf2rr672wz6xalv0bcix9j944j9graq4-libXcursor-1.2.2-dev/include -isystem /nix/store/xacx6igvzsc2fcgcyjdqyr5swv8a399a-libXi-1.8.1-dev/include -isystem /nix/store/3qs7qkqqy2izngsxdlflly14f98ii5cv-libXfixes-6.0.1-dev/include -isystem /nix/store/kracbbdhivyy1hsmsy78g62g49fb4yyz-libXext-1.3.6-dev/include -isystem /nix/store/w4wkxc261brlclagwxr0icck54dhk68d-libXau-1.0.11-dev/include -isystem /nix/store/2yx26204avg40jmhgb5j5i3pxn2zv3ai-libXrandr-1.5.4-dev/include -isystem /nix/store/r11lq032drbzvblbd3vmv6i1nwczg4s7-libXrender-0.9.11-dev/include -isystem /nix/store/cqsd8hp3lhkvql8rpncd7glxk81lzqy2-libxkbcommon-1.7.0-dev/include -isystem /nix/store/hzbp77x0zjyrhgirym2l1ikr1r5p7b8g-wayland-1.22.0-dev/include -isystem /nix/store/71m8cqhw5b7d2bz2971n2n5i5xc383kw-vulkan-headers-1.3.280.0/include -isystem /nix/store/axvmifip8rq7w2caw42sgi23lzh8ff5m-systemd-minimal-libs-255.4-dev/include -isystem /nix/store/dpgf3v45qli2irgvzhlm90q0i54iwsra-fontconfig-2.15.0-dev/include -isystem /nix/store/d9dj22m1qpvcqr4b2skxwh467a6hlrsb-freetype-2.13.2-dev/include -isystem /nix/store/wz1lmhhmvjxj2ipp2z5mvkydchhljggm-zlib-1.3.1-dev/include -isystem /nix/store/cz5vp8p8rzlq46qwsh6bxh3ymxs70skp-bzip2-1.0.8-dev/include -isystem /nix/store/9m1zwv61brcjjnc36qrwvx67xmcfqajm-brotli-1.1.0-dev/include -isystem /nix/store/997rri8chjh3blxpf5i3dn5c8nzq2y60-libpng-apng-1.6.43-dev/include -isystem /nix/store/0bp9inq3wd4car25n60idlfics6fajjv-openssl-3.0.13-dev/include -isystem /nix/store/93hz6i770d2awc6g37xj35kp5avnd4gk-protobuf-24.4/include -isystem /nix/store/i005wwms9cd45ha5hp8qb3mv797xcdmg-abseil-cpp-20240116.2/include -isystem /nix/store/vy0l2k4kh51w7hkqbnakyapgvsmgbwmb-libX11-1.8.9-dev/include -isystem /nix/store/9yjmpbn9x09b29plxvzq8p5wyvn15ap1-xorgproto-2024.1/include -isystem /nix/store/5b1kh5bgxb4y2wyjd9mza5781k0jgllh-libxcb-1.17.0-dev/include -isystem /nix/store/sf2rr672wz6xalv0bcix9j944j9graq4-libXcursor-1.2.2-dev/include -isystem /nix/store/xacx6igvzsc2fcgcyjdqyr5swv8a399a-libXi-1.8.1-dev/include -isystem /nix/store/3qs7qkqqy2izngsxdlflly14f98ii5cv-libXfixes-6.0.1-dev/include -isystem /nix/store/kracbbdhivyy1hsmsy78g62g49fb4yyz-libXext-1.3.6-dev/include -isystem /nix/store/w4wkxc261brlclagwxr0icck54dhk68d-libXau-1.0.11-dev/include -isystem /nix/store/2yx26204avg40jmhgb5j5i3pxn2zv3ai-libXrandr-1.5.4-dev/include -isystem /nix/store/r11lq032drbzvblbd3vmv6i1nwczg4s7-libXrender-0.9.11-dev/include -isystem /nix/store/cqsd8hp3lhkvql8rpncd7glxk81lzqy2-libxkbcommon-1.7.0-dev/include -isystem /nix/store/hzbp77x0zjyrhgirym2l1ikr1r5p7b8g-wayland-1.22.0-dev/include -isystem /nix/store/71m8cqhw5b7d2bz2971n2n5i5xc383kw-vulkan-headers-1.3.280.0/include -isystem /nix/store/axvmifip8rq7w2caw42sgi23lzh8ff5m-systemd-minimal-libs-255.4-dev/include' +export NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE='1' +export NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE='bindnow format fortify fortify3 pic relro stackprotector strictoverflow' +export NIX_HARDENING_ENABLE +NIX_LDFLAGS='-rpath /mnt/k/minky/trading/sdk/outputs/out/lib -L/nix/store/nw1bnjadmzk9hnd4nbvxmqlh074vr16j-zlib-1.3.1/lib -L/nix/store/q4k8gmw2gpncglwdvz9fmqqwnynsb143-bzip2-1.0.8/lib -L/nix/store/qa2j4ql5vb7n1zyi8ai5acivsjkg0l8m-brotli-1.1.0-lib/lib -L/nix/store/31l4c9kwx37gy2cr1xiswbbp4azsyp1n-libpng-apng-1.6.43/lib -L/nix/store/8ilnvaa1d66z1qn866phpdx5jpam0lm7-freetype-2.13.2/lib -L/nix/store/b2f6xbjgm7zs6z0hrvmwpxhiacigc4nh-fontconfig-2.15.0-lib/lib -L/nix/store/8f10pxi30lvkdjrkzfw5gzz4rzia8163-openssl-3.0.13/lib -L/nix/store/93hz6i770d2awc6g37xj35kp5avnd4gk-protobuf-24.4/lib -L/nix/store/i005wwms9cd45ha5hp8qb3mv797xcdmg-abseil-cpp-20240116.2/lib -L/nix/store/cvbf30dc4mamggijbxwlwxaxd7q4wch1-libxcb-1.17.0/lib -L/nix/store/h0aal69rli3p604dmijx7mps1diwx4f3-libX11-1.8.9/lib -L/nix/store/h6h29n0pv86n3r70fdcl2b96kpblffj5-libXcursor-1.2.2/lib -L/nix/store/5qfaigrq13k1fkyvzzdzdwj7c4iiyayr-libXfixes-6.0.1/lib -L/nix/store/mhs3ys5lbahsvrai5y0fv49q2xp4pc31-libXau-1.0.11/lib -L/nix/store/pdikq8hwkj15d1jvlv48p98xn0xnn4dx-libXext-1.3.6/lib -L/nix/store/83fywhh4p1bw1df21kjkiqs4dq24f6j7-libXi-1.8.1/lib -L/nix/store/7hg9q26kil1lc0aph6ipx4lhg7zilbvv-libXrender-0.9.11/lib -L/nix/store/nn8n0jxm4wsphi1xlvynjw72176kkdg1-libXrandr-1.5.4/lib -L/nix/store/sx108j0la4slxp8cr15kyg8jjy79p3dn-libxkbcommon-1.7.0/lib -L/nix/store/2kl8zy4yql419zsywn9q65hrp4fsjnj2-wayland-1.22.0/lib -L/nix/store/g4z99lhm1whxz58vcqq2snxin0kvhzc2-vulkan-validation-layers-1.3.280.0/lib -L/nix/store/7rs73b2461wcsqsg6lahxy6v5cl4kj9v-vulkan-loader-1.3.280.0/lib -L/nix/store/8f64rn26nd0cyy0brblzyn064fmcmy79-systemd-minimal-libs-255.4/lib -L/nix/store/nw1bnjadmzk9hnd4nbvxmqlh074vr16j-zlib-1.3.1/lib -L/nix/store/q4k8gmw2gpncglwdvz9fmqqwnynsb143-bzip2-1.0.8/lib -L/nix/store/qa2j4ql5vb7n1zyi8ai5acivsjkg0l8m-brotli-1.1.0-lib/lib -L/nix/store/31l4c9kwx37gy2cr1xiswbbp4azsyp1n-libpng-apng-1.6.43/lib -L/nix/store/8ilnvaa1d66z1qn866phpdx5jpam0lm7-freetype-2.13.2/lib -L/nix/store/b2f6xbjgm7zs6z0hrvmwpxhiacigc4nh-fontconfig-2.15.0-lib/lib -L/nix/store/8f10pxi30lvkdjrkzfw5gzz4rzia8163-openssl-3.0.13/lib -L/nix/store/93hz6i770d2awc6g37xj35kp5avnd4gk-protobuf-24.4/lib -L/nix/store/i005wwms9cd45ha5hp8qb3mv797xcdmg-abseil-cpp-20240116.2/lib -L/nix/store/cvbf30dc4mamggijbxwlwxaxd7q4wch1-libxcb-1.17.0/lib -L/nix/store/h0aal69rli3p604dmijx7mps1diwx4f3-libX11-1.8.9/lib -L/nix/store/h6h29n0pv86n3r70fdcl2b96kpblffj5-libXcursor-1.2.2/lib -L/nix/store/5qfaigrq13k1fkyvzzdzdwj7c4iiyayr-libXfixes-6.0.1/lib -L/nix/store/mhs3ys5lbahsvrai5y0fv49q2xp4pc31-libXau-1.0.11/lib -L/nix/store/pdikq8hwkj15d1jvlv48p98xn0xnn4dx-libXext-1.3.6/lib -L/nix/store/83fywhh4p1bw1df21kjkiqs4dq24f6j7-libXi-1.8.1/lib -L/nix/store/7hg9q26kil1lc0aph6ipx4lhg7zilbvv-libXrender-0.9.11/lib -L/nix/store/nn8n0jxm4wsphi1xlvynjw72176kkdg1-libXrandr-1.5.4/lib -L/nix/store/sx108j0la4slxp8cr15kyg8jjy79p3dn-libxkbcommon-1.7.0/lib -L/nix/store/2kl8zy4yql419zsywn9q65hrp4fsjnj2-wayland-1.22.0/lib -L/nix/store/g4z99lhm1whxz58vcqq2snxin0kvhzc2-vulkan-validation-layers-1.3.280.0/lib -L/nix/store/7rs73b2461wcsqsg6lahxy6v5cl4kj9v-vulkan-loader-1.3.280.0/lib -L/nix/store/8f64rn26nd0cyy0brblzyn064fmcmy79-systemd-minimal-libs-255.4/lib' +export NIX_LDFLAGS +NIX_NO_SELF_RPATH='1' +NIX_PKG_CONFIG_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu='1' +export NIX_PKG_CONFIG_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_STORE='/nix/store' +export NIX_STORE +NM='nm' +export NM +OBJCOPY='objcopy' +export OBJCOPY +OBJDUMP='objdump' +export OBJDUMP +OLDPWD='' +export OLDPWD +OPTERR='1' +OSTYPE='linux-gnu' +PATH='/nix/store/9h3zp47lx4ppdm1ym032b7cgl4vs4i01-fmt/bin:/nix/store/rk740zddfkyj8i81xdwwkgyayr42w405-sanetrade/bin:/nix/store/mil8a9jgadf9jjd4a9fw88l9kqxzdd49-pkg-config-wrapper-0.29.2/bin:/nix/store/d9dj22m1qpvcqr4b2skxwh467a6hlrsb-freetype-2.13.2-dev/bin:/nix/store/5giwsjx504zrgzl7cjzxm0s1423wndif-bzip2-1.0.8-bin/bin:/nix/store/p5qmhrmy35sz6aqm4brds8hk9pcsm1db-brotli-1.1.0/bin:/nix/store/997rri8chjh3blxpf5i3dn5c8nzq2y60-libpng-apng-1.6.43-dev/bin:/nix/store/wd9k0b25bm9qp5q5qbkqc680xbgy1wmh-fontconfig-2.15.0-bin/bin:/nix/store/pmg30939m4ymrqy83fzyzrlhnzd69dl4-openssl-3.0.13-bin/bin:/nix/store/93hz6i770d2awc6g37xj35kp5avnd4gk-protobuf-24.4/bin:/nix/store/sx108j0la4slxp8cr15kyg8jjy79p3dn-libxkbcommon-1.7.0/bin:/nix/store/j2d9i3rsdnvrwrbygz8c7d7axyh6vqp3-wayland-1.22.0-bin/bin:/nix/store/h6yiakrrww2js0ngakgr6ddxdjjp60sn-vulkan-tools-1.3.280.0/bin:/nix/store/yl9krrpgc5gzz0r7djyhrcikdvxrn42w-openapi-generator-cli-7.5.0/bin:/nix/store/n74bf0rpsazxb9i23wlzidkzk017py3v-devenv/bin:/nix/store/8g7b1jkj5fpq1xcy5jgxfn9fxjwhxzvb-patchelf-0.15.0/bin:/nix/store/md6hh4rrcrf99nssvcam3qaqs3skj086-gcc-wrapper-13.2.0/bin:/nix/store/9hgsinpfgyvsd92v0wlvmxv9wnaal68r-gcc-13.2.0/bin:/nix/store/nkdgysx90pln2l562l7lsk021hbxjdg8-glibc-2.39-31-bin/bin:/nix/store/ddypgcb25zgi0gwvklxlzazjrh9s63dg-coreutils-9.5/bin:/nix/store/m3gq2f6iwh3g67zrs27m7w82b37l8gf8-binutils-wrapper-2.41/bin:/nix/store/nd7ass1isid4vswpkfm82za4mcdwhzsm-binutils-2.41/bin:/nix/store/ddypgcb25zgi0gwvklxlzazjrh9s63dg-coreutils-9.5/bin:/nix/store/y21vimynf3h666dvi4z8abzphw8ibibj-findutils-4.9.0/bin:/nix/store/4crhxg3dmy1n16h55rk6banv5xssmsyp-diffutils-3.10/bin:/nix/store/4cps736z7in3d37qc801lwv9z0ib67ps-gnused-4.9/bin:/nix/store/wy37jk2hirzqzx0666w1849kjdgzdam6-gnugrep-3.11/bin:/nix/store/a2ffqcqzbp8k4fmkyhpjq2km0i9wr8d8-gawk-5.2.2/bin:/nix/store/4m4vnjdy44s4sb8hlv4qsph492zz3rly-gnutar-1.35/bin:/nix/store/hragmx5p3izmwinv4441hj5706sxy4xs-gzip-1.13/bin:/nix/store/5giwsjx504zrgzl7cjzxm0s1423wndif-bzip2-1.0.8-bin/bin:/nix/store/qwcdasr63dfp74g7djazx48fx9s28i7a-gnumake-4.4.1/bin:/nix/store/h3bhzvz9ipglcybbcvkxvm4vg9lwvqg4-bash-5.2p26/bin:/nix/store/lj804cdk0fcf9yhgqrvgaqv2dc3lmfgp-patch-2.7.6/bin:/nix/store/3iiml9pwff4y6zsis1gp4apbry1h1wfr-xz-5.4.6-bin/bin:/nix/store/kaiq352476xq7zb1p06yranc5j3jjlz2-file-5.45/bin' +export PATH +PKG_CONFIG='pkg-config' +export PKG_CONFIG +PKG_CONFIG_PATH='/nix/store/dpgf3v45qli2irgvzhlm90q0i54iwsra-fontconfig-2.15.0-dev/lib/pkgconfig:/nix/store/d9dj22m1qpvcqr4b2skxwh467a6hlrsb-freetype-2.13.2-dev/lib/pkgconfig:/nix/store/wz1lmhhmvjxj2ipp2z5mvkydchhljggm-zlib-1.3.1-dev/lib/pkgconfig:/nix/store/cz5vp8p8rzlq46qwsh6bxh3ymxs70skp-bzip2-1.0.8-dev/lib/pkgconfig:/nix/store/9m1zwv61brcjjnc36qrwvx67xmcfqajm-brotli-1.1.0-dev/lib/pkgconfig:/nix/store/997rri8chjh3blxpf5i3dn5c8nzq2y60-libpng-apng-1.6.43-dev/lib/pkgconfig:/nix/store/0bp9inq3wd4car25n60idlfics6fajjv-openssl-3.0.13-dev/lib/pkgconfig:/nix/store/93hz6i770d2awc6g37xj35kp5avnd4gk-protobuf-24.4/lib/pkgconfig:/nix/store/i005wwms9cd45ha5hp8qb3mv797xcdmg-abseil-cpp-20240116.2/lib/pkgconfig:/nix/store/vy0l2k4kh51w7hkqbnakyapgvsmgbwmb-libX11-1.8.9-dev/lib/pkgconfig:/nix/store/9yjmpbn9x09b29plxvzq8p5wyvn15ap1-xorgproto-2024.1/share/pkgconfig:/nix/store/5b1kh5bgxb4y2wyjd9mza5781k0jgllh-libxcb-1.17.0-dev/lib/pkgconfig:/nix/store/sf2rr672wz6xalv0bcix9j944j9graq4-libXcursor-1.2.2-dev/lib/pkgconfig:/nix/store/xacx6igvzsc2fcgcyjdqyr5swv8a399a-libXi-1.8.1-dev/lib/pkgconfig:/nix/store/3qs7qkqqy2izngsxdlflly14f98ii5cv-libXfixes-6.0.1-dev/lib/pkgconfig:/nix/store/kracbbdhivyy1hsmsy78g62g49fb4yyz-libXext-1.3.6-dev/lib/pkgconfig:/nix/store/w4wkxc261brlclagwxr0icck54dhk68d-libXau-1.0.11-dev/lib/pkgconfig:/nix/store/2yx26204avg40jmhgb5j5i3pxn2zv3ai-libXrandr-1.5.4-dev/lib/pkgconfig:/nix/store/r11lq032drbzvblbd3vmv6i1nwczg4s7-libXrender-0.9.11-dev/lib/pkgconfig:/nix/store/cqsd8hp3lhkvql8rpncd7glxk81lzqy2-libxkbcommon-1.7.0-dev/lib/pkgconfig:/nix/store/hzbp77x0zjyrhgirym2l1ikr1r5p7b8g-wayland-1.22.0-dev/lib/pkgconfig:/nix/store/j2d9i3rsdnvrwrbygz8c7d7axyh6vqp3-wayland-1.22.0-bin/lib/pkgconfig:/nix/store/i5m3r5khf90fbhijcxjvh81j5vxm0k6f-vulkan-loader-1.3.280.0-dev/lib/pkgconfig:/nix/store/axvmifip8rq7w2caw42sgi23lzh8ff5m-systemd-minimal-libs-255.4-dev/lib/pkgconfig:/nix/store/axvmifip8rq7w2caw42sgi23lzh8ff5m-systemd-minimal-libs-255.4-dev/share/pkgconfig' +export PKG_CONFIG_PATH +PS4='+ ' +RANLIB='ranlib' +export RANLIB +READELF='readelf' +export READELF +SIZE='size' +export SIZE +SOURCE_DATE_EPOCH='315532800' +export SOURCE_DATE_EPOCH +STRINGS='strings' +export STRINGS +STRIP='strip' +export STRIP +XDG_DATA_DIRS='/nix/store/mil8a9jgadf9jjd4a9fw88l9kqxzdd49-pkg-config-wrapper-0.29.2/share:/nix/store/d9dj22m1qpvcqr4b2skxwh467a6hlrsb-freetype-2.13.2-dev/share:/nix/store/nw1bnjadmzk9hnd4nbvxmqlh074vr16j-zlib-1.3.1/share:/nix/store/p5qmhrmy35sz6aqm4brds8hk9pcsm1db-brotli-1.1.0/share:/nix/store/8ilnvaa1d66z1qn866phpdx5jpam0lm7-freetype-2.13.2/share:/nix/store/wd9k0b25bm9qp5q5qbkqc680xbgy1wmh-fontconfig-2.15.0-bin/share:/nix/store/b2f6xbjgm7zs6z0hrvmwpxhiacigc4nh-fontconfig-2.15.0-lib/share:/nix/store/9yjmpbn9x09b29plxvzq8p5wyvn15ap1-xorgproto-2024.1/share:/nix/store/h0aal69rli3p604dmijx7mps1diwx4f3-libX11-1.8.9/share:/nix/store/h6h29n0pv86n3r70fdcl2b96kpblffj5-libXcursor-1.2.2/share:/nix/store/5qfaigrq13k1fkyvzzdzdwj7c4iiyayr-libXfixes-6.0.1/share:/nix/store/mhs3ys5lbahsvrai5y0fv49q2xp4pc31-libXau-1.0.11/share:/nix/store/nn8n0jxm4wsphi1xlvynjw72176kkdg1-libXrandr-1.5.4/share:/nix/store/sx108j0la4slxp8cr15kyg8jjy79p3dn-libxkbcommon-1.7.0/share:/nix/store/hzbp77x0zjyrhgirym2l1ikr1r5p7b8g-wayland-1.22.0-dev/share:/nix/store/2kl8zy4yql419zsywn9q65hrp4fsjnj2-wayland-1.22.0/share:/nix/store/71m8cqhw5b7d2bz2971n2n5i5xc383kw-vulkan-headers-1.3.280.0/share:/nix/store/g4z99lhm1whxz58vcqq2snxin0kvhzc2-vulkan-validation-layers-1.3.280.0/share:/nix/store/axvmifip8rq7w2caw42sgi23lzh8ff5m-systemd-minimal-libs-255.4-dev/share:/nix/store/yl9krrpgc5gzz0r7djyhrcikdvxrn42w-openapi-generator-cli-7.5.0/share:/nix/store/8g7b1jkj5fpq1xcy5jgxfn9fxjwhxzvb-patchelf-0.15.0/share' +export XDG_DATA_DIRS +__structuredAttrs='' +export __structuredAttrs +_substituteStream_has_warned_replace_deprecation='false' +buildInputs='' +export buildInputs +buildPhase='{ echo "------------------------------------------------------------"; + echo " WARNING: the existence of this path is not guaranteed."; + echo " It is an internal implementation detail for pkgs.mkShell."; + echo "------------------------------------------------------------"; + echo; + # Record all build inputs as runtime dependencies + export; +} >> "$out" +' +export buildPhase +builder='/nix/store/h3bhzvz9ipglcybbcvkxvm4vg9lwvqg4-bash-5.2p26/bin/bash' +export builder +cmakeFlags='' +export cmakeFlags +configureFlags='' +export configureFlags +defaultBuildInputs='' +defaultNativeBuildInputs='/nix/store/8g7b1jkj5fpq1xcy5jgxfn9fxjwhxzvb-patchelf-0.15.0 /nix/store/b9mcp2as85ckbh8v0821y7z06fixypqx-update-autotools-gnu-config-scripts-hook /nix/store/h9lc1dpi14z7is86ffhl3ld569138595-audit-tmpdir.sh /nix/store/m54bmrhj6fqz8nds5zcj97w9s9bckc9v-compress-man-pages.sh /nix/store/wgrbkkaldkrlrni33ccvm3b6vbxzb656-make-symlinks-relative.sh /nix/store/5yzw0vhkyszf2d179m0qfkgxmp5wjjx4-move-docs.sh /nix/store/fyaryjvghbkpfnsyw97hb3lyb37s1pd6-move-lib64.sh /nix/store/kd4xwxjpjxi71jkm6ka0np72if9rm3y0-move-sbin.sh /nix/store/pag6l61paj1dc9sv15l7bm5c17xn5kyk-move-systemd-user-units.sh /nix/store/jivxp510zxakaaic7qkrb7v1dd2rdbw9-multiple-outputs.sh /nix/store/ilaf1w22bxi6jsi45alhmvvdgy4ly3zs-patch-shebangs.sh /nix/store/cickvswrvann041nqxb0rxilc46svw1n-prune-libtool-files.sh /nix/store/xyff06pkhki3qy1ls77w10s0v79c9il0-reproducible-builds.sh /nix/store/ngg1cv31c8c7bcm2n8ww4g06nq7s4zhm-set-source-date-epoch-to-latest.sh /nix/store/wmknncrif06fqxa16hpdldhixk95nds0-strip.sh /nix/store/md6hh4rrcrf99nssvcam3qaqs3skj086-gcc-wrapper-13.2.0' +depsBuildBuild='' +export depsBuildBuild +depsBuildBuildPropagated='' +export depsBuildBuildPropagated +depsBuildTarget='' +export depsBuildTarget +depsBuildTargetPropagated='' +export depsBuildTargetPropagated +depsHostHost='' +export depsHostHost +depsHostHostPropagated='' +export depsHostHostPropagated +depsTargetTarget='' +export depsTargetTarget +depsTargetTargetPropagated='' +export depsTargetTargetPropagated +doCheck='' +export doCheck +doInstallCheck='' +export doInstallCheck +dontAddDisableDepTrack='1' +export dontAddDisableDepTrack +declare -a envBuildBuildHooks=() +declare -a envBuildHostHooks=() +declare -a envBuildTargetHooks=() +declare -a envHostHostHooks=('pkgConfigWrapper_addPkgConfigPath' 'ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' ) +declare -a envHostTargetHooks=('pkgConfigWrapper_addPkgConfigPath' 'ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' ) +declare -a envTargetTargetHooks=() +declare -a fixupOutputHooks=('if [ -z "${dontPatchELF-}" ]; then patchELF "$prefix"; fi' 'if [[ -z "${noAuditTmpdir-}" && -e "$prefix" ]]; then auditTmpdir "$prefix"; fi' 'if [ -z "${dontGzipMan-}" ]; then compressManPages "$prefix"; fi' '_moveLib64' '_moveSbin' '_moveSystemdUserUnits' 'patchShebangsAuto' '_pruneLibtoolFiles' '_doStrip' ) +guess='16' +initialPath='/nix/store/ddypgcb25zgi0gwvklxlzazjrh9s63dg-coreutils-9.5 /nix/store/y21vimynf3h666dvi4z8abzphw8ibibj-findutils-4.9.0 /nix/store/4crhxg3dmy1n16h55rk6banv5xssmsyp-diffutils-3.10 /nix/store/4cps736z7in3d37qc801lwv9z0ib67ps-gnused-4.9 /nix/store/wy37jk2hirzqzx0666w1849kjdgzdam6-gnugrep-3.11 /nix/store/a2ffqcqzbp8k4fmkyhpjq2km0i9wr8d8-gawk-5.2.2 /nix/store/4m4vnjdy44s4sb8hlv4qsph492zz3rly-gnutar-1.35 /nix/store/hragmx5p3izmwinv4441hj5706sxy4xs-gzip-1.13 /nix/store/5giwsjx504zrgzl7cjzxm0s1423wndif-bzip2-1.0.8-bin /nix/store/qwcdasr63dfp74g7djazx48fx9s28i7a-gnumake-4.4.1 /nix/store/h3bhzvz9ipglcybbcvkxvm4vg9lwvqg4-bash-5.2p26 /nix/store/lj804cdk0fcf9yhgqrvgaqv2dc3lmfgp-patch-2.7.6 /nix/store/3iiml9pwff4y6zsis1gp4apbry1h1wfr-xz-5.4.6-bin /nix/store/kaiq352476xq7zb1p06yranc5j3jjlz2-file-5.45' +mesonFlags='' +export mesonFlags +name='devenv-shell-env' +export name +nativeBuildInputs='/nix/store/9h3zp47lx4ppdm1ym032b7cgl4vs4i01-fmt /nix/store/rk740zddfkyj8i81xdwwkgyayr42w405-sanetrade /nix/store/mil8a9jgadf9jjd4a9fw88l9kqxzdd49-pkg-config-wrapper-0.29.2 /nix/store/dpgf3v45qli2irgvzhlm90q0i54iwsra-fontconfig-2.15.0-dev /nix/store/d9dj22m1qpvcqr4b2skxwh467a6hlrsb-freetype-2.13.2-dev /nix/store/0bp9inq3wd4car25n60idlfics6fajjv-openssl-3.0.13-dev /nix/store/93hz6i770d2awc6g37xj35kp5avnd4gk-protobuf-24.4 /nix/store/vy0l2k4kh51w7hkqbnakyapgvsmgbwmb-libX11-1.8.9-dev /nix/store/vy0l2k4kh51w7hkqbnakyapgvsmgbwmb-libX11-1.8.9-dev /nix/store/sf2rr672wz6xalv0bcix9j944j9graq4-libXcursor-1.2.2-dev /nix/store/xacx6igvzsc2fcgcyjdqyr5swv8a399a-libXi-1.8.1-dev /nix/store/2yx26204avg40jmhgb5j5i3pxn2zv3ai-libXrandr-1.5.4-dev /nix/store/cqsd8hp3lhkvql8rpncd7glxk81lzqy2-libxkbcommon-1.7.0-dev /nix/store/hzbp77x0zjyrhgirym2l1ikr1r5p7b8g-wayland-1.22.0-dev /nix/store/h6yiakrrww2js0ngakgr6ddxdjjp60sn-vulkan-tools-1.3.280.0 /nix/store/71m8cqhw5b7d2bz2971n2n5i5xc383kw-vulkan-headers-1.3.280.0 /nix/store/g4z99lhm1whxz58vcqq2snxin0kvhzc2-vulkan-validation-layers-1.3.280.0 /nix/store/i5m3r5khf90fbhijcxjvh81j5vxm0k6f-vulkan-loader-1.3.280.0-dev /nix/store/axvmifip8rq7w2caw42sgi23lzh8ff5m-systemd-minimal-libs-255.4-dev /nix/store/yl9krrpgc5gzz0r7djyhrcikdvxrn42w-openapi-generator-cli-7.5.0 /nix/store/n74bf0rpsazxb9i23wlzidkzk017py3v-devenv /nix/store/mil8a9jgadf9jjd4a9fw88l9kqxzdd49-pkg-config-wrapper-0.29.2' +export nativeBuildInputs +out='/mnt/k/minky/trading/sdk/outputs/out' +export out +outputBin='out' +outputDev='out' +outputDevdoc='REMOVE' +outputDevman='out' +outputDoc='out' +outputInclude='out' +outputInfo='out' +outputLib='out' +outputMan='out' +outputs='out' +export outputs +patches='' +export patches +phases='buildPhase' +export phases +pkg='/nix/store/md6hh4rrcrf99nssvcam3qaqs3skj086-gcc-wrapper-13.2.0' +declare -a pkgsBuildBuild=() +declare -a pkgsBuildHost=('/nix/store/9h3zp47lx4ppdm1ym032b7cgl4vs4i01-fmt' '/nix/store/rk740zddfkyj8i81xdwwkgyayr42w405-sanetrade' '/nix/store/mil8a9jgadf9jjd4a9fw88l9kqxzdd49-pkg-config-wrapper-0.29.2' '/nix/store/dpgf3v45qli2irgvzhlm90q0i54iwsra-fontconfig-2.15.0-dev' '/nix/store/d9dj22m1qpvcqr4b2skxwh467a6hlrsb-freetype-2.13.2-dev' '/nix/store/wz1lmhhmvjxj2ipp2z5mvkydchhljggm-zlib-1.3.1-dev' '/nix/store/nw1bnjadmzk9hnd4nbvxmqlh074vr16j-zlib-1.3.1' '/nix/store/cz5vp8p8rzlq46qwsh6bxh3ymxs70skp-bzip2-1.0.8-dev' '/nix/store/5giwsjx504zrgzl7cjzxm0s1423wndif-bzip2-1.0.8-bin' '/nix/store/q4k8gmw2gpncglwdvz9fmqqwnynsb143-bzip2-1.0.8' '/nix/store/9m1zwv61brcjjnc36qrwvx67xmcfqajm-brotli-1.1.0-dev' '/nix/store/qa2j4ql5vb7n1zyi8ai5acivsjkg0l8m-brotli-1.1.0-lib' '/nix/store/p5qmhrmy35sz6aqm4brds8hk9pcsm1db-brotli-1.1.0' '/nix/store/997rri8chjh3blxpf5i3dn5c8nzq2y60-libpng-apng-1.6.43-dev' '/nix/store/31l4c9kwx37gy2cr1xiswbbp4azsyp1n-libpng-apng-1.6.43' '/nix/store/8ilnvaa1d66z1qn866phpdx5jpam0lm7-freetype-2.13.2' '/nix/store/wd9k0b25bm9qp5q5qbkqc680xbgy1wmh-fontconfig-2.15.0-bin' '/nix/store/b2f6xbjgm7zs6z0hrvmwpxhiacigc4nh-fontconfig-2.15.0-lib' '/nix/store/0bp9inq3wd4car25n60idlfics6fajjv-openssl-3.0.13-dev' '/nix/store/pmg30939m4ymrqy83fzyzrlhnzd69dl4-openssl-3.0.13-bin' '/nix/store/8f10pxi30lvkdjrkzfw5gzz4rzia8163-openssl-3.0.13' '/nix/store/93hz6i770d2awc6g37xj35kp5avnd4gk-protobuf-24.4' '/nix/store/i005wwms9cd45ha5hp8qb3mv797xcdmg-abseil-cpp-20240116.2' '/nix/store/vy0l2k4kh51w7hkqbnakyapgvsmgbwmb-libX11-1.8.9-dev' '/nix/store/9yjmpbn9x09b29plxvzq8p5wyvn15ap1-xorgproto-2024.1' '/nix/store/5b1kh5bgxb4y2wyjd9mza5781k0jgllh-libxcb-1.17.0-dev' '/nix/store/cvbf30dc4mamggijbxwlwxaxd7q4wch1-libxcb-1.17.0' '/nix/store/h0aal69rli3p604dmijx7mps1diwx4f3-libX11-1.8.9' '/nix/store/sf2rr672wz6xalv0bcix9j944j9graq4-libXcursor-1.2.2-dev' '/nix/store/h6h29n0pv86n3r70fdcl2b96kpblffj5-libXcursor-1.2.2' '/nix/store/xacx6igvzsc2fcgcyjdqyr5swv8a399a-libXi-1.8.1-dev' '/nix/store/3qs7qkqqy2izngsxdlflly14f98ii5cv-libXfixes-6.0.1-dev' '/nix/store/5qfaigrq13k1fkyvzzdzdwj7c4iiyayr-libXfixes-6.0.1' '/nix/store/kracbbdhivyy1hsmsy78g62g49fb4yyz-libXext-1.3.6-dev' '/nix/store/w4wkxc261brlclagwxr0icck54dhk68d-libXau-1.0.11-dev' '/nix/store/mhs3ys5lbahsvrai5y0fv49q2xp4pc31-libXau-1.0.11' '/nix/store/pdikq8hwkj15d1jvlv48p98xn0xnn4dx-libXext-1.3.6' '/nix/store/83fywhh4p1bw1df21kjkiqs4dq24f6j7-libXi-1.8.1' '/nix/store/2yx26204avg40jmhgb5j5i3pxn2zv3ai-libXrandr-1.5.4-dev' '/nix/store/r11lq032drbzvblbd3vmv6i1nwczg4s7-libXrender-0.9.11-dev' '/nix/store/7hg9q26kil1lc0aph6ipx4lhg7zilbvv-libXrender-0.9.11' '/nix/store/nn8n0jxm4wsphi1xlvynjw72176kkdg1-libXrandr-1.5.4' '/nix/store/cqsd8hp3lhkvql8rpncd7glxk81lzqy2-libxkbcommon-1.7.0-dev' '/nix/store/sx108j0la4slxp8cr15kyg8jjy79p3dn-libxkbcommon-1.7.0' '/nix/store/hzbp77x0zjyrhgirym2l1ikr1r5p7b8g-wayland-1.22.0-dev' '/nix/store/j2d9i3rsdnvrwrbygz8c7d7axyh6vqp3-wayland-1.22.0-bin' '/nix/store/2kl8zy4yql419zsywn9q65hrp4fsjnj2-wayland-1.22.0' '/nix/store/h6yiakrrww2js0ngakgr6ddxdjjp60sn-vulkan-tools-1.3.280.0' '/nix/store/71m8cqhw5b7d2bz2971n2n5i5xc383kw-vulkan-headers-1.3.280.0' '/nix/store/g4z99lhm1whxz58vcqq2snxin0kvhzc2-vulkan-validation-layers-1.3.280.0' '/nix/store/i5m3r5khf90fbhijcxjvh81j5vxm0k6f-vulkan-loader-1.3.280.0-dev' '/nix/store/7rs73b2461wcsqsg6lahxy6v5cl4kj9v-vulkan-loader-1.3.280.0' '/nix/store/axvmifip8rq7w2caw42sgi23lzh8ff5m-systemd-minimal-libs-255.4-dev' '/nix/store/8f64rn26nd0cyy0brblzyn064fmcmy79-systemd-minimal-libs-255.4' '/nix/store/yl9krrpgc5gzz0r7djyhrcikdvxrn42w-openapi-generator-cli-7.5.0' '/nix/store/n74bf0rpsazxb9i23wlzidkzk017py3v-devenv' '/nix/store/8g7b1jkj5fpq1xcy5jgxfn9fxjwhxzvb-patchelf-0.15.0' '/nix/store/b9mcp2as85ckbh8v0821y7z06fixypqx-update-autotools-gnu-config-scripts-hook' '/nix/store/h9lc1dpi14z7is86ffhl3ld569138595-audit-tmpdir.sh' '/nix/store/m54bmrhj6fqz8nds5zcj97w9s9bckc9v-compress-man-pages.sh' '/nix/store/wgrbkkaldkrlrni33ccvm3b6vbxzb656-make-symlinks-relative.sh' '/nix/store/5yzw0vhkyszf2d179m0qfkgxmp5wjjx4-move-docs.sh' '/nix/store/fyaryjvghbkpfnsyw97hb3lyb37s1pd6-move-lib64.sh' '/nix/store/kd4xwxjpjxi71jkm6ka0np72if9rm3y0-move-sbin.sh' '/nix/store/pag6l61paj1dc9sv15l7bm5c17xn5kyk-move-systemd-user-units.sh' '/nix/store/jivxp510zxakaaic7qkrb7v1dd2rdbw9-multiple-outputs.sh' '/nix/store/ilaf1w22bxi6jsi45alhmvvdgy4ly3zs-patch-shebangs.sh' '/nix/store/cickvswrvann041nqxb0rxilc46svw1n-prune-libtool-files.sh' '/nix/store/xyff06pkhki3qy1ls77w10s0v79c9il0-reproducible-builds.sh' '/nix/store/ngg1cv31c8c7bcm2n8ww4g06nq7s4zhm-set-source-date-epoch-to-latest.sh' '/nix/store/wmknncrif06fqxa16hpdldhixk95nds0-strip.sh' '/nix/store/md6hh4rrcrf99nssvcam3qaqs3skj086-gcc-wrapper-13.2.0' '/nix/store/m3gq2f6iwh3g67zrs27m7w82b37l8gf8-binutils-wrapper-2.41' ) +declare -a pkgsBuildTarget=() +declare -a pkgsHostHost=() +declare -a pkgsHostTarget=() +declare -a pkgsTargetTarget=() +declare -a postFixupHooks=('_makeSymlinksRelativeInAllOutputs' '_multioutPropagateDev' ) +declare -a postUnpackHooks=('_updateSourceDateEpochFromSourceRoot' ) +declare -a preConfigureHooks=('_multioutConfig' ) +preConfigurePhases=' updateAutotoolsGnuConfigScriptsPhase' +declare -a preFixupHooks=('_moveToShare' '_multioutDocs' '_multioutDevs' ) +preferLocalBuild='1' +export preferLocalBuild +prefix='/mnt/k/minky/trading/sdk/outputs/out' +declare -a propagatedBuildDepFiles=('propagated-build-build-deps' 'propagated-native-build-inputs' 'propagated-build-target-deps' ) +propagatedBuildInputs='' +export propagatedBuildInputs +declare -a propagatedHostDepFiles=('propagated-host-host-deps' 'propagated-build-inputs' ) +propagatedNativeBuildInputs='' +export propagatedNativeBuildInputs +declare -a propagatedTargetDepFiles=('propagated-target-target-deps' ) +shell='/nix/store/h3bhzvz9ipglcybbcvkxvm4vg9lwvqg4-bash-5.2p26/bin/bash' +export shell +shellHook=' + +export PS1="\[\e[0;34m\](devenv)\[\e[0m\] ${PS1-}" + +# set path to locales on non-NixOS Linux hosts +if [ -z "${LOCALE_ARCHIVE-}" ]; then + export LOCALE_ARCHIVE=/nix/store/27gwcgljdp3h71791mz2ymfy1wjzppsk-glibc-locales-2.39-31/lib/locale/locale-archive +fi + + +# note what environments are active, but make sure we don'\''t repeat them +if [[ ! "${DIRENV_ACTIVE-}" =~ (^|:)"$PWD"(:|$) ]]; then + export DIRENV_ACTIVE="$PWD:${DIRENV_ACTIVE-}" +fi + +# devenv helper +if [ ! type -p direnv &>/dev/null && -f .envrc ]; then + echo "You have .envrc but direnv command is not installed." + echo "Please install direnv: https://direnv.net/docs/installation.html" +fi + +mkdir -p "$DEVENV_STATE" +if [ ! -L "$DEVENV_DOTFILE/profile" ] || [ "$(/nix/store/ddypgcb25zgi0gwvklxlzazjrh9s63dg-coreutils-9.5/bin/readlink $DEVENV_DOTFILE/profile)" != "/nix/store/ya15x5s5b8w1visadax2ffndw4fknkmb-devenv-profile" ] +then + ln -snf /nix/store/ya15x5s5b8w1visadax2ffndw4fknkmb-devenv-profile "$DEVENV_DOTFILE/profile" +fi +unset HOST_PATH NIX_BUILD_CORES __structuredAttrs buildInputs buildPhase builder depsBuildBuild depsBuildBuildPropagated depsBuildTarget depsBuildTargetPropagated depsHostHost depsHostHostPropagated depsTargetTarget depsTargetTargetPropagated dontAddDisableDepTrack doCheck doInstallCheck nativeBuildInputs out outputs patches phases preferLocalBuild propagatedBuildInputs propagatedNativeBuildInputs shell shellHook stdenv strictDeps + +mkdir -p '\''/run/user/1000/devenv-503e649'\'' +ln -snf '\''/run/user/1000/devenv-503e649'\'' '\''/mnt/k/minky/trading/sdk/.devenv'\''/run + +' +export shellHook +stdenv='/nix/store/wq046wv3s3h4m2n9ak3j534di2pzra93-stdenv-linux' +export stdenv +strictDeps='' +export strictDeps +system='x86_64-linux' +export system +declare -a unpackCmdHooks=('_defaultUnpack' ) +_accumFlagsArray () +{ + + local name; + if [ -n "$__structuredAttrs" ]; then + for name in "$@"; + do + local -n nameref="$name"; + flagsArray+=(${nameref+"${nameref[@]}"}); + done; + else + for name in "$@"; + do + local -n nameref="$name"; + case "$name" in + *Array) + flagsArray+=(${nameref+"${nameref[@]}"}) + ;; + *) + flagsArray+=(${nameref-}) + ;; + esac; + done; + fi +} +_activatePkgs () +{ + + local hostOffset targetOffset; + local pkg; + for hostOffset in "${allPlatOffsets[@]}"; + do + local pkgsVar="${pkgAccumVarVars[hostOffset + 1]}"; + for targetOffset in "${allPlatOffsets[@]}"; + do + (( hostOffset <= targetOffset )) || continue; + local pkgsRef="${pkgsVar}[$targetOffset - $hostOffset]"; + local pkgsSlice="${!pkgsRef}[@]"; + for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; + do + activatePackage "$pkg" "$hostOffset" "$targetOffset"; + done; + done; + done +} +_addRpathPrefix () +{ + + if [ "${NIX_NO_SELF_RPATH:-0}" != 1 ]; then + export NIX_LDFLAGS="-rpath $1/lib ${NIX_LDFLAGS-}"; + fi +} +_addToEnv () +{ + + local depHostOffset depTargetOffset; + local pkg; + for depHostOffset in "${allPlatOffsets[@]}"; + do + local hookVar="${pkgHookVarVars[depHostOffset + 1]}"; + local pkgsVar="${pkgAccumVarVars[depHostOffset + 1]}"; + for depTargetOffset in "${allPlatOffsets[@]}"; + do + (( depHostOffset <= depTargetOffset )) || continue; + local hookRef="${hookVar}[$depTargetOffset - $depHostOffset]"; + if [[ -z "${strictDeps-}" ]]; then + local visitedPkgs=""; + for pkg in "${pkgsBuildBuild[@]}" "${pkgsBuildHost[@]}" "${pkgsBuildTarget[@]}" "${pkgsHostHost[@]}" "${pkgsHostTarget[@]}" "${pkgsTargetTarget[@]}"; + do + if [[ "$visitedPkgs" = *"$pkg"* ]]; then + continue; + fi; + runHook "${!hookRef}" "$pkg"; + visitedPkgs+=" $pkg"; + done; + else + local pkgsRef="${pkgsVar}[$depTargetOffset - $depHostOffset]"; + local pkgsSlice="${!pkgsRef}[@]"; + for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; + do + runHook "${!hookRef}" "$pkg"; + done; + fi; + done; + done +} +_allFlags () +{ + + export system pname name version; + for varName in $(awk 'BEGIN { for (v in ENVIRON) if (v ~ /^[a-z][a-zA-Z0-9_]*$/) print v }'); + do + if (( "${NIX_DEBUG:-0}" >= 1 )); then + printf "@%s@ -> %q\n" "${varName}" "${!varName}" 1>&2; + fi; + args+=("--subst-var" "$varName"); + done +} +_assignFirst () +{ + + local varName="$1"; + local _var; + local REMOVE=REMOVE; + shift; + for _var in "$@"; + do + if [ -n "${!_var-}" ]; then + eval "${varName}"="${_var}"; + return; + fi; + done; + echo; + echo "error: _assignFirst: could not find a non-empty variable whose name to assign to ${varName}."; + echo " The following variables were all unset or empty:"; + echo " $*"; + if [ -z "${out:-}" ]; then + echo ' If you do not want an "out" output in your derivation, make sure to define'; + echo ' the other specific required outputs. This can be achieved by picking one'; + echo " of the above as an output."; + echo ' You do not have to remove "out" if you want to have a different default'; + echo ' output, because the first output is taken as a default.'; + echo; + fi; + return 1 +} +_callImplicitHook () +{ + + local def="$1"; + local hookName="$2"; + if declare -F "$hookName" > /dev/null; then + "$hookName"; + else + if type -p "$hookName" > /dev/null; then + source "$hookName"; + else + if [ -n "${!hookName:-}" ]; then + eval "${!hookName}"; + else + return "$def"; + fi; + fi; + fi +} +_defaultUnpack () +{ + + local fn="$1"; + local destination; + if [ -d "$fn" ]; then + destination="$(stripHash "$fn")"; + if [ -e "$destination" ]; then + echo "Cannot copy $fn to $destination: destination already exists!"; + echo "Did you specify two \"srcs\" with the same \"name\"?"; + return 1; + fi; + cp -pr --reflink=auto -- "$fn" "$destination"; + else + case "$fn" in + *.tar.xz | *.tar.lzma | *.txz) + ( XZ_OPT="--threads=$NIX_BUILD_CORES" xz -d < "$fn"; + true ) | tar xf - --mode=+w --warning=no-timestamp + ;; + *.tar | *.tar.* | *.tgz | *.tbz2 | *.tbz) + tar xf "$fn" --mode=+w --warning=no-timestamp + ;; + *) + return 1 + ;; + esac; + fi +} +_doStrip () +{ + + local -ra flags=(dontStripHost dontStripTarget); + local -ra debugDirs=(stripDebugList stripDebugListTarget); + local -ra allDirs=(stripAllList stripAllListTarget); + local -ra stripCmds=(STRIP STRIP_FOR_TARGET); + local -ra ranlibCmds=(RANLIB RANLIB_FOR_TARGET); + stripDebugList=${stripDebugList[*]:-lib lib32 lib64 libexec bin sbin}; + stripDebugListTarget=${stripDebugListTarget[*]:-}; + stripAllList=${stripAllList[*]:-}; + stripAllListTarget=${stripAllListTarget[*]:-}; + local i; + for i in ${!stripCmds[@]}; + do + local -n flag="${flags[$i]}"; + local -n debugDirList="${debugDirs[$i]}"; + local -n allDirList="${allDirs[$i]}"; + local -n stripCmd="${stripCmds[$i]}"; + local -n ranlibCmd="${ranlibCmds[$i]}"; + if [[ -n "${dontStrip-}" || -n "${flag-}" ]] || ! type -f "${stripCmd-}" 2> /dev/null 1>&2; then + continue; + fi; + stripDirs "$stripCmd" "$ranlibCmd" "$debugDirList" "${stripDebugFlags[*]:--S -p}"; + stripDirs "$stripCmd" "$ranlibCmd" "$allDirList" "${stripAllFlags[*]:--s -p}"; + done +} +_eval () +{ + + if declare -F "$1" > /dev/null 2>&1; then + "$@"; + else + eval "$1"; + fi +} +_makeSymlinksRelative () +{ + + local symlinkTarget; + if [ "${dontRewriteSymlinks-}" ] || [ ! -e "$prefix" ]; then + return; + fi; + while IFS= read -r -d '' f; do + symlinkTarget=$(readlink "$f"); + if [[ "$symlinkTarget"/ != "$prefix"/* ]]; then + continue; + fi; + if [ ! -e "$symlinkTarget" ]; then + echo "the symlink $f is broken, it points to $symlinkTarget (which is missing)"; + fi; + echo "rewriting symlink $f to be relative to $prefix"; + ln -snrf "$symlinkTarget" "$f"; + done < <(find $prefix -type l -print0) +} +_makeSymlinksRelativeInAllOutputs () +{ + + local output; + for output in $(getAllOutputNames); + do + prefix="${!output}" _makeSymlinksRelative; + done +} +_moveLib64 () +{ + + if [ "${dontMoveLib64-}" = 1 ]; then + return; + fi; + if [ ! -e "$prefix/lib64" -o -L "$prefix/lib64" ]; then + return; + fi; + echo "moving $prefix/lib64/* to $prefix/lib"; + mkdir -p $prefix/lib; + shopt -s dotglob; + for i in $prefix/lib64/*; + do + mv --no-clobber "$i" $prefix/lib; + done; + shopt -u dotglob; + rmdir $prefix/lib64; + ln -s lib $prefix/lib64 +} +_moveSbin () +{ + + if [ "${dontMoveSbin-}" = 1 ]; then + return; + fi; + if [ ! -e "$prefix/sbin" -o -L "$prefix/sbin" ]; then + return; + fi; + echo "moving $prefix/sbin/* to $prefix/bin"; + mkdir -p $prefix/bin; + shopt -s dotglob; + for i in $prefix/sbin/*; + do + mv "$i" $prefix/bin; + done; + shopt -u dotglob; + rmdir $prefix/sbin; + ln -s bin $prefix/sbin +} +_moveSystemdUserUnits () +{ + + if [ "${dontMoveSystemdUserUnits:-0}" = 1 ]; then + return; + fi; + if [ ! -e "${prefix:?}/lib/systemd/user" ]; then + return; + fi; + local source="$prefix/lib/systemd/user"; + local target="$prefix/share/systemd/user"; + echo "moving $source/* to $target"; + mkdir -p "$target"; + ( shopt -s dotglob; + for i in "$source"/*; + do + mv "$i" "$target"; + done ); + rmdir "$source"; + ln -s "$target" "$source" +} +_moveToShare () +{ + + if [ -n "$__structuredAttrs" ]; then + if [ -z "${forceShare-}" ]; then + forceShare=(man doc info); + fi; + else + forceShare=(${forceShare:-man doc info}); + fi; + if [[ -z "$out" ]]; then + return; + fi; + for d in "${forceShare[@]}"; + do + if [ -d "$out/$d" ]; then + if [ -d "$out/share/$d" ]; then + echo "both $d/ and share/$d/ exist!"; + else + echo "moving $out/$d to $out/share/$d"; + mkdir -p $out/share; + mv $out/$d $out/share/; + fi; + fi; + done +} +_multioutConfig () +{ + + if [ "$(getAllOutputNames)" = "out" ] || [ -z "${setOutputFlags-1}" ]; then + return; + fi; + if [ -z "${shareDocName:-}" ]; then + local confScript="${configureScript:-}"; + if [ -z "$confScript" ] && [ -x ./configure ]; then + confScript=./configure; + fi; + if [ -f "$confScript" ]; then + local shareDocName="$(sed -n "s/^PACKAGE_TARNAME='\(.*\)'$/\1/p" < "$confScript")"; + fi; + if [ -z "$shareDocName" ] || echo "$shareDocName" | grep -q '[^a-zA-Z0-9_-]'; then + shareDocName="$(echo "$name" | sed 's/-[^a-zA-Z].*//')"; + fi; + fi; + prependToVar configureFlags --bindir="${!outputBin}"/bin --sbindir="${!outputBin}"/sbin --includedir="${!outputInclude}"/include --oldincludedir="${!outputInclude}"/include --mandir="${!outputMan}"/share/man --infodir="${!outputInfo}"/share/info --docdir="${!outputDoc}"/share/doc/"${shareDocName}" --libdir="${!outputLib}"/lib --libexecdir="${!outputLib}"/libexec --localedir="${!outputLib}"/share/locale; + prependToVar installFlags pkgconfigdir="${!outputDev}"/lib/pkgconfig m4datadir="${!outputDev}"/share/aclocal aclocaldir="${!outputDev}"/share/aclocal +} +_multioutDevs () +{ + + if [ "$(getAllOutputNames)" = "out" ] || [ -z "${moveToDev-1}" ]; then + return; + fi; + moveToOutput include "${!outputInclude}"; + moveToOutput lib/pkgconfig "${!outputDev}"; + moveToOutput share/pkgconfig "${!outputDev}"; + moveToOutput lib/cmake "${!outputDev}"; + moveToOutput share/aclocal "${!outputDev}"; + for f in "${!outputDev}"/{lib,share}/pkgconfig/*.pc; + do + echo "Patching '$f' includedir to output ${!outputInclude}"; + sed -i "/^includedir=/s,=\${prefix},=${!outputInclude}," "$f"; + done +} +_multioutDocs () +{ + + local REMOVE=REMOVE; + moveToOutput share/info "${!outputInfo}"; + moveToOutput share/doc "${!outputDoc}"; + moveToOutput share/gtk-doc "${!outputDevdoc}"; + moveToOutput share/devhelp/books "${!outputDevdoc}"; + moveToOutput share/man "${!outputMan}"; + moveToOutput share/man/man3 "${!outputDevman}" +} +_multioutPropagateDev () +{ + + if [ "$(getAllOutputNames)" = "out" ]; then + return; + fi; + local outputFirst; + for outputFirst in $(getAllOutputNames); + do + break; + done; + local propagaterOutput="$outputDev"; + if [ -z "$propagaterOutput" ]; then + propagaterOutput="$outputFirst"; + fi; + if [ -z "${propagatedBuildOutputs+1}" ]; then + local po_dirty="$outputBin $outputInclude $outputLib"; + set +o pipefail; + propagatedBuildOutputs=`echo "$po_dirty" | tr -s ' ' '\n' | grep -v -F "$propagaterOutput" | sort -u | tr '\n' ' ' `; + set -o pipefail; + fi; + if [ -z "$propagatedBuildOutputs" ]; then + return; + fi; + mkdir -p "${!propagaterOutput}"/nix-support; + for output in $propagatedBuildOutputs; + do + echo -n " ${!output}" >> "${!propagaterOutput}"/nix-support/propagated-build-inputs; + done +} +_overrideFirst () +{ + + if [ -z "${!1-}" ]; then + _assignFirst "$@"; + fi +} +_pruneLibtoolFiles () +{ + + if [ "${dontPruneLibtoolFiles-}" ] || [ ! -e "$prefix" ]; then + return; + fi; + find "$prefix" -type f -name '*.la' -exec grep -q '^# Generated by .*libtool' {} \; -exec grep -q "^old_library=''" {} \; -exec sed -i {} -e "/^dependency_libs='[^']/ c dependency_libs='' #pruned" \; +} +_updateSourceDateEpochFromSourceRoot () +{ + + if [ -n "$sourceRoot" ]; then + updateSourceDateEpoch "$sourceRoot"; + fi +} +activatePackage () +{ + + local pkg="$1"; + local -r hostOffset="$2"; + local -r targetOffset="$3"; + (( hostOffset <= targetOffset )) || exit 1; + if [ -f "$pkg" ]; then + source "$pkg"; + fi; + if [[ -z "${strictDeps-}" || "$hostOffset" -le -1 ]]; then + addToSearchPath _PATH "$pkg/bin"; + fi; + if (( hostOffset <= -1 )); then + addToSearchPath _XDG_DATA_DIRS "$pkg/share"; + fi; + if [[ "$hostOffset" -eq 0 && -d "$pkg/bin" ]]; then + addToSearchPath _HOST_PATH "$pkg/bin"; + fi; + if [[ -f "$pkg/nix-support/setup-hook" ]]; then + source "$pkg/nix-support/setup-hook"; + fi +} +addEnvHooks () +{ + + local depHostOffset="$1"; + shift; + local pkgHookVarsSlice="${pkgHookVarVars[$depHostOffset + 1]}[@]"; + local pkgHookVar; + for pkgHookVar in "${!pkgHookVarsSlice}"; + do + eval "${pkgHookVar}s"'+=("$@")'; + done +} +addToSearchPath () +{ + + addToSearchPathWithCustomDelimiter ":" "$@" +} +addToSearchPathWithCustomDelimiter () +{ + + local delimiter="$1"; + local varName="$2"; + local dir="$3"; + if [[ -d "$dir" && "${!varName:+${delimiter}${!varName}${delimiter}}" != *"${delimiter}${dir}${delimiter}"* ]]; then + export "${varName}=${!varName:+${!varName}${delimiter}}${dir}"; + fi +} +appendToVar () +{ + + local -n nameref="$1"; + local useArray type; + if [ -n "$__structuredAttrs" ]; then + useArray=true; + else + useArray=false; + fi; + if declare -p "$1" 2> /dev/null | grep -q '^'; then + type="$(declare -p "$1")"; + if [[ "$type" =~ "declare -A" ]]; then + echo "appendToVar(): ERROR: trying to use appendToVar on an associative array, use variable+=([\"X\"]=\"Y\") instead." 1>&2; + return 1; + else + if [[ "$type" =~ "declare -a" ]]; then + useArray=true; + else + useArray=false; + fi; + fi; + fi; + shift; + if $useArray; then + nameref=(${nameref+"${nameref[@]}"} "$@"); + else + nameref="${nameref-} $*"; + fi +} +auditTmpdir () +{ + + local dir="$1"; + [ -e "$dir" ] || return 0; + echo "checking for references to $TMPDIR/ in $dir..."; + local i; + find "$dir" -type f -print0 | while IFS= read -r -d '' i; do + if [[ "$i" =~ .build-id ]]; then + continue; + fi; + if isELF "$i"; then + if { + printf :; + patchelf --print-rpath "$i" + } | grep -q -F ":$TMPDIR/"; then + echo "RPATH of binary $i contains a forbidden reference to $TMPDIR/"; + exit 1; + fi; + fi; + if isScript "$i"; then + if [ -e "$(dirname "$i")/.$(basename "$i")-wrapped" ]; then + if grep -q -F "$TMPDIR/" "$i"; then + echo "wrapper script $i contains a forbidden reference to $TMPDIR/"; + exit 1; + fi; + fi; + fi; + done +} +bintoolsWrapper_addLDVars () +{ + + local role_post; + getHostRoleEnvHook; + if [[ -d "$1/lib64" && ! -L "$1/lib64" ]]; then + export NIX_LDFLAGS${role_post}+=" -L$1/lib64"; + fi; + if [[ -d "$1/lib" ]]; then + local -a glob=($1/lib/lib*); + if [ "${#glob[*]}" -gt 0 ]; then + export NIX_LDFLAGS${role_post}+=" -L$1/lib"; + fi; + fi +} +buildPhase () +{ + + runHook preBuild; + if [[ -z "${makeFlags-}" && -z "${makefile:-}" && ! ( -e Makefile || -e makefile || -e GNUmakefile ) ]]; then + echo "no Makefile or custom buildPhase, doing nothing"; + else + foundMakefile=1; + local flagsArray=(${enableParallelBuilding:+-j${NIX_BUILD_CORES}} SHELL=$SHELL); + _accumFlagsArray makeFlags makeFlagsArray buildFlags buildFlagsArray; + echoCmd 'build flags' "${flagsArray[@]}"; + make ${makefile:+-f $makefile} "${flagsArray[@]}"; + unset flagsArray; + fi; + runHook postBuild +} +ccWrapper_addCVars () +{ + + local role_post; + getHostRoleEnvHook; + if [ -d "$1/include" ]; then + export NIX_CFLAGS_COMPILE${role_post}+=" -isystem $1/include"; + fi; + if [ -d "$1/Library/Frameworks" ]; then + export NIX_CFLAGS_COMPILE${role_post}+=" -iframework $1/Library/Frameworks"; + fi +} +checkPhase () +{ + + runHook preCheck; + if [[ -z "${foundMakefile:-}" ]]; then + echo "no Makefile or custom checkPhase, doing nothing"; + runHook postCheck; + return; + fi; + if [[ -z "${checkTarget:-}" ]]; then + if make -n ${makefile:+-f $makefile} check > /dev/null 2>&1; then + checkTarget=check; + else + if make -n ${makefile:+-f $makefile} test > /dev/null 2>&1; then + checkTarget=test; + fi; + fi; + fi; + if [[ -z "${checkTarget:-}" ]]; then + echo "no check/test target in ${makefile:-Makefile}, doing nothing"; + else + local flagsArray=(${enableParallelChecking:+-j${NIX_BUILD_CORES}} SHELL=$SHELL); + _accumFlagsArray makeFlags makeFlagsArray; + if [ -n "$__structuredAttrs" ]; then + flagsArray+=("${checkFlags[@]:-VERBOSE=y}"); + else + flagsArray+=(${checkFlags:-VERBOSE=y}); + fi; + _accumFlagsArray checkFlagsArray; + flagsArray+=(${checkTarget}); + echoCmd 'check flags' "${flagsArray[@]}"; + make ${makefile:+-f $makefile} "${flagsArray[@]}"; + unset flagsArray; + fi; + runHook postCheck +} +compressManPages () +{ + + local dir="$1"; + if [ -L "$dir"/share ] || [ -L "$dir"/share/man ] || [ ! -d "$dir/share/man" ]; then + return; + fi; + echo "gzipping man pages under $dir/share/man/"; + find "$dir"/share/man/ -type f -a '!' -regex '.*\.\(bz2\|gz\|xz\)$' -print0 | while IFS= read -r -d '' f; do + if gzip -c -n "$f" > "$f".gz; then + rm "$f"; + else + rm "$f".gz; + fi; + done; + find "$dir"/share/man/ -type l -a '!' -regex '.*\.\(bz2\|gz\|xz\)$' -print0 | sort -z | while IFS= read -r -d '' f; do + local target; + target="$(readlink -f "$f")"; + if [ -f "$target".gz ]; then + ln -sf "$target".gz "$f".gz && rm "$f"; + fi; + done +} +configurePhase () +{ + + runHook preConfigure; + : "${configureScript=}"; + if [[ -z "$configureScript" && -x ./configure ]]; then + configureScript=./configure; + fi; + if [ -z "${dontFixLibtool:-}" ]; then + export lt_cv_deplibs_check_method="${lt_cv_deplibs_check_method-pass_all}"; + local i; + find . -iname "ltmain.sh" -print0 | while IFS='' read -r -d '' i; do + echo "fixing libtool script $i"; + fixLibtool "$i"; + done; + CONFIGURE_MTIME_REFERENCE=$(mktemp configure.mtime.reference.XXXXXX); + find . -executable -type f -name configure -exec grep -l 'GNU Libtool is free software; you can redistribute it and/or modify' {} \; -exec touch -r {} "$CONFIGURE_MTIME_REFERENCE" \; -exec sed -i s_/usr/bin/file_file_g {} \; -exec touch -r "$CONFIGURE_MTIME_REFERENCE" {} \;; + rm -f "$CONFIGURE_MTIME_REFERENCE"; + fi; + if [[ -z "${dontAddPrefix:-}" && -n "$prefix" ]]; then + prependToVar configureFlags "${prefixKey:---prefix=}$prefix"; + fi; + if [[ -f "$configureScript" ]]; then + if [ -z "${dontAddDisableDepTrack:-}" ]; then + if grep -q dependency-tracking "$configureScript"; then + prependToVar configureFlags --disable-dependency-tracking; + fi; + fi; + if [ -z "${dontDisableStatic:-}" ]; then + if grep -q enable-static "$configureScript"; then + prependToVar configureFlags --disable-static; + fi; + fi; + if [ -z "${dontPatchShebangsInConfigure:-}" ]; then + patchShebangs --build "$configureScript"; + fi; + fi; + if [ -n "$configureScript" ]; then + local -a flagsArray; + _accumFlagsArray configureFlags configureFlagsArray; + echoCmd 'configure flags' "${flagsArray[@]}"; + $configureScript "${flagsArray[@]}"; + unset flagsArray; + else + echo "no configure script, doing nothing"; + fi; + runHook postConfigure +} +consumeEntire () +{ + + if IFS='' read -r -d '' "$1"; then + echo "consumeEntire(): ERROR: Input null bytes, won't process" 1>&2; + return 1; + fi +} +distPhase () +{ + + runHook preDist; + local flagsArray=(); + _accumFlagsArray distFlags distFlagsArray; + flagsArray+=(${distTarget:-dist}); + echo 'dist flags: %q' "${flagsArray[@]}"; + make ${makefile:+-f $makefile} "${flagsArray[@]}"; + if [ "${dontCopyDist:-0}" != 1 ]; then + mkdir -p "$out/tarballs"; + cp -pvd ${tarballs[*]:-*.tar.gz} "$out/tarballs"; + fi; + runHook postDist +} +dumpVars () +{ + + if [ "${noDumpEnvVars:-0}" != 1 ]; then + export 2> /dev/null >| "$NIX_BUILD_TOP/env-vars" || true; + fi +} +echoCmd () +{ + + printf "%s:" "$1"; + shift; + printf ' %q' "$@"; + echo +} +exitHandler () +{ + + exitCode="$?"; + set +e; + if [ -n "${showBuildStats:-}" ]; then + read -r -d '' -a buildTimes < <(times); + echo "build times:"; + echo "user time for the shell ${buildTimes[0]}"; + echo "system time for the shell ${buildTimes[1]}"; + echo "user time for all child processes ${buildTimes[2]}"; + echo "system time for all child processes ${buildTimes[3]}"; + fi; + if (( "$exitCode" != 0 )); then + runHook failureHook; + if [ -n "${succeedOnFailure:-}" ]; then + echo "build failed with exit code $exitCode (ignored)"; + mkdir -p "$out/nix-support"; + printf "%s" "$exitCode" > "$out/nix-support/failed"; + exit 0; + fi; + else + runHook exitHook; + fi; + return "$exitCode" +} +findInputs () +{ + + local -r pkg="$1"; + local -r hostOffset="$2"; + local -r targetOffset="$3"; + (( hostOffset <= targetOffset )) || exit 1; + local varVar="${pkgAccumVarVars[hostOffset + 1]}"; + local varRef="$varVar[$((targetOffset - hostOffset))]"; + local var="${!varRef}"; + unset -v varVar varRef; + local varSlice="$var[*]"; + case "${!varSlice-}" in + *" $pkg "*) + return 0 + ;; + esac; + unset -v varSlice; + eval "$var"'+=("$pkg")'; + if ! [ -e "$pkg" ]; then + echo "build input $pkg does not exist" 1>&2; + exit 1; + fi; + function mapOffset () + { + local -r inputOffset="$1"; + local -n outputOffset="$2"; + if (( inputOffset <= 0 )); then + outputOffset=$((inputOffset + hostOffset)); + else + outputOffset=$((inputOffset - 1 + targetOffset)); + fi + }; + local relHostOffset; + for relHostOffset in "${allPlatOffsets[@]}"; + do + local files="${propagatedDepFilesVars[relHostOffset + 1]}"; + local hostOffsetNext; + mapOffset "$relHostOffset" hostOffsetNext; + (( -1 <= hostOffsetNext && hostOffsetNext <= 1 )) || continue; + local relTargetOffset; + for relTargetOffset in "${allPlatOffsets[@]}"; + do + (( "$relHostOffset" <= "$relTargetOffset" )) || continue; + local fileRef="${files}[$relTargetOffset - $relHostOffset]"; + local file="${!fileRef}"; + unset -v fileRef; + local targetOffsetNext; + mapOffset "$relTargetOffset" targetOffsetNext; + (( -1 <= hostOffsetNext && hostOffsetNext <= 1 )) || continue; + [[ -f "$pkg/nix-support/$file" ]] || continue; + local pkgNext; + read -r -d '' pkgNext < "$pkg/nix-support/$file" || true; + for pkgNext in $pkgNext; + do + findInputs "$pkgNext" "$hostOffsetNext" "$targetOffsetNext"; + done; + done; + done +} +fixLibtool () +{ + + local search_path; + for flag in $NIX_LDFLAGS; + do + case $flag in + -L*) + search_path+=" ${flag#-L}" + ;; + esac; + done; + sed -i "$1" -e "s^eval \(sys_lib_search_path=\).*^\1'${search_path:-}'^" -e 's^eval sys_lib_.+search_path=.*^^' +} +fixupPhase () +{ + + local output; + for output in $(getAllOutputNames); + do + if [ -e "${!output}" ]; then + chmod -R u+w,u-s,g-s "${!output}"; + fi; + done; + runHook preFixup; + local output; + for output in $(getAllOutputNames); + do + prefix="${!output}" runHook fixupOutput; + done; + recordPropagatedDependencies; + if [ -n "${setupHook:-}" ]; then + mkdir -p "${!outputDev}/nix-support"; + substituteAll "$setupHook" "${!outputDev}/nix-support/setup-hook"; + fi; + if [ -n "${setupHooks:-}" ]; then + mkdir -p "${!outputDev}/nix-support"; + local hook; + for hook in ${setupHooks[@]}; + do + local content; + consumeEntire content < "$hook"; + substituteAllStream content "file '$hook'" >> "${!outputDev}/nix-support/setup-hook"; + unset -v content; + done; + unset -v hook; + fi; + if [ -n "${propagatedUserEnvPkgs:-}" ]; then + mkdir -p "${!outputBin}/nix-support"; + printWords $propagatedUserEnvPkgs > "${!outputBin}/nix-support/propagated-user-env-packages"; + fi; + runHook postFixup +} +genericBuild () +{ + + export GZIP_NO_TIMESTAMPS=1; + if [ -f "${buildCommandPath:-}" ]; then + source "$buildCommandPath"; + return; + fi; + if [ -n "${buildCommand:-}" ]; then + eval "$buildCommand"; + return; + fi; + if [ -z "${phases[*]:-}" ]; then + phases="${prePhases[*]:-} unpackPhase patchPhase ${preConfigurePhases[*]:-} configurePhase ${preBuildPhases[*]:-} buildPhase checkPhase ${preInstallPhases[*]:-} installPhase ${preFixupPhases[*]:-} fixupPhase installCheckPhase ${preDistPhases[*]:-} distPhase ${postPhases[*]:-}"; + fi; + for curPhase in ${phases[*]}; + do + runPhase "$curPhase"; + done +} +getAllOutputNames () +{ + + if [ -n "$__structuredAttrs" ]; then + echo "${!outputs[*]}"; + else + echo "$outputs"; + fi +} +getHostRole () +{ + + getRole "$hostOffset" +} +getHostRoleEnvHook () +{ + + getRole "$depHostOffset" +} +getRole () +{ + + case $1 in + -1) + role_post='_FOR_BUILD' + ;; + 0) + role_post='' + ;; + 1) + role_post='_FOR_TARGET' + ;; + *) + echo "binutils-wrapper-2.41: used as improper sort of dependency" 1>&2; + return 1 + ;; + esac +} +getTargetRole () +{ + + getRole "$targetOffset" +} +getTargetRoleEnvHook () +{ + + getRole "$depTargetOffset" +} +getTargetRoleWrapper () +{ + + case $targetOffset in + -1) + export NIX_BINTOOLS_WRAPPER_TARGET_BUILD_x86_64_unknown_linux_gnu=1 + ;; + 0) + export NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu=1 + ;; + 1) + export NIX_BINTOOLS_WRAPPER_TARGET_TARGET_x86_64_unknown_linux_gnu=1 + ;; + *) + echo "binutils-wrapper-2.41: used as improper sort of dependency" 1>&2; + return 1 + ;; + esac +} +installCheckPhase () +{ + + runHook preInstallCheck; + if [[ -z "${foundMakefile:-}" ]]; then + echo "no Makefile or custom installCheckPhase, doing nothing"; + else + if [[ -z "${installCheckTarget:-}" ]] && ! make -n ${makefile:+-f $makefile} "${installCheckTarget:-installcheck}" > /dev/null 2>&1; then + echo "no installcheck target in ${makefile:-Makefile}, doing nothing"; + else + local flagsArray=(${enableParallelChecking:+-j${NIX_BUILD_CORES}} SHELL=$SHELL); + _accumFlagsArray makeFlags makeFlagsArray installCheckFlags installCheckFlagsArray; + flagsArray+=(${installCheckTarget:-installcheck}); + echoCmd 'installcheck flags' "${flagsArray[@]}"; + make ${makefile:+-f $makefile} "${flagsArray[@]}"; + unset flagsArray; + fi; + fi; + runHook postInstallCheck +} +installPhase () +{ + + runHook preInstall; + if [[ -z "${makeFlags-}" && -z "${makefile:-}" && ! ( -e Makefile || -e makefile || -e GNUmakefile ) ]]; then + echo "no Makefile or custom installPhase, doing nothing"; + runHook postInstall; + return; + else + foundMakefile=1; + fi; + if [ -n "$prefix" ]; then + mkdir -p "$prefix"; + fi; + local flagsArray=(${enableParallelInstalling:+-j${NIX_BUILD_CORES}} SHELL=$SHELL); + _accumFlagsArray makeFlags makeFlagsArray installFlags installFlagsArray; + if [ -n "$__structuredAttrs" ]; then + flagsArray+=("${installTargets[@]:-install}"); + else + flagsArray+=(${installTargets:-install}); + fi; + echoCmd 'install flags' "${flagsArray[@]}"; + make ${makefile:+-f $makefile} "${flagsArray[@]}"; + unset flagsArray; + runHook postInstall +} +isELF () +{ + + local fn="$1"; + local fd; + local magic; + exec {fd}< "$fn"; + read -r -n 4 -u "$fd" magic; + exec {fd}>&-; + if [ "$magic" = 'ELF' ]; then + return 0; + else + return 1; + fi +} +isMachO () +{ + + local fn="$1"; + local fd; + local magic; + exec {fd}< "$fn"; + read -r -n 4 -u "$fd" magic; + exec {fd}>&-; + if [[ "$magic" = $(echo -ne "\xfe\xed\xfa\xcf") || "$magic" = $(echo -ne "\xcf\xfa\xed\xfe") ]]; then + return 0; + else + if [[ "$magic" = $(echo -ne "\xfe\xed\xfa\xce") || "$magic" = $(echo -ne "\xce\xfa\xed\xfe") ]]; then + return 0; + else + if [[ "$magic" = $(echo -ne "\xca\xfe\xba\xbe") || "$magic" = $(echo -ne "\xbe\xba\xfe\xca") ]]; then + return 0; + else + return 1; + fi; + fi; + fi +} +isScript () +{ + + local fn="$1"; + local fd; + local magic; + exec {fd}< "$fn"; + read -r -n 2 -u "$fd" magic; + exec {fd}>&-; + if [[ "$magic" =~ \#! ]]; then + return 0; + else + return 1; + fi +} +mapOffset () +{ + + local -r inputOffset="$1"; + local -n outputOffset="$2"; + if (( inputOffset <= 0 )); then + outputOffset=$((inputOffset + hostOffset)); + else + outputOffset=$((inputOffset - 1 + targetOffset)); + fi +} +moveToOutput () +{ + + local patt="$1"; + local dstOut="$2"; + local output; + for output in $(getAllOutputNames); + do + if [ "${!output}" = "$dstOut" ]; then + continue; + fi; + local srcPath; + for srcPath in "${!output}"/$patt; + do + if [ ! -e "$srcPath" ] && [ ! -L "$srcPath" ]; then + continue; + fi; + if [ "$dstOut" = REMOVE ]; then + echo "Removing $srcPath"; + rm -r "$srcPath"; + else + local dstPath="$dstOut${srcPath#${!output}}"; + echo "Moving $srcPath to $dstPath"; + if [ -d "$dstPath" ] && [ -d "$srcPath" ]; then + rmdir "$srcPath" --ignore-fail-on-non-empty; + if [ -d "$srcPath" ]; then + mv -t "$dstPath" "$srcPath"/*; + rmdir "$srcPath"; + fi; + else + mkdir -p "$(readlink -m "$dstPath/..")"; + mv "$srcPath" "$dstPath"; + fi; + fi; + local srcParent="$(readlink -m "$srcPath/..")"; + if [ -n "$(find "$srcParent" -maxdepth 0 -type d -empty 2> /dev/null)" ]; then + echo "Removing empty $srcParent/ and (possibly) its parents"; + rmdir -p --ignore-fail-on-non-empty "$srcParent" 2> /dev/null || true; + fi; + done; + done +} +patchELF () +{ + + local dir="$1"; + [ -e "$dir" ] || return 0; + echo "shrinking RPATHs of ELF executables and libraries in $dir"; + local i; + while IFS= read -r -d '' i; do + if [[ "$i" =~ .build-id ]]; then + continue; + fi; + if ! isELF "$i"; then + continue; + fi; + echo "shrinking $i"; + patchelf --shrink-rpath "$i" || true; + done < <(find "$dir" -type f -print0) +} +patchPhase () +{ + + runHook prePatch; + local -a patchesArray; + if [ -n "$__structuredAttrs" ]; then + patchesArray=(${patches:+"${patches[@]}"}); + else + patchesArray=(${patches:-}); + fi; + for i in "${patchesArray[@]}"; + do + echo "applying patch $i"; + local uncompress=cat; + case "$i" in + *.gz) + uncompress="gzip -d" + ;; + *.bz2) + uncompress="bzip2 -d" + ;; + *.xz) + uncompress="xz -d" + ;; + *.lzma) + uncompress="lzma -d" + ;; + esac; + local -a flagsArray; + if [ -n "$__structuredAttrs" ]; then + flagsArray=("${patchFlags[@]:--p1}"); + else + flagsArray=(${patchFlags:--p1}); + fi; + $uncompress < "$i" 2>&1 | patch "${flagsArray[@]}"; + done; + runHook postPatch +} +patchShebangs () +{ + + local pathName; + local update; + while [[ $# -gt 0 ]]; do + case "$1" in + --host) + pathName=HOST_PATH; + shift + ;; + --build) + pathName=PATH; + shift + ;; + --update) + update=true; + shift + ;; + --) + shift; + break + ;; + -* | --*) + echo "Unknown option $1 supplied to patchShebangs" 1>&2; + return 1 + ;; + *) + break + ;; + esac; + done; + echo "patching script interpreter paths in $@"; + local f; + local oldPath; + local newPath; + local arg0; + local args; + local oldInterpreterLine; + local newInterpreterLine; + if [[ $# -eq 0 ]]; then + echo "No arguments supplied to patchShebangs" 1>&2; + return 0; + fi; + local f; + while IFS= read -r -d '' f; do + isScript "$f" || continue; + read -r oldInterpreterLine < "$f" || [ "$oldInterpreterLine" ]; + read -r oldPath arg0 args <<< "${oldInterpreterLine:2}"; + if [[ -z "${pathName:-}" ]]; then + if [[ -n $strictDeps && $f == "$NIX_STORE"* ]]; then + pathName=HOST_PATH; + else + pathName=PATH; + fi; + fi; + if [[ "$oldPath" == *"/bin/env" ]]; then + if [[ $arg0 == "-S" ]]; then + arg0=${args%% *}; + args=${args#* }; + newPath="$(PATH="${!pathName}" command -v "env" || true)"; + args="-S $(PATH="${!pathName}" command -v "$arg0" || true) $args"; + else + if [[ $arg0 == "-"* || $arg0 == *"="* ]]; then + echo "$f: unsupported interpreter directive \"$oldInterpreterLine\" (set dontPatchShebangs=1 and handle shebang patching yourself)" 1>&2; + exit 1; + else + newPath="$(PATH="${!pathName}" command -v "$arg0" || true)"; + fi; + fi; + else + if [[ -z $oldPath ]]; then + oldPath="/bin/sh"; + fi; + newPath="$(PATH="${!pathName}" command -v "$(basename "$oldPath")" || true)"; + args="$arg0 $args"; + fi; + newInterpreterLine="$newPath $args"; + newInterpreterLine=${newInterpreterLine%${newInterpreterLine##*[![:space:]]}}; + if [[ -n "$oldPath" && ( "$update" == true || "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ) ]]; then + if [[ -n "$newPath" && "$newPath" != "$oldPath" ]]; then + echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\""; + escapedInterpreterLine=${newInterpreterLine//\\/\\\\}; + timestamp=$(stat --printf "%y" "$f"); + sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f"; + touch --date "$timestamp" "$f"; + fi; + fi; + done < <(find "$@" -type f -perm -0100 -print0) +} +patchShebangsAuto () +{ + + if [[ -z "${dontPatchShebangs-}" && -e "$prefix" ]]; then + if [[ "$output" != out && "$output" = "$outputDev" ]]; then + patchShebangs --build "$prefix"; + else + patchShebangs --host "$prefix"; + fi; + fi +} +pkgConfigWrapper_addPkgConfigPath () +{ + + local role_post; + getHostRoleEnvHook; + addToSearchPath "PKG_CONFIG_PATH${role_post}" "$1/lib/pkgconfig"; + addToSearchPath "PKG_CONFIG_PATH${role_post}" "$1/share/pkgconfig" +} +prependToVar () +{ + + local -n nameref="$1"; + local useArray type; + if [ -n "$__structuredAttrs" ]; then + useArray=true; + else + useArray=false; + fi; + if declare -p "$1" 2> /dev/null | grep -q '^'; then + type="$(declare -p "$1")"; + if [[ "$type" =~ "declare -A" ]]; then + echo "prependToVar(): ERROR: trying to use prependToVar on an associative array." 1>&2; + return 1; + else + if [[ "$type" =~ "declare -a" ]]; then + useArray=true; + else + useArray=false; + fi; + fi; + fi; + shift; + if $useArray; then + nameref=("$@" ${nameref+"${nameref[@]}"}); + else + nameref="$* ${nameref-}"; + fi +} +printLines () +{ + + (( "$#" > 0 )) || return 0; + printf '%s\n' "$@" +} +printWords () +{ + + (( "$#" > 0 )) || return 0; + printf '%s ' "$@" +} +recordPropagatedDependencies () +{ + + declare -ra flatVars=(depsBuildBuildPropagated propagatedNativeBuildInputs depsBuildTargetPropagated depsHostHostPropagated propagatedBuildInputs depsTargetTargetPropagated); + declare -ra flatFiles=("${propagatedBuildDepFiles[@]}" "${propagatedHostDepFiles[@]}" "${propagatedTargetDepFiles[@]}"); + local propagatedInputsIndex; + for propagatedInputsIndex in "${!flatVars[@]}"; + do + local propagatedInputsSlice="${flatVars[$propagatedInputsIndex]}[@]"; + local propagatedInputsFile="${flatFiles[$propagatedInputsIndex]}"; + [[ -n "${!propagatedInputsSlice}" ]] || continue; + mkdir -p "${!outputDev}/nix-support"; + printWords ${!propagatedInputsSlice} > "${!outputDev}/nix-support/$propagatedInputsFile"; + done +} +runHook () +{ + + local hookName="$1"; + shift; + local hooksSlice="${hookName%Hook}Hooks[@]"; + local hook; + for hook in "_callImplicitHook 0 $hookName" ${!hooksSlice+"${!hooksSlice}"}; + do + _eval "$hook" "$@"; + done; + return 0 +} +runOneHook () +{ + + local hookName="$1"; + shift; + local hooksSlice="${hookName%Hook}Hooks[@]"; + local hook ret=1; + for hook in "_callImplicitHook 1 $hookName" ${!hooksSlice+"${!hooksSlice}"}; + do + if _eval "$hook" "$@"; then + ret=0; + break; + fi; + done; + return "$ret" +} +runPhase () +{ + + local curPhase="$*"; + if [[ "$curPhase" = unpackPhase && -n "${dontUnpack:-}" ]]; then + return; + fi; + if [[ "$curPhase" = patchPhase && -n "${dontPatch:-}" ]]; then + return; + fi; + if [[ "$curPhase" = configurePhase && -n "${dontConfigure:-}" ]]; then + return; + fi; + if [[ "$curPhase" = buildPhase && -n "${dontBuild:-}" ]]; then + return; + fi; + if [[ "$curPhase" = checkPhase && -z "${doCheck:-}" ]]; then + return; + fi; + if [[ "$curPhase" = installPhase && -n "${dontInstall:-}" ]]; then + return; + fi; + if [[ "$curPhase" = fixupPhase && -n "${dontFixup:-}" ]]; then + return; + fi; + if [[ "$curPhase" = installCheckPhase && -z "${doInstallCheck:-}" ]]; then + return; + fi; + if [[ "$curPhase" = distPhase && -z "${doDist:-}" ]]; then + return; + fi; + if [[ -n $NIX_LOG_FD ]]; then + echo "@nix { \"action\": \"setPhase\", \"phase\": \"$curPhase\" }" >&"$NIX_LOG_FD"; + fi; + showPhaseHeader "$curPhase"; + dumpVars; + local startTime=$(date +"%s"); + eval "${!curPhase:-$curPhase}"; + local endTime=$(date +"%s"); + showPhaseFooter "$curPhase" "$startTime" "$endTime"; + if [ "$curPhase" = unpackPhase ]; then + [ -n "${sourceRoot:-}" ] && chmod +x "${sourceRoot}"; + cd "${sourceRoot:-.}"; + fi +} +showPhaseFooter () +{ + + local phase="$1"; + local startTime="$2"; + local endTime="$3"; + local delta=$(( endTime - startTime )); + (( delta < 30 )) && return; + local H=$((delta/3600)); + local M=$((delta%3600/60)); + local S=$((delta%60)); + echo -n "$phase completed in "; + (( H > 0 )) && echo -n "$H hours "; + (( M > 0 )) && echo -n "$M minutes "; + echo "$S seconds" +} +showPhaseHeader () +{ + + local phase="$1"; + echo "Running phase: $phase" +} +stripDirs () +{ + + local cmd="$1"; + local ranlibCmd="$2"; + local paths="$3"; + local stripFlags="$4"; + local excludeFlags=(); + local pathsNew=; + [ -z "$cmd" ] && echo "stripDirs: Strip command is empty" 1>&2 && exit 1; + [ -z "$ranlibCmd" ] && echo "stripDirs: Ranlib command is empty" 1>&2 && exit 1; + local pattern; + if [ -n "${stripExclude:-}" ]; then + for pattern in "${stripExclude[@]}"; + do + excludeFlags+=(-a '!' '(' -name "$pattern" -o -wholename "$prefix/$pattern" ')'); + done; + fi; + local p; + for p in ${paths}; + do + if [ -e "$prefix/$p" ]; then + pathsNew="${pathsNew} $prefix/$p"; + fi; + done; + paths=${pathsNew}; + if [ -n "${paths}" ]; then + echo "stripping (with command $cmd and flags $stripFlags) in $paths"; + local striperr; + striperr="$(mktemp --tmpdir="$TMPDIR" 'striperr.XXXXXX')"; + find $paths -type f "${excludeFlags[@]}" -a '!' -path "$prefix/lib/debug/*" -print0 | xargs -r -0 -n1 -- realpath -z | sort -u -z | xargs -r -0 -n1 -P "$NIX_BUILD_CORES" -- $cmd $stripFlags 2> "$striperr" || exit_code=$?; + [[ "$exit_code" = 123 || -z "$exit_code" ]] || ( cat "$striperr" 1>&2 && exit 1 ); + rm "$striperr"; + find $paths -name '*.a' -type f -exec $ranlibCmd '{}' \; 2> /dev/null; + fi +} +stripHash () +{ + + local strippedName casematchOpt=0; + strippedName="$(basename -- "$1")"; + shopt -q nocasematch && casematchOpt=1; + shopt -u nocasematch; + if [[ "$strippedName" =~ ^[a-z0-9]{32}- ]]; then + echo "${strippedName:33}"; + else + echo "$strippedName"; + fi; + if (( casematchOpt )); then + shopt -s nocasematch; + fi +} +substitute () +{ + + local input="$1"; + local output="$2"; + shift 2; + if [ ! -f "$input" ]; then + echo "substitute(): ERROR: file '$input' does not exist" 1>&2; + return 1; + fi; + local content; + consumeEntire content < "$input"; + if [ -e "$output" ]; then + chmod +w "$output"; + fi; + substituteStream content "file '$input'" "$@" > "$output" +} +substituteAll () +{ + + local input="$1"; + local output="$2"; + local -a args=(); + _allFlags; + substitute "$input" "$output" "${args[@]}" +} +substituteAllInPlace () +{ + + local fileName="$1"; + shift; + substituteAll "$fileName" "$fileName" "$@" +} +substituteAllStream () +{ + + local -a args=(); + _allFlags; + substituteStream "$1" "$2" "${args[@]}" +} +substituteInPlace () +{ + + local -a fileNames=(); + for arg in "$@"; + do + if [[ "$arg" = "--"* ]]; then + break; + fi; + fileNames+=("$arg"); + shift; + done; + for file in "${fileNames[@]}"; + do + substitute "$file" "$file" "$@"; + done +} +substituteStream () +{ + + local var=$1; + local description=$2; + shift 2; + while (( "$#" )); do + local replace_mode="$1"; + case "$1" in + --replace) + if ! "$_substituteStream_has_warned_replace_deprecation"; then + echo "substituteStream(): WARNING: '--replace' is deprecated, use --replace-{fail,warn,quiet}. ($description)" 1>&2; + _substituteStream_has_warned_replace_deprecation=true; + fi; + replace_mode='--replace-warn' + ;& + --replace-quiet | --replace-warn | --replace-fail) + pattern="$2"; + replacement="$3"; + shift 3; + local savedvar; + savedvar="${!var}"; + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}'; + if [ "$pattern" != "$replacement" ]; then + if [ "${!var}" == "$savedvar" ]; then + if [ "$replace_mode" == --replace-warn ]; then + printf "substituteStream(): WARNING: pattern %q doesn't match anything in %s\n" "$pattern" "$description" 1>&2; + else + if [ "$replace_mode" == --replace-fail ]; then + printf "substituteStream(): ERROR: pattern %q doesn't match anything in %s\n" "$pattern" "$description" 1>&2; + return 1; + fi; + fi; + fi; + fi + ;; + --subst-var) + local varName="$2"; + shift 2; + if ! [[ "$varName" =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]]; then + echo "substituteStream(): ERROR: substitution variables must be valid Bash names, \"$varName\" isn't." 1>&2; + return 1; + fi; + if [ -z ${!varName+x} ]; then + echo "substituteStream(): ERROR: variable \$$varName is unset" 1>&2; + return 1; + fi; + pattern="@$varName@"; + replacement="${!varName}"; + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}' + ;; + --subst-var-by) + pattern="@$2@"; + replacement="$3"; + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}'; + shift 3 + ;; + *) + echo "substituteStream(): ERROR: Invalid command line argument: $1" 1>&2; + return 1 + ;; + esac; + done; + printf "%s" "${!var}" +} +unpackFile () +{ + + curSrc="$1"; + echo "unpacking source archive $curSrc"; + if ! runOneHook unpackCmd "$curSrc"; then + echo "do not know how to unpack source archive $curSrc"; + exit 1; + fi +} +unpackPhase () +{ + + runHook preUnpack; + if [ -z "${srcs:-}" ]; then + if [ -z "${src:-}" ]; then + echo 'variable $src or $srcs should point to the source'; + exit 1; + fi; + srcs="$src"; + fi; + local -a srcsArray; + if [ -n "$__structuredAttrs" ]; then + srcsArray=("${srcs[@]}"); + else + srcsArray=($srcs); + fi; + local dirsBefore=""; + for i in *; + do + if [ -d "$i" ]; then + dirsBefore="$dirsBefore $i "; + fi; + done; + for i in "${srcsArray[@]}"; + do + unpackFile "$i"; + done; + : "${sourceRoot=}"; + if [ -n "${setSourceRoot:-}" ]; then + runOneHook setSourceRoot; + else + if [ -z "$sourceRoot" ]; then + for i in *; + do + if [ -d "$i" ]; then + case $dirsBefore in + *\ $i\ *) + + ;; + *) + if [ -n "$sourceRoot" ]; then + echo "unpacker produced multiple directories"; + exit 1; + fi; + sourceRoot="$i" + ;; + esac; + fi; + done; + fi; + fi; + if [ -z "$sourceRoot" ]; then + echo "unpacker appears to have produced no directories"; + exit 1; + fi; + echo "source root is $sourceRoot"; + if [ "${dontMakeSourcesWritable:-0}" != 1 ]; then + chmod -R u+w -- "$sourceRoot"; + fi; + runHook postUnpack +} +updateAutotoolsGnuConfigScriptsPhase () +{ + + if [ -n "${dontUpdateAutotoolsGnuConfigScripts-}" ]; then + return; + fi; + for script in config.sub config.guess; + do + for f in $(find . -type f -name "$script"); + do + echo "Updating Autotools / GNU config script to a newer upstream version: $f"; + cp -f "/nix/store/y2f45080fyi02g4imbf8h5xw0vviyh8v-gnu-config-2023-09-19/$script" "$f"; + done; + done +} +updateSourceDateEpoch () +{ + + local path="$1"; + local -a res=($(find "$path" -type f -not -newer "$NIX_BUILD_TOP/.." -printf '%T@ %p\0' | sort -n --zero-terminated | tail -n1 --zero-terminated | head -c -1)); + local time="${res[0]//\.[0-9]*/}"; + local newestFile="${res[1]}"; + if [ "${time:-0}" -gt "$SOURCE_DATE_EPOCH" ]; then + echo "setting SOURCE_DATE_EPOCH to timestamp $time of file $newestFile"; + export SOURCE_DATE_EPOCH="$time"; + local now="$(date +%s)"; + if [ "$time" -gt $((now - 60)) ]; then + echo "warning: file $newestFile may be generated; SOURCE_DATE_EPOCH may be non-deterministic"; + fi; + fi +} +PATH="$PATH${nix_saved_PATH:+:$nix_saved_PATH}" +XDG_DATA_DIRS="$XDG_DATA_DIRS${nix_saved_XDG_DATA_DIRS:+:$nix_saved_XDG_DATA_DIRS}" +export NIX_BUILD_TOP="$(mktemp -d -t nix-shell.XXXXXX)" +export TMP="$NIX_BUILD_TOP" +export TMPDIR="$NIX_BUILD_TOP" +export TEMP="$NIX_BUILD_TOP" +export TEMPDIR="$NIX_BUILD_TOP" +eval "$shellHook" diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..ef32a46 --- /dev/null +++ b/.envrc @@ -0,0 +1,4 @@ +if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" +fi +use flake . --impure diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..6c7edf5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "crates/tinkoff_invest/investapi"] + path = crates/tinkoff_invest/investapi + url = https://github.com/tinkoff/investapi diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..50a73df --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1922 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "alpaca_broker" +version = "1.0.0" +dependencies = [ + "reqwest", + "serde", + "serde_derive", + "serde_json", + "serde_with", + "url", + "uuid", +] + +[[package]] +name = "alpaca_data" +version = "2.0.0" +dependencies = [ + "reqwest", + "serde", + "serde_derive", + "serde_json", + "serde_with", + "url", + "uuid", +] + +[[package]] +name = "alpaca_openapi" +version = "0.1.0" +dependencies = [ + "alpaca_broker", + "alpaca_data", + "alpaca_trading", +] + +[[package]] +name = "alpaca_trading" +version = "2.0.0" +dependencies = [ + "reqwest", + "serde", + "serde_derive", + "serde_json", + "serde_with", + "url", + "uuid", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-trait" +version = "0.1.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "axum" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + +[[package]] +name = "backtrace" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "cc" +version = "1.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "serde", + "windows-targets 0.52.5", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "darling" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + +[[package]] +name = "either" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" + +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown 0.14.5", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "miette" +version = "7.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" +dependencies = [ + "cfg-if", + "miette-derive", + "thiserror", + "unicode-width", +] + +[[package]] +name = "miette-derive" +version = "7.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "multimap" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" + +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap 2.2.6", +] + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "prettyplease" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" +dependencies = [ + "bytes", + "heck", + "itertools 0.12.1", + "log", + "multimap", + "once_cell", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn", + "tempfile", +] + +[[package]] +name = "prost-derive" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +dependencies = [ + "anyhow", + "itertools 0.12.1", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" +dependencies = [ + "prost", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "regex" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "mime_guess", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] + +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "sanetrade" +version = "0.1.0" +dependencies = [ + "alpaca_openapi", + "miette", + "thiserror", + "tinkoff_invest", + "tokio", + "tonic", + "uuid", +] + +[[package]] +name = "sanetrade_algorithms" +version = "0.1.0" +dependencies = [ + "futures-core", + "itertools 0.13.0", + "pin-project", +] + +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "security-framework" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +dependencies = [ + "bitflags 2.5.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" +dependencies = [ + "base64 0.13.1", + "chrono", + "hex", + "indexmap 1.9.3", + "serde", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + +[[package]] +name = "thiserror" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinkoff_invest" +version = "0.1.0" +dependencies = [ + "prost", + "prost-types", + "tonic", + "tonic-build", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tonic" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.21.7", + "bytes", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost", + "tokio", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic-build" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4ef6dd70a610078cb4e338a0f79d06bc759ff1b22d2120c2ff02ae264ba9c2" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "quote", + "syn", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +dependencies = [ + "getrandom", + "serde", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[patch.unused]] +name = "funnylog" +version = "0.1.0" + +[[patch.unused]] +name = "funnylog_global" +version = "0.1.0" + +[[patch.unused]] +name = "funnylog_macros" +version = "0.1.0" + +[[patch.unused]] +name = "careless" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..81b1bc1 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,20 @@ +[workspace] +members = ["crates/*"] +resolver = "2" + +[workspace.package] +version = "0.1.0" +edition = "2021" + +[workspace.dependencies] +## crates/* +sanetrade_algorithms.path = "crates/algorithms" +alpaca_openapi.path = "crates/alpaca_openapi" +tinkoff_invest.path = "crates/tinkoff_invest" + +## deps +tokio = { version = "1", features = ["sync", "rt"] } +futures-core = { version = "0.3", features = ["std"], default-features = false } +tonic = "0.11" +prost = "0.12" +prost-types = "0.12" diff --git a/README.md b/README.md new file mode 100644 index 0000000..5d28efc --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +[README на русском](./README.ru.md) + +# sanetrade - a trading SDK that doesn't care what you're using + +## progress + +### Brokers + +#### USA +- [ ] [alpaca](https://alpaca.markets/) + +#### Russia +- [ ] [tinkoff](https://tinkoff.github.io/investAPI/) +- [ ] [alor](https://alor.dev/docs) +- [ ] [finam](https://finamweb.github.io/trade-api-docs/) diff --git a/README.ru.md b/README.ru.md new file mode 100644 index 0000000..ee44544 --- /dev/null +++ b/README.ru.md @@ -0,0 +1,15 @@ +# sanetrade - библиотека для трейдинга + +sanetrade позволяет легко и быстро писать трейдинг ботов и заставить их работать с любым доступным брокером. + +## прогресс + +### брокеры + +#### США +- [ ] [alpaca](https://alpaca.markets/) + +#### Россия +- [ ] [Тинькофф](https://tinkoff.github.io/investAPI/) +- [ ] [Алор](https://alor.dev/docs) +- [ ] [Финам](https://finamweb.github.io/trade-api-docs/) diff --git a/crates/algorithms/Cargo.toml b/crates/algorithms/Cargo.toml new file mode 100644 index 0000000..948e6fe --- /dev/null +++ b/crates/algorithms/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "sanetrade_algorithms" +version = "0.1.0" +edition = "2021" + +[dependencies] +futures-core.workspace = true +itertools = "0.13.0" +pin-project = "1.1.5" diff --git a/crates/algorithms/src/dev.rs b/crates/algorithms/src/dev.rs new file mode 100644 index 0000000..2234c8e --- /dev/null +++ b/crates/algorithms/src/dev.rs @@ -0,0 +1,48 @@ +/// An f64 wrapper that is NaN by default and has a NaN-safe getter +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Nanf64(pub f64); + +impl Default for Nanf64 { + fn default() -> Self { + Self::nan() + } +} + +impl Nanf64 { + pub const fn nan() -> Self { + Self(f64::NAN) + } + + pub const fn is_nan(&self) -> bool { + self.0.is_nan() + } + + pub const fn get(&self) -> Option { + if self.is_nan() { + None + } else { + Some(self.0) + } + } + + pub fn maybe_set(&mut self, value: f64) -> f64 { + if self.is_nan() { + self.0 = value; + value + } else { + self.0 + } + } + + pub fn update_to(&mut self, f: impl FnOnce(Option) -> f64) -> f64 { + let res = f(self.get()); + self.0 = res; + res + } + + pub fn update(&mut self, f: impl FnOnce(Option) -> (U, f64)) -> U { + let (res, val) = f(self.get()); + self.0 = val; + res + } +} diff --git a/crates/algorithms/src/divergence.rs b/crates/algorithms/src/divergence.rs new file mode 100644 index 0000000..1ead898 --- /dev/null +++ b/crates/algorithms/src/divergence.rs @@ -0,0 +1,187 @@ +use std::{ + ops::Range, + simd::{cmp::SimdPartialOrd, f64x2, f64x4, num::SimdFloat, simd_swizzle}, +}; + +use super::*; + +pub struct Divergences(pub O); + +impl Divergences { + pub fn new(oscillator: O) -> Self { + Self(oscillator) + } + + pub fn iter>(self, prices: I) -> DivergenceIter { + DivergenceIter { + prices, + state: DivergenceState::new(self.0), + } + } +} + +pub struct DivergenceIter> { + prices: I, + state: DivergenceState, +} + +struct DivergenceState { + oscillator: O, + //price_lo, price_hi; osc_lo, osc_hi + mask: f64x4, + cycle: usize, + divergence: Option<(usize, Divergence)>, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Divergence { + Bearish, + Bullish, + HiddenBearish, + HiddenBullish, +} + +impl DivergenceState { + pub fn new(oscillator: O) -> Self { + Self { + oscillator, + mask: f64x4::splat(f64::NAN), + cycle: 0, + divergence: None, + } + } + fn cycle(&mut self, price: f64) -> Option { + let osc = self.oscillator.advance(price); + println!( + "{price} {osc} phi={} plo={} ohi={} olo={}", + self.mask[0], self.mask[1], self.mask[2], self.mask[3] + ); + + if self.mask.is_nan().any() { + self.mask = simd_swizzle!(f64x2::splat(price), f64x2::splat(osc), [0, 1, 2, 3]); + + return None; + } + + // match ( + // (self.price_lo, self.price_hi), + // (self.osc_lo, funnies.osc_hi), + // ) { + // // classic bearish + // // price makes higher highs but oscillator makes lower highs + // ((price_hi, price_lo), (osc_hi, osc_lo)) + // if price > price_hi && osc < osc_hi && osc > osc_lo => + // { + // self.price_hi = price; + // self.osc_hi = osc; + // + // ControlFlow::Continue(Some(Divergence::Bearish)) + // } + // // classic bullish + // // price makes lower lows but oscillator makes higher lows + // ((price_hi, price_lo), (osc_hi, osc_lo)) + // if price < price_lo && osc > osc_lo && osc < osc_hi => + // { + // self.price_lo = price; + // self.osc_lo = osc; + // + // ControlFlow::Continue(Some(Divergence::Bullish)) + // } + // // hidden bearish + // // price makes lower lows but oscillator makes lower highs + // ((price_hi, price_lo), (osc_hi, osc_lo)) if price < price_lo && osc < osc_hi => { + // self.price_lo = price; + // self.osc_hi = osc; + // + // ControlFlow::Continue(Some(Divergence::HiddenBearish)) + // } + // // hidden bullish + // // price makes higher highs but oscillator makes higher lows + // ((price_hi, price_lo), (osc_hi, osc_lo)) if price > price_hi && osc > osc_lo => { + // self.price_hi = price; + // self.osc_lo = osc; + // + // ControlFlow::Continue(Some(Divergence::HiddenBullish)) + // } + // _ => { + // // no divergence detected + // ControlFlow::Continue(None) + // } + // }; + + match self + .mask + .simd_lt(f64x4::from_array([price, price, osc, osc])) + .to_array() + { + [true, _, false, true] => { + self.mask[0] = price; + self.mask[2] = osc; + + Some(Divergence::Bearish) + } + [false, true, true, true] => { + self.mask[1] = price; + self.mask[3] = osc; + + Some(Divergence::Bullish) + } + [_, false, false, _] => { + self.mask[1] = price; + self.mask[2] = osc; + + Some(Divergence::HiddenBearish) + } + [true, _, _, true] => { + self.mask[0] = price; + self.mask[3] = osc; + + Some(Divergence::HiddenBullish) + } + _ => None, + } + } +} + +impl> Iterator for DivergenceIter { + type Item = (Range, Divergence); + + fn next(&mut self) -> Option { + loop { + if let Some(current) = self.state.cycle(self.prices.next()?) { + match self.state.divergence { + Some((start, old)) if old == current => { + self.state.divergence = Some((start, current)) + } + Some((start, old)) => { + self.state.divergence = Some((self.state.cycle, current)); + return Some((start..self.state.cycle, old)); + } + _ => self.state.divergence = Some((self.state.cycle, current)), + } + } + + self.state.cycle += 1; + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::rsi::Rsi; + use crate::testing::*; + + #[test] + fn test_divergence() { + let iter = Divergences::new(Rsi::<10>::default()).iter( + vec![ + 234.05, 255.95, 260.05, 270.05, 280.05, 290.05, 300.05, 310.05, 320.05, 330.05, + 180.08, 190.08, 200.08, 210.08, 220.08, 230.08, 240.08, 250.08, 260.08, 270.08, + ] + .into_iter(), + ); + + panic!("{:#?}", iter.collect_vec()) + } +} diff --git a/crates/algorithms/src/lib.rs b/crates/algorithms/src/lib.rs new file mode 100644 index 0000000..243022f --- /dev/null +++ b/crates/algorithms/src/lib.rs @@ -0,0 +1,94 @@ +//! # sanetrade_algorithms - SIMD-accelerated implementations of common algorithms used by traders +//! +//! ## Indicators +//! - EMA (specifically combined 20,50,100,200 day) +//! - RSI +//! +//! ## Helpers - algorithms that find differences between prices and indicators' outputs +//! - A divergence detector (typically combined with RSI) + +#![feature(portable_simd, const_float_classify)] + +use std::simd::{LaneCount, Simd, SupportedLaneCount}; + +//use futures_core::{ready, Stream}; +use itertools::Itertools; + +pub fn chunk(iter: &mut impl Iterator, size: usize) -> Option> { + let vec = iter.take(size).collect_vec(); + + if vec.len() < size { + None + } else { + Some(vec) + } +} + +pub mod divergence; +pub mod obv; + +pub mod dev; +pub mod ma; +pub mod rsi; + +use crate::dev::*; + +pub trait Algorithm { + type Output; + + fn advance(&mut self, value: T) -> Self::Output; +} + +pub struct Candles +where + LaneCount: SupportedLaneCount, +{ + pub open: Simd, + pub high: Simd, + pub low: Simd, + pub close: Simd, + pub volume: Simd, +} + +pub trait SimdAlgorithm { + type Output; + + fn simd_advance(&mut self, candles: Candles) -> Self::Output + where + LaneCount: SupportedLaneCount; +} + +pub trait Close { + fn close(&self) -> f64; +} + +pub trait Volume { + fn volume(&self) -> f64; +} + +pub trait Oscillator: Algorithm { + const PERIOD: usize; +} + +pub mod testing { + pub use itertools::assert_equal; + use std::fmt::Debug; + + pub fn assert_iter_close(a: A, b: B, epsilon: f64) + where + T: Debug + PartialEq + Into, + A: Iterator, + B: IntoIterator, + B::IntoIter: Iterator, + { + a.zip(b).for_each(|(a, b)| { + let a: f64 = a.into(); + let b: f64 = b.into(); + + assert!( + (a - b).abs() < epsilon, + "assertion failed: {a:?} !~= (epsilon: {epsilon:?}) {b:?}" + ); + }) + } +} diff --git a/crates/algorithms/src/ma.rs b/crates/algorithms/src/ma.rs new file mode 100644 index 0000000..746d978 --- /dev/null +++ b/crates/algorithms/src/ma.rs @@ -0,0 +1,65 @@ +use super::*; + +#[derive(Default)] +pub struct Ema(Nanf64); + +impl Ema

{ + const WMUL: f64 = 2. / (P + 1) as f64; +} + +impl Algorithm for Ema

{ + type Output = f64; + + fn advance(&mut self, value: f64) -> Self::Output { + self.0 + .update_to(|v| v.map_or(value, |v| Self::WMUL * value + (1.0 - Self::WMUL) * v)) + } +} + +impl Oscillator for Ema

{ + const PERIOD: usize = P; +} + +pub struct Sma { + index: usize, + count: usize, + sum: f64, + deque: [f64; P], +} + +impl Default for Sma

{ + fn default() -> Self { + Self { + index: 0, + count: 0, + sum: 0., + deque: [0.; P], + } + } +} + +impl Oscillator for Sma

{ + const PERIOD: usize = P; +} + +impl Algorithm for Sma

{ + type Output = f64; + + fn advance(&mut self, value: f64) -> Self::Output { + let old_val = self.deque[self.index]; + self.deque[self.index] = value; + + self.index = if self.index + 1 < P { + self.index + 1 + } else { + 0 + }; + + if self.count < P { + self.count += 1; + } + + self.sum = self.sum - old_val + value; + self.sum / (self.count as f64) + } +} diff --git a/crates/algorithms/src/obv.rs b/crates/algorithms/src/obv.rs new file mode 100644 index 0000000..071388a --- /dev/null +++ b/crates/algorithms/src/obv.rs @@ -0,0 +1,25 @@ +use super::*; + +#[derive(Default)] +pub struct Obv { + obv: f64, + prev_close: f64, +} + +impl Algorithm<&T> for Obv { + type Output = f64; + + fn advance(&mut self, value: &T) -> Self::Output { + let close = value.close(); + let volume = value.volume(); + + if close > self.prev_close { + self.obv = self.obv + volume; + } else if close < self.prev_close { + self.obv = self.obv - volume; + } + + self.prev_close = close; + self.obv + } +} diff --git a/crates/algorithms/src/rsi.rs b/crates/algorithms/src/rsi.rs new file mode 100644 index 0000000..6c2dcd1 --- /dev/null +++ b/crates/algorithms/src/rsi.rs @@ -0,0 +1,35 @@ +use super::*; +use crate::ma::Ema; + +/// Relative strength index +#[derive(Default)] +pub struct Rsi { + up: Ema

, + down: Ema

, + prev: Nanf64, +} + +impl Oscillator for Rsi

{ + const PERIOD: usize = P; +} + +impl Algorithm for Rsi

{ + type Output = f64; + + fn advance(&mut self, value: f64) -> Self::Output { + let diff = self + .prev + .update(|opt| (opt.map_or(0., |prev| value - prev), value)); + + println!("{value} {diff}"); + + // clever math hack to avoid having 2 separate f64 vars for up and down + let up = dbg!(self.up.advance(diff.max(0.))); + 100.0 * up / (up + dbg!(self.down.advance(diff.min(0.)))) + } +} + +/// An absolutely tiny number that is used as a seed for the EMAs if it's the first time +/// calculating the diff in RSI +#[doc(hidden)] +pub const TINY: f64 = 1e-8; diff --git a/crates/alpaca_openapi/Cargo.toml b/crates/alpaca_openapi/Cargo.toml new file mode 100644 index 0000000..dee310b --- /dev/null +++ b/crates/alpaca_openapi/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "alpaca_openapi" +version = "0.1.0" +edition = "2021" + +[dependencies] +alpaca_broker = { path = "gen/broker" } +alpaca_trading = { path = "gen/trading" } +alpaca_data = { path = "gen/data" } diff --git a/crates/alpaca_openapi/gen/broker/.gitignore b/crates/alpaca_openapi/gen/broker/.gitignore new file mode 100644 index 0000000..6aa1064 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/crates/alpaca_openapi/gen/broker/.openapi-generator-ignore b/crates/alpaca_openapi/gen/broker/.openapi-generator-ignore new file mode 100644 index 0000000..7484ee5 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/crates/alpaca_openapi/gen/broker/.openapi-generator/FILES b/crates/alpaca_openapi/gen/broker/.openapi-generator/FILES new file mode 100644 index 0000000..1b25d37 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/.openapi-generator/FILES @@ -0,0 +1,212 @@ +.gitignore +.openapi-generator-ignore +.travis.yml +Cargo.toml +README.md +docs/Account.md +docs/AccountConfigurations.md +docs/AccountCreationRequest.md +docs/AccountDocument.md +docs/AccountExtended.md +docs/AccountStatus.md +docs/AccountStatusEvent.md +docs/AccountType.md +docs/AccountUpdateRequest.md +docs/AccountsApi.md +docs/AchRelationship.md +docs/Activity.md +docs/ActivityItem.md +docs/ActivityType.md +docs/Agreement.md +docs/AgreementType.md +docs/Announcement.md +docs/AnnouncementCaSubType.md +docs/AnnouncementCaType.md +docs/ApplicationDocument.md +docs/Asset.md +docs/AssetClass.md +docs/AssetsApi.md +docs/AuthorizeOAuthTokenResponse.md +docs/Bank.md +docs/BatchJournalRequest.md +docs/BatchJournalRequestEntriesInner.md +docs/BatchJournalResponse.md +docs/Calendar.md +docs/CalendarApi.md +docs/Clock.md +docs/ClockApi.md +docs/Contact.md +docs/CorporateActionsApi.md +docs/CreateAchRelationshipRequest.md +docs/CreateBankRequest.md +docs/CreateJournalRequest.md +docs/CreateOrderRequest.md +docs/CreateOrderRequestStopLoss.md +docs/CreateOrderRequestTakeProfit.md +docs/CreateTransferRequest.md +docs/CreateWatchlistRequest.md +docs/CustodialAccountMinorIdentity.md +docs/DisclosureContextAnnotation.md +docs/Disclosures.md +docs/DocumentInner.md +docs/DocumentType.md +docs/DocumentUpload.md +docs/DocumentUploadRequest.md +docs/DocumentsApi.md +docs/Error.md +docs/EventsApi.md +docs/Exchange.md +docs/FundingApi.md +docs/Identity.md +docs/IssueOAuthTokenResponse.md +docs/Jnlc.md +docs/Jnls.md +docs/Journal.md +docs/JournalData.md +docs/JournalEntryType.md +docs/JournalResource.md +docs/JournalStatus.md +docs/JournalStatusEvent.md +docs/JournalsApi.md +docs/KycResult.md +docs/NonTradeActivity.md +docs/OAuthApi.md +docs/OAuthTokenRequest.md +docs/OathClientResponse.md +docs/Order.md +docs/OrderClass.md +docs/OrderClosedResponse.md +docs/OrderSide.md +docs/OrderStatus.md +docs/OrderType.md +docs/PortfolioHistory.md +docs/Position.md +docs/PositionClosedResponse.md +docs/TaxIdType.md +docs/TimeInForce.md +docs/TradeAccount.md +docs/TradeActivity.md +docs/TradeUpdateEvent.md +docs/TradeUpdateEventType.md +docs/TradingApi.md +docs/Transfer.md +docs/TransferData.md +docs/TransferDirection.md +docs/TransferResource.md +docs/TransferStatus.md +docs/TransferStatusEvent.md +docs/TransferTiming.md +docs/TransferType.md +docs/TrustedContact.md +docs/UntypedAchTransferData.md +docs/UntypedTransferData.md +docs/UntypedWireTransferData.md +docs/UpdateOrderRequest.md +docs/Watchlist.md +docs/WatchlistApi.md +git_push.sh +src/apis/accounts_api.rs +src/apis/assets_api.rs +src/apis/calendar_api.rs +src/apis/clock_api.rs +src/apis/configuration.rs +src/apis/corporate_actions_api.rs +src/apis/documents_api.rs +src/apis/events_api.rs +src/apis/funding_api.rs +src/apis/journals_api.rs +src/apis/mod.rs +src/apis/o_auth_api.rs +src/apis/trading_api.rs +src/apis/watchlist_api.rs +src/lib.rs +src/models/account.rs +src/models/account_configurations.rs +src/models/account_creation_request.rs +src/models/account_document.rs +src/models/account_extended.rs +src/models/account_status.rs +src/models/account_status_event.rs +src/models/account_type.rs +src/models/account_update_request.rs +src/models/ach_relationship.rs +src/models/activity.rs +src/models/activity_item.rs +src/models/activity_type.rs +src/models/agreement.rs +src/models/agreement_type.rs +src/models/announcement.rs +src/models/announcement_ca_sub_type.rs +src/models/announcement_ca_type.rs +src/models/application_document.rs +src/models/asset.rs +src/models/asset_class.rs +src/models/authorize_o_auth_token_response.rs +src/models/bank.rs +src/models/batch_journal_request.rs +src/models/batch_journal_request_entries_inner.rs +src/models/batch_journal_response.rs +src/models/calendar.rs +src/models/clock.rs +src/models/contact.rs +src/models/create_ach_relationship_request.rs +src/models/create_bank_request.rs +src/models/create_journal_request.rs +src/models/create_order_request.rs +src/models/create_order_request_stop_loss.rs +src/models/create_order_request_take_profit.rs +src/models/create_transfer_request.rs +src/models/create_watchlist_request.rs +src/models/custodial_account_minor_identity.rs +src/models/disclosure_context_annotation.rs +src/models/disclosures.rs +src/models/document_inner.rs +src/models/document_type.rs +src/models/document_upload.rs +src/models/document_upload_request.rs +src/models/error.rs +src/models/exchange.rs +src/models/identity.rs +src/models/issue_o_auth_token_response.rs +src/models/jnlc.rs +src/models/jnls.rs +src/models/journal.rs +src/models/journal_data.rs +src/models/journal_entry_type.rs +src/models/journal_resource.rs +src/models/journal_status.rs +src/models/journal_status_event.rs +src/models/kyc_result.rs +src/models/mod.rs +src/models/non_trade_activity.rs +src/models/o_auth_token_request.rs +src/models/oath_client_response.rs +src/models/order.rs +src/models/order_class.rs +src/models/order_closed_response.rs +src/models/order_side.rs +src/models/order_status.rs +src/models/order_type.rs +src/models/portfolio_history.rs +src/models/position.rs +src/models/position_closed_response.rs +src/models/tax_id_type.rs +src/models/time_in_force.rs +src/models/trade_account.rs +src/models/trade_activity.rs +src/models/trade_update_event.rs +src/models/trade_update_event_type.rs +src/models/transfer.rs +src/models/transfer_data.rs +src/models/transfer_direction.rs +src/models/transfer_resource.rs +src/models/transfer_status.rs +src/models/transfer_status_event.rs +src/models/transfer_timing.rs +src/models/transfer_type.rs +src/models/trusted_contact.rs +src/models/untyped_ach_transfer_data.rs +src/models/untyped_transfer_data.rs +src/models/untyped_wire_transfer_data.rs +src/models/update_order_request.rs +src/models/watchlist.rs diff --git a/crates/alpaca_openapi/gen/broker/.openapi-generator/VERSION b/crates/alpaca_openapi/gen/broker/.openapi-generator/VERSION new file mode 100644 index 0000000..18bb418 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.5.0 diff --git a/crates/alpaca_openapi/gen/broker/.travis.yml b/crates/alpaca_openapi/gen/broker/.travis.yml new file mode 100644 index 0000000..22761ba --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/crates/alpaca_openapi/gen/broker/Cargo.toml b/crates/alpaca_openapi/gen/broker/Cargo.toml new file mode 100644 index 0000000..05003b3 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "alpaca_broker" +version = "1.0.0" +authors = ["support@alpaca.markets"] +description = "Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API" +# Override this license by providing a License Object in the OpenAPI. +license = "Unlicense" +edition = "2018" + +[dependencies] +serde = "^1.0" +serde_derive = "^1.0" +serde_with = "^2.0" +serde_json = "^1.0" +url = "^2.2" +uuid = { version = "^1.0", features = ["serde", "v4"] } +[dependencies.reqwest] +version = "^0.11" +features = ["json", "multipart"] diff --git a/crates/alpaca_openapi/gen/broker/README.md b/crates/alpaca_openapi/gen/broker/README.md new file mode 100644 index 0000000..f8c7dbb --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/README.md @@ -0,0 +1,199 @@ +# Rust API client for alpaca_broker + +Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + +For more information, please visit [https://alpaca.markets/support](https://alpaca.markets/support) + +## Overview + +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 1.0.0 +- Package version: 1.0.0 +- Generator version: 7.5.0 +- Build package: `org.openapitools.codegen.languages.RustClientCodegen` + +## Installation + +Put the package under your project folder in a directory named `alpaca_broker` and add the following to `Cargo.toml` under `[dependencies]`: + +``` +alpaca_broker = { path = "./alpaca_broker" } +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://broker-api.sandbox.alpaca.markets* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*AccountsApi* | [**create_account**](docs/AccountsApi.md#create_account) | **POST** /v1/accounts | Create an account +*AccountsApi* | [**create_ach_relationship_for_account**](docs/AccountsApi.md#create_ach_relationship_for_account) | **POST** /v1/accounts/{account_id}/ach_relationships | Create an ACH Relationship +*AccountsApi* | [**create_recipient_bank**](docs/AccountsApi.md#create_recipient_bank) | **POST** /v1/accounts/{account_id}/recipient_banks | Create a Bank Relationship for an account +*AccountsApi* | [**create_transfer_for_account**](docs/AccountsApi.md#create_transfer_for_account) | **POST** /v1/accounts/{account_id}/transfers | Request a new transfer +*AccountsApi* | [**delete_account**](docs/AccountsApi.md#delete_account) | **DELETE** /v1/accounts/{account_id} | Request to close an account +*AccountsApi* | [**delete_ach_relationship_from_account**](docs/AccountsApi.md#delete_ach_relationship_from_account) | **DELETE** /v1/accounts/{account_id}/ach_relationships/{ach_relationship_id} | Delete an existing ACH relationship +*AccountsApi* | [**delete_recipient_bank**](docs/AccountsApi.md#delete_recipient_bank) | **DELETE** /v1/accounts/{account_id}/recipient_banks/{bank_id} | Delete a Bank Relationship for an account +*AccountsApi* | [**delete_transfer**](docs/AccountsApi.md#delete_transfer) | **DELETE** /v1/accounts/{account_id}/transfers/{transfer_id} | Request to close a transfer +*AccountsApi* | [**get_account**](docs/AccountsApi.md#get_account) | **GET** /v1/accounts/{account_id} | Get an account by Id. +*AccountsApi* | [**get_account_ach_relationships**](docs/AccountsApi.md#get_account_ach_relationships) | **GET** /v1/accounts/{account_id}/ach_relationships | Retrieve ACH Relationships for an account +*AccountsApi* | [**get_account_activities**](docs/AccountsApi.md#get_account_activities) | **GET** /v1/accounts/activities | Retrieve account activities +*AccountsApi* | [**get_account_activities_by_type**](docs/AccountsApi.md#get_account_activities_by_type) | **GET** /v1/accounts/activities/{activity_type} | Retrieve specific account activities +*AccountsApi* | [**get_all_accounts**](docs/AccountsApi.md#get_all_accounts) | **GET** /v1/accounts | Get all accounts +*AccountsApi* | [**get_recipient_banks**](docs/AccountsApi.md#get_recipient_banks) | **GET** /v1/accounts/{account_id}/recipient_banks | Retrieve bank relationships for an account +*AccountsApi* | [**get_trading_account**](docs/AccountsApi.md#get_trading_account) | **GET** /v1/trading/accounts/{account_id}/account | Retrieve trading details for an account. +*AccountsApi* | [**get_transfers_for_account**](docs/AccountsApi.md#get_transfers_for_account) | **GET** /v1/accounts/{account_id}/transfers | Return a list of transfers for an account. +*AccountsApi* | [**patch_account**](docs/AccountsApi.md#patch_account) | **PATCH** /v1/accounts/{account_id} | Update an account +*AccountsApi* | [**suscribe_to_account_status_sse**](docs/AccountsApi.md#suscribe_to_account_status_sse) | **GET** /v1/events/accounts/status | Subscribe to account status events (SSE). +*AccountsApi* | [**upload_doc_to_account**](docs/AccountsApi.md#upload_doc_to_account) | **POST** /v1/accounts/{account_id}/documents/upload | Upload a document to an already existing account +*AssetsApi* | [**get_asset_by_symbol_or_id**](docs/AssetsApi.md#get_asset_by_symbol_or_id) | **GET** /v1/assets/{symbol_or_asset_id} | Retrieve an asset by UUID +*AssetsApi* | [**get_assets**](docs/AssetsApi.md#get_assets) | **GET** /v1/assets | Retrieve all assets +*CalendarApi* | [**query_market_calendar**](docs/CalendarApi.md#query_market_calendar) | **GET** /v1/calendar | Query market calendar +*ClockApi* | [**query_market_clock**](docs/ClockApi.md#query_market_clock) | **GET** /v1/clock | Query market clock +*CorporateActionsApi* | [**get_corporate_announcements**](docs/CorporateActionsApi.md#get_corporate_announcements) | **GET** /v1/corporate_actions/announcements | Retrieving Announcements +*DocumentsApi* | [**download_doc_from_account**](docs/DocumentsApi.md#download_doc_from_account) | **GET** /v1/accounts/{account_id}/documents/{document_id}/download | Download a document file that belongs to an account. +*DocumentsApi* | [**download_document_by_id**](docs/DocumentsApi.md#download_document_by_id) | **GET** /v1/documents/{document_id} | Download a document file directly +*DocumentsApi* | [**get_docs_for_account**](docs/DocumentsApi.md#get_docs_for_account) | **GET** /v1/accounts/{account_id}/documents | Return a list of account documents. +*EventsApi* | [**subscribe_to_journal_status_sse**](docs/EventsApi.md#subscribe_to_journal_status_sse) | **GET** /v1/events/journals/status | Subscribe to journal events (SSE). +*EventsApi* | [**subscribe_to_trade_sse**](docs/EventsApi.md#subscribe_to_trade_sse) | **GET** /v1/events/trades | Subscribe to Trade Events (SSE) +*EventsApi* | [**subscribe_to_transfer_status_sse**](docs/EventsApi.md#subscribe_to_transfer_status_sse) | **GET** /v1/events/transfers/status | Subscribe to Transfer Events (SSE) +*EventsApi* | [**suscribe_to_account_status_sse**](docs/EventsApi.md#suscribe_to_account_status_sse) | **GET** /v1/events/accounts/status | Subscribe to account status events (SSE). +*FundingApi* | [**create_ach_relationship_for_account**](docs/FundingApi.md#create_ach_relationship_for_account) | **POST** /v1/accounts/{account_id}/ach_relationships | Create an ACH Relationship +*FundingApi* | [**create_recipient_bank**](docs/FundingApi.md#create_recipient_bank) | **POST** /v1/accounts/{account_id}/recipient_banks | Create a Bank Relationship for an account +*FundingApi* | [**create_transfer_for_account**](docs/FundingApi.md#create_transfer_for_account) | **POST** /v1/accounts/{account_id}/transfers | Request a new transfer +*FundingApi* | [**delete_ach_relationship_from_account**](docs/FundingApi.md#delete_ach_relationship_from_account) | **DELETE** /v1/accounts/{account_id}/ach_relationships/{ach_relationship_id} | Delete an existing ACH relationship +*FundingApi* | [**delete_recipient_bank**](docs/FundingApi.md#delete_recipient_bank) | **DELETE** /v1/accounts/{account_id}/recipient_banks/{bank_id} | Delete a Bank Relationship for an account +*FundingApi* | [**delete_transfer**](docs/FundingApi.md#delete_transfer) | **DELETE** /v1/accounts/{account_id}/transfers/{transfer_id} | Request to close a transfer +*FundingApi* | [**get_account_ach_relationships**](docs/FundingApi.md#get_account_ach_relationships) | **GET** /v1/accounts/{account_id}/ach_relationships | Retrieve ACH Relationships for an account +*FundingApi* | [**get_recipient_banks**](docs/FundingApi.md#get_recipient_banks) | **GET** /v1/accounts/{account_id}/recipient_banks | Retrieve bank relationships for an account +*FundingApi* | [**get_transfers_for_account**](docs/FundingApi.md#get_transfers_for_account) | **GET** /v1/accounts/{account_id}/transfers | Return a list of transfers for an account. +*FundingApi* | [**subscribe_to_transfer_status_sse**](docs/FundingApi.md#subscribe_to_transfer_status_sse) | **GET** /v1/events/transfers/status | Subscribe to Transfer Events (SSE) +*JournalsApi* | [**create_batch_journal**](docs/JournalsApi.md#create_batch_journal) | **POST** /v1/journals/batch | Create a Batch Journal Transaction (One-to-Many) +*JournalsApi* | [**create_journal**](docs/JournalsApi.md#create_journal) | **POST** /v1/journals | Create a Journal. +*JournalsApi* | [**delete_journal_by_id**](docs/JournalsApi.md#delete_journal_by_id) | **DELETE** /v1/journals/{journal_id} | Cancel a pending journal. +*JournalsApi* | [**get_all_journals**](docs/JournalsApi.md#get_all_journals) | **GET** /v1/journals | Return a list of requested journals. +*JournalsApi* | [**subscribe_to_journal_status_sse**](docs/JournalsApi.md#subscribe_to_journal_status_sse) | **GET** /v1/events/journals/status | Subscribe to journal events (SSE). +*OAuthApi* | [**authorize_o_auth_token**](docs/OAuthApi.md#authorize_o_auth_token) | **POST** /v1/oauth/authorize | Authorize an OAuth Token +*OAuthApi* | [**get_o_auth_client**](docs/OAuthApi.md#get_o_auth_client) | **GET** /v1/oauth/clients/{client_id} | Get an OAuth client +*OAuthApi* | [**issue_o_auth_token**](docs/OAuthApi.md#issue_o_auth_token) | **POST** /v1/oauth/token | Issue an OAuth token. +*TradingApi* | [**close_all_positions_for_account**](docs/TradingApi.md#close_all_positions_for_account) | **DELETE** /v1/trading/accounts/{account_id}/positions | Close All Positions for an Account +*TradingApi* | [**close_position_for_account_by_symbol**](docs/TradingApi.md#close_position_for_account_by_symbol) | **DELETE** /v1/trading/accounts/{account_id}/positions/{symbol_or_asset_id} | Close a Position for an Account +*TradingApi* | [**create_order_for_account**](docs/TradingApi.md#create_order_for_account) | **POST** /v1/trading/accounts/{account_id}/orders | Create an order for an account. +*TradingApi* | [**delete_all_orders_for_account**](docs/TradingApi.md#delete_all_orders_for_account) | **DELETE** /v1/trading/accounts/{account_id}/orders | Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. +*TradingApi* | [**delete_order_for_account**](docs/TradingApi.md#delete_order_for_account) | **DELETE** /v1/trading/accounts/{account_id}/orders/{order_id} | Attempts to cancel an open order. +*TradingApi* | [**get_all_orders_for_account**](docs/TradingApi.md#get_all_orders_for_account) | **GET** /v1/trading/accounts/{account_id}/orders | Retrieves a list of orders for the account, filtered by the supplied query parameters. +*TradingApi* | [**get_order_for_account**](docs/TradingApi.md#get_order_for_account) | **GET** /v1/trading/accounts/{account_id}/orders/{order_id} | Retrieves a single order for the given order_id. +*TradingApi* | [**get_positions_for_account**](docs/TradingApi.md#get_positions_for_account) | **GET** /v1/trading/accounts/{account_id}/positions | List open positions for an account +*TradingApi* | [**get_positions_for_account_by_symbol**](docs/TradingApi.md#get_positions_for_account_by_symbol) | **GET** /v1/trading/accounts/{account_id}/positions/{symbol_or_asset_id} | Get an Open Position for account by Symbol or AssetId +*TradingApi* | [**replace_order_for_account**](docs/TradingApi.md#replace_order_for_account) | **PATCH** /v1/trading/accounts/{account_id}/orders/{order_id} | Replaces a single order with updated parameters +*TradingApi* | [**subscribe_to_trade_sse**](docs/TradingApi.md#subscribe_to_trade_sse) | **GET** /v1/events/trades | Subscribe to Trade Events (SSE) +*WatchlistApi* | [**create_watchlist_for_account**](docs/WatchlistApi.md#create_watchlist_for_account) | **POST** /v1/trading/accounts/{account_id}/watchlists | Create a new watchlist +*WatchlistApi* | [**delete_watchlist_from_account_by_id**](docs/WatchlistApi.md#delete_watchlist_from_account_by_id) | **DELETE** /v1/accounts/{account_id}/watchlists/{watchlist_id} | Remove a watchlist +*WatchlistApi* | [**get_all_watchlists_for_account**](docs/WatchlistApi.md#get_all_watchlists_for_account) | **GET** /v1/trading/accounts/{account_id}/watchlists | Retrieve all watchlists +*WatchlistApi* | [**get_watchlist_for_account_by_id**](docs/WatchlistApi.md#get_watchlist_for_account_by_id) | **GET** /v1/accounts/{account_id}/watchlists/{watchlist_id} | Manage watchlists +*WatchlistApi* | [**replace_watchlist_for_account_by_id**](docs/WatchlistApi.md#replace_watchlist_for_account_by_id) | **PUT** /v1/accounts/{account_id}/watchlists/{watchlist_id} | Update an existing watchlist + + +## Documentation For Models + + - [Account](docs/Account.md) + - [AccountConfigurations](docs/AccountConfigurations.md) + - [AccountCreationRequest](docs/AccountCreationRequest.md) + - [AccountDocument](docs/AccountDocument.md) + - [AccountExtended](docs/AccountExtended.md) + - [AccountStatus](docs/AccountStatus.md) + - [AccountStatusEvent](docs/AccountStatusEvent.md) + - [AccountType](docs/AccountType.md) + - [AccountUpdateRequest](docs/AccountUpdateRequest.md) + - [AchRelationship](docs/AchRelationship.md) + - [Activity](docs/Activity.md) + - [ActivityItem](docs/ActivityItem.md) + - [ActivityType](docs/ActivityType.md) + - [Agreement](docs/Agreement.md) + - [AgreementType](docs/AgreementType.md) + - [Announcement](docs/Announcement.md) + - [AnnouncementCaSubType](docs/AnnouncementCaSubType.md) + - [AnnouncementCaType](docs/AnnouncementCaType.md) + - [ApplicationDocument](docs/ApplicationDocument.md) + - [Asset](docs/Asset.md) + - [AssetClass](docs/AssetClass.md) + - [AuthorizeOAuthTokenResponse](docs/AuthorizeOAuthTokenResponse.md) + - [Bank](docs/Bank.md) + - [BatchJournalRequest](docs/BatchJournalRequest.md) + - [BatchJournalRequestEntriesInner](docs/BatchJournalRequestEntriesInner.md) + - [BatchJournalResponse](docs/BatchJournalResponse.md) + - [Calendar](docs/Calendar.md) + - [Clock](docs/Clock.md) + - [Contact](docs/Contact.md) + - [CreateAchRelationshipRequest](docs/CreateAchRelationshipRequest.md) + - [CreateBankRequest](docs/CreateBankRequest.md) + - [CreateJournalRequest](docs/CreateJournalRequest.md) + - [CreateOrderRequest](docs/CreateOrderRequest.md) + - [CreateOrderRequestStopLoss](docs/CreateOrderRequestStopLoss.md) + - [CreateOrderRequestTakeProfit](docs/CreateOrderRequestTakeProfit.md) + - [CreateTransferRequest](docs/CreateTransferRequest.md) + - [CreateWatchlistRequest](docs/CreateWatchlistRequest.md) + - [CustodialAccountMinorIdentity](docs/CustodialAccountMinorIdentity.md) + - [DisclosureContextAnnotation](docs/DisclosureContextAnnotation.md) + - [Disclosures](docs/Disclosures.md) + - [DocumentInner](docs/DocumentInner.md) + - [DocumentType](docs/DocumentType.md) + - [DocumentUpload](docs/DocumentUpload.md) + - [DocumentUploadRequest](docs/DocumentUploadRequest.md) + - [Error](docs/Error.md) + - [Exchange](docs/Exchange.md) + - [Identity](docs/Identity.md) + - [IssueOAuthTokenResponse](docs/IssueOAuthTokenResponse.md) + - [Jnlc](docs/Jnlc.md) + - [Jnls](docs/Jnls.md) + - [Journal](docs/Journal.md) + - [JournalData](docs/JournalData.md) + - [JournalEntryType](docs/JournalEntryType.md) + - [JournalResource](docs/JournalResource.md) + - [JournalStatus](docs/JournalStatus.md) + - [JournalStatusEvent](docs/JournalStatusEvent.md) + - [KycResult](docs/KycResult.md) + - [NonTradeActivity](docs/NonTradeActivity.md) + - [OAuthTokenRequest](docs/OAuthTokenRequest.md) + - [OathClientResponse](docs/OathClientResponse.md) + - [Order](docs/Order.md) + - [OrderClass](docs/OrderClass.md) + - [OrderClosedResponse](docs/OrderClosedResponse.md) + - [OrderSide](docs/OrderSide.md) + - [OrderStatus](docs/OrderStatus.md) + - [OrderType](docs/OrderType.md) + - [PortfolioHistory](docs/PortfolioHistory.md) + - [Position](docs/Position.md) + - [PositionClosedResponse](docs/PositionClosedResponse.md) + - [TaxIdType](docs/TaxIdType.md) + - [TimeInForce](docs/TimeInForce.md) + - [TradeAccount](docs/TradeAccount.md) + - [TradeActivity](docs/TradeActivity.md) + - [TradeUpdateEvent](docs/TradeUpdateEvent.md) + - [TradeUpdateEventType](docs/TradeUpdateEventType.md) + - [Transfer](docs/Transfer.md) + - [TransferData](docs/TransferData.md) + - [TransferDirection](docs/TransferDirection.md) + - [TransferResource](docs/TransferResource.md) + - [TransferStatus](docs/TransferStatus.md) + - [TransferStatusEvent](docs/TransferStatusEvent.md) + - [TransferTiming](docs/TransferTiming.md) + - [TransferType](docs/TransferType.md) + - [TrustedContact](docs/TrustedContact.md) + - [UntypedAchTransferData](docs/UntypedAchTransferData.md) + - [UntypedTransferData](docs/UntypedTransferData.md) + - [UntypedWireTransferData](docs/UntypedWireTransferData.md) + - [UpdateOrderRequest](docs/UpdateOrderRequest.md) + - [Watchlist](docs/Watchlist.md) + + +To get access to the crate's generated documentation, use: + +``` +cargo doc --open +``` + +## Author + +support@alpaca.markets + diff --git a/crates/alpaca_openapi/gen/broker/docs/Account.md b/crates/alpaca_openapi/gen/broker/docs/Account.md new file mode 100644 index 0000000..b63e4c9 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Account.md @@ -0,0 +1,19 @@ +# Account + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**account_number** | Option<**String**> | | +**status** | [**models::AccountStatus**](AccountStatus.md) | | +**crypto_status** | Option<[**models::AccountStatus**](AccountStatus.md)> | | [optional] +**currency** | **String** | Always \"USD\" | +**created_at** | **String** | | +**last_equity** | **String** | | +**kyc_results** | Option<[**models::KycResult**](KYCResult.md)> | | [optional] +**account_type** | Option<[**models::AccountType**](AccountType.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/AccountConfigurations.md b/crates/alpaca_openapi/gen/broker/docs/AccountConfigurations.md new file mode 100644 index 0000000..be1a64d --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AccountConfigurations.md @@ -0,0 +1,17 @@ +# AccountConfigurations + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dtbp_check** | **String** | both, entry, or exit. Controls Day Trading Margin Call (DTMC) checks. | +**trade_confirm_email** | **String** | all or none. If none, emails for order fills are not sent. | +**suspend_trade** | **bool** | If true, new orders are blocked. | +**no_shorting** | **bool** | If true, account becomes long-only mode. | +**fractional_trading** | **bool** | If true, account is able to participate in fractional trading | +**max_margin_multiplier** | **String** | Can be \"1\" or \"2\" | +**pdt_check** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/AccountCreationRequest.md b/crates/alpaca_openapi/gen/broker/docs/AccountCreationRequest.md new file mode 100644 index 0000000..e2e1bec --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AccountCreationRequest.md @@ -0,0 +1,16 @@ +# AccountCreationRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**contact** | [**models::Contact**](Contact.md) | | +**identity** | [**models::Identity**](Identity.md) | | +**disclosures** | [**models::Disclosures**](Disclosures.md) | | +**agreements** | [**Vec**](Agreement.md) | The client has to present the Alpaca Account and Margin Agreements to the end user, and have them read full sentences. | +**documents** | Option<[**Vec**](DocumentUploadRequest.md)> | | [optional] +**trusted_contact** | Option<[**models::TrustedContact**](TrustedContact.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/AccountDocument.md b/crates/alpaca_openapi/gen/broker/docs/AccountDocument.md new file mode 100644 index 0000000..30c5879 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AccountDocument.md @@ -0,0 +1,15 @@ +# AccountDocument + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**document_type** | [**models::DocumentType**](DocumentType.md) | | +**document_sub_type** | Option<**String**> | | [optional] +**mime_type** | Option<**String**> | | [optional] +**created_at** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/AccountExtended.md b/crates/alpaca_openapi/gen/broker/docs/AccountExtended.md new file mode 100644 index 0000000..c1c4aa5 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AccountExtended.md @@ -0,0 +1,29 @@ +# AccountExtended + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**account_number** | Option<**String**> | | +**status** | [**models::AccountStatus**](AccountStatus.md) | | +**crypto_status** | Option<[**models::AccountStatus**](AccountStatus.md)> | | [optional] +**kyc_result** | Option<[**models::KycResult**](KYCResult.md)> | | [optional] +**currency** | **String** | Always \"USD\" | +**last_equity** | **String** | | +**created_at** | **String** | | +**contact** | Option<[**models::Contact**](Contact.md)> | | [optional] +**identity** | Option<[**models::Identity**](Identity.md)> | | [optional] +**disclosures** | Option<[**models::Disclosures**](Disclosures.md)> | | [optional] +**agreements** | Option<[**Vec**](Agreement.md)> | | [optional] +**documents** | Option<[**Vec**](ApplicationDocument.md)> | | [optional] +**trusted_contact** | Option<[**models::TrustedContact**](TrustedContact.md)> | | [optional] +**account_name** | Option<**String**> | | [optional] +**account_type** | [**models::AccountType**](AccountType.md) | | +**custodial_account_type** | Option<**String**> | \"UGMA\" or \"UTMA\" only used when account_type is \"custodial\" | [optional] +**minor_identity** | Option<[**models::CustodialAccountMinorIdentity**](CustodialAccountMinorIdentity.md)> | | [optional] +**trading_configurations** | Option<[**models::AccountConfigurations**](AccountConfigurations.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/AccountStatus.md b/crates/alpaca_openapi/gen/broker/docs/AccountStatus.md new file mode 100644 index 0000000..8169b79 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AccountStatus.md @@ -0,0 +1,31 @@ +# AccountStatus + +## Enum Variants + +| Name | Value | +|---- | -----| +| Onboarding | ONBOARDING | +| Submitted | SUBMITTED | +| Resubmitted | RESUBMITTED | +| SubmissionFailed | SUBMISSION_FAILED | +| ActionRequired | ACTION_REQUIRED | +| Edited | EDITED | +| AccountUpdated | ACCOUNT_UPDATED | +| ApprovalPending | APPROVAL_PENDING | +| ReapprovalPending | REAPPROVAL_PENDING | +| SignedUp | SIGNED_UP | +| KycSubmitted | KYC_SUBMITTED | +| Limited | LIMITED | +| AmlReview | AML_REVIEW | +| Approved | APPROVED | +| Rejected | REJECTED | +| Active | ACTIVE | +| Disabled | DISABLED | +| DisablePending | DISABLE_PENDING | +| AccountClosed | ACCOUNT_CLOSED | +| PaperOnly | PAPER_ONLY | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/AccountStatusEvent.md b/crates/alpaca_openapi/gen/broker/docs/AccountStatusEvent.md new file mode 100644 index 0000000..be14e80 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AccountStatusEvent.md @@ -0,0 +1,18 @@ +# AccountStatusEvent + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account_id** | **String** | | +**account_number** | **String** | | +**status_from** | [**models::AccountStatus**](AccountStatus.md) | | +**status_to** | [**models::AccountStatus**](AccountStatus.md) | | +**reason** | **String** | Optional | +**at** | **String** | Timestamp of event | +**kyc_result** | Option<[**models::KycResult**](KYCResult.md)> | | [optional] +**event_id** | **i32** | monotonically increasing 64bit integer | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/AccountType.md b/crates/alpaca_openapi/gen/broker/docs/AccountType.md new file mode 100644 index 0000000..1db602d --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AccountType.md @@ -0,0 +1,14 @@ +# AccountType + +## Enum Variants + +| Name | Value | +|---- | -----| +| Trading | trading | +| Custodial | custodial | +| DonorAdvised | donor_advised | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/AccountUpdateRequest.md b/crates/alpaca_openapi/gen/broker/docs/AccountUpdateRequest.md new file mode 100644 index 0000000..4966033 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AccountUpdateRequest.md @@ -0,0 +1,14 @@ +# AccountUpdateRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**contact** | Option<[**models::Contact**](Contact.md)> | | [optional] +**identity** | Option<[**models::Identity**](Identity.md)> | | [optional] +**disclosures** | Option<[**models::Disclosures**](Disclosures.md)> | | [optional] +**trusted_contact** | Option<[**models::TrustedContact**](TrustedContact.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/AccountsApi.md b/crates/alpaca_openapi/gen/broker/docs/AccountsApi.md new file mode 100644 index 0000000..53fbd4b --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AccountsApi.md @@ -0,0 +1,632 @@ +# \AccountsApi + +All URIs are relative to *https://broker-api.sandbox.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_account**](AccountsApi.md#create_account) | **POST** /v1/accounts | Create an account +[**create_ach_relationship_for_account**](AccountsApi.md#create_ach_relationship_for_account) | **POST** /v1/accounts/{account_id}/ach_relationships | Create an ACH Relationship +[**create_recipient_bank**](AccountsApi.md#create_recipient_bank) | **POST** /v1/accounts/{account_id}/recipient_banks | Create a Bank Relationship for an account +[**create_transfer_for_account**](AccountsApi.md#create_transfer_for_account) | **POST** /v1/accounts/{account_id}/transfers | Request a new transfer +[**delete_account**](AccountsApi.md#delete_account) | **DELETE** /v1/accounts/{account_id} | Request to close an account +[**delete_ach_relationship_from_account**](AccountsApi.md#delete_ach_relationship_from_account) | **DELETE** /v1/accounts/{account_id}/ach_relationships/{ach_relationship_id} | Delete an existing ACH relationship +[**delete_recipient_bank**](AccountsApi.md#delete_recipient_bank) | **DELETE** /v1/accounts/{account_id}/recipient_banks/{bank_id} | Delete a Bank Relationship for an account +[**delete_transfer**](AccountsApi.md#delete_transfer) | **DELETE** /v1/accounts/{account_id}/transfers/{transfer_id} | Request to close a transfer +[**get_account**](AccountsApi.md#get_account) | **GET** /v1/accounts/{account_id} | Get an account by Id. +[**get_account_ach_relationships**](AccountsApi.md#get_account_ach_relationships) | **GET** /v1/accounts/{account_id}/ach_relationships | Retrieve ACH Relationships for an account +[**get_account_activities**](AccountsApi.md#get_account_activities) | **GET** /v1/accounts/activities | Retrieve account activities +[**get_account_activities_by_type**](AccountsApi.md#get_account_activities_by_type) | **GET** /v1/accounts/activities/{activity_type} | Retrieve specific account activities +[**get_all_accounts**](AccountsApi.md#get_all_accounts) | **GET** /v1/accounts | Get all accounts +[**get_recipient_banks**](AccountsApi.md#get_recipient_banks) | **GET** /v1/accounts/{account_id}/recipient_banks | Retrieve bank relationships for an account +[**get_trading_account**](AccountsApi.md#get_trading_account) | **GET** /v1/trading/accounts/{account_id}/account | Retrieve trading details for an account. +[**get_transfers_for_account**](AccountsApi.md#get_transfers_for_account) | **GET** /v1/accounts/{account_id}/transfers | Return a list of transfers for an account. +[**patch_account**](AccountsApi.md#patch_account) | **PATCH** /v1/accounts/{account_id} | Update an account +[**suscribe_to_account_status_sse**](AccountsApi.md#suscribe_to_account_status_sse) | **GET** /v1/events/accounts/status | Subscribe to account status events (SSE). +[**upload_doc_to_account**](AccountsApi.md#upload_doc_to_account) | **POST** /v1/accounts/{account_id}/documents/upload | Upload a document to an already existing account + + + +## create_account + +> models::Account create_account(account_creation_request) +Create an account + +Submit an account application with KYC information. This will create a trading account for the end user. The account status may or may not be ACTIVE immediately and you will receive account status updates on the event API. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_creation_request** | [**AccountCreationRequest**](AccountCreationRequest.md) | | [required] | + +### Return type + +[**models::Account**](Account.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## create_ach_relationship_for_account + +> models::AchRelationship create_ach_relationship_for_account(account_id, create_ach_relationship_request) +Create an ACH Relationship + +Create a new ACHRelationship for an account If successful, will return 200 code with a newly created ACH Relationship entity. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**create_ach_relationship_request** | [**CreateAchRelationshipRequest**](CreateAchRelationshipRequest.md) | Create ACH Relationship | [required] | + +### Return type + +[**models::AchRelationship**](ACHRelationship.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## create_recipient_bank + +> models::Bank create_recipient_bank(account_id, create_bank_request) +Create a Bank Relationship for an account + +If successful, retrieves Bank Relationships for an account + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**create_bank_request** | [**CreateBankRequest**](CreateBankRequest.md) | | [required] | + +### Return type + +[**models::Bank**](Bank.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## create_transfer_for_account + +> models::Transfer create_transfer_for_account(account_id, create_transfer_request) +Request a new transfer + +Create a new transfer to an account to fund it. In the sandbox environment, you can instantly deposit to or withdraw from an account with a virtual money amount. In the production environment, this endpoint is used only for requesting an outgoing (withdrawal) wire transfer at this moment. For the wire transfer (in production), you need to create a bank resource first using the Bank API. For more on how to fund an account in sandbox please check out this tutorial [here](https://alpaca.markets/learn/fund-broker-api/). + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**create_transfer_request** | [**CreateTransferRequest**](CreateTransferRequest.md) | | [required] | + +### Return type + +[**models::Transfer**](Transfer.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_account + +> delete_account(account_id) +Request to close an account + +This operation closes an active account. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_ach_relationship_from_account + +> delete_ach_relationship_from_account(account_id, ach_relationship_id) +Delete an existing ACH relationship + +Delete an existing ACH relationship for an account + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**ach_relationship_id** | **uuid::Uuid** | ACH relationship identifier | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_recipient_bank + +> delete_recipient_bank(account_id, bank_id) +Delete a Bank Relationship for an account + +If successful, deletes Bank Relationship for an account + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**bank_id** | **uuid::Uuid** | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_transfer + +> delete_transfer(account_id, transfer_id) +Request to close a transfer + +Request to close a transfer + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**transfer_id** | **uuid::Uuid** | Tranfer identifier | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_account + +> models::AccountExtended get_account(account_id) +Get an account by Id. + +You can query a specific account that you submitted to Alpaca by passing into the query the account_id associated with the account you’re retrieving. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | + +### Return type + +[**models::AccountExtended**](AccountExtended.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_account_ach_relationships + +> Vec get_account_ach_relationships(account_id, statuses) +Retrieve ACH Relationships for an account + +Returns a list of ACH Relationships for an account + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**statuses** | Option<**String**> | Comma-separated status values | | + +### Return type + +[**Vec**](ACHRelationship.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_account_activities + +> Vec get_account_activities(account_id, date, until, after, direction, page_size, page_token) +Retrieve account activities + +Returns an array of Activities Notes: * Pagination is handled using the `page_token` and `page_size` parameters. * `page_token` represents the ID of the end of your current page of results. for example if in your first response the id of the last Activiy item returned in the array was `20220203000000000::045b3b8d-c566-4bef-b741-2bf598dd6ae7`, you'd pass that value as `page_token` to get the next page of results * If specified with a `direction` of `desc`, for example, the results will end before the activity with the specified ID. * If specified with a `direction` of `asc`, results will begin with the activity immediately after the one specified. * `page_size` is the maximum number of entries to return in the response. * If `date` is not specified, the default and maximum value is 100. * If `date` is specified, the default behavior is to return all results, and there is no maximum page size. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | Option<**uuid::Uuid**> | id of a single account to filter by | | +**date** | Option<**String**> | Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported. | | +**until** | Option<**String**> | Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported. | | +**after** | Option<**String**> | Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported. Cannot be used with date. | | +**direction** | Option<**String**> | The chronological order of response based on the submission time. asc or desc. Defaults to desc. | | +**page_size** | Option<**i32**> | The maximum number of entries to return in the response | |[default to 100] +**page_token** | Option<**String**> | The Activity ID of the end of your current page of results. | | + +### Return type + +[**Vec**](Activity.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_account_activities_by_type + +> Vec get_account_activities_by_type(activity_type, account_id, date, until, after, direction, page_size, page_token) +Retrieve specific account activities + +Retrieves an Array of Activies by type Notes: * Pagination is handled using the `page_token` and `page_size` parameters. * `page_token` represents the ID of the end of your current page of results. for example if in your first response the id of the last Activiy item returned in the array was `20220203000000000::045b3b8d-c566-4bef-b741-2bf598dd6ae7`, you'd pass that value as `page_token` to get the next page of results * If specified with a `direction` of `desc`, for example, the results will end before the activity with the specified ID. * If specified with a `direction` of `asc`, results will begin with the activity immediately after the one specified. * `page_size` is the maximum number of entries to return in the response. * If `date` is not specified, the default and maximum value is 100. * If `date` is specified, the default behavior is to return all results, and there is no maximum page size. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**activity_type** | **String** | see ActivityType model for details about what the different types mean | [required] | +**account_id** | Option<**uuid::Uuid**> | id of a single account to filter by | | +**date** | Option<**String**> | Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported. | | +**until** | Option<**String**> | Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported. | | +**after** | Option<**String**> | Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported. | | +**direction** | Option<**String**> | The chronological order of response based on the submission time. asc or desc. Defaults to desc. | | +**page_size** | Option<**i32**> | The maximum number of entries to return in the response | |[default to 100] +**page_token** | Option<**String**> | The ID of the end of your current page of results | | + +### Return type + +[**Vec**](Activity.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_all_accounts + +> Vec get_all_accounts(query, created_after, created_before, status, sort, entities) +Get all accounts + +Retrieves all accounts found by the query' + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**query** | Option<**String**> | Pass space-delimited tokens. The response will contain accounts that match with each of the tokens (logical AND). A match means the token is present in either the account’s associated account number, phone number, name, or e-mail address (logical OR). | | +**created_after** | Option<**String**> | | | +**created_before** | Option<**String**> | | | +**status** | Option<**String**> | See the AccountStatus model for values | | +**sort** | Option<**String**> | The chronological order of response based on the submission time. asc or desc. Defaults to desc. | | +**entities** | Option<**String**> | Comma-delimited entity names to include in the response | | + +### Return type + +[**Vec**](Account.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_recipient_banks + +> Vec get_recipient_banks(account_id, status, bank_name) +Retrieve bank relationships for an account + +Retrieves Bank Relationships for an account + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**status** | Option<**String**> | | | +**bank_name** | Option<**String**> | | | + +### Return type + +[**Vec**](Bank.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_trading_account + +> models::TradeAccount get_trading_account(account_id) +Retrieve trading details for an account. + +As a broker you can view more trading details about your users. The response is a Trading Account model. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | + +### Return type + +[**models::TradeAccount**](TradeAccount.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_transfers_for_account + +> Vec get_transfers_for_account(account_id, direction, limit, offset) +Return a list of transfers for an account. + +You can query a list of transfers for an account. You can filter requested transfers by values such as direction and status. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**direction** | Option<**String**> | INCOMING or OUTGOING | | +**limit** | Option<**i32**> | | | +**offset** | Option<**i32**> | | | + +### Return type + +[**Vec**](Transfer.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## patch_account + +> models::AccountExtended patch_account(account_id, account_update_request) +Update an account + +This operation updates account information. If all parameters are valid and updates have been made, it returns with status code 200. The response is the account model. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**account_update_request** | [**AccountUpdateRequest**](AccountUpdateRequest.md) | | [required] | + +### Return type + +[**models::AccountExtended**](AccountExtended.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## suscribe_to_account_status_sse + +> Vec suscribe_to_account_status_sse(since, until, since_id, until_id) +Subscribe to account status events (SSE). + +Events API provide event push as well as historical queries via SSE (server sent events). Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**since** | Option<**String**> | Format: YYYY-MM-DD | | +**until** | Option<**String**> | Format: YYYY-MM-DD | | +**since_id** | Option<**i32**> | | | +**until_id** | Option<**i32**> | | | + +### Return type + +[**Vec**](AccountStatusEvent.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: text/event-stream + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## upload_doc_to_account + +> upload_doc_to_account(account_id, document_upload_request) +Upload a document to an already existing account + +Upload a document to be attached to an account. Documents are binary objects whose contents are encoded in base64. Each encoded content size is limited to 10MB if you use Alpaca for KYCaaS. If you perform your own KYC there are no document size limitations. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**document_upload_request** | [**DocumentUploadRequest**](DocumentUploadRequest.md) | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/broker/docs/AchRelationship.md b/crates/alpaca_openapi/gen/broker/docs/AchRelationship.md new file mode 100644 index 0000000..b6fe887 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AchRelationship.md @@ -0,0 +1,20 @@ +# AchRelationship + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**created_at** | **String** | Format: 2020-01-01T01:01:01Z | +**updated_at** | **String** | Format: 2020-01-01T01:01:01Z | +**account_id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**status** | **String** | | +**account_owner_name** | **String** | Name of the account owner | +**bank_account_type** | Option<**String**> | Must be CHECKING or SAVINGS | [optional] +**bank_account_number** | Option<**String**> | | [optional] +**bank_routing_number** | Option<**String**> | | [optional] +**nickname** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/Activity.md b/crates/alpaca_openapi/gen/broker/docs/Activity.md new file mode 100644 index 0000000..86be1c5 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Activity.md @@ -0,0 +1,28 @@ +# Activity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | | +**account_id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**activity_type** | [**models::ActivityType**](ActivityType.md) | | +**transaction_time** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**r#type** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**price** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**qty** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**side** | Option<[**models::OrderSide**](OrderSide.md)> | | [optional] +**symbol** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**leaves_qty** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**order_id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**cum_qty** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**order_status** | Option<[**models::OrderStatus**](OrderStatus.md)> | | [optional] +**date** | Option<[**String**](string.md)> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**net_amount** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**description** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**status** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**per_share_amount** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/ActivityItem.md b/crates/alpaca_openapi/gen/broker/docs/ActivityItem.md new file mode 100644 index 0000000..d65b38f --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/ActivityItem.md @@ -0,0 +1,25 @@ +# ActivityItem + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**transaction_time** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**r#type** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**price** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**qty** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**side** | Option<[**models::OrderSide**](OrderSide.md)> | | [optional] +**symbol** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**leaves_qty** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**order_id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**cum_qty** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**order_status** | Option<[**models::OrderStatus**](OrderStatus.md)> | | [optional] +**date** | Option<[**String**](string.md)> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**net_amount** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**description** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**status** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**per_share_amount** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/ActivityType.md b/crates/alpaca_openapi/gen/broker/docs/ActivityType.md new file mode 100644 index 0000000..92b2983 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/ActivityType.md @@ -0,0 +1,32 @@ +# ActivityType + +## Enum Variants + +| Name | Value | +|---- | -----| +| Fill | FILL | +| Acatc | ACATC | +| Acats | ACATS | +| Cil | CIL | +| Csd | CSD | +| Csw | CSW | +| Div | DIV | +| Divcgl | DIVCGL | +| Divcgs | DIVCGS | +| Divnra | DIVNRA | +| Divroc | DIVROC | +| Divtxex | DIVTXEX | +| Fee | FEE | +| Int | INT | +| Jnlc | JNLC | +| Jnls | JNLS | +| Ma | MA | +| Ptc | PTC | +| Reorg | REORG | +| Spin | SPIN | +| Split | SPLIT | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/Agreement.md b/crates/alpaca_openapi/gen/broker/docs/Agreement.md new file mode 100644 index 0000000..b1e092b --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Agreement.md @@ -0,0 +1,14 @@ +# Agreement + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**agreement** | [**models::AgreementType**](AgreementType.md) | | +**signed_at** | **String** | | +**ip_address** | **String** | | +**revision** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/AgreementType.md b/crates/alpaca_openapi/gen/broker/docs/AgreementType.md new file mode 100644 index 0000000..02f2beb --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AgreementType.md @@ -0,0 +1,15 @@ +# AgreementType + +## Enum Variants + +| Name | Value | +|---- | -----| +| MarginAgreement | margin_agreement | +| AccountAgreement | account_agreement | +| CustomerAgreement | customer_agreement | +| CryptoAgreement | crypto_agreement | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/Announcement.md b/crates/alpaca_openapi/gen/broker/docs/Announcement.md new file mode 100644 index 0000000..7238b57 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Announcement.md @@ -0,0 +1,25 @@ +# Announcement + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | ID that is specific to a single announcement. | +**corporate_action_id** | **String** | ID that remains consistent across all announcements for the same corporate action. Unlike ‘id’, this can be used to connect multiple announcements to see how the terms have changed throughout the lifecycle of the corporate action event. | +**ca_type** | [**models::AnnouncementCaType**](AnnouncementCAType.md) | | +**ca_sub_type** | [**models::AnnouncementCaSubType**](AnnouncementCASubType.md) | | +**initiating_symbol** | **String** | Symbol of the company initiating the announcement. | +**initiating_original_cusip** | **String** | CUSIP of the company initiating the announcement. | +**target_symbol** | Option<**String**> | Symbol of the child company involved in the announcement. | +**target_original_cusip** | Option<**String**> | CUSIP of the child company involved in the announcement. | +**declaration_date** | **String** | Date the corporate action or subsequent terms update was announced. | +**ex_date** | Option<**String**> | The first date that purchasing a security will not result in a corporate action entitlement. | +**record_date** | Option<**String**> | The date an account must hold a settled position in the security in order to receive the corporate action entitlement. | +**payable_date** | **String** | The date the announcement will take effect. On this date, account stock and cash balances are expected to be processed accordingly. | +**cash** | Option<**String**> | The amount of cash to be paid per share held by an account on the record date. | +**old_rate** | Option<**String**> | The denominator to determine any quantity change ratios in positions. | +**new_rate** | Option<**String**> | The numerator to determine any quantity change ratios in positions. | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/AnnouncementCaSubType.md b/crates/alpaca_openapi/gen/broker/docs/AnnouncementCaSubType.md new file mode 100644 index 0000000..e74dfde --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AnnouncementCaSubType.md @@ -0,0 +1,20 @@ +# AnnouncementCaSubType + +## Enum Variants + +| Name | Value | +|---- | -----| +| Cash | cash | +| Stock | stock | +| MergerUpdate | merger_update | +| MergerCompletion | merger_completion | +| StockSplit | stock_split | +| UntilSplit | until_split | +| ReverseSplit | reverse_split | +| Recapitalization | recapitalization | +| Spinoff | spinoff | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/AnnouncementCaType.md b/crates/alpaca_openapi/gen/broker/docs/AnnouncementCaType.md new file mode 100644 index 0000000..b793736 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AnnouncementCaType.md @@ -0,0 +1,15 @@ +# AnnouncementCaType + +## Enum Variants + +| Name | Value | +|---- | -----| +| Dividend | dividend | +| Merger | merger | +| Split | split | +| Spinoff | spinoff | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/ApplicationDocument.md b/crates/alpaca_openapi/gen/broker/docs/ApplicationDocument.md new file mode 100644 index 0000000..628bce8 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/ApplicationDocument.md @@ -0,0 +1,15 @@ +# ApplicationDocument + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**document_type** | [**models::DocumentType**](DocumentType.md) | | +**document_sub_type** | Option<**String**> | | [optional] +**mime_type** | Option<**String**> | | [optional] +**created_at** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/Asset.md b/crates/alpaca_openapi/gen/broker/docs/Asset.md new file mode 100644 index 0000000..5c023ce --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Asset.md @@ -0,0 +1,24 @@ +# Asset + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | Asset ID | +**class** | [**models::AssetClass**](AssetClass.md) | | +**exchange** | Option<[**models::Exchange**](Exchange.md)> | | [optional] +**symbol** | **String** | The symbol of the asset | +**name** | Option<**String**> | The official name of the asset | [optional] +**status** | Option<**String**> | active or inactive | [optional] +**tradable** | Option<**bool**> | Asset is tradable on Alpaca or not | [optional] +**marginable** | Option<**bool**> | Asset is marginable or not | [optional] +**shortable** | Option<**bool**> | Asset is shortable or not | [optional] +**easy_to_borrow** | Option<**bool**> | Asset is easy-to-borrow or not (filtering for easy_to_borrow = True is the best way to check whether the name is currently available to short at Alpaca). | [optional] +**fractionable** | Option<**bool**> | Asset is fractionable or not | [optional] +**last_close_pct_change** | Option<**String**> | Percent change for the trading day as of last market closure. NOTE: This field is currently in this spec however it may not be present in the production environment at time of publishing. It will be coming in a future update at which point this spec should be updated. | [optional] +**last_price** | Option<**String**> | Most recent available price for this asset on the market. NOTE: This field is currently in this spec however it may not be present in the production environment at time of publishing. It will be coming in a future update at which point this spec should be updated. | [optional] +**last_close** | Option<**String**> | Last price of the asset upon market closure on the most recent trading day. NOTE: This field is currently in this spec however it may not be present in the production environment at time of publishing. It will be coming in a future update at which point this spec should be updated. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/AssetClass.md b/crates/alpaca_openapi/gen/broker/docs/AssetClass.md new file mode 100644 index 0000000..1877fdb --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AssetClass.md @@ -0,0 +1,13 @@ +# AssetClass + +## Enum Variants + +| Name | Value | +|---- | -----| +| UsEquity | us_equity | +| Crypto | crypto | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/AssetsApi.md b/crates/alpaca_openapi/gen/broker/docs/AssetsApi.md new file mode 100644 index 0000000..cffbce5 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AssetsApi.md @@ -0,0 +1,71 @@ +# \AssetsApi + +All URIs are relative to *https://broker-api.sandbox.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_asset_by_symbol_or_id**](AssetsApi.md#get_asset_by_symbol_or_id) | **GET** /v1/assets/{symbol_or_asset_id} | Retrieve an asset by UUID +[**get_assets**](AssetsApi.md#get_assets) | **GET** /v1/assets | Retrieve all assets + + + +## get_asset_by_symbol_or_id + +> models::Asset get_asset_by_symbol_or_id(symbol_or_asset_id) +Retrieve an asset by UUID + +Returns the requested asset, if found + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol_or_asset_id** | **String** | you can use either the asset's Id or the symbol to search | [required] | + +### Return type + +[**models::Asset**](Asset.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_assets + +> Vec get_assets(status, asset_class) +Retrieve all assets + +Returns all assets + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | Option<**String**> | Asset status to filter by, will default to `all` | |[default to all] +**asset_class** | Option<**String**> | Asset class to filter by, `us_equity` or `crypto`. Defaults to `us_equity` | |[default to us_equity] + +### Return type + +[**Vec**](Asset.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/broker/docs/AuthorizeOAuthTokenResponse.md b/crates/alpaca_openapi/gen/broker/docs/AuthorizeOAuthTokenResponse.md new file mode 100644 index 0000000..bc15669 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/AuthorizeOAuthTokenResponse.md @@ -0,0 +1,14 @@ +# AuthorizeOAuthTokenResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **String** | OAuth code to exchange with token | +**client_id** | **String** | OAuth `client_id` | +**redirect_uri** | **String** | Redirect URI of OAuth flow | +**scope** | **String** | Granted scopes | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/Bank.md b/crates/alpaca_openapi/gen/broker/docs/Bank.md new file mode 100644 index 0000000..4ee8d0e --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Bank.md @@ -0,0 +1,24 @@ +# Bank + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**created_at** | **String** | Format: 2020-01-01T01:01:01Z | +**updated_at** | **String** | Format: 2020-01-01T01:01:01Z | +**account_id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**status** | Option<**String**> | QUEUED, SENT_TO_CLEARING, APPROVED, CANCELED | [optional] +**name** | **String** | Name of recipient bank | +**bank_code** | **String** | 9-Digit ABA RTN (Routing Number) or BIC | +**bank_code_type** | **String** | ABA (Domestic) or BIC (International) | +**country** | Option<**String**> | Only for international banks | [optional] +**state_province** | Option<**String**> | Only for international banks | [optional] +**postal_code** | Option<**String**> | Only for international banks | [optional] +**city** | Option<**String**> | Only for international banks | [optional] +**street_address** | Option<**String**> | Only for international banks | [optional] +**account_number** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/BatchJournalRequest.md b/crates/alpaca_openapi/gen/broker/docs/BatchJournalRequest.md new file mode 100644 index 0000000..dba39a9 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/BatchJournalRequest.md @@ -0,0 +1,14 @@ +# BatchJournalRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**entry_type** | **String** | Only supports `JNLC` for now | +**from_account** | [**uuid::Uuid**](uuid::Uuid.md) | The account id that is the originator of the funds being moved. Most likely is your Sweep Firm Account | +**description** | Option<**String**> | Journal description, gets returned in the response | [optional] +**entries** | [**Vec**](BatchJournalRequest_entries_inner.md) | An array of objects describing to what accounts you want to move funds into and how much to move into for each account | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/BatchJournalRequestEntriesInner.md b/crates/alpaca_openapi/gen/broker/docs/BatchJournalRequestEntriesInner.md new file mode 100644 index 0000000..51f9437 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/BatchJournalRequestEntriesInner.md @@ -0,0 +1,12 @@ +# BatchJournalRequestEntriesInner + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**to_account** | [**uuid::Uuid**](uuid::Uuid.md) | The ID of the account that you want to journal funds into | +**amount** | **String** | Journal amount in USD | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/BatchJournalResponse.md b/crates/alpaca_openapi/gen/broker/docs/BatchJournalResponse.md new file mode 100644 index 0000000..c99c3da --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/BatchJournalResponse.md @@ -0,0 +1,27 @@ +# BatchJournalResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | journal ID | +**entry_type** | [**models::JournalEntryType**](JournalEntryType.md) | | +**from_account** | [**uuid::Uuid**](uuid::Uuid.md) | account ID the shares go from | +**to_account** | [**uuid::Uuid**](uuid::Uuid.md) | account ID the shares go to | +**settle_date** | [**String**](string.md) | | +**status** | Option<[**models::JournalStatus**](JournalStatus.md)> | | [optional] +**symbol** | **String** | Only valid for JNLS journals. Null for JNLC. | +**qty** | **String** | Only valid for JNLS journals. Null for JNLC. | +**price** | **String** | Only valid for JNLS journals. Null for JNLC. | +**description** | Option<**String**> | ID the amount goes to. Only valid for JNLC journals. Null for JNLS. | [optional] +**net_amount** | **String** | Only valid for JNLC journals. Null for JNLS. | +**transmitter_name** | Option<**String**> | Only valid for JNLC journals. Null for JNLS. Max 255 characters. | [optional] +**transmitter_account_number** | Option<**String**> | Only valid for JNLC journals. Null for JNLS.max 255 characters | [optional] +**transmitter_address** | Option<**String**> | Only valid for JNLC journals. Null for JNLS.max 255 characters | [optional] +**transmitter_financial_institution** | Option<**String**> | Only valid for JNLC journals. Null for JNLS.max 255 characters | [optional] +**transmitter_timestamp** | Option<**String**> | Only valid for JNLC journals. Null for JNLS. | [optional] +**error_message** | **String** | Description of why this journal transaction failed | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/Calendar.md b/crates/alpaca_openapi/gen/broker/docs/Calendar.md new file mode 100644 index 0000000..bfac368 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Calendar.md @@ -0,0 +1,15 @@ +# Calendar + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**date** | [**String**](string.md) | Date string in YYYY-MM-DD format | +**open** | **String** | The time the market opens at on this date in HH:MM format | +**close** | **String** | The time the market closes at on this date in HH:MM format | +**session_open** | Option<**String**> | this field has been deprecated please ignore | [optional] +**session_close** | Option<**String**> | this field has been deprecated please ignore | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/CalendarApi.md b/crates/alpaca_openapi/gen/broker/docs/CalendarApi.md new file mode 100644 index 0000000..db41ffb --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/CalendarApi.md @@ -0,0 +1,40 @@ +# \CalendarApi + +All URIs are relative to *https://broker-api.sandbox.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**query_market_calendar**](CalendarApi.md#query_market_calendar) | **GET** /v1/calendar | Query market calendar + + + +## query_market_calendar + +> Vec query_market_calendar(start, end) +Query market calendar + +The calendar API serves the full list of market days from 1970 to 2029. It can also be queried by specifying a start and/or end time to narrow down the results. In addition to the dates, the response also contains the specific open and close times for the market days, taking into account early closures. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**start** | Option<**String**> | The first date to retrieve data for. (Inclusive) in YYYY-MM-DD format | | +**end** | Option<**String**> | The last date to retrieve data for. (Inclusive) in YYYY-MM-DD format | | + +### Return type + +[**Vec**](Calendar.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/broker/docs/Clock.md b/crates/alpaca_openapi/gen/broker/docs/Clock.md new file mode 100644 index 0000000..fb5da2a --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Clock.md @@ -0,0 +1,14 @@ +# Clock + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**timestamp** | **String** | Current timestamp | +**is_open** | **bool** | Whether the market is open or not | +**next_open** | **String** | Next market open timestamp | +**next_close** | **String** | Next market close timestamp | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/ClockApi.md b/crates/alpaca_openapi/gen/broker/docs/ClockApi.md new file mode 100644 index 0000000..79c3bf1 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/ClockApi.md @@ -0,0 +1,36 @@ +# \ClockApi + +All URIs are relative to *https://broker-api.sandbox.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**query_market_clock**](ClockApi.md#query_market_clock) | **GET** /v1/clock | Query market clock + + + +## query_market_clock + +> models::Clock query_market_clock() +Query market clock + +The Clock API serves the current market timestamp, whether or not the market is currently open, as well as the times of the next market open and close. + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::Clock**](Clock.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/broker/docs/Contact.md b/crates/alpaca_openapi/gen/broker/docs/Contact.md new file mode 100644 index 0000000..a1d053a --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Contact.md @@ -0,0 +1,16 @@ +# Contact + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**email_address** | Option<**String**> | | [optional] +**phone_number** | Option<**String**> | with country code, no hyphen or space | [optional] +**street_address** | Option<**Vec**> | | [optional] +**city** | Option<**String**> | | [optional] +**state** | Option<**String**> | | [optional] +**postal_code** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/CorporateActionsApi.md b/crates/alpaca_openapi/gen/broker/docs/CorporateActionsApi.md new file mode 100644 index 0000000..9383117 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/CorporateActionsApi.md @@ -0,0 +1,44 @@ +# \CorporateActionsApi + +All URIs are relative to *https://broker-api.sandbox.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_corporate_announcements**](CorporateActionsApi.md#get_corporate_announcements) | **GET** /v1/corporate_actions/announcements | Retrieving Announcements + + + +## get_corporate_announcements + +> Vec get_corporate_announcements(ca_types, since, until, symbol, cusip, date_type) +Retrieving Announcements + +This enables searching for an array of corporate action announcements based on criteria. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**ca_types** | **String** | A comma-delimited list of CorporateActionType values | [required] | +**since** | **String** | The start (inclusive) of the date range when searching corporate action announcements. This should follow the YYYY-MM-DD format. The date range is limited to 90 days. | [required] | +**until** | **String** | The end (inclusive) of the date range when searching corporate action announcements. This should follow the YYYY-MM-DD format. The date range is limited to 90 days. | [required] | +**symbol** | Option<**String**> | The symbol of the company initiating the announcement. | | +**cusip** | Option<**String**> | The CUSIP of the company initiating the announcement. | | +**date_type** | Option<**String**> | An emum of possible ways to use the `since` and `until` parameters to search by. the types are: - **declaration_date**: The date of the preliminary announcement details or the date that any subsequent term updates took place. - **ex_date**: The date on which any security purchasing activity will not result in a corporate action entitlement. Any selling activity that takes place on or after this date will result in a corporate action entitlement. - **record_date**: The date the company checks its records to determine who is shareholder in order to allocate entitlements. - **payable_date**: The date that the stock and cash positions will update according to the account positions as of the record date. | | + +### Return type + +[**Vec**](Announcement.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/broker/docs/CreateAchRelationshipRequest.md b/crates/alpaca_openapi/gen/broker/docs/CreateAchRelationshipRequest.md new file mode 100644 index 0000000..dbf0dd8 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/CreateAchRelationshipRequest.md @@ -0,0 +1,16 @@ +# CreateAchRelationshipRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account_owner_name** | **String** | | +**bank_account_type** | **String** | Must be CHECKING or SAVINGS | +**bank_account_number** | **String** | In sandbox, this still must be a valid format | +**bank_routing_number** | **String** | In sandbox, this still must be a valid format | +**nickname** | Option<**String**> | | [optional] +**processor_token** | Option<**String**> | If using Plaid, you can specify a Plaid processor token here | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/CreateBankRequest.md b/crates/alpaca_openapi/gen/broker/docs/CreateBankRequest.md new file mode 100644 index 0000000..73ff1a4 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/CreateBankRequest.md @@ -0,0 +1,19 @@ +# CreateBankRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **String** | Name of recipient bank | +**bank_code** | **String** | 9-Digit ABA RTN (Routing Number) or BIC | +**bank_code_type** | **String** | ABA (Domestic) or BIC (International) | +**country** | Option<**String**> | Only for international banks | [optional] +**state_province** | Option<**String**> | Only for international banks | [optional] +**postal_code** | Option<**String**> | Only for international banks | [optional] +**city** | Option<**String**> | Only for international banks | [optional] +**street_address** | Option<**String**> | Only for international banks | [optional] +**account_number** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/CreateJournalRequest.md b/crates/alpaca_openapi/gen/broker/docs/CreateJournalRequest.md new file mode 100644 index 0000000..d275ff0 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/CreateJournalRequest.md @@ -0,0 +1,22 @@ +# CreateJournalRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**to_account** | [**uuid::Uuid**](uuid::Uuid.md) | The account_id you wish to journal to | +**from_account** | [**uuid::Uuid**](uuid::Uuid.md) | The account_id you wish to journal from | +**entry_type** | [**models::JournalEntryType**](JournalEntryType.md) | | +**amount** | Option<**String**> | Required if `entry_type` = `JNLC` | [optional] +**symbol** | Option<**String**> | Required if `entry_type` = `JNLS` | [optional] +**qty** | Option<**String**> | Required if `entry_type` = `JNLS` | [optional] +**description** | Option<**String**> | Max 1024 characters. Can include fixtures for amounts that are above the transaction limit | [optional] +**transmitter_name** | Option<**String**> | Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation. | [optional] +**transmitter_account_number** | Option<**String**> | Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation. | [optional] +**transmitter_address** | Option<**String**> | Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation. | [optional] +**transmitter_financial_institution** | Option<**String**> | Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation. | [optional] +**transmitter_timestamp** | Option<**String**> | RFC 3339 format. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/CreateOrderRequest.md b/crates/alpaca_openapi/gen/broker/docs/CreateOrderRequest.md new file mode 100644 index 0000000..48fe312 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/CreateOrderRequest.md @@ -0,0 +1,26 @@ +# CreateOrderRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**symbol** | **String** | Symbol or asset ID to identify the asset to trade | +**qty** | Option<**String**> | Number of shares to trade. Can be fractionable for only market and day order types. | [optional] +**notional** | Option<**String**> | Dollar amount to trade. Cannot work with qty. Can only work for market order types and time_in_force = day. | [optional] +**side** | [**models::OrderSide**](OrderSide.md) | | +**r#type** | [**models::OrderType**](OrderType.md) | | +**time_in_force** | [**models::TimeInForce**](TimeInForce.md) | | +**limit_price** | Option<**String**> | Required if type is limit or stop_limit | [optional] +**stop_price** | Option<**String**> | Required if type is stop or stop_limit | [optional] +**trail_price** | Option<**String**> | If type is trailing_stop, then one of trail_price or trail_percent is required | [optional] +**trail_percent** | Option<**String**> | If type is trailing_stop, then one of trail_price or trail_percent is required | [optional] +**extended_hours** | Option<**bool**> | Defaults to false. If true, order will be eligible to execute in premarket/afterhours. Only works with type limit and time_in_force = day. | [optional] +**client_order_id** | Option<**String**> | A unique identifier for the order. Automatically generated if not sent. (<= 48 characters) | [optional] +**order_class** | Option<[**models::OrderClass**](OrderClass.md)> | | [optional] +**take_profit** | Option<[**models::CreateOrderRequestTakeProfit**](CreateOrderRequest_take_profit.md)> | | [optional] +**stop_loss** | Option<[**models::CreateOrderRequestStopLoss**](CreateOrderRequest_stop_loss.md)> | | [optional] +**commission** | Option<**String**> | The commission you want to collect from the user. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/CreateOrderRequestStopLoss.md b/crates/alpaca_openapi/gen/broker/docs/CreateOrderRequestStopLoss.md new file mode 100644 index 0000000..778e10b --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/CreateOrderRequestStopLoss.md @@ -0,0 +1,12 @@ +# CreateOrderRequestStopLoss + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**stop_price** | Option<**String**> | | [optional] +**limit_price** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/CreateOrderRequestTakeProfit.md b/crates/alpaca_openapi/gen/broker/docs/CreateOrderRequestTakeProfit.md new file mode 100644 index 0000000..7cd8481 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/CreateOrderRequestTakeProfit.md @@ -0,0 +1,11 @@ +# CreateOrderRequestTakeProfit + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**limit_price** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/CreateTransferRequest.md b/crates/alpaca_openapi/gen/broker/docs/CreateTransferRequest.md new file mode 100644 index 0000000..89a3c59 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/CreateTransferRequest.md @@ -0,0 +1,17 @@ +# CreateTransferRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**transfer_type** | [**models::TransferType**](TransferType.md) | | +**relationship_id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | Required if type = `ach` The ach_relationship created for the account_id [here](https://alpaca.markets/docs/api-references/broker-api/funding/ach/#creating-an-ach-relationship) | [optional] +**bank_id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | Required if type = `wire` The bank_relationship created for the account_id [here](https://alpaca.markets/docs/api-references/broker-api/funding/bank/#creating-a-new-bank-relationship) | [optional] +**amount** | **String** | Must be > 0.00 | +**direction** | [**models::TransferDirection**](TransferDirection.md) | | +**timing** | [**models::TransferTiming**](TransferTiming.md) | | +**additional_information** | Option<**String**> | Additional details for when type = `wire` | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/CreateWatchlistRequest.md b/crates/alpaca_openapi/gen/broker/docs/CreateWatchlistRequest.md new file mode 100644 index 0000000..56cc9f1 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/CreateWatchlistRequest.md @@ -0,0 +1,12 @@ +# CreateWatchlistRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **String** | The watchlist name | +**symbols** | **Vec** | The new list of symbol names to watch | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/CustodialAccountMinorIdentity.md b/crates/alpaca_openapi/gen/broker/docs/CustodialAccountMinorIdentity.md new file mode 100644 index 0000000..d2e5aa2 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/CustodialAccountMinorIdentity.md @@ -0,0 +1,20 @@ +# CustodialAccountMinorIdentity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**given_name** | **String** | | +**family_name** | **String** | | +**date_of_birth** | [**String**](string.md) | | +**tax_id** | Option<**String**> | | [optional] +**tax_id_type** | Option<[**models::TaxIdType**](TaxIdType.md)> | | [optional] +**country_of_citizenship** | Option<**String**> | | [optional] +**country_of_birth** | Option<**String**> | | [optional] +**country_of_tax_residence** | **String** | | +**state** | **String** | | +**email** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/DisclosureContextAnnotation.md b/crates/alpaca_openapi/gen/broker/docs/DisclosureContextAnnotation.md new file mode 100644 index 0000000..d9c2b6b --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/DisclosureContextAnnotation.md @@ -0,0 +1,19 @@ +# DisclosureContextAnnotation + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**context_type** | **String** | Specifies the type of disclosure annotation. Valid types are FINRA affiliations, for users affiliated with or employed by a FINRA member firm, a Stock Exchange Member, FINRA, Registered Investment Advisor, or a Municipal Securities Broker/Dealer; Company control relationships, for senior executives, and 10% or greater shareholders, of a publicly traded company; and immediate family members of politically exposed individuals. | +**company_name** | Option<**String**> | Required for FINRA affiliations and controlled firms. | [optional] +**company_street_address** | Option<**String**> | Required for FINRA affiliations and controlled firms. | [optional] +**company_city** | Option<**String**> | Required for FINRA affiliations and controlled firms. | [optional] +**company_state** | Option<**String**> | Required if and only if `company_country` is `USA`. | [optional] +**company_country** | Option<**String**> | Required for FINRA affiliations and controlled firms. | [optional] +**company_compliance_email** | Option<**String**> | Required for FINRA affiliations and controlled firms. | [optional] +**given_name** | Option<**String**> | Required for immediate family members of politically exposed persons. | [optional] +**family_name** | Option<**String**> | Required for immediate family members of politically exposed persons. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/Disclosures.md b/crates/alpaca_openapi/gen/broker/docs/Disclosures.md new file mode 100644 index 0000000..f8e2609 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Disclosures.md @@ -0,0 +1,19 @@ +# Disclosures + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**employment_status** | Option<**String**> | | [optional] +**employer_name** | Option<**String**> | | [optional] +**employer_address** | Option<**String**> | | [optional] +**employment_position** | Option<**String**> | | [optional] +**is_control_person** | **bool** | | +**is_affiliated_exchange_or_finra** | **bool** | | +**is_politically_exposed** | **bool** | | +**immediate_family_exposed** | **bool** | | +**context** | Option<[**Vec**](DisclosureContextAnnotation.md)> | Array of annotations describing the rational for marking `is_control_person`, `is_affiliated_exchange_or_finra`, and/or `immediate_family_exposed` as true | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/DocumentInner.md b/crates/alpaca_openapi/gen/broker/docs/DocumentInner.md new file mode 100644 index 0000000..29573c6 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/DocumentInner.md @@ -0,0 +1,13 @@ +# DocumentInner + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**document_id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**document_type** | [**models::DocumentType**](DocumentType.md) | | +**document_date** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/DocumentType.md b/crates/alpaca_openapi/gen/broker/docs/DocumentType.md new file mode 100644 index 0000000..97f653f --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/DocumentType.md @@ -0,0 +1,17 @@ +# DocumentType + +## Enum Variants + +| Name | Value | +|---- | -----| +| IdentityVerification | identity_verification | +| AddressVerification | address_verification | +| DateOfBirthVerification | date_of_birth_verification | +| TaxIdVerification | tax_id_verification | +| AccountApprovalLetter | account_approval_letter | +| CipResult | cip_result | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/DocumentUpload.md b/crates/alpaca_openapi/gen/broker/docs/DocumentUpload.md new file mode 100644 index 0000000..5b63eee --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/DocumentUpload.md @@ -0,0 +1,14 @@ +# DocumentUpload + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**document_type** | [**models::DocumentType**](DocumentType.md) | | +**document_sub_type** | Option<**String**> | | [optional] +**content** | **String** | | +**mime_type** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/DocumentUploadRequest.md b/crates/alpaca_openapi/gen/broker/docs/DocumentUploadRequest.md new file mode 100644 index 0000000..91c564b --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/DocumentUploadRequest.md @@ -0,0 +1,14 @@ +# DocumentUploadRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**document_type** | [**models::DocumentType**](DocumentType.md) | | +**document_sub_type** | Option<**String**> | | [optional] +**content** | **String** | | +**mime_type** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/DocumentsApi.md b/crates/alpaca_openapi/gen/broker/docs/DocumentsApi.md new file mode 100644 index 0000000..e08b840 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/DocumentsApi.md @@ -0,0 +1,105 @@ +# \DocumentsApi + +All URIs are relative to *https://broker-api.sandbox.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**download_doc_from_account**](DocumentsApi.md#download_doc_from_account) | **GET** /v1/accounts/{account_id}/documents/{document_id}/download | Download a document file that belongs to an account. +[**download_document_by_id**](DocumentsApi.md#download_document_by_id) | **GET** /v1/documents/{document_id} | Download a document file directly +[**get_docs_for_account**](DocumentsApi.md#get_docs_for_account) | **GET** /v1/accounts/{account_id}/documents | Return a list of account documents. + + + +## download_doc_from_account + +> download_doc_from_account(account_id, document_id) +Download a document file that belongs to an account. + +This endpoint allows you to download a document identified by the document_id passed in the header. The returned document is in PDF format. The operation returns a pre-signed downloadable link as a redirect with HTTP status code 301 if one is found. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**document_id** | **uuid::Uuid** | Document identifier. | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## download_document_by_id + +> download_document_by_id(document_id) +Download a document file directly + +The operation returns a pre-signed downloadable link as a redirect with HTTP status code 301 if one is found. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**document_id** | **uuid::Uuid** | Document identifier. | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_docs_for_account + +> Vec> get_docs_for_account(account_id, start_date, end_date, r#type) +Return a list of account documents. + +This endpoint allows you to query all the documents that belong to a certain account. You can filter by date, or type of document. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**start_date** | Option<**String**> | optional date value to filter the list (inclusive). | | +**end_date** | Option<**String**> | optional date value to filter the list (inclusive). | | +**r#type** | Option<**String**> | See DocumentType model for reference and explanation of values | | + +### Return type + +[**Vec>**](set.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/broker/docs/Error.md b/crates/alpaca_openapi/gen/broker/docs/Error.md new file mode 100644 index 0000000..222c3a2 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Error.md @@ -0,0 +1,12 @@ +# Error + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **f64** | | +**message** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/EventsApi.md b/crates/alpaca_openapi/gen/broker/docs/EventsApi.md new file mode 100644 index 0000000..8c97017 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/EventsApi.md @@ -0,0 +1,144 @@ +# \EventsApi + +All URIs are relative to *https://broker-api.sandbox.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**subscribe_to_journal_status_sse**](EventsApi.md#subscribe_to_journal_status_sse) | **GET** /v1/events/journals/status | Subscribe to journal events (SSE). +[**subscribe_to_trade_sse**](EventsApi.md#subscribe_to_trade_sse) | **GET** /v1/events/trades | Subscribe to Trade Events (SSE) +[**subscribe_to_transfer_status_sse**](EventsApi.md#subscribe_to_transfer_status_sse) | **GET** /v1/events/transfers/status | Subscribe to Transfer Events (SSE) +[**suscribe_to_account_status_sse**](EventsApi.md#suscribe_to_account_status_sse) | **GET** /v1/events/accounts/status | Subscribe to account status events (SSE). + + + +## subscribe_to_journal_status_sse + +> Vec subscribe_to_journal_status_sse(since, until, since_id, until_id) +Subscribe to journal events (SSE). + +The Events API provides event push as well as historical queries via SSE (server sent events). You can listen to journal status updates as they get processed by our backoffice. Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**since** | Option<**String**> | Format: YYYY-MM-DD | | +**until** | Option<**String**> | Format: YYYY-MM-DD | | +**since_id** | Option<**i32**> | | | +**until_id** | Option<**i32**> | | | + +### Return type + +[**Vec**](JournalStatusEvent.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: text/event-stream + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## subscribe_to_trade_sse + +> Vec subscribe_to_trade_sse(since, until, since_id, until_id) +Subscribe to Trade Events (SSE) + +The Events API provides event push as well as historical queries via SSE (server sent events). You can listen to events related to trade updates. Most market trades sent during market hours are filled instantly; you can listen to limit order updates through this endpoint. Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**since** | Option<**String**> | Format: YYYY-MM-DD | | +**until** | Option<**String**> | Format: YYYY-MM-DD | | +**since_id** | Option<**i32**> | | | +**until_id** | Option<**i32**> | | | + +### Return type + +[**Vec**](TradeUpdateEvent.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: text/event-stream + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## subscribe_to_transfer_status_sse + +> Vec subscribe_to_transfer_status_sse(since, until, since_id, until_id) +Subscribe to Transfer Events (SSE) + +The Events API provides event push as well as historical queries via SSE (server sent events). You can listen to transfer status updates as they get processed by our backoffice, for both end-user and firm accounts. Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**since** | Option<**String**> | Format: YYYY-MM-DD | | +**until** | Option<**String**> | Format: YYYY-MM-DD | | +**since_id** | Option<**i32**> | | | +**until_id** | Option<**i32**> | | | + +### Return type + +[**Vec**](TransferStatusEvent.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: text/event-stream + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## suscribe_to_account_status_sse + +> Vec suscribe_to_account_status_sse(since, until, since_id, until_id) +Subscribe to account status events (SSE). + +Events API provide event push as well as historical queries via SSE (server sent events). Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**since** | Option<**String**> | Format: YYYY-MM-DD | | +**until** | Option<**String**> | Format: YYYY-MM-DD | | +**since_id** | Option<**i32**> | | | +**until_id** | Option<**i32**> | | | + +### Return type + +[**Vec**](AccountStatusEvent.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: text/event-stream + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/broker/docs/Exchange.md b/crates/alpaca_openapi/gen/broker/docs/Exchange.md new file mode 100644 index 0000000..c2d8712 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Exchange.md @@ -0,0 +1,20 @@ +# Exchange + +## Enum Variants + +| Name | Value | +|---- | -----| +| Amex | AMEX | +| Arca | ARCA | +| Bats | BATS | +| Nyse | NYSE | +| Nasdaq | NASDAQ | +| Nysearca | NYSEARCA | +| Otc | OTC | +| Ersx | ERSX | +| Ftxu | FTXU | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/FundingApi.md b/crates/alpaca_openapi/gen/broker/docs/FundingApi.md new file mode 100644 index 0000000..fe18340 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/FundingApi.md @@ -0,0 +1,333 @@ +# \FundingApi + +All URIs are relative to *https://broker-api.sandbox.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_ach_relationship_for_account**](FundingApi.md#create_ach_relationship_for_account) | **POST** /v1/accounts/{account_id}/ach_relationships | Create an ACH Relationship +[**create_recipient_bank**](FundingApi.md#create_recipient_bank) | **POST** /v1/accounts/{account_id}/recipient_banks | Create a Bank Relationship for an account +[**create_transfer_for_account**](FundingApi.md#create_transfer_for_account) | **POST** /v1/accounts/{account_id}/transfers | Request a new transfer +[**delete_ach_relationship_from_account**](FundingApi.md#delete_ach_relationship_from_account) | **DELETE** /v1/accounts/{account_id}/ach_relationships/{ach_relationship_id} | Delete an existing ACH relationship +[**delete_recipient_bank**](FundingApi.md#delete_recipient_bank) | **DELETE** /v1/accounts/{account_id}/recipient_banks/{bank_id} | Delete a Bank Relationship for an account +[**delete_transfer**](FundingApi.md#delete_transfer) | **DELETE** /v1/accounts/{account_id}/transfers/{transfer_id} | Request to close a transfer +[**get_account_ach_relationships**](FundingApi.md#get_account_ach_relationships) | **GET** /v1/accounts/{account_id}/ach_relationships | Retrieve ACH Relationships for an account +[**get_recipient_banks**](FundingApi.md#get_recipient_banks) | **GET** /v1/accounts/{account_id}/recipient_banks | Retrieve bank relationships for an account +[**get_transfers_for_account**](FundingApi.md#get_transfers_for_account) | **GET** /v1/accounts/{account_id}/transfers | Return a list of transfers for an account. +[**subscribe_to_transfer_status_sse**](FundingApi.md#subscribe_to_transfer_status_sse) | **GET** /v1/events/transfers/status | Subscribe to Transfer Events (SSE) + + + +## create_ach_relationship_for_account + +> models::AchRelationship create_ach_relationship_for_account(account_id, create_ach_relationship_request) +Create an ACH Relationship + +Create a new ACHRelationship for an account If successful, will return 200 code with a newly created ACH Relationship entity. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**create_ach_relationship_request** | [**CreateAchRelationshipRequest**](CreateAchRelationshipRequest.md) | Create ACH Relationship | [required] | + +### Return type + +[**models::AchRelationship**](ACHRelationship.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## create_recipient_bank + +> models::Bank create_recipient_bank(account_id, create_bank_request) +Create a Bank Relationship for an account + +If successful, retrieves Bank Relationships for an account + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**create_bank_request** | [**CreateBankRequest**](CreateBankRequest.md) | | [required] | + +### Return type + +[**models::Bank**](Bank.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## create_transfer_for_account + +> models::Transfer create_transfer_for_account(account_id, create_transfer_request) +Request a new transfer + +Create a new transfer to an account to fund it. In the sandbox environment, you can instantly deposit to or withdraw from an account with a virtual money amount. In the production environment, this endpoint is used only for requesting an outgoing (withdrawal) wire transfer at this moment. For the wire transfer (in production), you need to create a bank resource first using the Bank API. For more on how to fund an account in sandbox please check out this tutorial [here](https://alpaca.markets/learn/fund-broker-api/). + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**create_transfer_request** | [**CreateTransferRequest**](CreateTransferRequest.md) | | [required] | + +### Return type + +[**models::Transfer**](Transfer.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_ach_relationship_from_account + +> delete_ach_relationship_from_account(account_id, ach_relationship_id) +Delete an existing ACH relationship + +Delete an existing ACH relationship for an account + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**ach_relationship_id** | **uuid::Uuid** | ACH relationship identifier | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_recipient_bank + +> delete_recipient_bank(account_id, bank_id) +Delete a Bank Relationship for an account + +If successful, deletes Bank Relationship for an account + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**bank_id** | **uuid::Uuid** | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_transfer + +> delete_transfer(account_id, transfer_id) +Request to close a transfer + +Request to close a transfer + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**transfer_id** | **uuid::Uuid** | Tranfer identifier | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_account_ach_relationships + +> Vec get_account_ach_relationships(account_id, statuses) +Retrieve ACH Relationships for an account + +Returns a list of ACH Relationships for an account + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**statuses** | Option<**String**> | Comma-separated status values | | + +### Return type + +[**Vec**](ACHRelationship.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_recipient_banks + +> Vec get_recipient_banks(account_id, status, bank_name) +Retrieve bank relationships for an account + +Retrieves Bank Relationships for an account + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**status** | Option<**String**> | | | +**bank_name** | Option<**String**> | | | + +### Return type + +[**Vec**](Bank.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_transfers_for_account + +> Vec get_transfers_for_account(account_id, direction, limit, offset) +Return a list of transfers for an account. + +You can query a list of transfers for an account. You can filter requested transfers by values such as direction and status. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**direction** | Option<**String**> | INCOMING or OUTGOING | | +**limit** | Option<**i32**> | | | +**offset** | Option<**i32**> | | | + +### Return type + +[**Vec**](Transfer.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## subscribe_to_transfer_status_sse + +> Vec subscribe_to_transfer_status_sse(since, until, since_id, until_id) +Subscribe to Transfer Events (SSE) + +The Events API provides event push as well as historical queries via SSE (server sent events). You can listen to transfer status updates as they get processed by our backoffice, for both end-user and firm accounts. Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**since** | Option<**String**> | Format: YYYY-MM-DD | | +**until** | Option<**String**> | Format: YYYY-MM-DD | | +**since_id** | Option<**i32**> | | | +**until_id** | Option<**i32**> | | | + +### Return type + +[**Vec**](TransferStatusEvent.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: text/event-stream + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/broker/docs/Identity.md b/crates/alpaca_openapi/gen/broker/docs/Identity.md new file mode 100644 index 0000000..e6517dc --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Identity.md @@ -0,0 +1,26 @@ +# Identity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**given_name** | **String** | | +**family_name** | **String** | | +**date_of_birth** | [**String**](string.md) | | +**tax_id** | Option<**String**> | | [optional] +**tax_id_type** | Option<[**models::TaxIdType**](TaxIdType.md)> | | [optional] +**country_of_citizenship** | Option<**String**> | [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html). | [optional] +**country_of_birth** | Option<**String**> | [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html). | [optional] +**country_of_tax_residence** | **String** | [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html). | +**funding_source** | **Vec** | | +**annual_income_min** | Option<**f64**> | | [optional] +**annual_income_max** | Option<**f64**> | | [optional] +**liquid_net_worth_min** | Option<**f64**> | | [optional] +**liquid_net_worth_max** | Option<**f64**> | | [optional] +**total_net_worth_min** | Option<**f64**> | | [optional] +**total_net_worth_max** | Option<**f64**> | | [optional] +**extra** | Option<[**serde_json::Value**](.md)> | any extra information used for KYC purposes | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/IssueOAuthTokenResponse.md b/crates/alpaca_openapi/gen/broker/docs/IssueOAuthTokenResponse.md new file mode 100644 index 0000000..cff313a --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/IssueOAuthTokenResponse.md @@ -0,0 +1,13 @@ +# IssueOAuthTokenResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**access_token** | **String** | OAuth token | +**token_type** | **String** | Always `Bearer` | +**scope** | **String** | Token’s scope | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/Jnlc.md b/crates/alpaca_openapi/gen/broker/docs/Jnlc.md new file mode 100644 index 0000000..aeaec3a --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Jnlc.md @@ -0,0 +1,17 @@ +# Jnlc + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**description** | Option<**String**> | ID the amount goes to. Only valid for JNLC journals. Null for JNLS. | [optional] +**net_amount** | **String** | Only valid for JNLC journals. Null for JNLS. | +**transmitter_name** | Option<**String**> | Only valid for JNLC journals. Null for JNLS. Max 255 characters. | [optional] +**transmitter_account_number** | Option<**String**> | Only valid for JNLC journals. Null for JNLS.max 255 characters | [optional] +**transmitter_address** | Option<**String**> | Only valid for JNLC journals. Null for JNLS.max 255 characters | [optional] +**transmitter_financial_institution** | Option<**String**> | Only valid for JNLC journals. Null for JNLS.max 255 characters | [optional] +**transmitter_timestamp** | Option<**String**> | Only valid for JNLC journals. Null for JNLS. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/Jnls.md b/crates/alpaca_openapi/gen/broker/docs/Jnls.md new file mode 100644 index 0000000..530aa5e --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Jnls.md @@ -0,0 +1,13 @@ +# Jnls + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**symbol** | **String** | Only valid for JNLS journals. Null for JNLC. | +**qty** | **String** | Only valid for JNLS journals. Null for JNLC. | +**price** | **String** | Only valid for JNLS journals. Null for JNLC. | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/Journal.md b/crates/alpaca_openapi/gen/broker/docs/Journal.md new file mode 100644 index 0000000..dd3bd84 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Journal.md @@ -0,0 +1,26 @@ +# Journal + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | journal ID | +**entry_type** | [**models::JournalEntryType**](JournalEntryType.md) | | +**from_account** | [**uuid::Uuid**](uuid::Uuid.md) | account ID the shares go from | +**to_account** | [**uuid::Uuid**](uuid::Uuid.md) | account ID the shares go to | +**settle_date** | [**String**](string.md) | | +**status** | Option<[**models::JournalStatus**](JournalStatus.md)> | | [optional] +**symbol** | **String** | Only valid for JNLS journals. Null for JNLC. | +**qty** | **String** | Only valid for JNLS journals. Null for JNLC. | +**price** | **String** | Only valid for JNLS journals. Null for JNLC. | +**description** | Option<**String**> | ID the amount goes to. Only valid for JNLC journals. Null for JNLS. | [optional] +**net_amount** | **String** | Only valid for JNLC journals. Null for JNLS. | +**transmitter_name** | Option<**String**> | Only valid for JNLC journals. Null for JNLS. Max 255 characters. | [optional] +**transmitter_account_number** | Option<**String**> | Only valid for JNLC journals. Null for JNLS.max 255 characters | [optional] +**transmitter_address** | Option<**String**> | Only valid for JNLC journals. Null for JNLS.max 255 characters | [optional] +**transmitter_financial_institution** | Option<**String**> | Only valid for JNLC journals. Null for JNLS.max 255 characters | [optional] +**transmitter_timestamp** | Option<**String**> | Only valid for JNLC journals. Null for JNLS. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/JournalData.md b/crates/alpaca_openapi/gen/broker/docs/JournalData.md new file mode 100644 index 0000000..dd9e86c --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/JournalData.md @@ -0,0 +1,16 @@ +# JournalData + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**entry_type** | [**models::JournalEntryType**](JournalEntryType.md) | | +**from_account** | [**uuid::Uuid**](uuid::Uuid.md) | | +**to_account** | [**uuid::Uuid**](uuid::Uuid.md) | | +**amount** | Option<**String**> | Required for JNLC. The dollar amount to move. It has to be a positive value. | [optional] +**symbol** | Option<**String**> | Required for JNLS. | [optional] +**qty** | Option<**String**> | Required for JNLS. The number of shares to move. It has to be a positive value. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/JournalEntryType.md b/crates/alpaca_openapi/gen/broker/docs/JournalEntryType.md new file mode 100644 index 0000000..a7bc0de --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/JournalEntryType.md @@ -0,0 +1,13 @@ +# JournalEntryType + +## Enum Variants + +| Name | Value | +|---- | -----| +| Jnlc | JNLC | +| Jnls | JNLS | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/JournalResource.md b/crates/alpaca_openapi/gen/broker/docs/JournalResource.md new file mode 100644 index 0000000..adf61d0 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/JournalResource.md @@ -0,0 +1,10 @@ +# JournalResource + +## Enum Variants + +| Name | Value | +|---- | -----| + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/JournalStatus.md b/crates/alpaca_openapi/gen/broker/docs/JournalStatus.md new file mode 100644 index 0000000..de750bd --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/JournalStatus.md @@ -0,0 +1,17 @@ +# JournalStatus + +## Enum Variants + +| Name | Value | +|---- | -----| +| Pending | pending | +| Canceled | canceled | +| Executed | executed | +| Queued | queued | +| Rejected | rejected | +| Deleted | deleted | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/JournalStatusEvent.md b/crates/alpaca_openapi/gen/broker/docs/JournalStatusEvent.md new file mode 100644 index 0000000..863c0a9 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/JournalStatusEvent.md @@ -0,0 +1,16 @@ +# JournalStatusEvent + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**at** | **String** | Timestamp of event | +**entry_type** | [**models::JournalEntryType**](JournalEntryType.md) | | +**event_id** | **i32** | Monotonically increasing 64bit integer | +**journal_id** | [**uuid::Uuid**](uuid::Uuid.md) | The UUID of the related Journal | +**status_from** | [**models::JournalStatus**](JournalStatus.md) | | +**status_to** | [**models::JournalStatus**](JournalStatus.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/JournalsApi.md b/crates/alpaca_openapi/gen/broker/docs/JournalsApi.md new file mode 100644 index 0000000..3bce4ef --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/JournalsApi.md @@ -0,0 +1,171 @@ +# \JournalsApi + +All URIs are relative to *https://broker-api.sandbox.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_batch_journal**](JournalsApi.md#create_batch_journal) | **POST** /v1/journals/batch | Create a Batch Journal Transaction (One-to-Many) +[**create_journal**](JournalsApi.md#create_journal) | **POST** /v1/journals | Create a Journal. +[**delete_journal_by_id**](JournalsApi.md#delete_journal_by_id) | **DELETE** /v1/journals/{journal_id} | Cancel a pending journal. +[**get_all_journals**](JournalsApi.md#get_all_journals) | **GET** /v1/journals | Return a list of requested journals. +[**subscribe_to_journal_status_sse**](JournalsApi.md#subscribe_to_journal_status_sse) | **GET** /v1/events/journals/status | Subscribe to journal events (SSE). + + + +## create_batch_journal + +> Vec create_batch_journal(batch_journal_request) +Create a Batch Journal Transaction (One-to-Many) + +You can create a batch of journal requests by using this endpoint. This is enabled on JNLC type Journals for now only. Every single request must be valid for the entire batch operation to succeed. In the case of a successful request, the response will contain an array of journal objects with an extra attribute error_message in the case when a specific account fails to receive a journal. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**batch_journal_request** | [**BatchJournalRequest**](BatchJournalRequest.md) | | [required] | + +### Return type + +[**Vec**](BatchJournalResponse.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## create_journal + +> models::Journal create_journal(create_journal_request) +Create a Journal. + +A journal can be JNLC (move cash) or JNLS (move shares), dictated by `entry_type`. Generally, journal requests are subject to approval and starts from the `pending` status. The status changes are propagated through the Event API. Under certain conditions agreed for the partner, such journal transactions that meet the criteria are executed right away. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**create_journal_request** | [**CreateJournalRequest**](CreateJournalRequest.md) | | [required] | + +### Return type + +[**models::Journal**](Journal.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_journal_by_id + +> delete_journal_by_id(journal_id) +Cancel a pending journal. + +You can only delete a journal if the journal is still in a pending state, if a journal is executed you will not be able to delete. The alternative is to create a mirror journal entry to reverse the flow of funds. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**journal_id** | **uuid::Uuid** | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_all_journals + +> Vec get_all_journals(after, before, status, entry_type, to_account, from_account) +Return a list of requested journals. + +Returns an array of journal objects. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**after** | Option<**String**> | By journal creation date. Format: 2020-01-01 | | +**before** | Option<**String**> | By journal creation date. Format: 2020-01-01 | | +**status** | Option<**String**> | See the JournalStatus model for more info | | +**entry_type** | Option<**String**> | JNLC or JNLS | | +**to_account** | Option<**uuid::Uuid**> | The account id that received the journal | | +**from_account** | Option<**uuid::Uuid**> | The account id that initiated the journal | | + +### Return type + +[**Vec**](Journal.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## subscribe_to_journal_status_sse + +> Vec subscribe_to_journal_status_sse(since, until, since_id, until_id) +Subscribe to journal events (SSE). + +The Events API provides event push as well as historical queries via SSE (server sent events). You can listen to journal status updates as they get processed by our backoffice. Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**since** | Option<**String**> | Format: YYYY-MM-DD | | +**until** | Option<**String**> | Format: YYYY-MM-DD | | +**since_id** | Option<**i32**> | | | +**until_id** | Option<**i32**> | | | + +### Return type + +[**Vec**](JournalStatusEvent.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: text/event-stream + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/broker/docs/KycResult.md b/crates/alpaca_openapi/gen/broker/docs/KycResult.md new file mode 100644 index 0000000..37164c5 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/KycResult.md @@ -0,0 +1,14 @@ +# KycResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**reject** | Option<[**serde_json::Value**](.md)> | | [optional] +**accept** | Option<[**serde_json::Value**](.md)> | | [optional] +**indeterminate** | Option<[**serde_json::Value**](.md)> | | [optional] +**addidional_information** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/NonTradeActivity.md b/crates/alpaca_openapi/gen/broker/docs/NonTradeActivity.md new file mode 100644 index 0000000..fb57ec7 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/NonTradeActivity.md @@ -0,0 +1,17 @@ +# NonTradeActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**date** | Option<[**String**](string.md)> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**net_amount** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**description** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**status** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**symbol** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**qty** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] +**per_share_amount** | Option<**String**> | Valid only for non-trading activity types. Null for trading activites. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/OAuthApi.md b/crates/alpaca_openapi/gen/broker/docs/OAuthApi.md new file mode 100644 index 0000000..874f8e8 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/OAuthApi.md @@ -0,0 +1,104 @@ +# \OAuthApi + +All URIs are relative to *https://broker-api.sandbox.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**authorize_o_auth_token**](OAuthApi.md#authorize_o_auth_token) | **POST** /v1/oauth/authorize | Authorize an OAuth Token +[**get_o_auth_client**](OAuthApi.md#get_o_auth_client) | **GET** /v1/oauth/clients/{client_id} | Get an OAuth client +[**issue_o_auth_token**](OAuthApi.md#issue_o_auth_token) | **POST** /v1/oauth/token | Issue an OAuth token. + + + +## authorize_o_auth_token + +> models::AuthorizeOAuthTokenResponse authorize_o_auth_token(o_auth_token_request) +Authorize an OAuth Token + +The operation issues an OAuth code which can be used in the OAuth code flow. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**o_auth_token_request** | [**OAuthTokenRequest**](OAuthTokenRequest.md) | | [required] | + +### Return type + +[**models::AuthorizeOAuthTokenResponse**](AuthorizeOAuthTokenResponse.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_o_auth_client + +> models::OathClientResponse get_o_auth_client(client_id, response_type, redirect_uri, scope) +Get an OAuth client + +The endpoint returns the details of OAuth client to display in the authorization page. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**client_id** | **uuid::Uuid** | | [required] | +**response_type** | Option<**String**> | code or token | | +**redirect_uri** | Option<**String**> | Redirect URI of the OAuth flow | | +**scope** | Option<**String**> | Requested scopes by the OAuth flow | | + +### Return type + +[**models::OathClientResponse**](OathClientResponse.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## issue_o_auth_token + +> models::IssueOAuthTokenResponse issue_o_auth_token(o_auth_token_request) +Issue an OAuth token. + +The operation issues an OAuth code which can be used in the OAuth code flow. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**o_auth_token_request** | [**OAuthTokenRequest**](OAuthTokenRequest.md) | | [required] | + +### Return type + +[**models::IssueOAuthTokenResponse**](IssueOAuthTokenResponse.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/broker/docs/OAuthTokenRequest.md b/crates/alpaca_openapi/gen/broker/docs/OAuthTokenRequest.md new file mode 100644 index 0000000..dc24285 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/OAuthTokenRequest.md @@ -0,0 +1,15 @@ +# OAuthTokenRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**client_id** | **String** | OAuth client ID | +**client_secret** | **String** | OAuth client secret | +**redirect_uri** | **String** | redirect URI for the OAuth flow | +**scope** | **String** | scopes requested by the OAuth flow | +**account_id** | [**uuid::Uuid**](uuid::Uuid.md) | end-user account ID | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/OathClientResponse.md b/crates/alpaca_openapi/gen/broker/docs/OathClientResponse.md new file mode 100644 index 0000000..2e71ce2 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/OathClientResponse.md @@ -0,0 +1,19 @@ +# OathClientResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**client_id** | Option<**String**> | OAuth client id | [optional] +**name** | Option<**String**> | Broker name (your name) | [optional] +**description** | Option<**String**> | | [optional] +**url** | Option<**String**> | | [optional] +**terms_of_use** | Option<**String**> | URL of Terms of Use | [optional] +**privacy_policy** | Option<**String**> | URL of Privacy Policy | [optional] +**status** | Option<**String**> | ACTIVE or DISABLED | [optional] +**redirect_uri** | Option<**Vec**> | | [optional] +**live_trading_approved** | Option<**bool**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/Order.md b/crates/alpaca_openapi/gen/broker/docs/Order.md new file mode 100644 index 0000000..0eabe80 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Order.md @@ -0,0 +1,43 @@ +# Order + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**client_order_id** | Option<**String**> | | [optional] +**created_at** | Option<**String**> | | [optional] +**updated_at** | Option<**String**> | | [optional] +**submitted_at** | Option<**String**> | | [optional] +**filled_at** | Option<**String**> | | [optional] +**expired_at** | Option<**String**> | | [optional] +**canceled_at** | Option<**String**> | | [optional] +**failed_at** | Option<**String**> | | [optional] +**replaced_at** | Option<**String**> | | [optional] +**replaced_by** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**replaces** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**asset_id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**symbol** | **String** | | +**asset_class** | Option<[**models::AssetClass**](AssetClass.md)> | | [optional] +**notional** | Option<**String**> | | [optional] +**qty** | Option<**String**> | | [optional] +**filled_qty** | Option<**String**> | | [optional] +**filled_avg_price** | Option<**String**> | | [optional] +**order_class** | Option<[**models::OrderClass**](OrderClass.md)> | | [optional] +**order_type** | Option<[**models::OrderType**](OrderType.md)> | | [optional] +**r#type** | Option<[**models::OrderType**](OrderType.md)> | | [optional] +**side** | Option<[**models::OrderSide**](OrderSide.md)> | | [optional] +**time_in_force** | Option<[**models::TimeInForce**](TimeInForce.md)> | | [optional] +**limit_price** | Option<**String**> | | [optional] +**stop_price** | Option<**String**> | | [optional] +**status** | Option<[**models::OrderStatus**](OrderStatus.md)> | | [optional] +**extended_hours** | Option<**bool**> | | [optional] +**legs** | Option<[**Vec**](Order.md)> | | [optional] +**trail_price** | Option<**String**> | | [optional] +**trail_percent** | Option<**String**> | | [optional] +**hwm** | Option<**String**> | | [optional] +**commission** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/OrderClass.md b/crates/alpaca_openapi/gen/broker/docs/OrderClass.md new file mode 100644 index 0000000..5222652 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/OrderClass.md @@ -0,0 +1,15 @@ +# OrderClass + +## Enum Variants + +| Name | Value | +|---- | -----| +| Simple | simple | +| Bracket | bracket | +| Oco | oco | +| Oto | oto | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/OrderClosedResponse.md b/crates/alpaca_openapi/gen/broker/docs/OrderClosedResponse.md new file mode 100644 index 0000000..0a2518e --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/OrderClosedResponse.md @@ -0,0 +1,13 @@ +# OrderClosedResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | UUID of the order that was canceled | +**status** | **i32** | Http status code for the attempt to close this Order | +**body** | Option<[**models::Order**](Order.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/OrderSide.md b/crates/alpaca_openapi/gen/broker/docs/OrderSide.md new file mode 100644 index 0000000..d9b9ea2 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/OrderSide.md @@ -0,0 +1,20 @@ +# OrderSide + +## Enum Variants + +| Name | Value | +|---- | -----| +| Buy | buy | +| Sell | sell | +| BuyMinus | buy_minus | +| SellPlus | sell_plus | +| SellShort | sell_short | +| SellShortExempt | sell_short_exempt | +| Undisclosed | undisclosed | +| Cross | cross | +| CrossShort | cross_short | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/OrderStatus.md b/crates/alpaca_openapi/gen/broker/docs/OrderStatus.md new file mode 100644 index 0000000..e5c3b1b --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/OrderStatus.md @@ -0,0 +1,27 @@ +# OrderStatus + +## Enum Variants + +| Name | Value | +|---- | -----| +| New | new | +| PartiallyFilled | partially_filled | +| Filled | filled | +| DoneForDay | done_for_day | +| Canceled | canceled | +| Expired | expired | +| Replaced | replaced | +| PendingCancel | pending_cancel | +| PendingReplace | pending_replace | +| Accepted | accepted | +| PendingNew | pending_new | +| AcceptedForBidding | accepted_for_bidding | +| Stopped | stopped | +| Rejected | rejected | +| Suspended | suspended | +| Calculated | calculated | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/OrderType.md b/crates/alpaca_openapi/gen/broker/docs/OrderType.md new file mode 100644 index 0000000..0c42e20 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/OrderType.md @@ -0,0 +1,16 @@ +# OrderType + +## Enum Variants + +| Name | Value | +|---- | -----| +| Market | market | +| Limit | limit | +| Stop | stop | +| StopLimit | stop_limit | +| TrailingStop | trailing_stop | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/PortfolioHistory.md b/crates/alpaca_openapi/gen/broker/docs/PortfolioHistory.md new file mode 100644 index 0000000..0693708 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/PortfolioHistory.md @@ -0,0 +1,16 @@ +# PortfolioHistory + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**timestamp** | **Vec** | time of each data element, left-labeled (the beginning of time window) | +**equity** | **Vec** | equity value of the account in dollar amount as of the end of each time window | +**profit_loss** | **Vec** | profit/loss in dollar from the base value | +**profit_loss_pct** | **Vec** | profit/loss in percentage from the base value | +**base_value** | Option<**f64**> | basis in dollar of the profit loss calculation | +**timeframe** | Option<**String**> | time window size of each data element | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/Position.md b/crates/alpaca_openapi/gen/broker/docs/Position.md new file mode 100644 index 0000000..c0c16d9 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Position.md @@ -0,0 +1,27 @@ +# Position + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**asset_id** | [**uuid::Uuid**](uuid::Uuid.md) | Asset ID | +**symbol** | **String** | Asset symbol | +**exchange** | **String** | Exchange name of the asset | +**asset_class** | [**models::AssetClass**](AssetClass.md) | | +**asset_marginable** | Option<**bool**> | Indicates if this asset is marginable | [optional] +**avg_entry_price** | **String** | Average entry price of the position | +**qty** | **String** | The number of shares | +**side** | **String** | | +**market_value** | **String** | Total dollar amount of the position | +**cost_basis** | **String** | Total cost basis in dollar | +**unrealized_pl** | **String** | Unrealized profit/loss in dollars | +**unrealized_plpc** | **String** | Unrealized profit/loss percent (by a factor of 1) | +**unrealized_intraday_pl** | **String** | Unrealized profit/loss in dollars for the day | +**unrealized_intraday_plpc** | **String** | Unrealized interday profit/loss percent (by a factor of 1) | +**current_price** | **String** | Current asset price per share | +**lastday_price** | **String** | Last day’s asset price per share based on the closing value of the last trading day | +**change_today** | **String** | Percent change from last day price (by a factor of 1) | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/PositionClosedResponse.md b/crates/alpaca_openapi/gen/broker/docs/PositionClosedResponse.md new file mode 100644 index 0000000..65f76d7 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/PositionClosedResponse.md @@ -0,0 +1,13 @@ +# PositionClosedResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**symbol** | **String** | Symbol name of the asset | +**status** | **i32** | Http status code for the attempt to close this position | +**body** | Option<[**models::Order**](Order.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TaxIdType.md b/crates/alpaca_openapi/gen/broker/docs/TaxIdType.md new file mode 100644 index 0000000..7f56133 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TaxIdType.md @@ -0,0 +1,49 @@ +# TaxIdType + +## Enum Variants + +| Name | Value | +|---- | -----| +| NotSpecified | NOT_SPECIFIED | +| UsaSsn | USA_SSN | +| ArgAgCuit | ARG_AG_CUIT | +| AusTfn | AUS_TFN | +| AusAbn | AUS_ABN | +| BolNit | BOL_NIT | +| BraCpf | BRA_CPF | +| ChlRut | CHL_RUT | +| ColNit | COL_NIT | +| CriNite | CRI_NITE | +| DeuTaxId | DEU_TAX_ID | +| DomRnc | DOM_RNC | +| EcuRuc | ECU_RUC | +| FraSpi | FRA_SPI | +| GbrUtr | GBR_UTR | +| GbrNino | GBR_NINO | +| GtmNit | GTM_NIT | +| HndRtn | HND_RTN | +| HunTin | HUN_TIN | +| IdnKtp | IDN_KTP | +| IndPan | IND_PAN | +| IsrTaxId | ISR_TAX_ID | +| ItaTaxId | ITA_TAX_ID | +| JpnTaxId | JPN_TAX_ID | +| MexRfc | MEX_RFC | +| NicRuc | NIC_RUC | +| NldTin | NLD_TIN | +| PanRuc | PAN_RUC | +| PerRuc | PER_RUC | +| PryRuc | PRY_RUC | +| SgpNric | SGP_NRIC | +| SgpFin | SGP_FIN | +| SgpAsgd | SGP_ASGD | +| SgpItr | SGP_ITR | +| SlvNit | SLV_NIT | +| SweTaxId | SWE_TAX_ID | +| UryRut | URY_RUT | +| VenRif | VEN_RIF | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TimeInForce.md b/crates/alpaca_openapi/gen/broker/docs/TimeInForce.md new file mode 100644 index 0000000..78b433a --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TimeInForce.md @@ -0,0 +1,17 @@ +# TimeInForce + +## Enum Variants + +| Name | Value | +|---- | -----| +| Day | day | +| Gtc | gtc | +| Opg | opg | +| Cls | cls | +| Ioc | ioc | +| Fok | fok | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TradeAccount.md b/crates/alpaca_openapi/gen/broker/docs/TradeAccount.md new file mode 100644 index 0000000..768f4f9 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TradeAccount.md @@ -0,0 +1,49 @@ +# TradeAccount + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | The account ID | +**account_number** | Option<**String**> | The account number | +**status** | [**models::AccountStatus**](AccountStatus.md) | | +**currency** | **String** | Always USD | +**buying_power** | **String** | Current available cash buying power. If multiplier = 2 then buying_power = max(equity-initial_margin(0) * 2). If multiplier = 1 then buying_power = cash. | +**regt_buying_power** | Option<**String**> | User’s buying power under Regulation T (excess equity - (equity - margin value) - * margin multiplier) | [optional] +**daytrading_buying_power** | Option<**String**> | Your buying power for day trades (continuously updated value) | [optional] +**cash** | **String** | Cash balance | +**cash_withdrawable** | Option<**String**> | Cash available for withdrawl | [optional] +**cash_transferable** | Option<**String**> | Cash available for transfer (JNLC) | [optional] +**pending_transfer_out** | Option<**String**> | Cash pending transfer out | [optional] +**portfolio_value** | Option<**String**> | Total value of cash + holding positions. (This field is deprecated. It is equivalent to the equity field.) | [optional] +**pattern_day_trader** | Option<**bool**> | Whether account is flagged as pattern day trader or not | [optional] +**trading_blocked** | Option<**bool**> | If true, the account is not allowed to place orders. | [optional] +**transfers_blocked** | Option<**bool**> | If true, the account is not allowed to request money transfers. | [optional] +**account_blocked** | Option<**bool**> | If true, the account activity by user is prohibited. | [optional] +**created_at** | **String** | Timestamp this account was created at | +**trade_suspended_by_user** | Option<**bool**> | If true, the account is not allowed to place orders. | [optional] +**multiplier** | Option<**String**> | “1”, “2”, \"3\", or \"4\" | [optional] +**shorting_enabled** | Option<**bool**> | Flag to denote whether or not the account is permitted to short | [optional] +**equity** | **String** | cash + long_market_value + short_market_value | +**last_equity** | **String** | Equity as of previous trading day at 16:00:00 ET | +**long_market_value** | Option<**String**> | Real-time MtM value of all long positions held in the account | [optional] +**short_market_value** | Option<**String**> | Real-time MtM value of all short positions held in the account | [optional] +**initial_margin** | Option<**String**> | Reg T initial margin requirement (continuously updated value) | [optional] +**maintenance_margin** | Option<**String**> | Maintenance margin requirement (continuously updated value) | [optional] +**last_maintenance_margin** | Option<**String**> | Maintenance margin requirement on the previous trading day | [optional] +**sma** | Option<**String**> | Value of Special Memorandum Account (will be used at a later date to provide additional buying_power) | [optional] +**daytrade_count** | Option<**i32**> | The current number of daytrades that have been made in the last 5 trading days (inclusive of today) | [optional] +**previous_close** | Option<**String**> | Previous sessions close time | [optional] +**last_long_market_value** | Option<**String**> | Value of all long positions as of previous trading day at 16:00:00 ET | [optional] +**last_short_market_value** | Option<**String**> | Value of all short positions as of previous trading day at 16:00:00 ET | [optional] +**last_cash** | Option<**String**> | Value of all cash as of previous trading day at 16:00:00 ET | [optional] +**last_initial_margin** | Option<**String**> | Value of Reg T margin as of previous trading day at 16:00:00 ET | [optional] +**last_regt_buying_power** | Option<**String**> | Value of Reg T buying power as of previous trading day at 16:00:00 ET | [optional] +**last_daytrading_buying_power** | Option<**String**> | Value of daytrading buying power as of previous trading day at 16:00:00 ET | [optional] +**last_buying_power** | Option<**String**> | Value of buying_power as of previous trading day at 16:00:00 ET | [optional] +**last_daytrade_count** | Option<**i32**> | Value of daytrade count as of previous trading day at 16:00:00 ET | [optional] +**clearing_broker** | Option<**String**> | Clearing broker | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TradeActivity.md b/crates/alpaca_openapi/gen/broker/docs/TradeActivity.md new file mode 100644 index 0000000..9d81373 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TradeActivity.md @@ -0,0 +1,20 @@ +# TradeActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**transaction_time** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**r#type** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**price** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**qty** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**side** | Option<[**models::OrderSide**](OrderSide.md)> | | [optional] +**symbol** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**leaves_qty** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**order_id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**cum_qty** | Option<**String**> | Valid only for trading activity types. Null for non-trading activites. | [optional] +**order_status** | Option<[**models::OrderStatus**](OrderStatus.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TradeUpdateEvent.md b/crates/alpaca_openapi/gen/broker/docs/TradeUpdateEvent.md new file mode 100644 index 0000000..5cc329c --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TradeUpdateEvent.md @@ -0,0 +1,17 @@ +# TradeUpdateEvent + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account_id** | [**uuid::Uuid**](uuid::Uuid.md) | Account UUID | +**at** | **String** | Timestamp of event | +**event** | [**models::TradeUpdateEventType**](TradeUpdateEventType.md) | | +**event_id** | **i64** | Monotonically increasing 64bit integer | +**execution_id** | [**uuid::Uuid**](uuid::Uuid.md) | Corresponding execution of an order. If an order gets filled over two executions (a partial_fill for example), you will receive two events with different IDs. | +**order** | [**models::Order**](Order.md) | | +**timestamp** | **String** | Has various different meanings depending on the value of `event`, please see the [Trading Events](https://alpaca.markets/docs/api-references/broker-api/events/#trade-events) Enum in the documentation or the TradeUpdateEventType model for more details on when it means different things. | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TradeUpdateEventType.md b/crates/alpaca_openapi/gen/broker/docs/TradeUpdateEventType.md new file mode 100644 index 0000000..8e66bf2 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TradeUpdateEventType.md @@ -0,0 +1,27 @@ +# TradeUpdateEventType + +## Enum Variants + +| Name | Value | +|---- | -----| +| New | new | +| Fill | fill | +| PartialFill | partial_fill | +| Canceled | canceled | +| Expired | expired | +| DoneForDay | done_for_day | +| Replaced | replaced | +| Rejected | rejected | +| PendingNew | pending_new | +| Stopped | stopped | +| PendingCancel | pending_cancel | +| PendingReplace | pending_replace | +| Calculated | calculated | +| Suspended | suspended | +| OrderReplaceRejected | order_replace_rejected | +| OrderCancelRejected | order_cancel_rejected | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TradingApi.md b/crates/alpaca_openapi/gen/broker/docs/TradingApi.md new file mode 100644 index 0000000..05a7d10 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TradingApi.md @@ -0,0 +1,369 @@ +# \TradingApi + +All URIs are relative to *https://broker-api.sandbox.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**close_all_positions_for_account**](TradingApi.md#close_all_positions_for_account) | **DELETE** /v1/trading/accounts/{account_id}/positions | Close All Positions for an Account +[**close_position_for_account_by_symbol**](TradingApi.md#close_position_for_account_by_symbol) | **DELETE** /v1/trading/accounts/{account_id}/positions/{symbol_or_asset_id} | Close a Position for an Account +[**create_order_for_account**](TradingApi.md#create_order_for_account) | **POST** /v1/trading/accounts/{account_id}/orders | Create an order for an account. +[**delete_all_orders_for_account**](TradingApi.md#delete_all_orders_for_account) | **DELETE** /v1/trading/accounts/{account_id}/orders | Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. +[**delete_order_for_account**](TradingApi.md#delete_order_for_account) | **DELETE** /v1/trading/accounts/{account_id}/orders/{order_id} | Attempts to cancel an open order. +[**get_all_orders_for_account**](TradingApi.md#get_all_orders_for_account) | **GET** /v1/trading/accounts/{account_id}/orders | Retrieves a list of orders for the account, filtered by the supplied query parameters. +[**get_order_for_account**](TradingApi.md#get_order_for_account) | **GET** /v1/trading/accounts/{account_id}/orders/{order_id} | Retrieves a single order for the given order_id. +[**get_positions_for_account**](TradingApi.md#get_positions_for_account) | **GET** /v1/trading/accounts/{account_id}/positions | List open positions for an account +[**get_positions_for_account_by_symbol**](TradingApi.md#get_positions_for_account_by_symbol) | **GET** /v1/trading/accounts/{account_id}/positions/{symbol_or_asset_id} | Get an Open Position for account by Symbol or AssetId +[**replace_order_for_account**](TradingApi.md#replace_order_for_account) | **PATCH** /v1/trading/accounts/{account_id}/orders/{order_id} | Replaces a single order with updated parameters +[**subscribe_to_trade_sse**](TradingApi.md#subscribe_to_trade_sse) | **GET** /v1/events/trades | Subscribe to Trade Events (SSE) + + + +## close_all_positions_for_account + +> Vec close_all_positions_for_account(account_id, cancel_orders) +Close All Positions for an Account + +Closes (liquidates) all of the account’s open long and short positions. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**cancel_orders** | Option<**bool**> | If true is specified, cancel all open orders before liquidating all positions. | | + +### Return type + +[**Vec**](PositionClosedResponse.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## close_position_for_account_by_symbol + +> models::Order close_position_for_account_by_symbol(account_id, symbol_or_asset_id, qty, percentage) +Close a Position for an Account + +Closes (liquidates) the account’s open position for the given symbol. Works for both long and short positions. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**symbol_or_asset_id** | **String** | The symbol or asset_id | [required] | +**qty** | Option<**String**> | Optional the number of shares to liquidate. Can accept up to 9 decimal points. Cannot work with percentage | | +**percentage** | Option<**String**> | percentage of position to liquidate. Must be between 0 and 100. Would only sell fractional if position is originally fractional. Can accept up to 9 decimal points. Cannot work with qty | | + +### Return type + +[**models::Order**](Order.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## create_order_for_account + +> models::Order create_order_for_account(account_id, create_order_request) +Create an order for an account. + +Create an order for an account. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**create_order_request** | [**CreateOrderRequest**](CreateOrderRequest.md) | | [required] | + +### Return type + +[**models::Order**](Order.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_all_orders_for_account + +> Vec delete_all_orders_for_account(account_id) +Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. + +Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | + +### Return type + +[**Vec**](OrderClosedResponse.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_order_for_account + +> delete_order_for_account(account_id, order_id) +Attempts to cancel an open order. + +Attempts to cancel an open order. If the order is no longer cancelable (for example if the status is \"filled\"), the server will respond with status 422, and reject the request. Upon acceptance of the cancel request, it returns status 204. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**order_id** | **String** | Order identifier. | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_all_orders_for_account + +> Vec get_all_orders_for_account(account_id, status, limit, after, until, direction, nested, symbols) +Retrieves a list of orders for the account, filtered by the supplied query parameters. + +Retrieves a list of orders for the account, filtered by the supplied query parameters. Endpoint defaults to open orders if no parameters are provided. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**status** | Option<**String**> | Order status to be queried. open, closed or all. Defaults to open. | | +**limit** | Option<**i32**> | The maximum number of orders in response. Defaults to 50 and max is 500. | | +**after** | Option<**String**> | The response will include only ones submitted after this timestamp (exclusive.) | | +**until** | Option<**String**> | The response will include only ones submitted until this timestamp (exclusive.) | | +**direction** | Option<**String**> | The chronological order of response based on the submission time. asc or desc. Defaults to desc. | | +**nested** | Option<**bool**> | If true, the result will roll up multi-leg orders under the legs field of primary order. | | +**symbols** | Option<**String**> | A comma-separated list of symbols to filter by. | | + +### Return type + +[**Vec**](Order.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_order_for_account + +> models::Order get_order_for_account(account_id, order_id) +Retrieves a single order for the given order_id. + +Retrieves a single order for the given order_id. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**order_id** | **String** | Order identifier. | [required] | + +### Return type + +[**models::Order**](Order.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_positions_for_account + +> Vec get_positions_for_account(account_id) +List open positions for an account + +List open positions for an account + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | + +### Return type + +[**Vec**](Position.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_positions_for_account_by_symbol + +> models::Position get_positions_for_account_by_symbol(account_id, symbol_or_asset_id) +Get an Open Position for account by Symbol or AssetId + +Retrieves the account’s open position for the given symbol or asset_id. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**symbol_or_asset_id** | **String** | The symbol or asset_id | [required] | + +### Return type + +[**models::Position**](Position.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## replace_order_for_account + +> models::Order replace_order_for_account(account_id, order_id, update_order_request) +Replaces a single order with updated parameters + +Replaces a single order with updated parameters. Each parameter overrides the corresponding attribute of the existing order. The other attributes remain the same as the existing order. A success return code from a replaced order does NOT guarantee the existing open order has been replaced. If the existing open order is filled before the replacing (new) order reaches the execution venue, the replacing (new) order is rejected, and these events are sent in the trade_updates stream channel found [here in the market data api](https://alpaca.markets/docs/api-references/market-data-api/#order-updates). While an order is being replaced, the account's buying power is reduced by the larger of the two orders that have been placed (the old order being replaced, and the newly placed order to replace it). If you are replacing a buy entry order with a higher limit price than the original order, the buying power is calculated based on the newly placed order. If you are replacing it with a lower limit price, the buying power is calculated based on the old order. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Account identifier. | [required] | +**order_id** | **String** | Order identifier. | [required] | +**update_order_request** | [**UpdateOrderRequest**](UpdateOrderRequest.md) | | [required] | + +### Return type + +[**models::Order**](Order.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## subscribe_to_trade_sse + +> Vec subscribe_to_trade_sse(since, until, since_id, until_id) +Subscribe to Trade Events (SSE) + +The Events API provides event push as well as historical queries via SSE (server sent events). You can listen to events related to trade updates. Most market trades sent during market hours are filled instantly; you can listen to limit order updates through this endpoint. Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**since** | Option<**String**> | Format: YYYY-MM-DD | | +**until** | Option<**String**> | Format: YYYY-MM-DD | | +**since_id** | Option<**i32**> | | | +**until_id** | Option<**i32**> | | | + +### Return type + +[**Vec**](TradeUpdateEvent.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: text/event-stream + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/broker/docs/Transfer.md b/crates/alpaca_openapi/gen/broker/docs/Transfer.md new file mode 100644 index 0000000..e3423b5 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Transfer.md @@ -0,0 +1,25 @@ +# Transfer + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | The transfer ID | +**relationship_id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | The ACH relationship ID only present if type = \"ach\" | [optional] +**bank_id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | The ID of the Bank, only present if type = \"wire\" | [optional] +**account_id** | [**uuid::Uuid**](uuid::Uuid.md) | The account ID | +**r#type** | [**models::TransferType**](TransferType.md) | | +**status** | [**models::TransferStatus**](TransferStatus.md) | | +**reason** | Option<**String**> | Cause of the status | [optional] +**amount** | **String** | Must be > 0.00 | +**direction** | [**models::TransferDirection**](TransferDirection.md) | | +**created_at** | **String** | Timedate when transfer was created | +**updated_at** | Option<**String**> | Timedate when transfer was updated | [optional] +**expires_at** | Option<**String**> | Timedate when transfer was expired | [optional] +**additional_information** | Option<**String**> | Additional information. Only applies when type = \"wire\". | [optional] +**hold_until** | Option<**String**> | | [optional] +**instant_amount** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TransferData.md b/crates/alpaca_openapi/gen/broker/docs/TransferData.md new file mode 100644 index 0000000..cf9389d --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TransferData.md @@ -0,0 +1,17 @@ +# TransferData + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**transfer_type** | **String** | | +**timing** | Option<**String**> | | [optional] +**amount** | **String** | | +**direction** | **String** | | +**relationship_id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**additional_information** | Option<**String**> | | [optional] +**bank_id** | [**uuid::Uuid**](uuid::Uuid.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TransferDirection.md b/crates/alpaca_openapi/gen/broker/docs/TransferDirection.md new file mode 100644 index 0000000..fa6c209 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TransferDirection.md @@ -0,0 +1,13 @@ +# TransferDirection + +## Enum Variants + +| Name | Value | +|---- | -----| +| Incoming | INCOMING | +| Outgoing | OUTGOING | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TransferResource.md b/crates/alpaca_openapi/gen/broker/docs/TransferResource.md new file mode 100644 index 0000000..47df33d --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TransferResource.md @@ -0,0 +1,23 @@ +# TransferResource + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**created_at** | **String** | Format: 2020-01-01T01:01:01Z | +**updated_at** | **String** | Format: 2020-01-01T01:01:01Z | +**r#type** | **String** | | +**status** | **String** | | +**account_id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**reason** | Option<**String**> | | [optional] +**expires_at** | **String** | | +**amount** | **String** | | +**direction** | **String** | | +**relationship_id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**additional_information** | Option<**String**> | | [optional] +**bank_id** | [**uuid::Uuid**](uuid::Uuid.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TransferStatus.md b/crates/alpaca_openapi/gen/broker/docs/TransferStatus.md new file mode 100644 index 0000000..8b4e55e --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TransferStatus.md @@ -0,0 +1,20 @@ +# TransferStatus + +## Enum Variants + +| Name | Value | +|---- | -----| +| Queued | QUEUED | +| ApprovalPending | APPROVAL_PENDING | +| Pending | PENDING | +| SentToClearing | SENT_TO_CLEARING | +| Rejected | REJECTED | +| Canceled | CANCELED | +| Approved | APPROVED | +| Complete | COMPLETE | +| Returned | RETURNED | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TransferStatusEvent.md b/crates/alpaca_openapi/gen/broker/docs/TransferStatusEvent.md new file mode 100644 index 0000000..9dd8176 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TransferStatusEvent.md @@ -0,0 +1,16 @@ +# TransferStatusEvent + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account_id** | [**uuid::Uuid**](uuid::Uuid.md) | Account UUID | +**at** | **String** | Timedate of when the transfer status changed | +**event_id** | **i32** | Monotonically increasing 64bit integer | +**status_from** | [**models::TransferStatus**](TransferStatus.md) | | +**status_to** | [**models::TransferStatus**](TransferStatus.md) | | +**transfer_id** | [**uuid::Uuid**](uuid::Uuid.md) | Transfer UUID | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TransferTiming.md b/crates/alpaca_openapi/gen/broker/docs/TransferTiming.md new file mode 100644 index 0000000..92ecb8e --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TransferTiming.md @@ -0,0 +1,12 @@ +# TransferTiming + +## Enum Variants + +| Name | Value | +|---- | -----| +| Immediate | immediate | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TransferType.md b/crates/alpaca_openapi/gen/broker/docs/TransferType.md new file mode 100644 index 0000000..e865da2 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TransferType.md @@ -0,0 +1,14 @@ +# TransferType + +## Enum Variants + +| Name | Value | +|---- | -----| +| Ach | ach | +| InstantAch | instant_ach | +| Wire | wire | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/TrustedContact.md b/crates/alpaca_openapi/gen/broker/docs/TrustedContact.md new file mode 100644 index 0000000..76fe9ef --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/TrustedContact.md @@ -0,0 +1,19 @@ +# TrustedContact + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**given_name** | **String** | | +**family_name** | **String** | | +**email_address** | Option<**String**> | at least one of `email_address`, `phone_number` or `street_address` is required | [optional] +**phone_number** | Option<**String**> | at least one of `email_address`, `phone_number` or `street_address` is required | [optional] +**street_address** | Option<**Vec**> | at least one of `email_address`, `phone_number` or `street_address` is required | [optional] +**city** | Option<**String**> | required if `street_address` is set | [optional] +**state** | Option<**String**> | required if `street_address` is set | [optional] +**postal_code** | Option<**String**> | required if `street_address` is set | [optional] +**country** | Option<**String**> | [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html). required if `street_address` is set | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/UntypedAchTransferData.md b/crates/alpaca_openapi/gen/broker/docs/UntypedAchTransferData.md new file mode 100644 index 0000000..5349109 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/UntypedAchTransferData.md @@ -0,0 +1,13 @@ +# UntypedAchTransferData + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**amount** | **String** | | +**direction** | **String** | | +**relationship_id** | [**uuid::Uuid**](uuid::Uuid.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/UntypedTransferData.md b/crates/alpaca_openapi/gen/broker/docs/UntypedTransferData.md new file mode 100644 index 0000000..d0afb26 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/UntypedTransferData.md @@ -0,0 +1,12 @@ +# UntypedTransferData + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**amount** | **String** | | +**direction** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/UntypedWireTransferData.md b/crates/alpaca_openapi/gen/broker/docs/UntypedWireTransferData.md new file mode 100644 index 0000000..c7a8e92 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/UntypedWireTransferData.md @@ -0,0 +1,14 @@ +# UntypedWireTransferData + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**amount** | **String** | | +**direction** | **String** | | +**additional_information** | Option<**String**> | | [optional] +**bank_id** | [**uuid::Uuid**](uuid::Uuid.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/UpdateOrderRequest.md b/crates/alpaca_openapi/gen/broker/docs/UpdateOrderRequest.md new file mode 100644 index 0000000..3f81c91 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/UpdateOrderRequest.md @@ -0,0 +1,16 @@ +# UpdateOrderRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**qty** | Option<**String**> | You can only patch full shares for now | [optional] +**time_in_force** | Option<[**models::TimeInForce**](TimeInForce.md)> | | [optional] +**limit_price** | Option<**String**> | Required if original order's `type` field was limit or stop_limit | [optional] +**stop_price** | Option<**String**> | Required if original order's `type` field was stop or stop_limit | [optional] +**trail** | Option<**String**> | The new value of the trail_price or trail_percent | [optional] +**client_order_id** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/Watchlist.md b/crates/alpaca_openapi/gen/broker/docs/Watchlist.md new file mode 100644 index 0000000..d1a5176 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/Watchlist.md @@ -0,0 +1,16 @@ +# Watchlist + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | Unique identifier of the watchlist itself. | +**account_id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | Unique identifier of the account that owns this watchlist. | [optional] +**created_at** | Option<**String**> | When watchlist was created | [optional] +**updated_at** | Option<**String**> | When watchlist was last updated | [optional] +**name** | **String** | User friendly Name of watchlist | +**assets** | Option<[**Vec**](Asset.md)> | The contents of the watchlist, in the order as registered | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/broker/docs/WatchlistApi.md b/crates/alpaca_openapi/gen/broker/docs/WatchlistApi.md new file mode 100644 index 0000000..325b526 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/docs/WatchlistApi.md @@ -0,0 +1,168 @@ +# \WatchlistApi + +All URIs are relative to *https://broker-api.sandbox.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_watchlist_for_account**](WatchlistApi.md#create_watchlist_for_account) | **POST** /v1/trading/accounts/{account_id}/watchlists | Create a new watchlist +[**delete_watchlist_from_account_by_id**](WatchlistApi.md#delete_watchlist_from_account_by_id) | **DELETE** /v1/accounts/{account_id}/watchlists/{watchlist_id} | Remove a watchlist +[**get_all_watchlists_for_account**](WatchlistApi.md#get_all_watchlists_for_account) | **GET** /v1/trading/accounts/{account_id}/watchlists | Retrieve all watchlists +[**get_watchlist_for_account_by_id**](WatchlistApi.md#get_watchlist_for_account_by_id) | **GET** /v1/accounts/{account_id}/watchlists/{watchlist_id} | Manage watchlists +[**replace_watchlist_for_account_by_id**](WatchlistApi.md#replace_watchlist_for_account_by_id) | **PUT** /v1/accounts/{account_id}/watchlists/{watchlist_id} | Update an existing watchlist + + + +## create_watchlist_for_account + +> models::Watchlist create_watchlist_for_account(account_id, create_watchlist_request) +Create a new watchlist + +Returns the watchlist object + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Unique identifier of an account. | [required] | +**create_watchlist_request** | Option<[**CreateWatchlistRequest**](CreateWatchlistRequest.md)> | | | + +### Return type + +[**models::Watchlist**](Watchlist.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_watchlist_from_account_by_id + +> delete_watchlist_from_account_by_id(account_id, watchlist_id) +Remove a watchlist + +Irrevocably delete a watchlist. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Unique identifier of an account | [required] | +**watchlist_id** | **uuid::Uuid** | Unique identifier of a watchlist | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_all_watchlists_for_account + +> Vec get_all_watchlists_for_account(account_id) +Retrieve all watchlists + +Fetch a list of all watchlists currently in an account. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Unique identifier of an account. | [required] | + +### Return type + +[**Vec**](Watchlist.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_watchlist_for_account_by_id + +> models::Watchlist get_watchlist_for_account_by_id(account_id, watchlist_id) +Manage watchlists + +Fetch a single watchlist by identifier. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Unique identifier of an account | [required] | +**watchlist_id** | **uuid::Uuid** | Unique identifier of a watchlist | [required] | + +### Return type + +[**models::Watchlist**](Watchlist.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## replace_watchlist_for_account_by_id + +> models::Watchlist replace_watchlist_for_account_by_id(account_id, watchlist_id, create_watchlist_request) +Update an existing watchlist + +Replace entirely the set of securities contained in the watchlist while optionally renaming it. Destructive operation. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_id** | **uuid::Uuid** | Unique identifier of an account | [required] | +**watchlist_id** | **uuid::Uuid** | Unique identifier of a watchlist | [required] | +**create_watchlist_request** | Option<[**CreateWatchlistRequest**](CreateWatchlistRequest.md)> | | | + +### Return type + +[**models::Watchlist**](Watchlist.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/broker/git_push.sh b/crates/alpaca_openapi/gen/broker/git_push.sh new file mode 100644 index 0000000..f53a75d --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/crates/alpaca_openapi/gen/broker/src/apis/accounts_api.rs b/crates/alpaca_openapi/gen/broker/src/apis/accounts_api.rs new file mode 100644 index 0000000..9fcc9f7 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/apis/accounts_api.rs @@ -0,0 +1,1778 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`create_account`] +#[derive(Clone, Debug)] +pub struct CreateAccountParams { + pub account_creation_request: models::AccountCreationRequest, +} + +/// struct for passing parameters to the method [`create_ach_relationship_for_account`] +#[derive(Clone, Debug)] +pub struct CreateAchRelationshipForAccountParams { + /// Account identifier. + pub account_id: String, + /// Create ACH Relationship + pub create_ach_relationship_request: models::CreateAchRelationshipRequest, +} + +/// struct for passing parameters to the method [`create_recipient_bank`] +#[derive(Clone, Debug)] +pub struct CreateRecipientBankParams { + /// Account identifier. + pub account_id: String, + pub create_bank_request: models::CreateBankRequest, +} + +/// struct for passing parameters to the method [`create_transfer_for_account`] +#[derive(Clone, Debug)] +pub struct CreateTransferForAccountParams { + /// Account identifier. + pub account_id: String, + pub create_transfer_request: models::CreateTransferRequest, +} + +/// struct for passing parameters to the method [`delete_account`] +#[derive(Clone, Debug)] +pub struct DeleteAccountParams { + /// Account identifier. + pub account_id: String, +} + +/// struct for passing parameters to the method [`delete_ach_relationship_from_account`] +#[derive(Clone, Debug)] +pub struct DeleteAchRelationshipFromAccountParams { + /// Account identifier. + pub account_id: String, + /// ACH relationship identifier + pub ach_relationship_id: String, +} + +/// struct for passing parameters to the method [`delete_recipient_bank`] +#[derive(Clone, Debug)] +pub struct DeleteRecipientBankParams { + /// Account identifier. + pub account_id: String, + pub bank_id: String, +} + +/// struct for passing parameters to the method [`delete_transfer`] +#[derive(Clone, Debug)] +pub struct DeleteTransferParams { + /// Account identifier. + pub account_id: String, + /// Tranfer identifier + pub transfer_id: String, +} + +/// struct for passing parameters to the method [`get_account`] +#[derive(Clone, Debug)] +pub struct GetAccountParams { + /// Account identifier. + pub account_id: String, +} + +/// struct for passing parameters to the method [`get_account_ach_relationships`] +#[derive(Clone, Debug)] +pub struct GetAccountAchRelationshipsParams { + /// Account identifier. + pub account_id: String, + /// Comma-separated status values + pub statuses: Option, +} + +/// struct for passing parameters to the method [`get_account_activities`] +#[derive(Clone, Debug)] +pub struct GetAccountActivitiesParams { + /// id of a single account to filter by + pub account_id: Option, + /// Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported. + pub date: Option, + /// Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported. + pub until: Option, + /// Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported. Cannot be used with date. + pub after: Option, + /// The chronological order of response based on the submission time. asc or desc. Defaults to desc. + pub direction: Option, + /// The maximum number of entries to return in the response + pub page_size: Option, + /// The Activity ID of the end of your current page of results. + pub page_token: Option, +} + +/// struct for passing parameters to the method [`get_account_activities_by_type`] +#[derive(Clone, Debug)] +pub struct GetAccountActivitiesByTypeParams { + /// see ActivityType model for details about what the different types mean + pub activity_type: String, + /// id of a single account to filter by + pub account_id: Option, + /// Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported. + pub date: Option, + /// Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported. + pub until: Option, + /// Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported. + pub after: Option, + /// The chronological order of response based on the submission time. asc or desc. Defaults to desc. + pub direction: Option, + /// The maximum number of entries to return in the response + pub page_size: Option, + /// The ID of the end of your current page of results + pub page_token: Option, +} + +/// struct for passing parameters to the method [`get_all_accounts`] +#[derive(Clone, Debug)] +pub struct GetAllAccountsParams { + /// Pass space-delimited tokens. The response will contain accounts that match with each of the tokens (logical AND). A match means the token is present in either the account’s associated account number, phone number, name, or e-mail address (logical OR). + pub query: Option, + pub created_after: Option, + pub created_before: Option, + /// See the AccountStatus model for values + pub status: Option, + /// The chronological order of response based on the submission time. asc or desc. Defaults to desc. + pub sort: Option, + /// Comma-delimited entity names to include in the response + pub entities: Option, +} + +/// struct for passing parameters to the method [`get_recipient_banks`] +#[derive(Clone, Debug)] +pub struct GetRecipientBanksParams { + /// Account identifier. + pub account_id: String, + pub status: Option, + pub bank_name: Option, +} + +/// struct for passing parameters to the method [`get_trading_account`] +#[derive(Clone, Debug)] +pub struct GetTradingAccountParams { + /// Account identifier. + pub account_id: String, +} + +/// struct for passing parameters to the method [`get_transfers_for_account`] +#[derive(Clone, Debug)] +pub struct GetTransfersForAccountParams { + /// Account identifier. + pub account_id: String, + /// INCOMING or OUTGOING + pub direction: Option, + pub limit: Option, + pub offset: Option, +} + +/// struct for passing parameters to the method [`patch_account`] +#[derive(Clone, Debug)] +pub struct PatchAccountParams { + /// Account identifier. + pub account_id: String, + pub account_update_request: models::AccountUpdateRequest, +} + +/// struct for passing parameters to the method [`suscribe_to_account_status_sse`] +#[derive(Clone, Debug)] +pub struct SuscribeToAccountStatusSseParams { + /// Format: YYYY-MM-DD + pub since: Option, + /// Format: YYYY-MM-DD + pub until: Option, + pub since_id: Option, + pub until_id: Option, +} + +/// struct for passing parameters to the method [`upload_doc_to_account`] +#[derive(Clone, Debug)] +pub struct UploadDocToAccountParams { + /// Account identifier. + pub account_id: String, + pub document_upload_request: models::DocumentUploadRequest, +} + +/// struct for typed successes of method [`create_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateAccountSuccess { + Status200(models::Account), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`create_ach_relationship_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateAchRelationshipForAccountSuccess { + Status200(models::AchRelationship), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`create_recipient_bank`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateRecipientBankSuccess { + Status200(models::Bank), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`create_transfer_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateTransferForAccountSuccess { + Status200(models::Transfer), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAccountSuccess { + Status204(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_ach_relationship_from_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAchRelationshipFromAccountSuccess { + Status204(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_recipient_bank`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteRecipientBankSuccess { + Status204(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_transfer`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteTransferSuccess { + Status204(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountSuccess { + Status200(models::AccountExtended), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_account_ach_relationships`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountAchRelationshipsSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_account_activities`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountActivitiesSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_account_activities_by_type`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountActivitiesByTypeSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_all_accounts`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAllAccountsSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_recipient_banks`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetRecipientBanksSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_trading_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTradingAccountSuccess { + Status200(models::TradeAccount), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_transfers_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTransfersForAccountSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`patch_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PatchAccountSuccess { + Status200(models::AccountExtended), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`suscribe_to_account_status_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SuscribeToAccountStatusSseSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`upload_doc_to_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UploadDocToAccountSuccess { + Status204(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateAccountError { + Status400(String), + Status409(), + Status422(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_ach_relationship_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateAchRelationshipForAccountError { + Status400(models::Error), + Status401(models::Error), + Status409(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_recipient_bank`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateRecipientBankError { + Status400(), + Status409(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_transfer_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateTransferForAccountError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAccountError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_ach_relationship_from_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAchRelationshipFromAccountError { + Status400(), + Status404(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_recipient_bank`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteRecipientBankError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_transfer`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteTransferError { + Status404(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_account_ach_relationships`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountAchRelationshipsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_account_activities`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountActivitiesError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_account_activities_by_type`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountActivitiesByTypeError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_all_accounts`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAllAccountsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_recipient_banks`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetRecipientBanksError { + Status400(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_trading_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTradingAccountError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_transfers_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTransfersForAccountError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`patch_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PatchAccountError { + Status400(String), + Status422(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`suscribe_to_account_status_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SuscribeToAccountStatusSseError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`upload_doc_to_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UploadDocToAccountError { + Status400(String), + Status404(String), + UnknownValue(serde_json::Value), +} + +/// Submit an account application with KYC information. This will create a trading account for the end user. The account status may or may not be ACTIVE immediately and you will receive account status updates on the event API. +pub async fn create_account( + configuration: &configuration::Configuration, + params: CreateAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_creation_request = params.account_creation_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v1/accounts", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&account_creation_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Create a new ACHRelationship for an account If successful, will return 200 code with a newly created ACH Relationship entity. +pub async fn create_ach_relationship_for_account( + configuration: &configuration::Configuration, + params: CreateAchRelationshipForAccountParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let create_ach_relationship_request = params.create_ach_relationship_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/ach_relationships", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&create_ach_relationship_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// If successful, retrieves Bank Relationships for an account +pub async fn create_recipient_bank( + configuration: &configuration::Configuration, + params: CreateRecipientBankParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let create_bank_request = params.create_bank_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/recipient_banks", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&create_bank_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Create a new transfer to an account to fund it. In the sandbox environment, you can instantly deposit to or withdraw from an account with a virtual money amount. In the production environment, this endpoint is used only for requesting an outgoing (withdrawal) wire transfer at this moment. For the wire transfer (in production), you need to create a bank resource first using the Bank API. For more on how to fund an account in sandbox please check out this tutorial [here](https://alpaca.markets/learn/fund-broker-api/). +pub async fn create_transfer_for_account( + configuration: &configuration::Configuration, + params: CreateTransferForAccountParams, +) -> Result, Error> +{ + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let create_transfer_request = params.create_transfer_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/transfers", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&create_transfer_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// This operation closes an active account. +pub async fn delete_account( + configuration: &configuration::Configuration, + params: DeleteAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Delete an existing ACH relationship for an account +pub async fn delete_ach_relationship_from_account( + configuration: &configuration::Configuration, + params: DeleteAchRelationshipFromAccountParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let ach_relationship_id = params.ach_relationship_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/ach_relationships/{ach_relationship_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + ach_relationship_id = crate::apis::urlencode(ach_relationship_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// If successful, deletes Bank Relationship for an account +pub async fn delete_recipient_bank( + configuration: &configuration::Configuration, + params: DeleteRecipientBankParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let bank_id = params.bank_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/recipient_banks/{bank_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + bank_id = crate::apis::urlencode(bank_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Request to close a transfer +pub async fn delete_transfer( + configuration: &configuration::Configuration, + params: DeleteTransferParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let transfer_id = params.transfer_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/transfers/{transfer_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + transfer_id = crate::apis::urlencode(transfer_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// You can query a specific account that you submitted to Alpaca by passing into the query the account_id associated with the account you’re retrieving. +pub async fn get_account( + configuration: &configuration::Configuration, + params: GetAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns a list of ACH Relationships for an account +pub async fn get_account_ach_relationships( + configuration: &configuration::Configuration, + params: GetAccountAchRelationshipsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let statuses = params.statuses; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/ach_relationships", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = statuses { + local_var_req_builder = + local_var_req_builder.query(&[("statuses", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns an array of Activities Notes: * Pagination is handled using the `page_token` and `page_size` parameters. * `page_token` represents the ID of the end of your current page of results. for example if in your first response the id of the last Activiy item returned in the array was `20220203000000000::045b3b8d-c566-4bef-b741-2bf598dd6ae7`, you'd pass that value as `page_token` to get the next page of results * If specified with a `direction` of `desc`, for example, the results will end before the activity with the specified ID. * If specified with a `direction` of `asc`, results will begin with the activity immediately after the one specified. * `page_size` is the maximum number of entries to return in the response. * If `date` is not specified, the default and maximum value is 100. * If `date` is specified, the default behavior is to return all results, and there is no maximum page size. +pub async fn get_account_activities( + configuration: &configuration::Configuration, + params: GetAccountActivitiesParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let date = params.date; + let until = params.until; + let after = params.after; + let direction = params.direction; + let page_size = params.page_size; + let page_token = params.page_token; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/activities", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = account_id { + local_var_req_builder = + local_var_req_builder.query(&[("account_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = date { + local_var_req_builder = + local_var_req_builder.query(&[("date", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until { + local_var_req_builder = + local_var_req_builder.query(&[("until", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = after { + local_var_req_builder = + local_var_req_builder.query(&[("after", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = direction { + local_var_req_builder = + local_var_req_builder.query(&[("direction", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_size { + local_var_req_builder = + local_var_req_builder.query(&[("page_size", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Retrieves an Array of Activies by type Notes: * Pagination is handled using the `page_token` and `page_size` parameters. * `page_token` represents the ID of the end of your current page of results. for example if in your first response the id of the last Activiy item returned in the array was `20220203000000000::045b3b8d-c566-4bef-b741-2bf598dd6ae7`, you'd pass that value as `page_token` to get the next page of results * If specified with a `direction` of `desc`, for example, the results will end before the activity with the specified ID. * If specified with a `direction` of `asc`, results will begin with the activity immediately after the one specified. * `page_size` is the maximum number of entries to return in the response. * If `date` is not specified, the default and maximum value is 100. * If `date` is specified, the default behavior is to return all results, and there is no maximum page size. +pub async fn get_account_activities_by_type( + configuration: &configuration::Configuration, + params: GetAccountActivitiesByTypeParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let activity_type = params.activity_type; + let account_id = params.account_id; + let date = params.date; + let until = params.until; + let after = params.after; + let direction = params.direction; + let page_size = params.page_size; + let page_token = params.page_token; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/activities/{activity_type}", + local_var_configuration.base_path, + activity_type = crate::apis::urlencode(activity_type) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = account_id { + local_var_req_builder = + local_var_req_builder.query(&[("account_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = date { + local_var_req_builder = + local_var_req_builder.query(&[("date", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until { + local_var_req_builder = + local_var_req_builder.query(&[("until", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = after { + local_var_req_builder = + local_var_req_builder.query(&[("after", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = direction { + local_var_req_builder = + local_var_req_builder.query(&[("direction", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_size { + local_var_req_builder = + local_var_req_builder.query(&[("page_size", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Retrieves all accounts found by the query' +pub async fn get_all_accounts( + configuration: &configuration::Configuration, + params: GetAllAccountsParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let query = params.query; + let created_after = params.created_after; + let created_before = params.created_before; + let status = params.status; + let sort = params.sort; + let entities = params.entities; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v1/accounts", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = query { + local_var_req_builder = + local_var_req_builder.query(&[("query", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = created_after { + local_var_req_builder = + local_var_req_builder.query(&[("created_after", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = created_before { + local_var_req_builder = + local_var_req_builder.query(&[("created_before", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = status { + local_var_req_builder = + local_var_req_builder.query(&[("status", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = sort { + local_var_req_builder = + local_var_req_builder.query(&[("sort", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = entities { + local_var_req_builder = + local_var_req_builder.query(&[("entities", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Retrieves Bank Relationships for an account +pub async fn get_recipient_banks( + configuration: &configuration::Configuration, + params: GetRecipientBanksParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let status = params.status; + let bank_name = params.bank_name; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/recipient_banks", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = status { + local_var_req_builder = + local_var_req_builder.query(&[("status", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = bank_name { + local_var_req_builder = + local_var_req_builder.query(&[("bank_name", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// As a broker you can view more trading details about your users. The response is a Trading Account model. +pub async fn get_trading_account( + configuration: &configuration::Configuration, + params: GetTradingAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/trading/accounts/{account_id}/account", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// You can query a list of transfers for an account. You can filter requested transfers by values such as direction and status. +pub async fn get_transfers_for_account( + configuration: &configuration::Configuration, + params: GetTransfersForAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let direction = params.direction; + let limit = params.limit; + let offset = params.offset; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/transfers", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = direction { + local_var_req_builder = + local_var_req_builder.query(&[("direction", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = offset { + local_var_req_builder = + local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// This operation updates account information. If all parameters are valid and updates have been made, it returns with status code 200. The response is the account model. +pub async fn patch_account( + configuration: &configuration::Configuration, + params: PatchAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let account_update_request = params.account_update_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&account_update_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Events API provide event push as well as historical queries via SSE (server sent events). Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. +pub async fn suscribe_to_account_status_sse( + configuration: &configuration::Configuration, + params: SuscribeToAccountStatusSseParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let since = params.since; + let until = params.until; + let since_id = params.since_id; + let until_id = params.until_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/events/accounts/status", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = since { + local_var_req_builder = + local_var_req_builder.query(&[("since", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until { + local_var_req_builder = + local_var_req_builder.query(&[("until", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = since_id { + local_var_req_builder = + local_var_req_builder.query(&[("since_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until_id { + local_var_req_builder = + local_var_req_builder.query(&[("until_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Upload a document to be attached to an account. Documents are binary objects whose contents are encoded in base64. Each encoded content size is limited to 10MB if you use Alpaca for KYCaaS. If you perform your own KYC there are no document size limitations. +pub async fn upload_doc_to_account( + configuration: &configuration::Configuration, + params: UploadDocToAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let document_upload_request = params.document_upload_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/documents/upload", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&document_upload_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/apis/assets_api.rs b/crates/alpaca_openapi/gen/broker/src/apis/assets_api.rs new file mode 100644 index 0000000..276ff4a --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/apis/assets_api.rs @@ -0,0 +1,182 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`get_asset_by_symbol_or_id`] +#[derive(Clone, Debug)] +pub struct GetAssetBySymbolOrIdParams { + /// you can use either the asset's Id or the symbol to search + pub symbol_or_asset_id: String, +} + +/// struct for passing parameters to the method [`get_assets`] +#[derive(Clone, Debug)] +pub struct GetAssetsParams { + /// Asset status to filter by, will default to `all` + pub status: Option, + /// Asset class to filter by, `us_equity` or `crypto`. Defaults to `us_equity` + pub asset_class: Option, +} + +/// struct for typed successes of method [`get_asset_by_symbol_or_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAssetBySymbolOrIdSuccess { + Status200(models::Asset), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_assets`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAssetsSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_asset_by_symbol_or_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAssetBySymbolOrIdError { + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_assets`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAssetsError { + UnknownValue(serde_json::Value), +} + +/// Returns the requested asset, if found +pub async fn get_asset_by_symbol_or_id( + configuration: &configuration::Configuration, + params: GetAssetBySymbolOrIdParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol_or_asset_id = params.symbol_or_asset_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/assets/{symbol_or_asset_id}", + local_var_configuration.base_path, + symbol_or_asset_id = crate::apis::urlencode(symbol_or_asset_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns all assets +pub async fn get_assets( + configuration: &configuration::Configuration, + params: GetAssetsParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let status = params.status; + let asset_class = params.asset_class; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v1/assets", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = status { + local_var_req_builder = + local_var_req_builder.query(&[("status", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = asset_class { + local_var_req_builder = + local_var_req_builder.query(&[("asset_class", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/apis/calendar_api.rs b/crates/alpaca_openapi/gen/broker/src/apis/calendar_api.rs new file mode 100644 index 0000000..0f1dd3d --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/apis/calendar_api.rs @@ -0,0 +1,100 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`query_market_calendar`] +#[derive(Clone, Debug)] +pub struct QueryMarketCalendarParams { + /// The first date to retrieve data for. (Inclusive) in YYYY-MM-DD format + pub start: Option, + /// The last date to retrieve data for. (Inclusive) in YYYY-MM-DD format + pub end: Option, +} + +/// struct for typed successes of method [`query_market_calendar`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum QueryMarketCalendarSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`query_market_calendar`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum QueryMarketCalendarError { + UnknownValue(serde_json::Value), +} + +/// The calendar API serves the full list of market days from 1970 to 2029. It can also be queried by specifying a start and/or end time to narrow down the results. In addition to the dates, the response also contains the specific open and close times for the market days, taking into account early closures. +pub async fn query_market_calendar( + configuration: &configuration::Configuration, + params: QueryMarketCalendarParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let start = params.start; + let end = params.end; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v1/calendar", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/apis/clock_api.rs b/crates/alpaca_openapi/gen/broker/src/apis/clock_api.rs new file mode 100644 index 0000000..c05e3b2 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/apis/clock_api.rs @@ -0,0 +1,81 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for typed successes of method [`query_market_clock`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum QueryMarketClockSuccess { + Status200(models::Clock), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`query_market_clock`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum QueryMarketClockError { + UnknownValue(serde_json::Value), +} + +/// The Clock API serves the current market timestamp, whether or not the market is currently open, as well as the times of the next market open and close. +pub async fn query_market_clock( + configuration: &configuration::Configuration, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v1/clock", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/apis/configuration.rs b/crates/alpaca_openapi/gen/broker/src/apis/configuration.rs new file mode 100644 index 0000000..7ca316b --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/apis/configuration.rs @@ -0,0 +1,49 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, + // TODO: take an oauth2 token source, similar to the go one +} + +pub type BasicAuth = (String, Option); + +#[derive(Debug, Clone)] +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + +impl Configuration { + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Default for Configuration { + fn default() -> Self { + Configuration { + base_path: "https://broker-api.sandbox.alpaca.markets".to_owned(), + user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()), + client: reqwest::Client::new(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/apis/corporate_actions_api.rs b/crates/alpaca_openapi/gen/broker/src/apis/corporate_actions_api.rs new file mode 100644 index 0000000..cf0d319 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/apis/corporate_actions_api.rs @@ -0,0 +1,125 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`get_corporate_announcements`] +#[derive(Clone, Debug)] +pub struct GetCorporateAnnouncementsParams { + /// A comma-delimited list of CorporateActionType values + pub ca_types: String, + /// The start (inclusive) of the date range when searching corporate action announcements. This should follow the YYYY-MM-DD format. The date range is limited to 90 days. + pub since: String, + /// The end (inclusive) of the date range when searching corporate action announcements. This should follow the YYYY-MM-DD format. The date range is limited to 90 days. + pub until: String, + /// The symbol of the company initiating the announcement. + pub symbol: Option, + /// The CUSIP of the company initiating the announcement. + pub cusip: Option, + /// An emum of possible ways to use the `since` and `until` parameters to search by. the types are: - **declaration_date**: The date of the preliminary announcement details or the date that any subsequent term updates took place. - **ex_date**: The date on which any security purchasing activity will not result in a corporate action entitlement. Any selling activity that takes place on or after this date will result in a corporate action entitlement. - **record_date**: The date the company checks its records to determine who is shareholder in order to allocate entitlements. - **payable_date**: The date that the stock and cash positions will update according to the account positions as of the record date. + pub date_type: Option, +} + +/// struct for typed successes of method [`get_corporate_announcements`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetCorporateAnnouncementsSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_corporate_announcements`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetCorporateAnnouncementsError { + Status400(models::Error), + UnknownValue(serde_json::Value), +} + +/// This enables searching for an array of corporate action announcements based on criteria. +pub async fn get_corporate_announcements( + configuration: &configuration::Configuration, + params: GetCorporateAnnouncementsParams, +) -> Result, Error> +{ + let local_var_configuration = configuration; + + // unbox the parameters + let ca_types = params.ca_types; + let since = params.since; + let until = params.until; + let symbol = params.symbol; + let cusip = params.cusip; + let date_type = params.date_type; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/corporate_actions/announcements", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("ca_types", &ca_types.to_string())]); + local_var_req_builder = local_var_req_builder.query(&[("since", &since.to_string())]); + local_var_req_builder = local_var_req_builder.query(&[("until", &until.to_string())]); + if let Some(ref local_var_str) = symbol { + local_var_req_builder = + local_var_req_builder.query(&[("symbol", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = cusip { + local_var_req_builder = + local_var_req_builder.query(&[("cusip", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = date_type { + local_var_req_builder = + local_var_req_builder.query(&[("date_type", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/apis/documents_api.rs b/crates/alpaca_openapi/gen/broker/src/apis/documents_api.rs new file mode 100644 index 0000000..006a3d8 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/apis/documents_api.rs @@ -0,0 +1,282 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`download_doc_from_account`] +#[derive(Clone, Debug)] +pub struct DownloadDocFromAccountParams { + /// Account identifier. + pub account_id: String, + /// Document identifier. + pub document_id: String, +} + +/// struct for passing parameters to the method [`download_document_by_id`] +#[derive(Clone, Debug)] +pub struct DownloadDocumentByIdParams { + /// Document identifier. + pub document_id: String, +} + +/// struct for passing parameters to the method [`get_docs_for_account`] +#[derive(Clone, Debug)] +pub struct GetDocsForAccountParams { + /// Account identifier. + pub account_id: String, + /// optional date value to filter the list (inclusive). + pub start_date: Option, + /// optional date value to filter the list (inclusive). + pub end_date: Option, + /// See DocumentType model for reference and explanation of values + pub r#type: Option, +} + +/// struct for typed successes of method [`download_doc_from_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DownloadDocFromAccountSuccess { + Status301(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`download_document_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DownloadDocumentByIdSuccess { + Status301(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_docs_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetDocsForAccountSuccess { + Status200(Vec>), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`download_doc_from_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DownloadDocFromAccountError { + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`download_document_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DownloadDocumentByIdError { + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_docs_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetDocsForAccountError { + Status404(String), + UnknownValue(serde_json::Value), +} + +/// This endpoint allows you to download a document identified by the document_id passed in the header. The returned document is in PDF format. The operation returns a pre-signed downloadable link as a redirect with HTTP status code 301 if one is found. +pub async fn download_doc_from_account( + configuration: &configuration::Configuration, + params: DownloadDocFromAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let document_id = params.document_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/documents/{document_id}/download", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + document_id = crate::apis::urlencode(document_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The operation returns a pre-signed downloadable link as a redirect with HTTP status code 301 if one is found. +pub async fn download_document_by_id( + configuration: &configuration::Configuration, + params: DownloadDocumentByIdParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let document_id = params.document_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/documents/{document_id}", + local_var_configuration.base_path, + document_id = crate::apis::urlencode(document_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// This endpoint allows you to query all the documents that belong to a certain account. You can filter by date, or type of document. +pub async fn get_docs_for_account( + configuration: &configuration::Configuration, + params: GetDocsForAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let start_date = params.start_date; + let end_date = params.end_date; + let r#type = params.r#type; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/documents", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = start_date { + local_var_req_builder = + local_var_req_builder.query(&[("start_date", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end_date { + local_var_req_builder = + local_var_req_builder.query(&[("end_date", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = r#type { + local_var_req_builder = + local_var_req_builder.query(&[("type", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/apis/events_api.rs b/crates/alpaca_openapi/gen/broker/src/apis/events_api.rs new file mode 100644 index 0000000..571d3e3 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/apis/events_api.rs @@ -0,0 +1,428 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`subscribe_to_journal_status_sse`] +#[derive(Clone, Debug)] +pub struct SubscribeToJournalStatusSseParams { + /// Format: YYYY-MM-DD + pub since: Option, + /// Format: YYYY-MM-DD + pub until: Option, + pub since_id: Option, + pub until_id: Option, +} + +/// struct for passing parameters to the method [`subscribe_to_trade_sse`] +#[derive(Clone, Debug)] +pub struct SubscribeToTradeSseParams { + /// Format: YYYY-MM-DD + pub since: Option, + /// Format: YYYY-MM-DD + pub until: Option, + pub since_id: Option, + pub until_id: Option, +} + +/// struct for passing parameters to the method [`subscribe_to_transfer_status_sse`] +#[derive(Clone, Debug)] +pub struct SubscribeToTransferStatusSseParams { + /// Format: YYYY-MM-DD + pub since: Option, + /// Format: YYYY-MM-DD + pub until: Option, + pub since_id: Option, + pub until_id: Option, +} + +/// struct for passing parameters to the method [`suscribe_to_account_status_sse`] +#[derive(Clone, Debug)] +pub struct SuscribeToAccountStatusSseParams { + /// Format: YYYY-MM-DD + pub since: Option, + /// Format: YYYY-MM-DD + pub until: Option, + pub since_id: Option, + pub until_id: Option, +} + +/// struct for typed successes of method [`subscribe_to_journal_status_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SubscribeToJournalStatusSseSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`subscribe_to_trade_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SubscribeToTradeSseSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`subscribe_to_transfer_status_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SubscribeToTransferStatusSseSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`suscribe_to_account_status_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SuscribeToAccountStatusSseSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`subscribe_to_journal_status_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SubscribeToJournalStatusSseError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`subscribe_to_trade_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SubscribeToTradeSseError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`subscribe_to_transfer_status_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SubscribeToTransferStatusSseError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`suscribe_to_account_status_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SuscribeToAccountStatusSseError { + UnknownValue(serde_json::Value), +} + +/// The Events API provides event push as well as historical queries via SSE (server sent events). You can listen to journal status updates as they get processed by our backoffice. Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. +pub async fn subscribe_to_journal_status_sse( + configuration: &configuration::Configuration, + params: SubscribeToJournalStatusSseParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let since = params.since; + let until = params.until; + let since_id = params.since_id; + let until_id = params.until_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/events/journals/status", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = since { + local_var_req_builder = + local_var_req_builder.query(&[("since", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until { + local_var_req_builder = + local_var_req_builder.query(&[("until", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = since_id { + local_var_req_builder = + local_var_req_builder.query(&[("since_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until_id { + local_var_req_builder = + local_var_req_builder.query(&[("until_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Events API provides event push as well as historical queries via SSE (server sent events). You can listen to events related to trade updates. Most market trades sent during market hours are filled instantly; you can listen to limit order updates through this endpoint. Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. +pub async fn subscribe_to_trade_sse( + configuration: &configuration::Configuration, + params: SubscribeToTradeSseParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let since = params.since; + let until = params.until; + let since_id = params.since_id; + let until_id = params.until_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v1/events/trades", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = since { + local_var_req_builder = + local_var_req_builder.query(&[("since", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until { + local_var_req_builder = + local_var_req_builder.query(&[("until", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = since_id { + local_var_req_builder = + local_var_req_builder.query(&[("since_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until_id { + local_var_req_builder = + local_var_req_builder.query(&[("until_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Events API provides event push as well as historical queries via SSE (server sent events). You can listen to transfer status updates as they get processed by our backoffice, for both end-user and firm accounts. Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. +pub async fn subscribe_to_transfer_status_sse( + configuration: &configuration::Configuration, + params: SubscribeToTransferStatusSseParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let since = params.since; + let until = params.until; + let since_id = params.since_id; + let until_id = params.until_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/events/transfers/status", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = since { + local_var_req_builder = + local_var_req_builder.query(&[("since", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until { + local_var_req_builder = + local_var_req_builder.query(&[("until", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = since_id { + local_var_req_builder = + local_var_req_builder.query(&[("since_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until_id { + local_var_req_builder = + local_var_req_builder.query(&[("until_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Events API provide event push as well as historical queries via SSE (server sent events). Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. +pub async fn suscribe_to_account_status_sse( + configuration: &configuration::Configuration, + params: SuscribeToAccountStatusSseParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let since = params.since; + let until = params.until; + let since_id = params.since_id; + let until_id = params.until_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/events/accounts/status", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = since { + local_var_req_builder = + local_var_req_builder.query(&[("since", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until { + local_var_req_builder = + local_var_req_builder.query(&[("until", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = since_id { + local_var_req_builder = + local_var_req_builder.query(&[("since_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until_id { + local_var_req_builder = + local_var_req_builder.query(&[("until_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/apis/funding_api.rs b/crates/alpaca_openapi/gen/broker/src/apis/funding_api.rs new file mode 100644 index 0000000..04028fb --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/apis/funding_api.rs @@ -0,0 +1,919 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`create_ach_relationship_for_account`] +#[derive(Clone, Debug)] +pub struct CreateAchRelationshipForAccountParams { + /// Account identifier. + pub account_id: String, + /// Create ACH Relationship + pub create_ach_relationship_request: models::CreateAchRelationshipRequest, +} + +/// struct for passing parameters to the method [`create_recipient_bank`] +#[derive(Clone, Debug)] +pub struct CreateRecipientBankParams { + /// Account identifier. + pub account_id: String, + pub create_bank_request: models::CreateBankRequest, +} + +/// struct for passing parameters to the method [`create_transfer_for_account`] +#[derive(Clone, Debug)] +pub struct CreateTransferForAccountParams { + /// Account identifier. + pub account_id: String, + pub create_transfer_request: models::CreateTransferRequest, +} + +/// struct for passing parameters to the method [`delete_ach_relationship_from_account`] +#[derive(Clone, Debug)] +pub struct DeleteAchRelationshipFromAccountParams { + /// Account identifier. + pub account_id: String, + /// ACH relationship identifier + pub ach_relationship_id: String, +} + +/// struct for passing parameters to the method [`delete_recipient_bank`] +#[derive(Clone, Debug)] +pub struct DeleteRecipientBankParams { + /// Account identifier. + pub account_id: String, + pub bank_id: String, +} + +/// struct for passing parameters to the method [`delete_transfer`] +#[derive(Clone, Debug)] +pub struct DeleteTransferParams { + /// Account identifier. + pub account_id: String, + /// Tranfer identifier + pub transfer_id: String, +} + +/// struct for passing parameters to the method [`get_account_ach_relationships`] +#[derive(Clone, Debug)] +pub struct GetAccountAchRelationshipsParams { + /// Account identifier. + pub account_id: String, + /// Comma-separated status values + pub statuses: Option, +} + +/// struct for passing parameters to the method [`get_recipient_banks`] +#[derive(Clone, Debug)] +pub struct GetRecipientBanksParams { + /// Account identifier. + pub account_id: String, + pub status: Option, + pub bank_name: Option, +} + +/// struct for passing parameters to the method [`get_transfers_for_account`] +#[derive(Clone, Debug)] +pub struct GetTransfersForAccountParams { + /// Account identifier. + pub account_id: String, + /// INCOMING or OUTGOING + pub direction: Option, + pub limit: Option, + pub offset: Option, +} + +/// struct for passing parameters to the method [`subscribe_to_transfer_status_sse`] +#[derive(Clone, Debug)] +pub struct SubscribeToTransferStatusSseParams { + /// Format: YYYY-MM-DD + pub since: Option, + /// Format: YYYY-MM-DD + pub until: Option, + pub since_id: Option, + pub until_id: Option, +} + +/// struct for typed successes of method [`create_ach_relationship_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateAchRelationshipForAccountSuccess { + Status200(models::AchRelationship), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`create_recipient_bank`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateRecipientBankSuccess { + Status200(models::Bank), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`create_transfer_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateTransferForAccountSuccess { + Status200(models::Transfer), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_ach_relationship_from_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAchRelationshipFromAccountSuccess { + Status204(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_recipient_bank`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteRecipientBankSuccess { + Status204(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_transfer`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteTransferSuccess { + Status204(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_account_ach_relationships`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountAchRelationshipsSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_recipient_banks`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetRecipientBanksSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_transfers_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTransfersForAccountSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`subscribe_to_transfer_status_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SubscribeToTransferStatusSseSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_ach_relationship_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateAchRelationshipForAccountError { + Status400(models::Error), + Status401(models::Error), + Status409(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_recipient_bank`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateRecipientBankError { + Status400(), + Status409(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_transfer_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateTransferForAccountError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_ach_relationship_from_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAchRelationshipFromAccountError { + Status400(), + Status404(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_recipient_bank`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteRecipientBankError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_transfer`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteTransferError { + Status404(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_account_ach_relationships`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountAchRelationshipsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_recipient_banks`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetRecipientBanksError { + Status400(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_transfers_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTransfersForAccountError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`subscribe_to_transfer_status_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SubscribeToTransferStatusSseError { + UnknownValue(serde_json::Value), +} + +/// Create a new ACHRelationship for an account If successful, will return 200 code with a newly created ACH Relationship entity. +pub async fn create_ach_relationship_for_account( + configuration: &configuration::Configuration, + params: CreateAchRelationshipForAccountParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let create_ach_relationship_request = params.create_ach_relationship_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/ach_relationships", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&create_ach_relationship_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// If successful, retrieves Bank Relationships for an account +pub async fn create_recipient_bank( + configuration: &configuration::Configuration, + params: CreateRecipientBankParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let create_bank_request = params.create_bank_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/recipient_banks", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&create_bank_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Create a new transfer to an account to fund it. In the sandbox environment, you can instantly deposit to or withdraw from an account with a virtual money amount. In the production environment, this endpoint is used only for requesting an outgoing (withdrawal) wire transfer at this moment. For the wire transfer (in production), you need to create a bank resource first using the Bank API. For more on how to fund an account in sandbox please check out this tutorial [here](https://alpaca.markets/learn/fund-broker-api/). +pub async fn create_transfer_for_account( + configuration: &configuration::Configuration, + params: CreateTransferForAccountParams, +) -> Result, Error> +{ + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let create_transfer_request = params.create_transfer_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/transfers", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&create_transfer_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Delete an existing ACH relationship for an account +pub async fn delete_ach_relationship_from_account( + configuration: &configuration::Configuration, + params: DeleteAchRelationshipFromAccountParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let ach_relationship_id = params.ach_relationship_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/ach_relationships/{ach_relationship_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + ach_relationship_id = crate::apis::urlencode(ach_relationship_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// If successful, deletes Bank Relationship for an account +pub async fn delete_recipient_bank( + configuration: &configuration::Configuration, + params: DeleteRecipientBankParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let bank_id = params.bank_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/recipient_banks/{bank_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + bank_id = crate::apis::urlencode(bank_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Request to close a transfer +pub async fn delete_transfer( + configuration: &configuration::Configuration, + params: DeleteTransferParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let transfer_id = params.transfer_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/transfers/{transfer_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + transfer_id = crate::apis::urlencode(transfer_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns a list of ACH Relationships for an account +pub async fn get_account_ach_relationships( + configuration: &configuration::Configuration, + params: GetAccountAchRelationshipsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let statuses = params.statuses; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/ach_relationships", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = statuses { + local_var_req_builder = + local_var_req_builder.query(&[("statuses", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Retrieves Bank Relationships for an account +pub async fn get_recipient_banks( + configuration: &configuration::Configuration, + params: GetRecipientBanksParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let status = params.status; + let bank_name = params.bank_name; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/recipient_banks", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = status { + local_var_req_builder = + local_var_req_builder.query(&[("status", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = bank_name { + local_var_req_builder = + local_var_req_builder.query(&[("bank_name", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// You can query a list of transfers for an account. You can filter requested transfers by values such as direction and status. +pub async fn get_transfers_for_account( + configuration: &configuration::Configuration, + params: GetTransfersForAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let direction = params.direction; + let limit = params.limit; + let offset = params.offset; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/transfers", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = direction { + local_var_req_builder = + local_var_req_builder.query(&[("direction", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = offset { + local_var_req_builder = + local_var_req_builder.query(&[("offset", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Events API provides event push as well as historical queries via SSE (server sent events). You can listen to transfer status updates as they get processed by our backoffice, for both end-user and firm accounts. Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. +pub async fn subscribe_to_transfer_status_sse( + configuration: &configuration::Configuration, + params: SubscribeToTransferStatusSseParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let since = params.since; + let until = params.until; + let since_id = params.since_id; + let until_id = params.until_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/events/transfers/status", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = since { + local_var_req_builder = + local_var_req_builder.query(&[("since", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until { + local_var_req_builder = + local_var_req_builder.query(&[("until", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = since_id { + local_var_req_builder = + local_var_req_builder.query(&[("since_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until_id { + local_var_req_builder = + local_var_req_builder.query(&[("until_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/apis/journals_api.rs b/crates/alpaca_openapi/gen/broker/src/apis/journals_api.rs new file mode 100644 index 0000000..113ef71 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/apis/journals_api.rs @@ -0,0 +1,471 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`create_batch_journal`] +#[derive(Clone, Debug)] +pub struct CreateBatchJournalParams { + /// + pub batch_journal_request: models::BatchJournalRequest, +} + +/// struct for passing parameters to the method [`create_journal`] +#[derive(Clone, Debug)] +pub struct CreateJournalParams { + pub create_journal_request: models::CreateJournalRequest, +} + +/// struct for passing parameters to the method [`delete_journal_by_id`] +#[derive(Clone, Debug)] +pub struct DeleteJournalByIdParams { + pub journal_id: String, +} + +/// struct for passing parameters to the method [`get_all_journals`] +#[derive(Clone, Debug)] +pub struct GetAllJournalsParams { + /// By journal creation date. Format: 2020-01-01 + pub after: Option, + /// By journal creation date. Format: 2020-01-01 + pub before: Option, + /// See the JournalStatus model for more info + pub status: Option, + /// JNLC or JNLS + pub entry_type: Option, + /// The account id that received the journal + pub to_account: Option, + /// The account id that initiated the journal + pub from_account: Option, +} + +/// struct for passing parameters to the method [`subscribe_to_journal_status_sse`] +#[derive(Clone, Debug)] +pub struct SubscribeToJournalStatusSseParams { + /// Format: YYYY-MM-DD + pub since: Option, + /// Format: YYYY-MM-DD + pub until: Option, + pub since_id: Option, + pub until_id: Option, +} + +/// struct for typed successes of method [`create_batch_journal`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateBatchJournalSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`create_journal`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateJournalSuccess { + Status200(models::Journal), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_journal_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteJournalByIdSuccess { + Status204(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_all_journals`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAllJournalsSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`subscribe_to_journal_status_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SubscribeToJournalStatusSseSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_batch_journal`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateBatchJournalError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_journal`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateJournalError { + Status400(String), + Status403(String), + Status404(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_journal_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteJournalByIdError { + Status404(), + Status422(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_all_journals`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAllJournalsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`subscribe_to_journal_status_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SubscribeToJournalStatusSseError { + UnknownValue(serde_json::Value), +} + +/// You can create a batch of journal requests by using this endpoint. This is enabled on JNLC type Journals for now only. Every single request must be valid for the entire batch operation to succeed. In the case of a successful request, the response will contain an array of journal objects with an extra attribute error_message in the case when a specific account fails to receive a journal. +pub async fn create_batch_journal( + configuration: &configuration::Configuration, + params: CreateBatchJournalParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let batch_journal_request = params.batch_journal_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v1/journals/batch", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&batch_journal_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// A journal can be JNLC (move cash) or JNLS (move shares), dictated by `entry_type`. Generally, journal requests are subject to approval and starts from the `pending` status. The status changes are propagated through the Event API. Under certain conditions agreed for the partner, such journal transactions that meet the criteria are executed right away. +pub async fn create_journal( + configuration: &configuration::Configuration, + params: CreateJournalParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let create_journal_request = params.create_journal_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v1/journals", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&create_journal_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// You can only delete a journal if the journal is still in a pending state, if a journal is executed you will not be able to delete. The alternative is to create a mirror journal entry to reverse the flow of funds. +pub async fn delete_journal_by_id( + configuration: &configuration::Configuration, + params: DeleteJournalByIdParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let journal_id = params.journal_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/journals/{journal_id}", + local_var_configuration.base_path, + journal_id = crate::apis::urlencode(journal_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns an array of journal objects. +pub async fn get_all_journals( + configuration: &configuration::Configuration, + params: GetAllJournalsParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let after = params.after; + let before = params.before; + let status = params.status; + let entry_type = params.entry_type; + let to_account = params.to_account; + let from_account = params.from_account; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v1/journals", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = after { + local_var_req_builder = + local_var_req_builder.query(&[("after", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = before { + local_var_req_builder = + local_var_req_builder.query(&[("before", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = status { + local_var_req_builder = + local_var_req_builder.query(&[("status", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = entry_type { + local_var_req_builder = + local_var_req_builder.query(&[("entry_type", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = to_account { + local_var_req_builder = + local_var_req_builder.query(&[("to_account", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = from_account { + local_var_req_builder = + local_var_req_builder.query(&[("from_account", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Events API provides event push as well as historical queries via SSE (server sent events). You can listen to journal status updates as they get processed by our backoffice. Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. +pub async fn subscribe_to_journal_status_sse( + configuration: &configuration::Configuration, + params: SubscribeToJournalStatusSseParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let since = params.since; + let until = params.until; + let since_id = params.since_id; + let until_id = params.until_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/events/journals/status", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = since { + local_var_req_builder = + local_var_req_builder.query(&[("since", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until { + local_var_req_builder = + local_var_req_builder.query(&[("until", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = since_id { + local_var_req_builder = + local_var_req_builder.query(&[("since_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until_id { + local_var_req_builder = + local_var_req_builder.query(&[("until_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/apis/mod.rs b/crates/alpaca_openapi/gen/broker/src/apis/mod.rs new file mode 100644 index 0000000..d8ceb72 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/apis/mod.rs @@ -0,0 +1,108 @@ +use std::error; +use std::fmt; + +#[derive(Debug, Clone)] +pub struct ResponseContent { + pub status: reqwest::StatusCode, + pub content: String, + pub entity: Option, +} + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), + ResponseError(ResponseContent), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (module, e) = match self { + Error::Reqwest(e) => ("reqwest", e.to_string()), + Error::Serde(e) => ("serde", e.to_string()), + Error::Io(e) => ("IO", e.to_string()), + Error::ResponseError(e) => ("response", format!("status code {}", e.status)), + }; + write!(f, "error in {}: {}", module, e) + } +} + +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + Some(match self { + Error::Reqwest(e) => e, + Error::Serde(e) => e, + Error::Io(e) => e, + Error::ResponseError(_) => return None, + }) + } +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> { + if let serde_json::Value::Object(object) = value { + let mut params = vec![]; + + for (key, value) in object { + match value { + serde_json::Value::Object(_) => params.append(&mut parse_deep_object( + &format!("{}[{}]", prefix, key), + value, + )), + serde_json::Value::Array(array) => { + for (i, value) in array.iter().enumerate() { + params.append(&mut parse_deep_object( + &format!("{}[{}][{}]", prefix, key, i), + value, + )); + } + } + serde_json::Value::String(s) => { + params.push((format!("{}[{}]", prefix, key), s.clone())) + } + _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), + } + } + + return params; + } + + unimplemented!("Only objects are supported with style=deepObject") +} + +pub mod accounts_api; +pub mod assets_api; +pub mod calendar_api; +pub mod clock_api; +pub mod corporate_actions_api; +pub mod documents_api; +pub mod events_api; +pub mod funding_api; +pub mod journals_api; +pub mod o_auth_api; +pub mod trading_api; +pub mod watchlist_api; + +pub mod configuration; diff --git a/crates/alpaca_openapi/gen/broker/src/apis/o_auth_api.rs b/crates/alpaca_openapi/gen/broker/src/apis/o_auth_api.rs new file mode 100644 index 0000000..bf98218 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/apis/o_auth_api.rs @@ -0,0 +1,271 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`authorize_o_auth_token`] +#[derive(Clone, Debug)] +pub struct AuthorizeOAuthTokenParams { + pub o_auth_token_request: models::OAuthTokenRequest, +} + +/// struct for passing parameters to the method [`get_o_auth_client`] +#[derive(Clone, Debug)] +pub struct GetOAuthClientParams { + pub client_id: String, + /// code or token + pub response_type: Option, + /// Redirect URI of the OAuth flow + pub redirect_uri: Option, + /// Requested scopes by the OAuth flow + pub scope: Option, +} + +/// struct for passing parameters to the method [`issue_o_auth_token`] +#[derive(Clone, Debug)] +pub struct IssueOAuthTokenParams { + pub o_auth_token_request: models::OAuthTokenRequest, +} + +/// struct for typed successes of method [`authorize_o_auth_token`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AuthorizeOAuthTokenSuccess { + Status200(models::AuthorizeOAuthTokenResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_o_auth_client`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOAuthClientSuccess { + Status200(models::OathClientResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`issue_o_auth_token`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum IssueOAuthTokenSuccess { + Status200(models::IssueOAuthTokenResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`authorize_o_auth_token`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AuthorizeOAuthTokenError { + Status401(String), + Status422(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_o_auth_client`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOAuthClientError { + Status401(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`issue_o_auth_token`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum IssueOAuthTokenError { + Status401(String), + Status422(String), + UnknownValue(serde_json::Value), +} + +/// The operation issues an OAuth code which can be used in the OAuth code flow. +pub async fn authorize_o_auth_token( + configuration: &configuration::Configuration, + params: AuthorizeOAuthTokenParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let o_auth_token_request = params.o_auth_token_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v1/oauth/authorize", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&o_auth_token_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The endpoint returns the details of OAuth client to display in the authorization page. +pub async fn get_o_auth_client( + configuration: &configuration::Configuration, + params: GetOAuthClientParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let client_id = params.client_id; + let response_type = params.response_type; + let redirect_uri = params.redirect_uri; + let scope = params.scope; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/oauth/clients/{client_id}", + local_var_configuration.base_path, + client_id = crate::apis::urlencode(client_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = response_type { + local_var_req_builder = + local_var_req_builder.query(&[("response_type", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = redirect_uri { + local_var_req_builder = + local_var_req_builder.query(&[("redirect_uri", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = scope { + local_var_req_builder = + local_var_req_builder.query(&[("scope", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The operation issues an OAuth code which can be used in the OAuth code flow. +pub async fn issue_o_auth_token( + configuration: &configuration::Configuration, + params: IssueOAuthTokenParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let o_auth_token_request = params.o_auth_token_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v1/oauth/token", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&o_auth_token_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/apis/trading_api.rs b/crates/alpaca_openapi/gen/broker/src/apis/trading_api.rs new file mode 100644 index 0000000..1f51b10 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/apis/trading_api.rs @@ -0,0 +1,1034 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`close_all_positions_for_account`] +#[derive(Clone, Debug)] +pub struct CloseAllPositionsForAccountParams { + /// Account identifier. + pub account_id: String, + /// If true is specified, cancel all open orders before liquidating all positions. + pub cancel_orders: Option, +} + +/// struct for passing parameters to the method [`close_position_for_account_by_symbol`] +#[derive(Clone, Debug)] +pub struct ClosePositionForAccountBySymbolParams { + /// Account identifier. + pub account_id: String, + /// The symbol or asset_id + pub symbol_or_asset_id: String, + /// Optional the number of shares to liquidate. Can accept up to 9 decimal points. Cannot work with percentage + pub qty: Option, + /// percentage of position to liquidate. Must be between 0 and 100. Would only sell fractional if position is originally fractional. Can accept up to 9 decimal points. Cannot work with qty + pub percentage: Option, +} + +/// struct for passing parameters to the method [`create_order_for_account`] +#[derive(Clone, Debug)] +pub struct CreateOrderForAccountParams { + /// Account identifier. + pub account_id: String, + pub create_order_request: models::CreateOrderRequest, +} + +/// struct for passing parameters to the method [`delete_all_orders_for_account`] +#[derive(Clone, Debug)] +pub struct DeleteAllOrdersForAccountParams { + /// Account identifier. + pub account_id: String, +} + +/// struct for passing parameters to the method [`delete_order_for_account`] +#[derive(Clone, Debug)] +pub struct DeleteOrderForAccountParams { + /// Account identifier. + pub account_id: String, + /// Order identifier. + pub order_id: String, +} + +/// struct for passing parameters to the method [`get_all_orders_for_account`] +#[derive(Clone, Debug)] +pub struct GetAllOrdersForAccountParams { + /// Account identifier. + pub account_id: String, + /// Order status to be queried. open, closed or all. Defaults to open. + pub status: Option, + /// The maximum number of orders in response. Defaults to 50 and max is 500. + pub limit: Option, + /// The response will include only ones submitted after this timestamp (exclusive.) + pub after: Option, + /// The response will include only ones submitted until this timestamp (exclusive.) + pub until: Option, + /// The chronological order of response based on the submission time. asc or desc. Defaults to desc. + pub direction: Option, + /// If true, the result will roll up multi-leg orders under the legs field of primary order. + pub nested: Option, + /// A comma-separated list of symbols to filter by. + pub symbols: Option, +} + +/// struct for passing parameters to the method [`get_order_for_account`] +#[derive(Clone, Debug)] +pub struct GetOrderForAccountParams { + /// Account identifier. + pub account_id: String, + /// Order identifier. + pub order_id: String, +} + +/// struct for passing parameters to the method [`get_positions_for_account`] +#[derive(Clone, Debug)] +pub struct GetPositionsForAccountParams { + /// Account identifier. + pub account_id: String, +} + +/// struct for passing parameters to the method [`get_positions_for_account_by_symbol`] +#[derive(Clone, Debug)] +pub struct GetPositionsForAccountBySymbolParams { + /// Account identifier. + pub account_id: String, + /// The symbol or asset_id + pub symbol_or_asset_id: String, +} + +/// struct for passing parameters to the method [`replace_order_for_account`] +#[derive(Clone, Debug)] +pub struct ReplaceOrderForAccountParams { + /// Account identifier. + pub account_id: String, + /// Order identifier. + pub order_id: String, + pub update_order_request: models::UpdateOrderRequest, +} + +/// struct for passing parameters to the method [`subscribe_to_trade_sse`] +#[derive(Clone, Debug)] +pub struct SubscribeToTradeSseParams { + /// Format: YYYY-MM-DD + pub since: Option, + /// Format: YYYY-MM-DD + pub until: Option, + pub since_id: Option, + pub until_id: Option, +} + +/// struct for typed successes of method [`close_all_positions_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CloseAllPositionsForAccountSuccess { + Status207(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`close_position_for_account_by_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ClosePositionForAccountBySymbolSuccess { + Status200(models::Order), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`create_order_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateOrderForAccountSuccess { + Status200(models::Order), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_all_orders_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAllOrdersForAccountSuccess { + Status207(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_order_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteOrderForAccountSuccess { + Status204(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_all_orders_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAllOrdersForAccountSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_order_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOrderForAccountSuccess { + Status200(models::Order), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_positions_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetPositionsForAccountSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_positions_for_account_by_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetPositionsForAccountBySymbolSuccess { + Status200(models::Position), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`replace_order_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ReplaceOrderForAccountSuccess { + Status200(models::Order), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`subscribe_to_trade_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SubscribeToTradeSseSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`close_all_positions_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CloseAllPositionsForAccountError { + Status500(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`close_position_for_account_by_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ClosePositionForAccountBySymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_order_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateOrderForAccountError { + Status400(models::Error), + Status403(String), + Status404(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_all_orders_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAllOrdersForAccountError { + Status400(models::Error), + Status404(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_order_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteOrderForAccountError { + Status400(models::Error), + Status404(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_all_orders_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAllOrdersForAccountError { + Status400(models::Error), + Status404(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_order_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOrderForAccountError { + Status400(models::Error), + Status404(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_positions_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetPositionsForAccountError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_positions_for_account_by_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetPositionsForAccountBySymbolError { + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`replace_order_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ReplaceOrderForAccountError { + Status400(models::Error), + Status403(), + Status404(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`subscribe_to_trade_sse`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SubscribeToTradeSseError { + UnknownValue(serde_json::Value), +} + +/// Closes (liquidates) all of the account’s open long and short positions. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request. +pub async fn close_all_positions_for_account( + configuration: &configuration::Configuration, + params: CloseAllPositionsForAccountParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let cancel_orders = params.cancel_orders; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/trading/accounts/{account_id}/positions", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = cancel_orders { + local_var_req_builder = + local_var_req_builder.query(&[("cancel_orders", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Closes (liquidates) the account’s open position for the given symbol. Works for both long and short positions. +pub async fn close_position_for_account_by_symbol( + configuration: &configuration::Configuration, + params: ClosePositionForAccountBySymbolParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let symbol_or_asset_id = params.symbol_or_asset_id; + let qty = params.qty; + let percentage = params.percentage; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/trading/accounts/{account_id}/positions/{symbol_or_asset_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + symbol_or_asset_id = crate::apis::urlencode(symbol_or_asset_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = qty { + local_var_req_builder = local_var_req_builder.query(&[("qty", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = percentage { + local_var_req_builder = + local_var_req_builder.query(&[("percentage", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Create an order for an account. +pub async fn create_order_for_account( + configuration: &configuration::Configuration, + params: CreateOrderForAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let create_order_request = params.create_order_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/trading/accounts/{account_id}/orders", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&create_order_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. +pub async fn delete_all_orders_for_account( + configuration: &configuration::Configuration, + params: DeleteAllOrdersForAccountParams, +) -> Result, Error> +{ + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/trading/accounts/{account_id}/orders", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Attempts to cancel an open order. If the order is no longer cancelable (for example if the status is \"filled\"), the server will respond with status 422, and reject the request. Upon acceptance of the cancel request, it returns status 204. +pub async fn delete_order_for_account( + configuration: &configuration::Configuration, + params: DeleteOrderForAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let order_id = params.order_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/trading/accounts/{account_id}/orders/{order_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + order_id = crate::apis::urlencode(order_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Retrieves a list of orders for the account, filtered by the supplied query parameters. Endpoint defaults to open orders if no parameters are provided. +pub async fn get_all_orders_for_account( + configuration: &configuration::Configuration, + params: GetAllOrdersForAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let status = params.status; + let limit = params.limit; + let after = params.after; + let until = params.until; + let direction = params.direction; + let nested = params.nested; + let symbols = params.symbols; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/trading/accounts/{account_id}/orders", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = status { + local_var_req_builder = + local_var_req_builder.query(&[("status", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = after { + local_var_req_builder = + local_var_req_builder.query(&[("after", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until { + local_var_req_builder = + local_var_req_builder.query(&[("until", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = direction { + local_var_req_builder = + local_var_req_builder.query(&[("direction", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = nested { + local_var_req_builder = + local_var_req_builder.query(&[("nested", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = symbols { + local_var_req_builder = + local_var_req_builder.query(&[("symbols", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Retrieves a single order for the given order_id. +pub async fn get_order_for_account( + configuration: &configuration::Configuration, + params: GetOrderForAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let order_id = params.order_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/trading/accounts/{account_id}/orders/{order_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + order_id = crate::apis::urlencode(order_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// List open positions for an account +pub async fn get_positions_for_account( + configuration: &configuration::Configuration, + params: GetPositionsForAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/trading/accounts/{account_id}/positions", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Retrieves the account’s open position for the given symbol or asset_id. +pub async fn get_positions_for_account_by_symbol( + configuration: &configuration::Configuration, + params: GetPositionsForAccountBySymbolParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let symbol_or_asset_id = params.symbol_or_asset_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/trading/accounts/{account_id}/positions/{symbol_or_asset_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + symbol_or_asset_id = crate::apis::urlencode(symbol_or_asset_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Replaces a single order with updated parameters. Each parameter overrides the corresponding attribute of the existing order. The other attributes remain the same as the existing order. A success return code from a replaced order does NOT guarantee the existing open order has been replaced. If the existing open order is filled before the replacing (new) order reaches the execution venue, the replacing (new) order is rejected, and these events are sent in the trade_updates stream channel found [here in the market data api](https://alpaca.markets/docs/api-references/market-data-api/#order-updates). While an order is being replaced, the account's buying power is reduced by the larger of the two orders that have been placed (the old order being replaced, and the newly placed order to replace it). If you are replacing a buy entry order with a higher limit price than the original order, the buying power is calculated based on the newly placed order. If you are replacing it with a lower limit price, the buying power is calculated based on the old order. +pub async fn replace_order_for_account( + configuration: &configuration::Configuration, + params: ReplaceOrderForAccountParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let order_id = params.order_id; + let update_order_request = params.update_order_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/trading/accounts/{account_id}/orders/{order_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + order_id = crate::apis::urlencode(order_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&update_order_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Events API provides event push as well as historical queries via SSE (server sent events). You can listen to events related to trade updates. Most market trades sent during market hours are filled instantly; you can listen to limit order updates through this endpoint. Historical events are streamed immediately if queried, and updates are pushed as events occur. Query Params Rules: - `since` required if `until` specified - `since_id` required if `until_id` specified - `since` and `since_id` can’t be used at the same time Behavior: - if `since` or `since_id` not specified this will not return any historic data - if `until` or `until_id` reached stream will end (status 200) --- Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. +pub async fn subscribe_to_trade_sse( + configuration: &configuration::Configuration, + params: SubscribeToTradeSseParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let since = params.since; + let until = params.until; + let since_id = params.since_id; + let until_id = params.until_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v1/events/trades", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = since { + local_var_req_builder = + local_var_req_builder.query(&[("since", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until { + local_var_req_builder = + local_var_req_builder.query(&[("until", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = since_id { + local_var_req_builder = + local_var_req_builder.query(&[("since_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until_id { + local_var_req_builder = + local_var_req_builder.query(&[("until_id", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/apis/watchlist_api.rs b/crates/alpaca_openapi/gen/broker/src/apis/watchlist_api.rs new file mode 100644 index 0000000..f44a23e --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/apis/watchlist_api.rs @@ -0,0 +1,445 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`create_watchlist_for_account`] +#[derive(Clone, Debug)] +pub struct CreateWatchlistForAccountParams { + /// Unique identifier of an account. + pub account_id: String, + pub create_watchlist_request: Option, +} + +/// struct for passing parameters to the method [`delete_watchlist_from_account_by_id`] +#[derive(Clone, Debug)] +pub struct DeleteWatchlistFromAccountByIdParams { + /// Unique identifier of an account + pub account_id: String, + /// Unique identifier of a watchlist + pub watchlist_id: String, +} + +/// struct for passing parameters to the method [`get_all_watchlists_for_account`] +#[derive(Clone, Debug)] +pub struct GetAllWatchlistsForAccountParams { + /// Unique identifier of an account. + pub account_id: String, +} + +/// struct for passing parameters to the method [`get_watchlist_for_account_by_id`] +#[derive(Clone, Debug)] +pub struct GetWatchlistForAccountByIdParams { + /// Unique identifier of an account + pub account_id: String, + /// Unique identifier of a watchlist + pub watchlist_id: String, +} + +/// struct for passing parameters to the method [`replace_watchlist_for_account_by_id`] +#[derive(Clone, Debug)] +pub struct ReplaceWatchlistForAccountByIdParams { + /// Unique identifier of an account + pub account_id: String, + /// Unique identifier of a watchlist + pub watchlist_id: String, + pub create_watchlist_request: Option, +} + +/// struct for typed successes of method [`create_watchlist_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateWatchlistForAccountSuccess { + Status200(models::Watchlist), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_watchlist_from_account_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteWatchlistFromAccountByIdSuccess { + Status200(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_all_watchlists_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAllWatchlistsForAccountSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_watchlist_for_account_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetWatchlistForAccountByIdSuccess { + Status200(models::Watchlist), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`replace_watchlist_for_account_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ReplaceWatchlistForAccountByIdSuccess { + Status200(models::Watchlist), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_watchlist_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateWatchlistForAccountError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_watchlist_from_account_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteWatchlistFromAccountByIdError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_all_watchlists_for_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAllWatchlistsForAccountError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_watchlist_for_account_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetWatchlistForAccountByIdError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`replace_watchlist_for_account_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ReplaceWatchlistForAccountByIdError { + UnknownValue(serde_json::Value), +} + +/// Returns the watchlist object +pub async fn create_watchlist_for_account( + configuration: &configuration::Configuration, + params: CreateWatchlistForAccountParams, +) -> Result, Error> +{ + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let create_watchlist_request = params.create_watchlist_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/trading/accounts/{account_id}/watchlists", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&create_watchlist_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Irrevocably delete a watchlist. +pub async fn delete_watchlist_from_account_by_id( + configuration: &configuration::Configuration, + params: DeleteWatchlistFromAccountByIdParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let watchlist_id = params.watchlist_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/watchlists/{watchlist_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + watchlist_id = crate::apis::urlencode(watchlist_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Fetch a list of all watchlists currently in an account. +pub async fn get_all_watchlists_for_account( + configuration: &configuration::Configuration, + params: GetAllWatchlistsForAccountParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/trading/accounts/{account_id}/watchlists", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Fetch a single watchlist by identifier. +pub async fn get_watchlist_for_account_by_id( + configuration: &configuration::Configuration, + params: GetWatchlistForAccountByIdParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let watchlist_id = params.watchlist_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/watchlists/{watchlist_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + watchlist_id = crate::apis::urlencode(watchlist_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Replace entirely the set of securities contained in the watchlist while optionally renaming it. Destructive operation. +pub async fn replace_watchlist_for_account_by_id( + configuration: &configuration::Configuration, + params: ReplaceWatchlistForAccountByIdParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_id = params.account_id; + let watchlist_id = params.watchlist_id; + let create_watchlist_request = params.create_watchlist_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1/accounts/{account_id}/watchlists/{watchlist_id}", + local_var_configuration.base_path, + account_id = crate::apis::urlencode(account_id), + watchlist_id = crate::apis::urlencode(watchlist_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth( + local_var_auth_conf.0.to_owned(), + local_var_auth_conf.1.to_owned(), + ); + }; + local_var_req_builder = local_var_req_builder.json(&create_watchlist_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/lib.rs b/crates/alpaca_openapi/gen/broker/src/lib.rs new file mode 100644 index 0000000..92760eb --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/lib.rs @@ -0,0 +1,12 @@ +#![allow(unused_imports)] + +#[macro_use] +extern crate serde_derive; + +extern crate reqwest; +extern crate serde; +extern crate serde_json; +extern crate url; + +pub mod apis; +pub mod models; diff --git a/crates/alpaca_openapi/gen/broker/src/models/account.rs b/crates/alpaca_openapi/gen/broker/src/models/account.rs new file mode 100644 index 0000000..3ad9671 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/account.rs @@ -0,0 +1,59 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Account : Represents high level account info. Used when returning entire account information would not be useful like the getAllAccounts operation +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Account { + #[serde(rename = "id")] + pub id: uuid::Uuid, + #[serde(rename = "account_number", deserialize_with = "Option::deserialize")] + pub account_number: Option, + #[serde(rename = "status")] + pub status: models::AccountStatus, + #[serde(rename = "crypto_status", skip_serializing_if = "Option::is_none")] + pub crypto_status: Option, + /// Always \"USD\" + #[serde(rename = "currency")] + pub currency: String, + #[serde(rename = "created_at")] + pub created_at: String, + #[serde(rename = "last_equity")] + pub last_equity: String, + #[serde(rename = "kyc_results", skip_serializing_if = "Option::is_none")] + pub kyc_results: Option>, + #[serde(rename = "account_type", skip_serializing_if = "Option::is_none")] + pub account_type: Option, +} + +impl Account { + /// Represents high level account info. Used when returning entire account information would not be useful like the getAllAccounts operation + pub fn new( + id: uuid::Uuid, + account_number: Option, + status: models::AccountStatus, + currency: String, + created_at: String, + last_equity: String, + ) -> Account { + Account { + id, + account_number, + status, + crypto_status: None, + currency, + created_at, + last_equity, + kyc_results: None, + account_type: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/account_configurations.rs b/crates/alpaca_openapi/gen/broker/src/models/account_configurations.rs new file mode 100644 index 0000000..b9f67b3 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/account_configurations.rs @@ -0,0 +1,89 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AccountConfigurations : Represents additional configuration settings for an account +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AccountConfigurations { + /// both, entry, or exit. Controls Day Trading Margin Call (DTMC) checks. + #[serde(rename = "dtbp_check")] + pub dtbp_check: DtbpCheck, + /// all or none. If none, emails for order fills are not sent. + #[serde(rename = "trade_confirm_email")] + pub trade_confirm_email: TradeConfirmEmail, + /// If true, new orders are blocked. + #[serde(rename = "suspend_trade")] + pub suspend_trade: bool, + /// If true, account becomes long-only mode. + #[serde(rename = "no_shorting")] + pub no_shorting: bool, + /// If true, account is able to participate in fractional trading + #[serde(rename = "fractional_trading")] + pub fractional_trading: bool, + /// Can be \"1\" or \"2\" + #[serde(rename = "max_margin_multiplier")] + pub max_margin_multiplier: String, + #[serde(rename = "pdt_check")] + pub pdt_check: String, +} + +impl AccountConfigurations { + /// Represents additional configuration settings for an account + pub fn new( + dtbp_check: DtbpCheck, + trade_confirm_email: TradeConfirmEmail, + suspend_trade: bool, + no_shorting: bool, + fractional_trading: bool, + max_margin_multiplier: String, + pdt_check: String, + ) -> AccountConfigurations { + AccountConfigurations { + dtbp_check, + trade_confirm_email, + suspend_trade, + no_shorting, + fractional_trading, + max_margin_multiplier, + pdt_check, + } + } +} +/// both, entry, or exit. Controls Day Trading Margin Call (DTMC) checks. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum DtbpCheck { + #[serde(rename = "both")] + Both, + #[serde(rename = "entry")] + Entry, + #[serde(rename = "exit")] + Exit, +} + +impl Default for DtbpCheck { + fn default() -> DtbpCheck { + Self::Both + } +} +/// all or none. If none, emails for order fills are not sent. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TradeConfirmEmail { + #[serde(rename = "all")] + All, + #[serde(rename = "none")] + None, +} + +impl Default for TradeConfirmEmail { + fn default() -> TradeConfirmEmail { + Self::All + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/account_creation_request.rs b/crates/alpaca_openapi/gen/broker/src/models/account_creation_request.rs new file mode 100644 index 0000000..f5b0664 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/account_creation_request.rs @@ -0,0 +1,48 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AccountCreationRequest : Represents the fields required to create a new account +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AccountCreationRequest { + #[serde(rename = "contact")] + pub contact: Box, + #[serde(rename = "identity")] + pub identity: Box, + #[serde(rename = "disclosures")] + pub disclosures: Box, + /// The client has to present the Alpaca Account and Margin Agreements to the end user, and have them read full sentences. + #[serde(rename = "agreements")] + pub agreements: Vec, + #[serde(rename = "documents", skip_serializing_if = "Option::is_none")] + pub documents: Option>, + #[serde(rename = "trusted_contact", skip_serializing_if = "Option::is_none")] + pub trusted_contact: Option>, +} + +impl AccountCreationRequest { + /// Represents the fields required to create a new account + pub fn new( + contact: models::Contact, + identity: models::Identity, + disclosures: models::Disclosures, + agreements: Vec, + ) -> AccountCreationRequest { + AccountCreationRequest { + contact: Box::new(contact), + identity: Box::new(identity), + disclosures: Box::new(disclosures), + agreements, + documents: None, + trusted_contact: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/account_document.rs b/crates/alpaca_openapi/gen/broker/src/models/account_document.rs new file mode 100644 index 0000000..2538a14 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/account_document.rs @@ -0,0 +1,43 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AccountDocument : If an account has documents on the application submission, it has the ApplicationDocument model in exchange with DocumentUploadRequest. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AccountDocument { + #[serde(rename = "id")] + pub id: uuid::Uuid, + #[serde(rename = "document_type")] + pub document_type: models::DocumentType, + #[serde(rename = "document_sub_type", skip_serializing_if = "Option::is_none")] + pub document_sub_type: Option, + #[serde(rename = "mime_type", skip_serializing_if = "Option::is_none")] + pub mime_type: Option, + #[serde(rename = "created_at")] + pub created_at: String, +} + +impl AccountDocument { + /// If an account has documents on the application submission, it has the ApplicationDocument model in exchange with DocumentUploadRequest. + pub fn new( + id: uuid::Uuid, + document_type: models::DocumentType, + created_at: String, + ) -> AccountDocument { + AccountDocument { + id, + document_type, + document_sub_type: None, + mime_type: None, + created_at, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/account_extended.rs b/crates/alpaca_openapi/gen/broker/src/models/account_extended.rs new file mode 100644 index 0000000..367c973 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/account_extended.rs @@ -0,0 +1,111 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AccountExtended : Represents an account with all data available. If your api response is missing some of these fields, there is a good chance you are using a route that returns `Account` instances instead of these. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AccountExtended { + #[serde(rename = "id")] + pub id: uuid::Uuid, + #[serde(rename = "account_number", deserialize_with = "Option::deserialize")] + pub account_number: Option, + #[serde(rename = "status")] + pub status: models::AccountStatus, + #[serde(rename = "crypto_status", skip_serializing_if = "Option::is_none")] + pub crypto_status: Option, + #[serde(rename = "kyc_result", skip_serializing_if = "Option::is_none")] + pub kyc_result: Option>, + /// Always \"USD\" + #[serde(rename = "currency")] + pub currency: String, + #[serde(rename = "last_equity")] + pub last_equity: String, + #[serde(rename = "created_at")] + pub created_at: String, + #[serde(rename = "contact", skip_serializing_if = "Option::is_none")] + pub contact: Option>, + #[serde(rename = "identity", skip_serializing_if = "Option::is_none")] + pub identity: Option>, + #[serde(rename = "disclosures", skip_serializing_if = "Option::is_none")] + pub disclosures: Option>, + #[serde(rename = "agreements", skip_serializing_if = "Option::is_none")] + pub agreements: Option>, + #[serde(rename = "documents", skip_serializing_if = "Option::is_none")] + pub documents: Option>, + #[serde(rename = "trusted_contact", skip_serializing_if = "Option::is_none")] + pub trusted_contact: Option>, + #[serde(rename = "account_name", skip_serializing_if = "Option::is_none")] + pub account_name: Option, + #[serde(rename = "account_type")] + pub account_type: models::AccountType, + /// \"UGMA\" or \"UTMA\" only used when account_type is \"custodial\" + #[serde( + rename = "custodial_account_type", + skip_serializing_if = "Option::is_none" + )] + pub custodial_account_type: Option, + #[serde(rename = "minor_identity", skip_serializing_if = "Option::is_none")] + pub minor_identity: Option>, + #[serde( + rename = "trading_configurations", + skip_serializing_if = "Option::is_none" + )] + pub trading_configurations: Option>, +} + +impl AccountExtended { + /// Represents an account with all data available. If your api response is missing some of these fields, there is a good chance you are using a route that returns `Account` instances instead of these. + pub fn new( + id: uuid::Uuid, + account_number: Option, + status: models::AccountStatus, + currency: String, + last_equity: String, + created_at: String, + account_type: models::AccountType, + ) -> AccountExtended { + AccountExtended { + id, + account_number, + status, + crypto_status: None, + kyc_result: None, + currency, + last_equity, + created_at, + contact: None, + identity: None, + disclosures: None, + agreements: None, + documents: None, + trusted_contact: None, + account_name: None, + account_type, + custodial_account_type: None, + minor_identity: None, + trading_configurations: None, + } + } +} +/// \"UGMA\" or \"UTMA\" only used when account_type is \"custodial\" +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum CustodialAccountType { + #[serde(rename = "UTMA")] + Utma, + #[serde(rename = "UGMA")] + Ugma, +} + +impl Default for CustodialAccountType { + fn default() -> CustodialAccountType { + Self::Utma + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/account_status.rs b/crates/alpaca_openapi/gen/broker/src/models/account_status.rs new file mode 100644 index 0000000..d9e73cd --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/account_status.rs @@ -0,0 +1,90 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AccountStatus : Designates the current status of this account Possible Values: - **ONBOARDING** An application is expected for this user, but has not been submitted yet. - **SUBMITTED** The application has been submitted and in process. - **RESUBMITTED** Resubmitted is used to display when request has been re-submitted to Apex after account update - **SUBMISSION_FAILED** Used to display if failure on submission - **ACTION_REQUIRED** The application requires manual action. - **EDITED** Application was edited (e.g. to match info from uploaded docs). This is a transient status. - **ACCOUNT_UPDATED** Used to display when Account has been modified by user - **APPROVAL_PENDING** Initial value. The application approval process is in process. - **REAPPROVAL_PENDING** This is a transient status used to display once apex approves a re-submission - **SIGNED_UP** Users who were directed to and competed the [first stage](https://app.alpaca.markets/signup) of v2 registration - **KYC_SUBMITTED** Users that have had their KYC submitted to the routed KYC Provider - **LIMITED** Limited Users that pass KYC but are missing financial_information and employment_details - **AML_REVIEW** Users that pass KYC but from a restricted/high risk country and need manual AML approval - **APPROVED** The account application has been approved, and waiting to be ACTIVE - **REJECTED** The account application is rejected for some reason - **ACTIVE** The account is fully active. Trading and funding are processed under this status. - **DISABLED** The account is disabled after ACTIVE status. - **DISABLE_PENDING** DisablePending is used for accounts which requested to be disabled, but have not been processed yet. - **ACCOUNT_CLOSED** The account is closed. - **PAPER_ONLY** Used to display when only paper trading is allowed for this account +/// Designates the current status of this account Possible Values: - **ONBOARDING** An application is expected for this user, but has not been submitted yet. - **SUBMITTED** The application has been submitted and in process. - **RESUBMITTED** Resubmitted is used to display when request has been re-submitted to Apex after account update - **SUBMISSION_FAILED** Used to display if failure on submission - **ACTION_REQUIRED** The application requires manual action. - **EDITED** Application was edited (e.g. to match info from uploaded docs). This is a transient status. - **ACCOUNT_UPDATED** Used to display when Account has been modified by user - **APPROVAL_PENDING** Initial value. The application approval process is in process. - **REAPPROVAL_PENDING** This is a transient status used to display once apex approves a re-submission - **SIGNED_UP** Users who were directed to and competed the [first stage](https://app.alpaca.markets/signup) of v2 registration - **KYC_SUBMITTED** Users that have had their KYC submitted to the routed KYC Provider - **LIMITED** Limited Users that pass KYC but are missing financial_information and employment_details - **AML_REVIEW** Users that pass KYC but from a restricted/high risk country and need manual AML approval - **APPROVED** The account application has been approved, and waiting to be ACTIVE - **REJECTED** The account application is rejected for some reason - **ACTIVE** The account is fully active. Trading and funding are processed under this status. - **DISABLED** The account is disabled after ACTIVE status. - **DISABLE_PENDING** DisablePending is used for accounts which requested to be disabled, but have not been processed yet. - **ACCOUNT_CLOSED** The account is closed. - **PAPER_ONLY** Used to display when only paper trading is allowed for this account +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum AccountStatus { + #[serde(rename = "ONBOARDING")] + Onboarding, + #[serde(rename = "SUBMITTED")] + Submitted, + #[serde(rename = "RESUBMITTED")] + Resubmitted, + #[serde(rename = "SUBMISSION_FAILED")] + SubmissionFailed, + #[serde(rename = "ACTION_REQUIRED")] + ActionRequired, + #[serde(rename = "EDITED")] + Edited, + #[serde(rename = "ACCOUNT_UPDATED")] + AccountUpdated, + #[serde(rename = "APPROVAL_PENDING")] + ApprovalPending, + #[serde(rename = "REAPPROVAL_PENDING")] + ReapprovalPending, + #[serde(rename = "SIGNED_UP")] + SignedUp, + #[serde(rename = "KYC_SUBMITTED")] + KycSubmitted, + #[serde(rename = "LIMITED")] + Limited, + #[serde(rename = "AML_REVIEW")] + AmlReview, + #[serde(rename = "APPROVED")] + Approved, + #[serde(rename = "REJECTED")] + Rejected, + #[serde(rename = "ACTIVE")] + Active, + #[serde(rename = "DISABLED")] + Disabled, + #[serde(rename = "DISABLE_PENDING")] + DisablePending, + #[serde(rename = "ACCOUNT_CLOSED")] + AccountClosed, + #[serde(rename = "PAPER_ONLY")] + PaperOnly, +} + +impl ToString for AccountStatus { + fn to_string(&self) -> String { + match self { + Self::Onboarding => String::from("ONBOARDING"), + Self::Submitted => String::from("SUBMITTED"), + Self::Resubmitted => String::from("RESUBMITTED"), + Self::SubmissionFailed => String::from("SUBMISSION_FAILED"), + Self::ActionRequired => String::from("ACTION_REQUIRED"), + Self::Edited => String::from("EDITED"), + Self::AccountUpdated => String::from("ACCOUNT_UPDATED"), + Self::ApprovalPending => String::from("APPROVAL_PENDING"), + Self::ReapprovalPending => String::from("REAPPROVAL_PENDING"), + Self::SignedUp => String::from("SIGNED_UP"), + Self::KycSubmitted => String::from("KYC_SUBMITTED"), + Self::Limited => String::from("LIMITED"), + Self::AmlReview => String::from("AML_REVIEW"), + Self::Approved => String::from("APPROVED"), + Self::Rejected => String::from("REJECTED"), + Self::Active => String::from("ACTIVE"), + Self::Disabled => String::from("DISABLED"), + Self::DisablePending => String::from("DISABLE_PENDING"), + Self::AccountClosed => String::from("ACCOUNT_CLOSED"), + Self::PaperOnly => String::from("PAPER_ONLY"), + } + } +} + +impl Default for AccountStatus { + fn default() -> AccountStatus { + Self::Onboarding + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/account_status_event.rs b/crates/alpaca_openapi/gen/broker/src/models/account_status_event.rs new file mode 100644 index 0000000..0a2c0dd --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/account_status_event.rs @@ -0,0 +1,59 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AccountStatusEvent : Represents a change in an Account's status, sent over the events streaming api. For partners who utilize Alpaca’s KYC service for opening brokerage accounts an additional `kyc_results` object is represented in the account status update events. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AccountStatusEvent { + #[serde(rename = "account_id")] + pub account_id: String, + #[serde(rename = "account_number")] + pub account_number: String, + #[serde(rename = "status_from")] + pub status_from: models::AccountStatus, + #[serde(rename = "status_to")] + pub status_to: models::AccountStatus, + /// Optional + #[serde(rename = "reason")] + pub reason: String, + /// Timestamp of event + #[serde(rename = "at")] + pub at: String, + #[serde(rename = "kyc_result", skip_serializing_if = "Option::is_none")] + pub kyc_result: Option>, + /// monotonically increasing 64bit integer + #[serde(rename = "event_id")] + pub event_id: i32, +} + +impl AccountStatusEvent { + /// Represents a change in an Account's status, sent over the events streaming api. For partners who utilize Alpaca’s KYC service for opening brokerage accounts an additional `kyc_results` object is represented in the account status update events. + pub fn new( + account_id: String, + account_number: String, + status_from: models::AccountStatus, + status_to: models::AccountStatus, + reason: String, + at: String, + event_id: i32, + ) -> AccountStatusEvent { + AccountStatusEvent { + account_id, + account_number, + status_from, + status_to, + reason, + at, + kyc_result: None, + event_id, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/account_type.rs b/crates/alpaca_openapi/gen/broker/src/models/account_type.rs new file mode 100644 index 0000000..d583688 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/account_type.rs @@ -0,0 +1,39 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AccountType : Possible values are: - trading - custodial - donor_advised +/// Possible values are: - trading - custodial - donor_advised +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum AccountType { + #[serde(rename = "trading")] + Trading, + #[serde(rename = "custodial")] + Custodial, + #[serde(rename = "donor_advised")] + DonorAdvised, +} + +impl ToString for AccountType { + fn to_string(&self) -> String { + match self { + Self::Trading => String::from("trading"), + Self::Custodial => String::from("custodial"), + Self::DonorAdvised => String::from("donor_advised"), + } + } +} + +impl Default for AccountType { + fn default() -> AccountType { + Self::Trading + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/account_update_request.rs b/crates/alpaca_openapi/gen/broker/src/models/account_update_request.rs new file mode 100644 index 0000000..84416e8 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/account_update_request.rs @@ -0,0 +1,34 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AccountUpdateRequest { + #[serde(rename = "contact", skip_serializing_if = "Option::is_none")] + pub contact: Option>, + #[serde(rename = "identity", skip_serializing_if = "Option::is_none")] + pub identity: Option>, + #[serde(rename = "disclosures", skip_serializing_if = "Option::is_none")] + pub disclosures: Option>, + #[serde(rename = "trustedContact", skip_serializing_if = "Option::is_none")] + pub trusted_contact: Option>, +} + +impl AccountUpdateRequest { + pub fn new() -> AccountUpdateRequest { + AccountUpdateRequest { + contact: None, + identity: None, + disclosures: None, + trusted_contact: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/ach_relationship.rs b/crates/alpaca_openapi/gen/broker/src/models/ach_relationship.rs new file mode 100644 index 0000000..2326beb --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/ach_relationship.rs @@ -0,0 +1,101 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AchRelationship { + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// Format: 2020-01-01T01:01:01Z + #[serde(rename = "created_at")] + pub created_at: String, + /// Format: 2020-01-01T01:01:01Z + #[serde(rename = "updated_at")] + pub updated_at: String, + #[serde(rename = "account_id")] + pub account_id: uuid::Uuid, + #[serde(rename = "status")] + pub status: Status, + /// Name of the account owner + #[serde(rename = "account_owner_name")] + pub account_owner_name: String, + /// Must be CHECKING or SAVINGS + #[serde(rename = "bank_account_type", skip_serializing_if = "Option::is_none")] + pub bank_account_type: Option, + #[serde( + rename = "bank_account_number", + skip_serializing_if = "Option::is_none" + )] + pub bank_account_number: Option, + #[serde( + rename = "bank_routing_number", + skip_serializing_if = "Option::is_none" + )] + pub bank_routing_number: Option, + #[serde(rename = "nickname", skip_serializing_if = "Option::is_none")] + pub nickname: Option, +} + +impl AchRelationship { + pub fn new( + id: uuid::Uuid, + created_at: String, + updated_at: String, + account_id: uuid::Uuid, + status: Status, + account_owner_name: String, + ) -> AchRelationship { + AchRelationship { + id, + created_at, + updated_at, + account_id, + status, + account_owner_name, + bank_account_type: None, + bank_account_number: None, + bank_routing_number: None, + nickname: None, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "QUEUED")] + Queued, + #[serde(rename = "APPROVED")] + Approved, + #[serde(rename = "PENDING")] + Pending, + #[serde(rename = "CANCEL_REQUESTED")] + CancelRequested, +} + +impl Default for Status { + fn default() -> Status { + Self::Queued + } +} +/// Must be CHECKING or SAVINGS +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum BankAccountType { + #[serde(rename = "CHECKING")] + Checking, + #[serde(rename = "SAVINGS")] + Savings, +} + +impl Default for BankAccountType { + fn default() -> BankAccountType { + Self::Checking + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/activity.rs b/crates/alpaca_openapi/gen/broker/src/models/activity.rs new file mode 100644 index 0000000..bd4bd80 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/activity.rs @@ -0,0 +1,121 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Activity : Base for activity types +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Activity { + #[serde(rename = "id")] + pub id: String, + #[serde(rename = "account_id", skip_serializing_if = "Option::is_none")] + pub account_id: Option, + #[serde(rename = "activity_type")] + pub activity_type: models::ActivityType, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "transaction_time", skip_serializing_if = "Option::is_none")] + pub transaction_time: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + pub r#type: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "price", skip_serializing_if = "Option::is_none")] + pub price: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "qty", skip_serializing_if = "Option::is_none")] + pub qty: Option, + #[serde(rename = "side", skip_serializing_if = "Option::is_none")] + pub side: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "symbol", skip_serializing_if = "Option::is_none")] + pub symbol: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "leaves_qty", skip_serializing_if = "Option::is_none")] + pub leaves_qty: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "order_id", skip_serializing_if = "Option::is_none")] + pub order_id: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "cum_qty", skip_serializing_if = "Option::is_none")] + pub cum_qty: Option, + #[serde(rename = "order_status", skip_serializing_if = "Option::is_none")] + pub order_status: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "date", skip_serializing_if = "Option::is_none")] + pub date: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "net_amount", skip_serializing_if = "Option::is_none")] + pub net_amount: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "per_share_amount", skip_serializing_if = "Option::is_none")] + pub per_share_amount: Option, +} + +impl Activity { + /// Base for activity types + pub fn new(id: String, activity_type: models::ActivityType) -> Activity { + Activity { + id, + account_id: None, + activity_type, + transaction_time: None, + r#type: None, + price: None, + qty: None, + side: None, + symbol: None, + leaves_qty: None, + order_id: None, + cum_qty: None, + order_status: None, + date: None, + net_amount: None, + description: None, + status: None, + per_share_amount: None, + } + } +} +/// Valid only for trading activity types. Null for non-trading activites. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Type { + #[serde(rename = "fill")] + Fill, + #[serde(rename = "partial_fill")] + PartialFill, +} + +impl Default for Type { + fn default() -> Type { + Self::Fill + } +} +/// Valid only for non-trading activity types. Null for trading activites. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "executed")] + Executed, + #[serde(rename = "correct")] + Correct, + #[serde(rename = "canceled")] + Canceled, +} + +impl Default for Status { + fn default() -> Status { + Self::Executed + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/activity_item.rs b/crates/alpaca_openapi/gen/broker/src/models/activity_item.rs new file mode 100644 index 0000000..117a712 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/activity_item.rs @@ -0,0 +1,110 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ActivityItem { + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "transaction_time", skip_serializing_if = "Option::is_none")] + pub transaction_time: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + pub r#type: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "price", skip_serializing_if = "Option::is_none")] + pub price: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "qty", skip_serializing_if = "Option::is_none")] + pub qty: Option, + #[serde(rename = "side", skip_serializing_if = "Option::is_none")] + pub side: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "symbol", skip_serializing_if = "Option::is_none")] + pub symbol: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "leaves_qty", skip_serializing_if = "Option::is_none")] + pub leaves_qty: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "order_id", skip_serializing_if = "Option::is_none")] + pub order_id: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "cum_qty", skip_serializing_if = "Option::is_none")] + pub cum_qty: Option, + #[serde(rename = "order_status", skip_serializing_if = "Option::is_none")] + pub order_status: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "date", skip_serializing_if = "Option::is_none")] + pub date: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "net_amount", skip_serializing_if = "Option::is_none")] + pub net_amount: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "per_share_amount", skip_serializing_if = "Option::is_none")] + pub per_share_amount: Option, +} + +impl ActivityItem { + pub fn new() -> ActivityItem { + ActivityItem { + transaction_time: None, + r#type: None, + price: None, + qty: None, + side: None, + symbol: None, + leaves_qty: None, + order_id: None, + cum_qty: None, + order_status: None, + date: None, + net_amount: None, + description: None, + status: None, + per_share_amount: None, + } + } +} +/// Valid only for trading activity types. Null for non-trading activites. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Type { + #[serde(rename = "fill")] + Fill, + #[serde(rename = "partial_fill")] + PartialFill, +} + +impl Default for Type { + fn default() -> Type { + Self::Fill + } +} +/// Valid only for non-trading activity types. Null for trading activites. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "executed")] + Executed, + #[serde(rename = "correct")] + Correct, + #[serde(rename = "canceled")] + Canceled, +} + +impl Default for Status { + fn default() -> Status { + Self::Executed + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/activity_type.rs b/crates/alpaca_openapi/gen/broker/src/models/activity_type.rs new file mode 100644 index 0000000..7b3ef88 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/activity_type.rs @@ -0,0 +1,93 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// ActivityType : Represents the various kinds of activity. TradeActivity's will always have the type `FILL` - **FILL** Order Fills (Partial/Full) - **ACATC** ACATS IN/OUT (Cash) - **ACATS** ACATS IN/OUT (Securities) - **CIL** Cash in Lieu of Stock - **CSD** Cash Disbursement (+) - **CSW** Cash Withdrawable - **DIV** Dividend - **DIVCGL** Dividend (Capital Gain Long Term) - **DIVCGS** Dividend (Capital Gain Short Term) - **DIVNRA** Dividend Adjusted (NRA Withheld) - **DIVROC** Dividend Return of Capital - **DIVTXEX** Dividend (Tax Exempt) - **FEE** REG and TAF Fees - **INT** Interest (Credit/Margin) - **JNLC** Journal Entry (Cash) - **JNLS** Journal Entry (Stock) - **MA** Merger/Acquisition - **PTC** Pass Thru Change - **REORG** Reorg CA - **SPIN** Stock Spinoff - **SPLIT** Stock Split +/// Represents the various kinds of activity. TradeActivity's will always have the type `FILL` - **FILL** Order Fills (Partial/Full) - **ACATC** ACATS IN/OUT (Cash) - **ACATS** ACATS IN/OUT (Securities) - **CIL** Cash in Lieu of Stock - **CSD** Cash Disbursement (+) - **CSW** Cash Withdrawable - **DIV** Dividend - **DIVCGL** Dividend (Capital Gain Long Term) - **DIVCGS** Dividend (Capital Gain Short Term) - **DIVNRA** Dividend Adjusted (NRA Withheld) - **DIVROC** Dividend Return of Capital - **DIVTXEX** Dividend (Tax Exempt) - **FEE** REG and TAF Fees - **INT** Interest (Credit/Margin) - **JNLC** Journal Entry (Cash) - **JNLS** Journal Entry (Stock) - **MA** Merger/Acquisition - **PTC** Pass Thru Change - **REORG** Reorg CA - **SPIN** Stock Spinoff - **SPLIT** Stock Split +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum ActivityType { + #[serde(rename = "FILL")] + Fill, + #[serde(rename = "ACATC")] + Acatc, + #[serde(rename = "ACATS")] + Acats, + #[serde(rename = "CIL")] + Cil, + #[serde(rename = "CSD")] + Csd, + #[serde(rename = "CSW")] + Csw, + #[serde(rename = "DIV")] + Div, + #[serde(rename = "DIVCGL")] + Divcgl, + #[serde(rename = "DIVCGS")] + Divcgs, + #[serde(rename = "DIVNRA")] + Divnra, + #[serde(rename = "DIVROC")] + Divroc, + #[serde(rename = "DIVTXEX")] + Divtxex, + #[serde(rename = "FEE")] + Fee, + #[serde(rename = "INT")] + Int, + #[serde(rename = "JNLC")] + Jnlc, + #[serde(rename = "JNLS")] + Jnls, + #[serde(rename = "MA")] + Ma, + #[serde(rename = "PTC")] + Ptc, + #[serde(rename = "REORG")] + Reorg, + #[serde(rename = "SPIN")] + Spin, + #[serde(rename = "SPLIT")] + Split, +} + +impl ToString for ActivityType { + fn to_string(&self) -> String { + match self { + Self::Fill => String::from("FILL"), + Self::Acatc => String::from("ACATC"), + Self::Acats => String::from("ACATS"), + Self::Cil => String::from("CIL"), + Self::Csd => String::from("CSD"), + Self::Csw => String::from("CSW"), + Self::Div => String::from("DIV"), + Self::Divcgl => String::from("DIVCGL"), + Self::Divcgs => String::from("DIVCGS"), + Self::Divnra => String::from("DIVNRA"), + Self::Divroc => String::from("DIVROC"), + Self::Divtxex => String::from("DIVTXEX"), + Self::Fee => String::from("FEE"), + Self::Int => String::from("INT"), + Self::Jnlc => String::from("JNLC"), + Self::Jnls => String::from("JNLS"), + Self::Ma => String::from("MA"), + Self::Ptc => String::from("PTC"), + Self::Reorg => String::from("REORG"), + Self::Spin => String::from("SPIN"), + Self::Split => String::from("SPLIT"), + } + } +} + +impl Default for ActivityType { + fn default() -> ActivityType { + Self::Fill + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/agreement.rs b/crates/alpaca_openapi/gen/broker/src/models/agreement.rs new file mode 100644 index 0000000..aa70498 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/agreement.rs @@ -0,0 +1,38 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Agreement { + #[serde(rename = "agreement")] + pub agreement: models::AgreementType, + #[serde(rename = "signed_at")] + pub signed_at: String, + #[serde(rename = "ip_address")] + pub ip_address: String, + #[serde(rename = "revision", skip_serializing_if = "Option::is_none")] + pub revision: Option, +} + +impl Agreement { + pub fn new( + agreement: models::AgreementType, + signed_at: String, + ip_address: String, + ) -> Agreement { + Agreement { + agreement, + signed_at, + ip_address, + revision: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/agreement_type.rs b/crates/alpaca_openapi/gen/broker/src/models/agreement_type.rs new file mode 100644 index 0000000..49c7482 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/agreement_type.rs @@ -0,0 +1,42 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AgreementType : - margin_agreement: Alpaca Margin Agreement - account_agreement: Alpaca Account Agreement - customer_agreement: Alpaca Customer Agreement - crypto_agreement: Alpaca Crypto agreement +/// - margin_agreement: Alpaca Margin Agreement - account_agreement: Alpaca Account Agreement - customer_agreement: Alpaca Customer Agreement - crypto_agreement: Alpaca Crypto agreement +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum AgreementType { + #[serde(rename = "margin_agreement")] + MarginAgreement, + #[serde(rename = "account_agreement")] + AccountAgreement, + #[serde(rename = "customer_agreement")] + CustomerAgreement, + #[serde(rename = "crypto_agreement")] + CryptoAgreement, +} + +impl ToString for AgreementType { + fn to_string(&self) -> String { + match self { + Self::MarginAgreement => String::from("margin_agreement"), + Self::AccountAgreement => String::from("account_agreement"), + Self::CustomerAgreement => String::from("customer_agreement"), + Self::CryptoAgreement => String::from("crypto_agreement"), + } + } +} + +impl Default for AgreementType { + fn default() -> AgreementType { + Self::MarginAgreement + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/announcement.rs b/crates/alpaca_openapi/gen/broker/src/models/announcement.rs new file mode 100644 index 0000000..d441845 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/announcement.rs @@ -0,0 +1,101 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Announcement : The announcements endpoint contains public information on previous and upcoming dividends, mergers, spinoffs, and stock splits. Announcement data is made available through the API as soon as it is ingested by Alpaca, which is typically the following trading day after the declaration date. This provides insight into future account stock position and cash balance changes that will take effect on an announcement’s payable date. Additionally, viewing previous announcement details can improve bookkeeping and reconciling previous account cash and position changes. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Announcement { + /// ID that is specific to a single announcement. + #[serde(rename = "id")] + pub id: String, + /// ID that remains consistent across all announcements for the same corporate action. Unlike ‘id’, this can be used to connect multiple announcements to see how the terms have changed throughout the lifecycle of the corporate action event. + #[serde(rename = "corporate_action_id")] + pub corporate_action_id: String, + #[serde(rename = "ca_type")] + pub ca_type: models::AnnouncementCaType, + #[serde(rename = "ca_sub_type")] + pub ca_sub_type: models::AnnouncementCaSubType, + /// Symbol of the company initiating the announcement. + #[serde(rename = "initiating_symbol")] + pub initiating_symbol: String, + /// CUSIP of the company initiating the announcement. + #[serde(rename = "initiating_original_cusip")] + pub initiating_original_cusip: String, + /// Symbol of the child company involved in the announcement. + #[serde(rename = "target_symbol", deserialize_with = "Option::deserialize")] + pub target_symbol: Option, + /// CUSIP of the child company involved in the announcement. + #[serde( + rename = "target_original_cusip", + deserialize_with = "Option::deserialize" + )] + pub target_original_cusip: Option, + /// Date the corporate action or subsequent terms update was announced. + #[serde(rename = "declaration_date")] + pub declaration_date: String, + /// The first date that purchasing a security will not result in a corporate action entitlement. + #[serde(rename = "ex_date", deserialize_with = "Option::deserialize")] + pub ex_date: Option, + /// The date an account must hold a settled position in the security in order to receive the corporate action entitlement. + #[serde(rename = "record_date", deserialize_with = "Option::deserialize")] + pub record_date: Option, + /// The date the announcement will take effect. On this date, account stock and cash balances are expected to be processed accordingly. + #[serde(rename = "payable_date")] + pub payable_date: String, + /// The amount of cash to be paid per share held by an account on the record date. + #[serde(rename = "cash", deserialize_with = "Option::deserialize")] + pub cash: Option, + /// The denominator to determine any quantity change ratios in positions. + #[serde(rename = "old_rate", deserialize_with = "Option::deserialize")] + pub old_rate: Option, + /// The numerator to determine any quantity change ratios in positions. + #[serde(rename = "new_rate", deserialize_with = "Option::deserialize")] + pub new_rate: Option, +} + +impl Announcement { + /// The announcements endpoint contains public information on previous and upcoming dividends, mergers, spinoffs, and stock splits. Announcement data is made available through the API as soon as it is ingested by Alpaca, which is typically the following trading day after the declaration date. This provides insight into future account stock position and cash balance changes that will take effect on an announcement’s payable date. Additionally, viewing previous announcement details can improve bookkeeping and reconciling previous account cash and position changes. + pub fn new( + id: String, + corporate_action_id: String, + ca_type: models::AnnouncementCaType, + ca_sub_type: models::AnnouncementCaSubType, + initiating_symbol: String, + initiating_original_cusip: String, + target_symbol: Option, + target_original_cusip: Option, + declaration_date: String, + ex_date: Option, + record_date: Option, + payable_date: String, + cash: Option, + old_rate: Option, + new_rate: Option, + ) -> Announcement { + Announcement { + id, + corporate_action_id, + ca_type, + ca_sub_type, + initiating_symbol, + initiating_original_cusip, + target_symbol, + target_original_cusip, + declaration_date, + ex_date, + record_date, + payable_date, + cash, + old_rate, + new_rate, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/announcement_ca_sub_type.rs b/crates/alpaca_openapi/gen/broker/src/models/announcement_ca_sub_type.rs new file mode 100644 index 0000000..e54c82b --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/announcement_ca_sub_type.rs @@ -0,0 +1,57 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AnnouncementCaSubType : Announcements have both a type and a subtype to categorize them. This model represents the lowever level abstract \"sub types\" of Announcement. Please see the AnnouncementCAType model for higher level descriptions of the possible types Possible values are: - from the `dividend` type: - **cash** A cash payment based on the number of shares the account holds on the record date. - **stock** A stock payment based on the number of shares the account holds on the record date. - from the `merger` type: - **merger_update** An update to the terms of an upcoming merger. This can happen any number of times before the merger is completed and can be tracked by using the id parameter. - **merger_completion** A final update in the terms of the merger in which the intiating_symbol will acquire the target_symbol. Any previous terms updates for this announcement will have the same id value. - from the `split` type: - **stock_split** An increase in the number of shares outstanding with a decrease in the dollar value of each share. The new_rate and old_rate parameters will be returned in order to derive the ratio of the split - **until_split** An increase in the number of shares outstanding with a decrease in the dollar value of each share. The new_rate and old_rate parameters will be returned in order to derive the ratio of the split. - **reverse_split** A decrease in the number of shares outstanding with an increase in the dollar value of each share. The new_rate and old_rate parameters will be returned in order to derive the ratio of the spli - **recapitalization** A stock recapitalization, typically used by a company to adjust debt and equity ratios. - from the `spinoff` type: - **spinoff** A disbursement of a newly tradable security when the intiating_symbol creates the target_symbol. +/// Announcements have both a type and a subtype to categorize them. This model represents the lowever level abstract \"sub types\" of Announcement. Please see the AnnouncementCAType model for higher level descriptions of the possible types Possible values are: - from the `dividend` type: - **cash** A cash payment based on the number of shares the account holds on the record date. - **stock** A stock payment based on the number of shares the account holds on the record date. - from the `merger` type: - **merger_update** An update to the terms of an upcoming merger. This can happen any number of times before the merger is completed and can be tracked by using the id parameter. - **merger_completion** A final update in the terms of the merger in which the intiating_symbol will acquire the target_symbol. Any previous terms updates for this announcement will have the same id value. - from the `split` type: - **stock_split** An increase in the number of shares outstanding with a decrease in the dollar value of each share. The new_rate and old_rate parameters will be returned in order to derive the ratio of the split - **until_split** An increase in the number of shares outstanding with a decrease in the dollar value of each share. The new_rate and old_rate parameters will be returned in order to derive the ratio of the split. - **reverse_split** A decrease in the number of shares outstanding with an increase in the dollar value of each share. The new_rate and old_rate parameters will be returned in order to derive the ratio of the spli - **recapitalization** A stock recapitalization, typically used by a company to adjust debt and equity ratios. - from the `spinoff` type: - **spinoff** A disbursement of a newly tradable security when the intiating_symbol creates the target_symbol. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum AnnouncementCaSubType { + #[serde(rename = "cash")] + Cash, + #[serde(rename = "stock")] + Stock, + #[serde(rename = "merger_update")] + MergerUpdate, + #[serde(rename = "merger_completion")] + MergerCompletion, + #[serde(rename = "stock_split")] + StockSplit, + #[serde(rename = "until_split")] + UntilSplit, + #[serde(rename = "reverse_split")] + ReverseSplit, + #[serde(rename = "recapitalization")] + Recapitalization, + #[serde(rename = "spinoff")] + Spinoff, +} + +impl ToString for AnnouncementCaSubType { + fn to_string(&self) -> String { + match self { + Self::Cash => String::from("cash"), + Self::Stock => String::from("stock"), + Self::MergerUpdate => String::from("merger_update"), + Self::MergerCompletion => String::from("merger_completion"), + Self::StockSplit => String::from("stock_split"), + Self::UntilSplit => String::from("until_split"), + Self::ReverseSplit => String::from("reverse_split"), + Self::Recapitalization => String::from("recapitalization"), + Self::Spinoff => String::from("spinoff"), + } + } +} + +impl Default for AnnouncementCaSubType { + fn default() -> AnnouncementCaSubType { + Self::Cash + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/announcement_ca_type.rs b/crates/alpaca_openapi/gen/broker/src/models/announcement_ca_type.rs new file mode 100644 index 0000000..b0448c5 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/announcement_ca_type.rs @@ -0,0 +1,42 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AnnouncementCaType : Announcements have both a type and a subtype to categorize them. This model represents the higher level abstract \"types\" of Announcement. Please see the AnnouncementCASubType model for finer grain descriptions of the subtypes Possible values are: - dividend can have `cash` and `stock` subtypes - merger has `merger_update` and `merger_completion` sub types - split has `stock_split`, `until_split`, `reverse_split`, and `recapitalization` sub types - spinoff currently has only the `spinoff` subtype and thus is just this higher level category for now. A disbursement of a newly tradable security when the intiating_symbol creates the target_symbol. +/// Announcements have both a type and a subtype to categorize them. This model represents the higher level abstract \"types\" of Announcement. Please see the AnnouncementCASubType model for finer grain descriptions of the subtypes Possible values are: - dividend can have `cash` and `stock` subtypes - merger has `merger_update` and `merger_completion` sub types - split has `stock_split`, `until_split`, `reverse_split`, and `recapitalization` sub types - spinoff currently has only the `spinoff` subtype and thus is just this higher level category for now. A disbursement of a newly tradable security when the intiating_symbol creates the target_symbol. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum AnnouncementCaType { + #[serde(rename = "dividend")] + Dividend, + #[serde(rename = "merger")] + Merger, + #[serde(rename = "split")] + Split, + #[serde(rename = "spinoff")] + Spinoff, +} + +impl ToString for AnnouncementCaType { + fn to_string(&self) -> String { + match self { + Self::Dividend => String::from("dividend"), + Self::Merger => String::from("merger"), + Self::Split => String::from("split"), + Self::Spinoff => String::from("spinoff"), + } + } +} + +impl Default for AnnouncementCaType { + fn default() -> AnnouncementCaType { + Self::Dividend + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/application_document.rs b/crates/alpaca_openapi/gen/broker/src/models/application_document.rs new file mode 100644 index 0000000..373facb --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/application_document.rs @@ -0,0 +1,43 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// ApplicationDocument : If an account has documents on the application submission, it has the ApplicationDocument model in exchange with DocumentUpload. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ApplicationDocument { + #[serde(rename = "id")] + pub id: uuid::Uuid, + #[serde(rename = "document_type")] + pub document_type: models::DocumentType, + #[serde(rename = "document_sub_type", skip_serializing_if = "Option::is_none")] + pub document_sub_type: Option, + #[serde(rename = "mime_type", skip_serializing_if = "Option::is_none")] + pub mime_type: Option, + #[serde(rename = "created_at")] + pub created_at: String, +} + +impl ApplicationDocument { + /// If an account has documents on the application submission, it has the ApplicationDocument model in exchange with DocumentUpload. + pub fn new( + id: uuid::Uuid, + document_type: models::DocumentType, + created_at: String, + ) -> ApplicationDocument { + ApplicationDocument { + id, + document_type, + document_sub_type: None, + mime_type: None, + created_at, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/asset.rs b/crates/alpaca_openapi/gen/broker/src/models/asset.rs new file mode 100644 index 0000000..3f3963b --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/asset.rs @@ -0,0 +1,95 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Asset : Assets are sorted by asset class, exchange and symbol. Some assets are not tradable with Alpaca. These assets will be marked with the flag tradable=false +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Asset { + /// Asset ID + #[serde(rename = "id")] + pub id: uuid::Uuid, + #[serde(rename = "class")] + pub class: models::AssetClass, + #[serde(rename = "exchange", skip_serializing_if = "Option::is_none")] + pub exchange: Option, + /// The symbol of the asset + #[serde(rename = "symbol")] + pub symbol: String, + /// The official name of the asset + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, + /// active or inactive + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + /// Asset is tradable on Alpaca or not + #[serde(rename = "tradable", skip_serializing_if = "Option::is_none")] + pub tradable: Option, + /// Asset is marginable or not + #[serde(rename = "marginable", skip_serializing_if = "Option::is_none")] + pub marginable: Option, + /// Asset is shortable or not + #[serde(rename = "shortable", skip_serializing_if = "Option::is_none")] + pub shortable: Option, + /// Asset is easy-to-borrow or not (filtering for easy_to_borrow = True is the best way to check whether the name is currently available to short at Alpaca). + #[serde(rename = "easy_to_borrow", skip_serializing_if = "Option::is_none")] + pub easy_to_borrow: Option, + /// Asset is fractionable or not + #[serde(rename = "fractionable", skip_serializing_if = "Option::is_none")] + pub fractionable: Option, + /// Percent change for the trading day as of last market closure. NOTE: This field is currently in this spec however it may not be present in the production environment at time of publishing. It will be coming in a future update at which point this spec should be updated. + #[serde( + rename = "last_close_pct_change", + skip_serializing_if = "Option::is_none" + )] + pub last_close_pct_change: Option, + /// Most recent available price for this asset on the market. NOTE: This field is currently in this spec however it may not be present in the production environment at time of publishing. It will be coming in a future update at which point this spec should be updated. + #[serde(rename = "last_price", skip_serializing_if = "Option::is_none")] + pub last_price: Option, + /// Last price of the asset upon market closure on the most recent trading day. NOTE: This field is currently in this spec however it may not be present in the production environment at time of publishing. It will be coming in a future update at which point this spec should be updated. + #[serde(rename = "last_close", skip_serializing_if = "Option::is_none")] + pub last_close: Option, +} + +impl Asset { + /// Assets are sorted by asset class, exchange and symbol. Some assets are not tradable with Alpaca. These assets will be marked with the flag tradable=false + pub fn new(id: uuid::Uuid, class: models::AssetClass, symbol: String) -> Asset { + Asset { + id, + class, + exchange: None, + symbol, + name: None, + status: None, + tradable: None, + marginable: None, + shortable: None, + easy_to_borrow: None, + fractionable: None, + last_close_pct_change: None, + last_price: None, + last_close: None, + } + } +} +/// active or inactive +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "active")] + Active, + #[serde(rename = "inactive")] + Inactive, +} + +impl Default for Status { + fn default() -> Status { + Self::Active + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/asset_class.rs b/crates/alpaca_openapi/gen/broker/src/models/asset_class.rs new file mode 100644 index 0000000..9bd1f32 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/asset_class.rs @@ -0,0 +1,35 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum AssetClass { + #[serde(rename = "us_equity")] + UsEquity, + #[serde(rename = "crypto")] + Crypto, +} + +impl ToString for AssetClass { + fn to_string(&self) -> String { + match self { + Self::UsEquity => String::from("us_equity"), + Self::Crypto => String::from("crypto"), + } + } +} + +impl Default for AssetClass { + fn default() -> AssetClass { + Self::UsEquity + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/authorize_o_auth_token_response.rs b/crates/alpaca_openapi/gen/broker/src/models/authorize_o_auth_token_response.rs new file mode 100644 index 0000000..2b0d875 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/authorize_o_auth_token_response.rs @@ -0,0 +1,45 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AuthorizeOAuthTokenResponse : +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AuthorizeOAuthTokenResponse { + /// OAuth code to exchange with token + #[serde(rename = "code")] + pub code: String, + /// OAuth `client_id` + #[serde(rename = "client_id")] + pub client_id: String, + /// Redirect URI of OAuth flow + #[serde(rename = "redirect_uri")] + pub redirect_uri: String, + /// Granted scopes + #[serde(rename = "scope")] + pub scope: String, +} + +impl AuthorizeOAuthTokenResponse { + /// + pub fn new( + code: String, + client_id: String, + redirect_uri: String, + scope: String, + ) -> AuthorizeOAuthTokenResponse { + AuthorizeOAuthTokenResponse { + code, + client_id, + redirect_uri, + scope, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/bank.rs b/crates/alpaca_openapi/gen/broker/src/models/bank.rs new file mode 100644 index 0000000..03b5408 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/bank.rs @@ -0,0 +1,115 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Bank { + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// Format: 2020-01-01T01:01:01Z + #[serde(rename = "created_at")] + pub created_at: String, + /// Format: 2020-01-01T01:01:01Z + #[serde(rename = "updated_at")] + pub updated_at: String, + #[serde(rename = "account_id", skip_serializing_if = "Option::is_none")] + pub account_id: Option, + /// QUEUED, SENT_TO_CLEARING, APPROVED, CANCELED + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + /// Name of recipient bank + #[serde(rename = "name")] + pub name: String, + /// 9-Digit ABA RTN (Routing Number) or BIC + #[serde(rename = "bank_code")] + pub bank_code: String, + /// ABA (Domestic) or BIC (International) + #[serde(rename = "bank_code_type")] + pub bank_code_type: BankCodeType, + /// Only for international banks + #[serde(rename = "country", skip_serializing_if = "Option::is_none")] + pub country: Option, + /// Only for international banks + #[serde(rename = "state_province", skip_serializing_if = "Option::is_none")] + pub state_province: Option, + /// Only for international banks + #[serde(rename = "postal_code", skip_serializing_if = "Option::is_none")] + pub postal_code: Option, + /// Only for international banks + #[serde(rename = "city", skip_serializing_if = "Option::is_none")] + pub city: Option, + /// Only for international banks + #[serde(rename = "street_address", skip_serializing_if = "Option::is_none")] + pub street_address: Option, + #[serde(rename = "account_number")] + pub account_number: String, +} + +impl Bank { + pub fn new( + id: uuid::Uuid, + created_at: String, + updated_at: String, + name: String, + bank_code: String, + bank_code_type: BankCodeType, + account_number: String, + ) -> Bank { + Bank { + id, + created_at, + updated_at, + account_id: None, + status: None, + name, + bank_code, + bank_code_type, + country: None, + state_province: None, + postal_code: None, + city: None, + street_address: None, + account_number, + } + } +} +/// QUEUED, SENT_TO_CLEARING, APPROVED, CANCELED +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "QUEUED")] + Queued, + #[serde(rename = "SENT_TO_CLEARING")] + SentToClearing, + #[serde(rename = "APPROVED")] + Approved, + #[serde(rename = "CANCELED")] + Canceled, +} + +impl Default for Status { + fn default() -> Status { + Self::Queued + } +} +/// ABA (Domestic) or BIC (International) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum BankCodeType { + #[serde(rename = "ABA")] + Aba, + #[serde(rename = "BIC")] + Bic, +} + +impl Default for BankCodeType { + fn default() -> BankCodeType { + Self::Aba + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/batch_journal_request.rs b/crates/alpaca_openapi/gen/broker/src/models/batch_journal_request.rs new file mode 100644 index 0000000..7510962 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/batch_journal_request.rs @@ -0,0 +1,56 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// BatchJournalRequest : Journals API allows you to move cash or securities from one account to another. This model represents the fields you can specify when creating a request of many Journals out of one account to many others at once. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct BatchJournalRequest { + /// Only supports `JNLC` for now + #[serde(rename = "entry_type")] + pub entry_type: EntryType, + /// The account id that is the originator of the funds being moved. Most likely is your Sweep Firm Account + #[serde(rename = "from_account")] + pub from_account: uuid::Uuid, + /// Journal description, gets returned in the response + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, + /// An array of objects describing to what accounts you want to move funds into and how much to move into for each account + #[serde(rename = "entries")] + pub entries: Vec, +} + +impl BatchJournalRequest { + /// Journals API allows you to move cash or securities from one account to another. This model represents the fields you can specify when creating a request of many Journals out of one account to many others at once. + pub fn new( + entry_type: EntryType, + from_account: uuid::Uuid, + entries: Vec, + ) -> BatchJournalRequest { + BatchJournalRequest { + entry_type, + from_account, + description: None, + entries, + } + } +} +/// Only supports `JNLC` for now +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum EntryType { + #[serde(rename = "JNLC")] + Jnlc, +} + +impl Default for EntryType { + fn default() -> EntryType { + Self::Jnlc + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/batch_journal_request_entries_inner.rs b/crates/alpaca_openapi/gen/broker/src/models/batch_journal_request_entries_inner.rs new file mode 100644 index 0000000..e0647d1 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/batch_journal_request_entries_inner.rs @@ -0,0 +1,27 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct BatchJournalRequestEntriesInner { + /// The ID of the account that you want to journal funds into + #[serde(rename = "to_account")] + pub to_account: uuid::Uuid, + /// Journal amount in USD + #[serde(rename = "amount")] + pub amount: String, +} + +impl BatchJournalRequestEntriesInner { + pub fn new(to_account: uuid::Uuid, amount: String) -> BatchJournalRequestEntriesInner { + BatchJournalRequestEntriesInner { to_account, amount } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/batch_journal_response.rs b/crates/alpaca_openapi/gen/broker/src/models/batch_journal_response.rs new file mode 100644 index 0000000..f1f497b --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/batch_journal_response.rs @@ -0,0 +1,112 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// BatchJournalResponse : A Journal object with an extra attribute error_message in the case when a specific account fails to receive a journal. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct BatchJournalResponse { + /// journal ID + #[serde(rename = "id")] + pub id: uuid::Uuid, + #[serde(rename = "entry_type")] + pub entry_type: models::JournalEntryType, + /// account ID the shares go from + #[serde(rename = "from_account")] + pub from_account: uuid::Uuid, + /// account ID the shares go to + #[serde(rename = "to_account")] + pub to_account: uuid::Uuid, + #[serde(rename = "settle_date")] + pub settle_date: String, + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + /// Only valid for JNLS journals. Null for JNLC. + #[serde(rename = "symbol")] + pub symbol: String, + /// Only valid for JNLS journals. Null for JNLC. + #[serde(rename = "qty")] + pub qty: String, + /// Only valid for JNLS journals. Null for JNLC. + #[serde(rename = "price")] + pub price: String, + /// ID the amount goes to. Only valid for JNLC journals. Null for JNLS. + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, + /// Only valid for JNLC journals. Null for JNLS. + #[serde(rename = "net_amount")] + pub net_amount: String, + /// Only valid for JNLC journals. Null for JNLS. Max 255 characters. + #[serde(rename = "transmitter_name", skip_serializing_if = "Option::is_none")] + pub transmitter_name: Option, + /// Only valid for JNLC journals. Null for JNLS.max 255 characters + #[serde( + rename = "transmitter_account_number", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_account_number: Option, + /// Only valid for JNLC journals. Null for JNLS.max 255 characters + #[serde( + rename = "transmitter_address", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_address: Option, + /// Only valid for JNLC journals. Null for JNLS.max 255 characters + #[serde( + rename = "transmitter_financial_institution", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_financial_institution: Option, + /// Only valid for JNLC journals. Null for JNLS. + #[serde( + rename = "transmitter_timestamp", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_timestamp: Option, + /// Description of why this journal transaction failed + #[serde(rename = "error_message")] + pub error_message: String, +} + +impl BatchJournalResponse { + /// A Journal object with an extra attribute error_message in the case when a specific account fails to receive a journal. + pub fn new( + id: uuid::Uuid, + entry_type: models::JournalEntryType, + from_account: uuid::Uuid, + to_account: uuid::Uuid, + settle_date: String, + symbol: String, + qty: String, + price: String, + net_amount: String, + error_message: String, + ) -> BatchJournalResponse { + BatchJournalResponse { + id, + entry_type, + from_account, + to_account, + settle_date, + status: None, + symbol, + qty, + price, + description: None, + net_amount, + transmitter_name: None, + transmitter_account_number: None, + transmitter_address: None, + transmitter_financial_institution: None, + transmitter_timestamp: None, + error_message, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/calendar.rs b/crates/alpaca_openapi/gen/broker/src/models/calendar.rs new file mode 100644 index 0000000..e854718 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/calendar.rs @@ -0,0 +1,44 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Calendar : The calendar API serves the full list of market days from 1970 to 2029. It can also be queried by specifying a start and/or end time to narrow down the results. In addition to the dates, the response also contains the specific open and close times for the market days, taking into account early closures. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Calendar { + /// Date string in YYYY-MM-DD format + #[serde(rename = "date")] + pub date: String, + /// The time the market opens at on this date in HH:MM format + #[serde(rename = "open")] + pub open: String, + /// The time the market closes at on this date in HH:MM format + #[serde(rename = "close")] + pub close: String, + /// this field has been deprecated please ignore + #[serde(rename = "session_open", skip_serializing_if = "Option::is_none")] + pub session_open: Option, + /// this field has been deprecated please ignore + #[serde(rename = "session_close", skip_serializing_if = "Option::is_none")] + pub session_close: Option, +} + +impl Calendar { + /// The calendar API serves the full list of market days from 1970 to 2029. It can also be queried by specifying a start and/or end time to narrow down the results. In addition to the dates, the response also contains the specific open and close times for the market days, taking into account early closures. + pub fn new(date: String, open: String, close: String) -> Calendar { + Calendar { + date, + open, + close, + session_open: None, + session_close: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/clock.rs b/crates/alpaca_openapi/gen/broker/src/models/clock.rs new file mode 100644 index 0000000..85c3a94 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/clock.rs @@ -0,0 +1,40 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Clock : Represents the current market time and open/close events. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Clock { + /// Current timestamp + #[serde(rename = "timestamp")] + pub timestamp: String, + /// Whether the market is open or not + #[serde(rename = "is_open")] + pub is_open: bool, + /// Next market open timestamp + #[serde(rename = "next_open")] + pub next_open: String, + /// Next market close timestamp + #[serde(rename = "next_close")] + pub next_close: String, +} + +impl Clock { + /// Represents the current market time and open/close events. + pub fn new(timestamp: String, is_open: bool, next_open: String, next_close: String) -> Clock { + Clock { + timestamp, + is_open, + next_open, + next_close, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/contact.rs b/crates/alpaca_openapi/gen/broker/src/models/contact.rs new file mode 100644 index 0000000..ce9fde5 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/contact.rs @@ -0,0 +1,43 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Contact : Contact is the model for the account owner contact information. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Contact { + #[serde(rename = "email_address", skip_serializing_if = "Option::is_none")] + pub email_address: Option, + /// with country code, no hyphen or space + #[serde(rename = "phone_number", skip_serializing_if = "Option::is_none")] + pub phone_number: Option, + #[serde(rename = "street_address", skip_serializing_if = "Option::is_none")] + pub street_address: Option>, + #[serde(rename = "city", skip_serializing_if = "Option::is_none")] + pub city: Option, + #[serde(rename = "state", skip_serializing_if = "Option::is_none")] + pub state: Option, + #[serde(rename = "postal_code", skip_serializing_if = "Option::is_none")] + pub postal_code: Option, +} + +impl Contact { + /// Contact is the model for the account owner contact information. + pub fn new() -> Contact { + Contact { + email_address: None, + phone_number: None, + street_address: None, + city: None, + state: None, + postal_code: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/create_ach_relationship_request.rs b/crates/alpaca_openapi/gen/broker/src/models/create_ach_relationship_request.rs new file mode 100644 index 0000000..4281ee0 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/create_ach_relationship_request.rs @@ -0,0 +1,65 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// CreateAchRelationshipRequest : Represents the fields used in creation of a new ACHRelationship. You can create an ACHRelationship by passing the required fields here or if you have an account with Plaid you can use our integration with Plaid to create a relationship. Please see the documentation [here](https://alpaca.markets/docs/api-references/broker-api/funding/ach/#plaid-integration-for-bank-transfers) for more info on using Plaid with Alpaca +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateAchRelationshipRequest { + #[serde(rename = "account_owner_name")] + pub account_owner_name: String, + /// Must be CHECKING or SAVINGS + #[serde(rename = "bank_account_type")] + pub bank_account_type: BankAccountType, + /// In sandbox, this still must be a valid format + #[serde(rename = "bank_account_number")] + pub bank_account_number: String, + /// In sandbox, this still must be a valid format + #[serde(rename = "bank_routing_number")] + pub bank_routing_number: String, + #[serde(rename = "nickname", skip_serializing_if = "Option::is_none")] + pub nickname: Option, + /// If using Plaid, you can specify a Plaid processor token here + #[serde(rename = "processor_token", skip_serializing_if = "Option::is_none")] + pub processor_token: Option, +} + +impl CreateAchRelationshipRequest { + /// Represents the fields used in creation of a new ACHRelationship. You can create an ACHRelationship by passing the required fields here or if you have an account with Plaid you can use our integration with Plaid to create a relationship. Please see the documentation [here](https://alpaca.markets/docs/api-references/broker-api/funding/ach/#plaid-integration-for-bank-transfers) for more info on using Plaid with Alpaca + pub fn new( + account_owner_name: String, + bank_account_type: BankAccountType, + bank_account_number: String, + bank_routing_number: String, + ) -> CreateAchRelationshipRequest { + CreateAchRelationshipRequest { + account_owner_name, + bank_account_type, + bank_account_number, + bank_routing_number, + nickname: None, + processor_token: None, + } + } +} +/// Must be CHECKING or SAVINGS +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum BankAccountType { + #[serde(rename = "CHECKING")] + Checking, + #[serde(rename = "SAVINGS")] + Savings, +} + +impl Default for BankAccountType { + fn default() -> BankAccountType { + Self::Checking + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/create_bank_request.rs b/crates/alpaca_openapi/gen/broker/src/models/create_bank_request.rs new file mode 100644 index 0000000..274001b --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/create_bank_request.rs @@ -0,0 +1,78 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// CreateBankRequest : Represents the possible fields to send when creating a new associated Bank resource for an account +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateBankRequest { + /// Name of recipient bank + #[serde(rename = "name")] + pub name: String, + /// 9-Digit ABA RTN (Routing Number) or BIC + #[serde(rename = "bank_code")] + pub bank_code: String, + /// ABA (Domestic) or BIC (International) + #[serde(rename = "bank_code_type")] + pub bank_code_type: BankCodeType, + /// Only for international banks + #[serde(rename = "country", skip_serializing_if = "Option::is_none")] + pub country: Option, + /// Only for international banks + #[serde(rename = "state_province", skip_serializing_if = "Option::is_none")] + pub state_province: Option, + /// Only for international banks + #[serde(rename = "postal_code", skip_serializing_if = "Option::is_none")] + pub postal_code: Option, + /// Only for international banks + #[serde(rename = "city", skip_serializing_if = "Option::is_none")] + pub city: Option, + /// Only for international banks + #[serde(rename = "street_address", skip_serializing_if = "Option::is_none")] + pub street_address: Option, + #[serde(rename = "account_number")] + pub account_number: String, +} + +impl CreateBankRequest { + /// Represents the possible fields to send when creating a new associated Bank resource for an account + pub fn new( + name: String, + bank_code: String, + bank_code_type: BankCodeType, + account_number: String, + ) -> CreateBankRequest { + CreateBankRequest { + name, + bank_code, + bank_code_type, + country: None, + state_province: None, + postal_code: None, + city: None, + street_address: None, + account_number, + } + } +} +/// ABA (Domestic) or BIC (International) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum BankCodeType { + #[serde(rename = "ABA")] + Aba, + #[serde(rename = "BIC")] + Bic, +} + +impl Default for BankCodeType { + fn default() -> BankCodeType { + Self::Aba + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/create_journal_request.rs b/crates/alpaca_openapi/gen/broker/src/models/create_journal_request.rs new file mode 100644 index 0000000..fa886e1 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/create_journal_request.rs @@ -0,0 +1,87 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// CreateJournalRequest : Journals API allows you to move cash or securities from one account to another. This model represents the fields you can specify when creating a Journal Fixture Rules - No Fixtures - anything below limit is executed immediately - anything above limit is pending until executed at EOD, - With Fixtures - any status = rejected will be rejected EOD - any status = pending will be pending forever +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateJournalRequest { + /// The account_id you wish to journal to + #[serde(rename = "to_account")] + pub to_account: uuid::Uuid, + /// The account_id you wish to journal from + #[serde(rename = "from_account")] + pub from_account: uuid::Uuid, + #[serde(rename = "entry_type")] + pub entry_type: models::JournalEntryType, + /// Required if `entry_type` = `JNLC` + #[serde(rename = "amount", skip_serializing_if = "Option::is_none")] + pub amount: Option, + /// Required if `entry_type` = `JNLS` + #[serde(rename = "symbol", skip_serializing_if = "Option::is_none")] + pub symbol: Option, + /// Required if `entry_type` = `JNLS` + #[serde(rename = "qty", skip_serializing_if = "Option::is_none")] + pub qty: Option, + /// Max 1024 characters. Can include fixtures for amounts that are above the transaction limit + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, + /// Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation. + #[serde(rename = "transmitter_name", skip_serializing_if = "Option::is_none")] + pub transmitter_name: Option, + /// Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation. + #[serde( + rename = "transmitter_account_number", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_account_number: Option, + /// Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation. + #[serde( + rename = "transmitter_address", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_address: Option, + /// Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation. + #[serde( + rename = "transmitter_financial_institution", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_financial_institution: Option, + /// RFC 3339 format. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation. + #[serde( + rename = "transmitter_timestamp", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_timestamp: Option, +} + +impl CreateJournalRequest { + /// Journals API allows you to move cash or securities from one account to another. This model represents the fields you can specify when creating a Journal Fixture Rules - No Fixtures - anything below limit is executed immediately - anything above limit is pending until executed at EOD, - With Fixtures - any status = rejected will be rejected EOD - any status = pending will be pending forever + pub fn new( + to_account: uuid::Uuid, + from_account: uuid::Uuid, + entry_type: models::JournalEntryType, + ) -> CreateJournalRequest { + CreateJournalRequest { + to_account, + from_account, + entry_type, + amount: None, + symbol: None, + qty: None, + description: None, + transmitter_name: None, + transmitter_account_number: None, + transmitter_address: None, + transmitter_financial_institution: None, + transmitter_timestamp: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/create_order_request.rs b/crates/alpaca_openapi/gen/broker/src/models/create_order_request.rs new file mode 100644 index 0000000..aa3cdc0 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/create_order_request.rs @@ -0,0 +1,87 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// CreateOrderRequest : +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateOrderRequest { + /// Symbol or asset ID to identify the asset to trade + #[serde(rename = "symbol")] + pub symbol: String, + /// Number of shares to trade. Can be fractionable for only market and day order types. + #[serde(rename = "qty", skip_serializing_if = "Option::is_none")] + pub qty: Option, + /// Dollar amount to trade. Cannot work with qty. Can only work for market order types and time_in_force = day. + #[serde(rename = "notional", skip_serializing_if = "Option::is_none")] + pub notional: Option, + #[serde(rename = "side")] + pub side: models::OrderSide, + #[serde(rename = "type")] + pub r#type: models::OrderType, + #[serde(rename = "time_in_force")] + pub time_in_force: models::TimeInForce, + /// Required if type is limit or stop_limit + #[serde(rename = "limit_price", skip_serializing_if = "Option::is_none")] + pub limit_price: Option, + /// Required if type is stop or stop_limit + #[serde(rename = "stop_price", skip_serializing_if = "Option::is_none")] + pub stop_price: Option, + /// If type is trailing_stop, then one of trail_price or trail_percent is required + #[serde(rename = "trail_price", skip_serializing_if = "Option::is_none")] + pub trail_price: Option, + /// If type is trailing_stop, then one of trail_price or trail_percent is required + #[serde(rename = "trail_percent", skip_serializing_if = "Option::is_none")] + pub trail_percent: Option, + /// Defaults to false. If true, order will be eligible to execute in premarket/afterhours. Only works with type limit and time_in_force = day. + #[serde(rename = "extended_hours", skip_serializing_if = "Option::is_none")] + pub extended_hours: Option, + /// A unique identifier for the order. Automatically generated if not sent. (<= 48 characters) + #[serde(rename = "client_order_id", skip_serializing_if = "Option::is_none")] + pub client_order_id: Option, + #[serde(rename = "order_class", skip_serializing_if = "Option::is_none")] + pub order_class: Option, + #[serde(rename = "take_profit", skip_serializing_if = "Option::is_none")] + pub take_profit: Option>, + #[serde(rename = "stop_loss", skip_serializing_if = "Option::is_none")] + pub stop_loss: Option>, + /// The commission you want to collect from the user. + #[serde(rename = "commission", skip_serializing_if = "Option::is_none")] + pub commission: Option, +} + +impl CreateOrderRequest { + /// + pub fn new( + symbol: String, + side: models::OrderSide, + r#type: models::OrderType, + time_in_force: models::TimeInForce, + ) -> CreateOrderRequest { + CreateOrderRequest { + symbol, + qty: None, + notional: None, + side, + r#type, + time_in_force, + limit_price: None, + stop_price: None, + trail_price: None, + trail_percent: None, + extended_hours: None, + client_order_id: None, + order_class: None, + take_profit: None, + stop_loss: None, + commission: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/create_order_request_stop_loss.rs b/crates/alpaca_openapi/gen/broker/src/models/create_order_request_stop_loss.rs new file mode 100644 index 0000000..06e4d5e --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/create_order_request_stop_loss.rs @@ -0,0 +1,30 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// CreateOrderRequestStopLoss : Takes in a string/number values for stop_price and limit_price +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateOrderRequestStopLoss { + #[serde(rename = "stop_price", skip_serializing_if = "Option::is_none")] + pub stop_price: Option, + #[serde(rename = "limit_price", skip_serializing_if = "Option::is_none")] + pub limit_price: Option, +} + +impl CreateOrderRequestStopLoss { + /// Takes in a string/number values for stop_price and limit_price + pub fn new() -> CreateOrderRequestStopLoss { + CreateOrderRequestStopLoss { + stop_price: None, + limit_price: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/create_order_request_take_profit.rs b/crates/alpaca_openapi/gen/broker/src/models/create_order_request_take_profit.rs new file mode 100644 index 0000000..48ddc4a --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/create_order_request_take_profit.rs @@ -0,0 +1,25 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// CreateOrderRequestTakeProfit : Takes in a string/number value for limit_price +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateOrderRequestTakeProfit { + #[serde(rename = "limit_price", skip_serializing_if = "Option::is_none")] + pub limit_price: Option, +} + +impl CreateOrderRequestTakeProfit { + /// Takes in a string/number value for limit_price + pub fn new() -> CreateOrderRequestTakeProfit { + CreateOrderRequestTakeProfit { limit_price: None } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/create_transfer_request.rs b/crates/alpaca_openapi/gen/broker/src/models/create_transfer_request.rs new file mode 100644 index 0000000..31fc098 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/create_transfer_request.rs @@ -0,0 +1,59 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// CreateTransferRequest : [See main docs here](https://alpaca.markets/docs/api-references/broker-api/funding/transfers/#creating-a-transfer-entity) +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateTransferRequest { + #[serde(rename = "transfer_type")] + pub transfer_type: models::TransferType, + /// Required if type = `ach` The ach_relationship created for the account_id [here](https://alpaca.markets/docs/api-references/broker-api/funding/ach/#creating-an-ach-relationship) + #[serde(rename = "relationship_id", skip_serializing_if = "Option::is_none")] + pub relationship_id: Option, + /// Required if type = `wire` The bank_relationship created for the account_id [here](https://alpaca.markets/docs/api-references/broker-api/funding/bank/#creating-a-new-bank-relationship) + #[serde(rename = "bank_id", skip_serializing_if = "Option::is_none")] + pub bank_id: Option, + /// Must be > 0.00 + #[serde(rename = "amount")] + pub amount: String, + #[serde(rename = "direction")] + pub direction: models::TransferDirection, + #[serde(rename = "timing")] + pub timing: models::TransferTiming, + /// Additional details for when type = `wire` + #[serde( + rename = "additional_information", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub additional_information: Option>, +} + +impl CreateTransferRequest { + /// [See main docs here](https://alpaca.markets/docs/api-references/broker-api/funding/transfers/#creating-a-transfer-entity) + pub fn new( + transfer_type: models::TransferType, + amount: String, + direction: models::TransferDirection, + timing: models::TransferTiming, + ) -> CreateTransferRequest { + CreateTransferRequest { + transfer_type, + relationship_id: None, + bank_id: None, + amount, + direction, + timing, + additional_information: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/create_watchlist_request.rs b/crates/alpaca_openapi/gen/broker/src/models/create_watchlist_request.rs new file mode 100644 index 0000000..c6fe7a1 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/create_watchlist_request.rs @@ -0,0 +1,29 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// CreateWatchlistRequest : This model represents the fields you can specify when Creating or Updating/Replacing a Watchlist +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateWatchlistRequest { + /// The watchlist name + #[serde(rename = "name")] + pub name: String, + /// The new list of symbol names to watch + #[serde(rename = "symbols")] + pub symbols: Vec, +} + +impl CreateWatchlistRequest { + /// This model represents the fields you can specify when Creating or Updating/Replacing a Watchlist + pub fn new(name: String, symbols: Vec) -> CreateWatchlistRequest { + CreateWatchlistRequest { name, symbols } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/custodial_account_minor_identity.rs b/crates/alpaca_openapi/gen/broker/src/models/custodial_account_minor_identity.rs new file mode 100644 index 0000000..a6af98b --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/custodial_account_minor_identity.rs @@ -0,0 +1,64 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// CustodialAccountMinorIdentity : Represents Identity information for a minor that an account of type \"custodial\" is for +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CustodialAccountMinorIdentity { + #[serde(rename = "given_name")] + pub given_name: String, + #[serde(rename = "family_name")] + pub family_name: String, + #[serde(rename = "date_of_birth")] + pub date_of_birth: String, + #[serde(rename = "tax_id", skip_serializing_if = "Option::is_none")] + pub tax_id: Option, + #[serde(rename = "tax_id_type", skip_serializing_if = "Option::is_none")] + pub tax_id_type: Option, + #[serde( + rename = "country_of_citizenship", + skip_serializing_if = "Option::is_none" + )] + pub country_of_citizenship: Option, + #[serde(rename = "country_of_birth", skip_serializing_if = "Option::is_none")] + pub country_of_birth: Option, + #[serde(rename = "country_of_tax_residence")] + pub country_of_tax_residence: String, + #[serde(rename = "state")] + pub state: String, + #[serde(rename = "email")] + pub email: String, +} + +impl CustodialAccountMinorIdentity { + /// Represents Identity information for a minor that an account of type \"custodial\" is for + pub fn new( + given_name: String, + family_name: String, + date_of_birth: String, + country_of_tax_residence: String, + state: String, + email: String, + ) -> CustodialAccountMinorIdentity { + CustodialAccountMinorIdentity { + given_name, + family_name, + date_of_birth, + tax_id: None, + tax_id_type: None, + country_of_citizenship: None, + country_of_birth: None, + country_of_tax_residence, + state, + email, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/disclosure_context_annotation.rs b/crates/alpaca_openapi/gen/broker/src/models/disclosure_context_annotation.rs new file mode 100644 index 0000000..0d65efd --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/disclosure_context_annotation.rs @@ -0,0 +1,80 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct DisclosureContextAnnotation { + /// Specifies the type of disclosure annotation. Valid types are FINRA affiliations, for users affiliated with or employed by a FINRA member firm, a Stock Exchange Member, FINRA, Registered Investment Advisor, or a Municipal Securities Broker/Dealer; Company control relationships, for senior executives, and 10% or greater shareholders, of a publicly traded company; and immediate family members of politically exposed individuals. + #[serde(rename = "context_type")] + pub context_type: ContextType, + /// Required for FINRA affiliations and controlled firms. + #[serde(rename = "company_name", skip_serializing_if = "Option::is_none")] + pub company_name: Option, + /// Required for FINRA affiliations and controlled firms. + #[serde( + rename = "company_street_address", + skip_serializing_if = "Option::is_none" + )] + pub company_street_address: Option, + /// Required for FINRA affiliations and controlled firms. + #[serde(rename = "company_city", skip_serializing_if = "Option::is_none")] + pub company_city: Option, + /// Required if and only if `company_country` is `USA`. + #[serde(rename = "company_state", skip_serializing_if = "Option::is_none")] + pub company_state: Option, + /// Required for FINRA affiliations and controlled firms. + #[serde(rename = "company_country", skip_serializing_if = "Option::is_none")] + pub company_country: Option, + /// Required for FINRA affiliations and controlled firms. + #[serde( + rename = "company_compliance_email", + skip_serializing_if = "Option::is_none" + )] + pub company_compliance_email: Option, + /// Required for immediate family members of politically exposed persons. + #[serde(rename = "given_name", skip_serializing_if = "Option::is_none")] + pub given_name: Option, + /// Required for immediate family members of politically exposed persons. + #[serde(rename = "family_name", skip_serializing_if = "Option::is_none")] + pub family_name: Option, +} + +impl DisclosureContextAnnotation { + pub fn new(context_type: ContextType) -> DisclosureContextAnnotation { + DisclosureContextAnnotation { + context_type, + company_name: None, + company_street_address: None, + company_city: None, + company_state: None, + company_country: None, + company_compliance_email: None, + given_name: None, + family_name: None, + } + } +} +/// Specifies the type of disclosure annotation. Valid types are FINRA affiliations, for users affiliated with or employed by a FINRA member firm, a Stock Exchange Member, FINRA, Registered Investment Advisor, or a Municipal Securities Broker/Dealer; Company control relationships, for senior executives, and 10% or greater shareholders, of a publicly traded company; and immediate family members of politically exposed individuals. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum ContextType { + #[serde(rename = "CONTROLLED_FIRM")] + ControlledFirm, + #[serde(rename = "IMMEDIATE_FAMILY_EXPOSED")] + ImmediateFamilyExposed, + #[serde(rename = "AFFILIATE_FIRM")] + AffiliateFirm, +} + +impl Default for ContextType { + fn default() -> ContextType { + Self::ControlledFirm + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/disclosures.rs b/crates/alpaca_openapi/gen/broker/src/models/disclosures.rs new file mode 100644 index 0000000..74f2ab7 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/disclosures.rs @@ -0,0 +1,83 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Disclosures : Disclosures fields denote if the account owner falls under each category defined by FINRA rule. The client has to ask questions for the end user and the values should reflect their answers. If one of the answers is true (yes), the account goes into ACTION_REQUIRED status. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Disclosures { + #[serde(rename = "employment_status", skip_serializing_if = "Option::is_none")] + pub employment_status: Option, + #[serde(rename = "employer_name", skip_serializing_if = "Option::is_none")] + pub employer_name: Option, + #[serde(rename = "employer_address", skip_serializing_if = "Option::is_none")] + pub employer_address: Option, + #[serde( + rename = "employment_position", + skip_serializing_if = "Option::is_none" + )] + pub employment_position: Option, + #[serde(rename = "is_control_person")] + pub is_control_person: bool, + #[serde(rename = "is_affiliated_exchange_or_finra")] + pub is_affiliated_exchange_or_finra: bool, + #[serde(rename = "is_politically_exposed")] + pub is_politically_exposed: bool, + #[serde(rename = "immediate_family_exposed")] + pub immediate_family_exposed: bool, + /// Array of annotations describing the rational for marking `is_control_person`, `is_affiliated_exchange_or_finra`, and/or `immediate_family_exposed` as true + #[serde( + rename = "context", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub context: Option>>, +} + +impl Disclosures { + /// Disclosures fields denote if the account owner falls under each category defined by FINRA rule. The client has to ask questions for the end user and the values should reflect their answers. If one of the answers is true (yes), the account goes into ACTION_REQUIRED status. + pub fn new( + is_control_person: bool, + is_affiliated_exchange_or_finra: bool, + is_politically_exposed: bool, + immediate_family_exposed: bool, + ) -> Disclosures { + Disclosures { + employment_status: None, + employer_name: None, + employer_address: None, + employment_position: None, + is_control_person, + is_affiliated_exchange_or_finra, + is_politically_exposed, + immediate_family_exposed, + context: None, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum EmploymentStatus { + #[serde(rename = "unemployed")] + Unemployed, + #[serde(rename = "employed")] + Employed, + #[serde(rename = "student")] + Student, + #[serde(rename = "retired")] + Retired, +} + +impl Default for EmploymentStatus { + fn default() -> EmploymentStatus { + Self::Unemployed + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/document_inner.rs b/crates/alpaca_openapi/gen/broker/src/models/document_inner.rs new file mode 100644 index 0000000..4edef3d --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/document_inner.rs @@ -0,0 +1,35 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct DocumentInner { + #[serde(rename = "document_id")] + pub document_id: uuid::Uuid, + #[serde(rename = "document_type")] + pub document_type: models::DocumentType, + #[serde(rename = "document_date")] + pub document_date: String, +} + +impl DocumentInner { + pub fn new( + document_id: uuid::Uuid, + document_type: models::DocumentType, + document_date: String, + ) -> DocumentInner { + DocumentInner { + document_id, + document_type, + document_date, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/document_type.rs b/crates/alpaca_openapi/gen/broker/src/models/document_type.rs new file mode 100644 index 0000000..0d45a84 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/document_type.rs @@ -0,0 +1,48 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// DocumentType : - identity_verification: identity verification document - address_verification: address verification document - date_of_birth_verification: date of birth verification document - tax_id_verification: tax ID verification document - account_approval_letter: 407 approval letter - cip_result: initial CIP result +/// - identity_verification: identity verification document - address_verification: address verification document - date_of_birth_verification: date of birth verification document - tax_id_verification: tax ID verification document - account_approval_letter: 407 approval letter - cip_result: initial CIP result +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum DocumentType { + #[serde(rename = "identity_verification")] + IdentityVerification, + #[serde(rename = "address_verification")] + AddressVerification, + #[serde(rename = "date_of_birth_verification")] + DateOfBirthVerification, + #[serde(rename = "tax_id_verification")] + TaxIdVerification, + #[serde(rename = "account_approval_letter")] + AccountApprovalLetter, + #[serde(rename = "cip_result")] + CipResult, +} + +impl ToString for DocumentType { + fn to_string(&self) -> String { + match self { + Self::IdentityVerification => String::from("identity_verification"), + Self::AddressVerification => String::from("address_verification"), + Self::DateOfBirthVerification => String::from("date_of_birth_verification"), + Self::TaxIdVerification => String::from("tax_id_verification"), + Self::AccountApprovalLetter => String::from("account_approval_letter"), + Self::CipResult => String::from("cip_result"), + } + } +} + +impl Default for DocumentType { + fn default() -> DocumentType { + Self::IdentityVerification + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/document_upload.rs b/crates/alpaca_openapi/gen/broker/src/models/document_upload.rs new file mode 100644 index 0000000..130b23f --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/document_upload.rs @@ -0,0 +1,40 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// DocumentUpload : If an account has documents after the submission, it has the Document model in exchange with DocumentUpload. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct DocumentUpload { + #[serde(rename = "document_type")] + pub document_type: models::DocumentType, + #[serde(rename = "document_sub_type", skip_serializing_if = "Option::is_none")] + pub document_sub_type: Option, + #[serde(rename = "content")] + pub content: String, + #[serde(rename = "mime_type")] + pub mime_type: String, +} + +impl DocumentUpload { + /// If an account has documents after the submission, it has the Document model in exchange with DocumentUpload. + pub fn new( + document_type: models::DocumentType, + content: String, + mime_type: String, + ) -> DocumentUpload { + DocumentUpload { + document_type, + document_sub_type: None, + content, + mime_type, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/document_upload_request.rs b/crates/alpaca_openapi/gen/broker/src/models/document_upload_request.rs new file mode 100644 index 0000000..7378e32 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/document_upload_request.rs @@ -0,0 +1,40 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// DocumentUploadRequest : If an account has documents after the submission, it has the Document model in exchange with DocumentUploadRequest. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct DocumentUploadRequest { + #[serde(rename = "document_type")] + pub document_type: models::DocumentType, + #[serde(rename = "document_sub_type", skip_serializing_if = "Option::is_none")] + pub document_sub_type: Option, + #[serde(rename = "content")] + pub content: String, + #[serde(rename = "mime_type")] + pub mime_type: String, +} + +impl DocumentUploadRequest { + /// If an account has documents after the submission, it has the Document model in exchange with DocumentUploadRequest. + pub fn new( + document_type: models::DocumentType, + content: String, + mime_type: String, + ) -> DocumentUploadRequest { + DocumentUploadRequest { + document_type, + document_sub_type: None, + content, + mime_type, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/error.rs b/crates/alpaca_openapi/gen/broker/src/models/error.rs new file mode 100644 index 0000000..4d0b0ad --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/error.rs @@ -0,0 +1,25 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Error { + #[serde(rename = "code")] + pub code: f64, + #[serde(rename = "message")] + pub message: String, +} + +impl Error { + pub fn new(code: f64, message: String) -> Error { + Error { code, message } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/exchange.rs b/crates/alpaca_openapi/gen/broker/src/models/exchange.rs new file mode 100644 index 0000000..09352ff --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/exchange.rs @@ -0,0 +1,57 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Exchange : Represents the exchange where an asset is traded. For Stocks: - AMEX - ARCA - BATS - NYSE - NASDAQ - NYSEARCA - OTC For Crypto: - ERSX - FTXU +/// Represents the exchange where an asset is traded. For Stocks: - AMEX - ARCA - BATS - NYSE - NASDAQ - NYSEARCA - OTC For Crypto: - ERSX - FTXU +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Exchange { + #[serde(rename = "AMEX")] + Amex, + #[serde(rename = "ARCA")] + Arca, + #[serde(rename = "BATS")] + Bats, + #[serde(rename = "NYSE")] + Nyse, + #[serde(rename = "NASDAQ")] + Nasdaq, + #[serde(rename = "NYSEARCA")] + Nysearca, + #[serde(rename = "OTC")] + Otc, + #[serde(rename = "ERSX")] + Ersx, + #[serde(rename = "FTXU")] + Ftxu, +} + +impl ToString for Exchange { + fn to_string(&self) -> String { + match self { + Self::Amex => String::from("AMEX"), + Self::Arca => String::from("ARCA"), + Self::Bats => String::from("BATS"), + Self::Nyse => String::from("NYSE"), + Self::Nasdaq => String::from("NASDAQ"), + Self::Nysearca => String::from("NYSEARCA"), + Self::Otc => String::from("OTC"), + Self::Ersx => String::from("ERSX"), + Self::Ftxu => String::from("FTXU"), + } + } +} + +impl Default for Exchange { + fn default() -> Exchange { + Self::Amex + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/identity.rs b/crates/alpaca_openapi/gen/broker/src/models/identity.rs new file mode 100644 index 0000000..9529de8 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/identity.rs @@ -0,0 +1,119 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Identity : Identity is the model to provide account owner’s identity information. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Identity { + #[serde(rename = "given_name")] + pub given_name: String, + #[serde(rename = "family_name")] + pub family_name: String, + #[serde(rename = "date_of_birth")] + pub date_of_birth: String, + #[serde(rename = "tax_id", skip_serializing_if = "Option::is_none")] + pub tax_id: Option, + #[serde(rename = "tax_id_type", skip_serializing_if = "Option::is_none")] + pub tax_id_type: Option, + /// [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html). + #[serde( + rename = "country_of_citizenship", + skip_serializing_if = "Option::is_none" + )] + pub country_of_citizenship: Option, + /// [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html). + #[serde(rename = "country_of_birth", skip_serializing_if = "Option::is_none")] + pub country_of_birth: Option, + /// [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html). + #[serde(rename = "country_of_tax_residence")] + pub country_of_tax_residence: String, + #[serde(rename = "funding_source")] + pub funding_source: Vec, + #[serde(rename = "annual_income_min", skip_serializing_if = "Option::is_none")] + pub annual_income_min: Option, + #[serde(rename = "annual_income_max", skip_serializing_if = "Option::is_none")] + pub annual_income_max: Option, + #[serde( + rename = "liquid_net_worth_min", + skip_serializing_if = "Option::is_none" + )] + pub liquid_net_worth_min: Option, + #[serde( + rename = "liquid_net_worth_max", + skip_serializing_if = "Option::is_none" + )] + pub liquid_net_worth_max: Option, + #[serde( + rename = "total_net_worth_min", + skip_serializing_if = "Option::is_none" + )] + pub total_net_worth_min: Option, + #[serde( + rename = "total_net_worth_max", + skip_serializing_if = "Option::is_none" + )] + pub total_net_worth_max: Option, + /// any extra information used for KYC purposes + #[serde(rename = "extra", skip_serializing_if = "Option::is_none")] + pub extra: Option, +} + +impl Identity { + /// Identity is the model to provide account owner’s identity information. + pub fn new( + given_name: String, + family_name: String, + date_of_birth: String, + country_of_tax_residence: String, + funding_source: Vec, + ) -> Identity { + Identity { + given_name, + family_name, + date_of_birth, + tax_id: None, + tax_id_type: None, + country_of_citizenship: None, + country_of_birth: None, + country_of_tax_residence, + funding_source, + annual_income_min: None, + annual_income_max: None, + liquid_net_worth_min: None, + liquid_net_worth_max: None, + total_net_worth_min: None, + total_net_worth_max: None, + extra: None, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum FundingSource { + #[serde(rename = "employment_income")] + EmploymentIncome, + #[serde(rename = "investments")] + Investments, + #[serde(rename = "inheritance")] + Inheritance, + #[serde(rename = "business_income")] + BusinessIncome, + #[serde(rename = "savings")] + Savings, + #[serde(rename = "family")] + Family, +} + +impl Default for FundingSource { + fn default() -> FundingSource { + Self::EmploymentIncome + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/issue_o_auth_token_response.rs b/crates/alpaca_openapi/gen/broker/src/models/issue_o_auth_token_response.rs new file mode 100644 index 0000000..87cc352 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/issue_o_auth_token_response.rs @@ -0,0 +1,52 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// IssueOAuthTokenResponse : +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct IssueOAuthTokenResponse { + /// OAuth token + #[serde(rename = "access_token")] + pub access_token: String, + /// Always `Bearer` + #[serde(rename = "token_type")] + pub token_type: TokenType, + /// Token’s scope + #[serde(rename = "scope")] + pub scope: String, +} + +impl IssueOAuthTokenResponse { + /// + pub fn new( + access_token: String, + token_type: TokenType, + scope: String, + ) -> IssueOAuthTokenResponse { + IssueOAuthTokenResponse { + access_token, + token_type, + scope, + } + } +} +/// Always `Bearer` +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TokenType { + #[serde(rename = "Bearer")] + Bearer, +} + +impl Default for TokenType { + fn default() -> TokenType { + Self::Bearer + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/jnlc.rs b/crates/alpaca_openapi/gen/broker/src/models/jnlc.rs new file mode 100644 index 0000000..19cd101 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/jnlc.rs @@ -0,0 +1,64 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Jnlc : Journal information specific to cash transfers. This field is required for `Journal`s with an `entry_type` of `jnlc` (cash transfers), but will be null for those with `jnls` (securities transfers). +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Jnlc { + /// ID the amount goes to. Only valid for JNLC journals. Null for JNLS. + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, + /// Only valid for JNLC journals. Null for JNLS. + #[serde(rename = "net_amount")] + pub net_amount: String, + /// Only valid for JNLC journals. Null for JNLS. Max 255 characters. + #[serde(rename = "transmitter_name", skip_serializing_if = "Option::is_none")] + pub transmitter_name: Option, + /// Only valid for JNLC journals. Null for JNLS.max 255 characters + #[serde( + rename = "transmitter_account_number", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_account_number: Option, + /// Only valid for JNLC journals. Null for JNLS.max 255 characters + #[serde( + rename = "transmitter_address", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_address: Option, + /// Only valid for JNLC journals. Null for JNLS.max 255 characters + #[serde( + rename = "transmitter_financial_institution", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_financial_institution: Option, + /// Only valid for JNLC journals. Null for JNLS. + #[serde( + rename = "transmitter_timestamp", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_timestamp: Option, +} + +impl Jnlc { + /// Journal information specific to cash transfers. This field is required for `Journal`s with an `entry_type` of `jnlc` (cash transfers), but will be null for those with `jnls` (securities transfers). + pub fn new(net_amount: String) -> Jnlc { + Jnlc { + description: None, + net_amount, + transmitter_name: None, + transmitter_account_number: None, + transmitter_address: None, + transmitter_financial_institution: None, + transmitter_timestamp: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/jnls.rs b/crates/alpaca_openapi/gen/broker/src/models/jnls.rs new file mode 100644 index 0000000..2306ada --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/jnls.rs @@ -0,0 +1,32 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Jnls : Journal information specific to securities transfers. This field is required for `Journal`s with an `entry_type` of `jnls` (securities transfers), but will be null for those with `jnlc` (cash transfers). +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Jnls { + /// Only valid for JNLS journals. Null for JNLC. + #[serde(rename = "symbol")] + pub symbol: String, + /// Only valid for JNLS journals. Null for JNLC. + #[serde(rename = "qty")] + pub qty: String, + /// Only valid for JNLS journals. Null for JNLC. + #[serde(rename = "price")] + pub price: String, +} + +impl Jnls { + /// Journal information specific to securities transfers. This field is required for `Journal`s with an `entry_type` of `jnls` (securities transfers), but will be null for those with `jnlc` (cash transfers). + pub fn new(symbol: String, qty: String, price: String) -> Jnls { + Jnls { symbol, qty, price } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/journal.rs b/crates/alpaca_openapi/gen/broker/src/models/journal.rs new file mode 100644 index 0000000..f505ded --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/journal.rs @@ -0,0 +1,107 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Journal : Represents a cash or security transfer between accounts, as specified by the `entry_type` parameter. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Journal { + /// journal ID + #[serde(rename = "id")] + pub id: uuid::Uuid, + #[serde(rename = "entry_type")] + pub entry_type: models::JournalEntryType, + /// account ID the shares go from + #[serde(rename = "from_account")] + pub from_account: uuid::Uuid, + /// account ID the shares go to + #[serde(rename = "to_account")] + pub to_account: uuid::Uuid, + #[serde(rename = "settle_date")] + pub settle_date: String, + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + /// Only valid for JNLS journals. Null for JNLC. + #[serde(rename = "symbol")] + pub symbol: String, + /// Only valid for JNLS journals. Null for JNLC. + #[serde(rename = "qty")] + pub qty: String, + /// Only valid for JNLS journals. Null for JNLC. + #[serde(rename = "price")] + pub price: String, + /// ID the amount goes to. Only valid for JNLC journals. Null for JNLS. + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, + /// Only valid for JNLC journals. Null for JNLS. + #[serde(rename = "net_amount")] + pub net_amount: String, + /// Only valid for JNLC journals. Null for JNLS. Max 255 characters. + #[serde(rename = "transmitter_name", skip_serializing_if = "Option::is_none")] + pub transmitter_name: Option, + /// Only valid for JNLC journals. Null for JNLS.max 255 characters + #[serde( + rename = "transmitter_account_number", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_account_number: Option, + /// Only valid for JNLC journals. Null for JNLS.max 255 characters + #[serde( + rename = "transmitter_address", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_address: Option, + /// Only valid for JNLC journals. Null for JNLS.max 255 characters + #[serde( + rename = "transmitter_financial_institution", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_financial_institution: Option, + /// Only valid for JNLC journals. Null for JNLS. + #[serde( + rename = "transmitter_timestamp", + skip_serializing_if = "Option::is_none" + )] + pub transmitter_timestamp: Option, +} + +impl Journal { + /// Represents a cash or security transfer between accounts, as specified by the `entry_type` parameter. + pub fn new( + id: uuid::Uuid, + entry_type: models::JournalEntryType, + from_account: uuid::Uuid, + to_account: uuid::Uuid, + settle_date: String, + symbol: String, + qty: String, + price: String, + net_amount: String, + ) -> Journal { + Journal { + id, + entry_type, + from_account, + to_account, + settle_date, + status: None, + symbol, + qty, + price, + description: None, + net_amount, + transmitter_name: None, + transmitter_account_number: None, + transmitter_address: None, + transmitter_financial_institution: None, + transmitter_timestamp: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/journal_data.rs b/crates/alpaca_openapi/gen/broker/src/models/journal_data.rs new file mode 100644 index 0000000..c52f189 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/journal_data.rs @@ -0,0 +1,47 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct JournalData { + #[serde(rename = "entry_type")] + pub entry_type: models::JournalEntryType, + #[serde(rename = "from_account")] + pub from_account: uuid::Uuid, + #[serde(rename = "to_account")] + pub to_account: uuid::Uuid, + /// Required for JNLC. The dollar amount to move. It has to be a positive value. + #[serde(rename = "amount", skip_serializing_if = "Option::is_none")] + pub amount: Option, + /// Required for JNLS. + #[serde(rename = "symbol", skip_serializing_if = "Option::is_none")] + pub symbol: Option, + /// Required for JNLS. The number of shares to move. It has to be a positive value. + #[serde(rename = "qty", skip_serializing_if = "Option::is_none")] + pub qty: Option, +} + +impl JournalData { + pub fn new( + entry_type: models::JournalEntryType, + from_account: uuid::Uuid, + to_account: uuid::Uuid, + ) -> JournalData { + JournalData { + entry_type, + from_account, + to_account, + amount: None, + symbol: None, + qty: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/journal_entry_type.rs b/crates/alpaca_openapi/gen/broker/src/models/journal_entry_type.rs new file mode 100644 index 0000000..b673d84 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/journal_entry_type.rs @@ -0,0 +1,36 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// JournalEntryType : This enum represents the various kinds of Journal alpaca supports. Current values are: - **JNLC** Journal Cash between accounts - **JNLS** Journal Securities between accounts +/// This enum represents the various kinds of Journal alpaca supports. Current values are: - **JNLC** Journal Cash between accounts - **JNLS** Journal Securities between accounts +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum JournalEntryType { + #[serde(rename = "JNLC")] + Jnlc, + #[serde(rename = "JNLS")] + Jnls, +} + +impl ToString for JournalEntryType { + fn to_string(&self) -> String { + match self { + Self::Jnlc => String::from("JNLC"), + Self::Jnls => String::from("JNLS"), + } + } +} + +impl Default for JournalEntryType { + fn default() -> JournalEntryType { + Self::Jnlc + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/journal_resource.rs b/crates/alpaca_openapi/gen/broker/src/models/journal_resource.rs new file mode 100644 index 0000000..de237c4 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/journal_resource.rs @@ -0,0 +1,26 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(tag = "entry_type")] +pub enum JournalResource { + #[serde(rename = "JNLC")] + Jnlc(Box), + #[serde(rename = "JNLS")] + Jnls(Box), +} + +impl Default for JournalResource { + fn default() -> Self { + Self::Jnlc(Default::default()) + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/journal_status.rs b/crates/alpaca_openapi/gen/broker/src/models/journal_status.rs new file mode 100644 index 0000000..36c32fa --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/journal_status.rs @@ -0,0 +1,48 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// JournalStatus : Represents the status that a Journal instance can be in. Current Values: - pending - canceled - executed - queued - rejected - deleted +/// Represents the status that a Journal instance can be in. Current Values: - pending - canceled - executed - queued - rejected - deleted +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum JournalStatus { + #[serde(rename = "pending")] + Pending, + #[serde(rename = "canceled")] + Canceled, + #[serde(rename = "executed")] + Executed, + #[serde(rename = "queued")] + Queued, + #[serde(rename = "rejected")] + Rejected, + #[serde(rename = "deleted")] + Deleted, +} + +impl ToString for JournalStatus { + fn to_string(&self) -> String { + match self { + Self::Pending => String::from("pending"), + Self::Canceled => String::from("canceled"), + Self::Executed => String::from("executed"), + Self::Queued => String::from("queued"), + Self::Rejected => String::from("rejected"), + Self::Deleted => String::from("deleted"), + } + } +} + +impl Default for JournalStatus { + fn default() -> JournalStatus { + Self::Pending + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/journal_status_event.rs b/crates/alpaca_openapi/gen/broker/src/models/journal_status_event.rs new file mode 100644 index 0000000..14c5fa6 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/journal_status_event.rs @@ -0,0 +1,52 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// JournalStatusEvent : Represents a change in a Journal's status, sent over the events streaming api. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct JournalStatusEvent { + /// Timestamp of event + #[serde(rename = "at")] + pub at: String, + #[serde(rename = "entry_type")] + pub entry_type: models::JournalEntryType, + /// Monotonically increasing 64bit integer + #[serde(rename = "event_id")] + pub event_id: i32, + /// The UUID of the related Journal + #[serde(rename = "journal_id")] + pub journal_id: uuid::Uuid, + #[serde(rename = "status_from")] + pub status_from: models::JournalStatus, + #[serde(rename = "status_to")] + pub status_to: models::JournalStatus, +} + +impl JournalStatusEvent { + /// Represents a change in a Journal's status, sent over the events streaming api. + pub fn new( + at: String, + entry_type: models::JournalEntryType, + event_id: i32, + journal_id: uuid::Uuid, + status_from: models::JournalStatus, + status_to: models::JournalStatus, + ) -> JournalStatusEvent { + JournalStatusEvent { + at, + entry_type, + event_id, + journal_id, + status_from, + status_to, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/kyc_result.rs b/crates/alpaca_openapi/gen/broker/src/models/kyc_result.rs new file mode 100644 index 0000000..4c8b59f --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/kyc_result.rs @@ -0,0 +1,39 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// KycResult : Hold information about the result of KYC. Please see the documentation [here](https://alpaca.markets/docs/api-references/broker-api/events/#kyc-results) for more indepth details +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct KycResult { + #[serde(rename = "reject", skip_serializing_if = "Option::is_none")] + pub reject: Option, + #[serde(rename = "accept", skip_serializing_if = "Option::is_none")] + pub accept: Option, + #[serde(rename = "indeterminate", skip_serializing_if = "Option::is_none")] + pub indeterminate: Option, + #[serde( + rename = "addidional_information", + skip_serializing_if = "Option::is_none" + )] + pub addidional_information: Option, +} + +impl KycResult { + /// Hold information about the result of KYC. Please see the documentation [here](https://alpaca.markets/docs/api-references/broker-api/events/#kyc-results) for more indepth details + pub fn new() -> KycResult { + KycResult { + reject: None, + accept: None, + indeterminate: None, + addidional_information: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/mod.rs b/crates/alpaca_openapi/gen/broker/src/models/mod.rs new file mode 100644 index 0000000..3e03c0a --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/mod.rs @@ -0,0 +1,178 @@ +pub mod account; +pub use self::account::Account; +pub mod account_configurations; +pub use self::account_configurations::AccountConfigurations; +pub mod account_creation_request; +pub use self::account_creation_request::AccountCreationRequest; +pub mod account_document; +pub use self::account_document::AccountDocument; +pub mod account_extended; +pub use self::account_extended::AccountExtended; +pub mod account_status; +pub use self::account_status::AccountStatus; +pub mod account_status_event; +pub use self::account_status_event::AccountStatusEvent; +pub mod account_type; +pub use self::account_type::AccountType; +pub mod account_update_request; +pub use self::account_update_request::AccountUpdateRequest; +pub mod ach_relationship; +pub use self::ach_relationship::AchRelationship; +pub mod activity; +pub use self::activity::Activity; +pub mod activity_item; +pub use self::activity_item::ActivityItem; +pub mod activity_type; +pub use self::activity_type::ActivityType; +pub mod agreement; +pub use self::agreement::Agreement; +pub mod agreement_type; +pub use self::agreement_type::AgreementType; +pub mod announcement; +pub use self::announcement::Announcement; +pub mod announcement_ca_sub_type; +pub use self::announcement_ca_sub_type::AnnouncementCaSubType; +pub mod announcement_ca_type; +pub use self::announcement_ca_type::AnnouncementCaType; +pub mod application_document; +pub use self::application_document::ApplicationDocument; +pub mod asset; +pub use self::asset::Asset; +pub mod asset_class; +pub use self::asset_class::AssetClass; +pub mod authorize_o_auth_token_response; +pub use self::authorize_o_auth_token_response::AuthorizeOAuthTokenResponse; +pub mod bank; +pub use self::bank::Bank; +pub mod batch_journal_request; +pub use self::batch_journal_request::BatchJournalRequest; +pub mod batch_journal_request_entries_inner; +pub use self::batch_journal_request_entries_inner::BatchJournalRequestEntriesInner; +pub mod batch_journal_response; +pub use self::batch_journal_response::BatchJournalResponse; +pub mod calendar; +pub use self::calendar::Calendar; +pub mod clock; +pub use self::clock::Clock; +pub mod contact; +pub use self::contact::Contact; +pub mod create_ach_relationship_request; +pub use self::create_ach_relationship_request::CreateAchRelationshipRequest; +pub mod create_bank_request; +pub use self::create_bank_request::CreateBankRequest; +pub mod create_journal_request; +pub use self::create_journal_request::CreateJournalRequest; +pub mod create_order_request; +pub use self::create_order_request::CreateOrderRequest; +pub mod create_order_request_stop_loss; +pub use self::create_order_request_stop_loss::CreateOrderRequestStopLoss; +pub mod create_order_request_take_profit; +pub use self::create_order_request_take_profit::CreateOrderRequestTakeProfit; +pub mod create_transfer_request; +pub use self::create_transfer_request::CreateTransferRequest; +pub mod create_watchlist_request; +pub use self::create_watchlist_request::CreateWatchlistRequest; +pub mod custodial_account_minor_identity; +pub use self::custodial_account_minor_identity::CustodialAccountMinorIdentity; +pub mod disclosure_context_annotation; +pub use self::disclosure_context_annotation::DisclosureContextAnnotation; +pub mod disclosures; +pub use self::disclosures::Disclosures; +pub mod document_inner; +pub use self::document_inner::DocumentInner; +pub mod document_type; +pub use self::document_type::DocumentType; +pub mod document_upload; +pub use self::document_upload::DocumentUpload; +pub mod document_upload_request; +pub use self::document_upload_request::DocumentUploadRequest; +pub mod error; +pub use self::error::Error; +pub mod exchange; +pub use self::exchange::Exchange; +pub mod identity; +pub use self::identity::Identity; +pub mod issue_o_auth_token_response; +pub use self::issue_o_auth_token_response::IssueOAuthTokenResponse; +pub mod jnlc; +pub use self::jnlc::Jnlc; +pub mod jnls; +pub use self::jnls::Jnls; +pub mod journal; +pub use self::journal::Journal; +pub mod journal_data; +pub use self::journal_data::JournalData; +pub mod journal_entry_type; +pub use self::journal_entry_type::JournalEntryType; +pub mod journal_resource; +pub use self::journal_resource::JournalResource; +pub mod journal_status; +pub use self::journal_status::JournalStatus; +pub mod journal_status_event; +pub use self::journal_status_event::JournalStatusEvent; +pub mod kyc_result; +pub use self::kyc_result::KycResult; +pub mod non_trade_activity; +pub use self::non_trade_activity::NonTradeActivity; +pub mod o_auth_token_request; +pub use self::o_auth_token_request::OAuthTokenRequest; +pub mod oath_client_response; +pub use self::oath_client_response::OathClientResponse; +pub mod order; +pub use self::order::Order; +pub mod order_class; +pub use self::order_class::OrderClass; +pub mod order_closed_response; +pub use self::order_closed_response::OrderClosedResponse; +pub mod order_side; +pub use self::order_side::OrderSide; +pub mod order_status; +pub use self::order_status::OrderStatus; +pub mod order_type; +pub use self::order_type::OrderType; +pub mod portfolio_history; +pub use self::portfolio_history::PortfolioHistory; +pub mod position; +pub use self::position::Position; +pub mod position_closed_response; +pub use self::position_closed_response::PositionClosedResponse; +pub mod tax_id_type; +pub use self::tax_id_type::TaxIdType; +pub mod time_in_force; +pub use self::time_in_force::TimeInForce; +pub mod trade_account; +pub use self::trade_account::TradeAccount; +pub mod trade_activity; +pub use self::trade_activity::TradeActivity; +pub mod trade_update_event; +pub use self::trade_update_event::TradeUpdateEvent; +pub mod trade_update_event_type; +pub use self::trade_update_event_type::TradeUpdateEventType; +pub mod transfer; +pub use self::transfer::Transfer; +pub mod transfer_data; +pub use self::transfer_data::TransferData; +pub mod transfer_direction; +pub use self::transfer_direction::TransferDirection; +pub mod transfer_resource; +pub use self::transfer_resource::TransferResource; +pub mod transfer_status; +pub use self::transfer_status::TransferStatus; +pub mod transfer_status_event; +pub use self::transfer_status_event::TransferStatusEvent; +pub mod transfer_timing; +pub use self::transfer_timing::TransferTiming; +pub mod transfer_type; +pub use self::transfer_type::TransferType; +pub mod trusted_contact; +pub use self::trusted_contact::TrustedContact; +pub mod untyped_ach_transfer_data; +pub use self::untyped_ach_transfer_data::UntypedAchTransferData; +pub mod untyped_transfer_data; +pub use self::untyped_transfer_data::UntypedTransferData; +pub mod untyped_wire_transfer_data; +pub use self::untyped_wire_transfer_data::UntypedWireTransferData; +pub mod update_order_request; +pub use self::update_order_request::UpdateOrderRequest; +pub mod watchlist; +pub use self::watchlist::Watchlist; diff --git a/crates/alpaca_openapi/gen/broker/src/models/non_trade_activity.rs b/crates/alpaca_openapi/gen/broker/src/models/non_trade_activity.rs new file mode 100644 index 0000000..8dd5c69 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/non_trade_activity.rs @@ -0,0 +1,66 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct NonTradeActivity { + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "date", skip_serializing_if = "Option::is_none")] + pub date: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "net_amount", skip_serializing_if = "Option::is_none")] + pub net_amount: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "symbol", skip_serializing_if = "Option::is_none")] + pub symbol: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "qty", skip_serializing_if = "Option::is_none")] + pub qty: Option, + /// Valid only for non-trading activity types. Null for trading activites. + #[serde(rename = "per_share_amount", skip_serializing_if = "Option::is_none")] + pub per_share_amount: Option, +} + +impl NonTradeActivity { + pub fn new() -> NonTradeActivity { + NonTradeActivity { + date: None, + net_amount: None, + description: None, + status: None, + symbol: None, + qty: None, + per_share_amount: None, + } + } +} +/// Valid only for non-trading activity types. Null for trading activites. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "executed")] + Executed, + #[serde(rename = "correct")] + Correct, + #[serde(rename = "canceled")] + Canceled, +} + +impl Default for Status { + fn default() -> Status { + Self::Executed + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/o_auth_token_request.rs b/crates/alpaca_openapi/gen/broker/src/models/o_auth_token_request.rs new file mode 100644 index 0000000..6f099fc --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/o_auth_token_request.rs @@ -0,0 +1,50 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// OAuthTokenRequest : This model is used for both the Issue and Authorize OAuth token routes +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct OAuthTokenRequest { + /// OAuth client ID + #[serde(rename = "client_id")] + pub client_id: String, + /// OAuth client secret + #[serde(rename = "client_secret")] + pub client_secret: String, + /// redirect URI for the OAuth flow + #[serde(rename = "redirect_uri")] + pub redirect_uri: String, + /// scopes requested by the OAuth flow + #[serde(rename = "scope")] + pub scope: String, + /// end-user account ID + #[serde(rename = "account_id")] + pub account_id: uuid::Uuid, +} + +impl OAuthTokenRequest { + /// This model is used for both the Issue and Authorize OAuth token routes + pub fn new( + client_id: String, + client_secret: String, + redirect_uri: String, + scope: String, + account_id: uuid::Uuid, + ) -> OAuthTokenRequest { + OAuthTokenRequest { + client_id, + client_secret, + redirect_uri, + scope, + account_id, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/oath_client_response.rs b/crates/alpaca_openapi/gen/broker/src/models/oath_client_response.rs new file mode 100644 index 0000000..bc26568 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/oath_client_response.rs @@ -0,0 +1,71 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct OathClientResponse { + /// OAuth client id + #[serde(rename = "client_id", skip_serializing_if = "Option::is_none")] + pub client_id: Option, + /// Broker name (your name) + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, + #[serde(rename = "description", skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(rename = "url", skip_serializing_if = "Option::is_none")] + pub url: Option, + /// URL of Terms of Use + #[serde(rename = "terms_of_use", skip_serializing_if = "Option::is_none")] + pub terms_of_use: Option, + /// URL of Privacy Policy + #[serde(rename = "privacy_policy", skip_serializing_if = "Option::is_none")] + pub privacy_policy: Option, + /// ACTIVE or DISABLED + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + #[serde(rename = "redirect_uri", skip_serializing_if = "Option::is_none")] + pub redirect_uri: Option>, + #[serde( + rename = "live_trading_approved", + skip_serializing_if = "Option::is_none" + )] + pub live_trading_approved: Option, +} + +impl OathClientResponse { + pub fn new() -> OathClientResponse { + OathClientResponse { + client_id: None, + name: None, + description: None, + url: None, + terms_of_use: None, + privacy_policy: None, + status: None, + redirect_uri: None, + live_trading_approved: None, + } + } +} +/// ACTIVE or DISABLED +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "ACTIVE")] + Active, + #[serde(rename = "DISABLED")] + Disabled, +} + +impl Default for Status { + fn default() -> Status { + Self::Active + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/order.rs b/crates/alpaca_openapi/gen/broker/src/models/order.rs new file mode 100644 index 0000000..27900ae --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/order.rs @@ -0,0 +1,201 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Order { + #[serde(rename = "id")] + pub id: uuid::Uuid, + #[serde(rename = "client_order_id", skip_serializing_if = "Option::is_none")] + pub client_order_id: Option, + #[serde(rename = "created_at", skip_serializing_if = "Option::is_none")] + pub created_at: Option, + #[serde(rename = "updated_at", skip_serializing_if = "Option::is_none")] + pub updated_at: Option, + #[serde(rename = "submitted_at", skip_serializing_if = "Option::is_none")] + pub submitted_at: Option, + #[serde( + rename = "filled_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub filled_at: Option>, + #[serde( + rename = "expired_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub expired_at: Option>, + #[serde( + rename = "canceled_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub canceled_at: Option>, + #[serde( + rename = "failed_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub failed_at: Option>, + #[serde( + rename = "replaced_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub replaced_at: Option>, + #[serde( + rename = "replaced_by", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub replaced_by: Option>, + #[serde( + rename = "replaces", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub replaces: Option>, + #[serde(rename = "asset_id", skip_serializing_if = "Option::is_none")] + pub asset_id: Option, + #[serde(rename = "symbol")] + pub symbol: String, + #[serde(rename = "asset_class", skip_serializing_if = "Option::is_none")] + pub asset_class: Option, + #[serde( + rename = "notional", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub notional: Option>, + #[serde( + rename = "qty", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub qty: Option>, + #[serde(rename = "filled_qty", skip_serializing_if = "Option::is_none")] + pub filled_qty: Option, + #[serde( + rename = "filled_avg_price", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub filled_avg_price: Option>, + #[serde(rename = "order_class", skip_serializing_if = "Option::is_none")] + pub order_class: Option, + #[serde(rename = "order_type", skip_serializing_if = "Option::is_none")] + pub order_type: Option, + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + pub r#type: Option, + #[serde(rename = "side", skip_serializing_if = "Option::is_none")] + pub side: Option, + #[serde(rename = "time_in_force", skip_serializing_if = "Option::is_none")] + pub time_in_force: Option, + #[serde( + rename = "limit_price", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub limit_price: Option>, + #[serde( + rename = "stop_price", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub stop_price: Option>, + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + #[serde(rename = "extended_hours", skip_serializing_if = "Option::is_none")] + pub extended_hours: Option, + #[serde( + rename = "legs", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub legs: Option>>, + #[serde( + rename = "trail_price", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub trail_price: Option>, + #[serde( + rename = "trail_percent", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub trail_percent: Option>, + #[serde( + rename = "hwm", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub hwm: Option>, + #[serde(rename = "commission", skip_serializing_if = "Option::is_none")] + pub commission: Option, +} + +impl Order { + pub fn new(id: uuid::Uuid, symbol: String) -> Order { + Order { + id, + client_order_id: None, + created_at: None, + updated_at: None, + submitted_at: None, + filled_at: None, + expired_at: None, + canceled_at: None, + failed_at: None, + replaced_at: None, + replaced_by: None, + replaces: None, + asset_id: None, + symbol, + asset_class: None, + notional: None, + qty: None, + filled_qty: None, + filled_avg_price: None, + order_class: None, + order_type: None, + r#type: None, + side: None, + time_in_force: None, + limit_price: None, + stop_price: None, + status: None, + extended_hours: None, + legs: None, + trail_price: None, + trail_percent: None, + hwm: None, + commission: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/order_class.rs b/crates/alpaca_openapi/gen/broker/src/models/order_class.rs new file mode 100644 index 0000000..566aaaa --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/order_class.rs @@ -0,0 +1,41 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum OrderClass { + #[serde(rename = "simple")] + Simple, + #[serde(rename = "bracket")] + Bracket, + #[serde(rename = "oco")] + Oco, + #[serde(rename = "oto")] + Oto, +} + +impl ToString for OrderClass { + fn to_string(&self) -> String { + match self { + Self::Simple => String::from("simple"), + Self::Bracket => String::from("bracket"), + Self::Oco => String::from("oco"), + Self::Oto => String::from("oto"), + } + } +} + +impl Default for OrderClass { + fn default() -> OrderClass { + Self::Simple + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/order_closed_response.rs b/crates/alpaca_openapi/gen/broker/src/models/order_closed_response.rs new file mode 100644 index 0000000..3cec701 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/order_closed_response.rs @@ -0,0 +1,35 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// OrderClosedResponse : Represents the result of asking the api to cancel an Order. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct OrderClosedResponse { + /// UUID of the order that was canceled + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// Http status code for the attempt to close this Order + #[serde(rename = "status")] + pub status: i32, + #[serde(rename = "body", skip_serializing_if = "Option::is_none")] + pub body: Option>, +} + +impl OrderClosedResponse { + /// Represents the result of asking the api to cancel an Order. + pub fn new(id: uuid::Uuid, status: i32) -> OrderClosedResponse { + OrderClosedResponse { + id, + status, + body: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/order_side.rs b/crates/alpaca_openapi/gen/broker/src/models/order_side.rs new file mode 100644 index 0000000..b1ea97d --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/order_side.rs @@ -0,0 +1,57 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// OrderSide : Represents what side of the transaction an order was on. +/// Represents what side of the transaction an order was on. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum OrderSide { + #[serde(rename = "buy")] + Buy, + #[serde(rename = "sell")] + Sell, + #[serde(rename = "buy_minus")] + BuyMinus, + #[serde(rename = "sell_plus")] + SellPlus, + #[serde(rename = "sell_short")] + SellShort, + #[serde(rename = "sell_short_exempt")] + SellShortExempt, + #[serde(rename = "undisclosed")] + Undisclosed, + #[serde(rename = "cross")] + Cross, + #[serde(rename = "cross_short")] + CrossShort, +} + +impl ToString for OrderSide { + fn to_string(&self) -> String { + match self { + Self::Buy => String::from("buy"), + Self::Sell => String::from("sell"), + Self::BuyMinus => String::from("buy_minus"), + Self::SellPlus => String::from("sell_plus"), + Self::SellShort => String::from("sell_short"), + Self::SellShortExempt => String::from("sell_short_exempt"), + Self::Undisclosed => String::from("undisclosed"), + Self::Cross => String::from("cross"), + Self::CrossShort => String::from("cross_short"), + } + } +} + +impl Default for OrderSide { + fn default() -> OrderSide { + Self::Buy + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/order_status.rs b/crates/alpaca_openapi/gen/broker/src/models/order_status.rs new file mode 100644 index 0000000..f85eb75 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/order_status.rs @@ -0,0 +1,77 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum OrderStatus { + #[serde(rename = "new")] + New, + #[serde(rename = "partially_filled")] + PartiallyFilled, + #[serde(rename = "filled")] + Filled, + #[serde(rename = "done_for_day")] + DoneForDay, + #[serde(rename = "canceled")] + Canceled, + #[serde(rename = "expired")] + Expired, + #[serde(rename = "replaced")] + Replaced, + #[serde(rename = "pending_cancel")] + PendingCancel, + #[serde(rename = "pending_replace")] + PendingReplace, + #[serde(rename = "accepted")] + Accepted, + #[serde(rename = "pending_new")] + PendingNew, + #[serde(rename = "accepted_for_bidding")] + AcceptedForBidding, + #[serde(rename = "stopped")] + Stopped, + #[serde(rename = "rejected")] + Rejected, + #[serde(rename = "suspended")] + Suspended, + #[serde(rename = "calculated")] + Calculated, +} + +impl ToString for OrderStatus { + fn to_string(&self) -> String { + match self { + Self::New => String::from("new"), + Self::PartiallyFilled => String::from("partially_filled"), + Self::Filled => String::from("filled"), + Self::DoneForDay => String::from("done_for_day"), + Self::Canceled => String::from("canceled"), + Self::Expired => String::from("expired"), + Self::Replaced => String::from("replaced"), + Self::PendingCancel => String::from("pending_cancel"), + Self::PendingReplace => String::from("pending_replace"), + Self::Accepted => String::from("accepted"), + Self::PendingNew => String::from("pending_new"), + Self::AcceptedForBidding => String::from("accepted_for_bidding"), + Self::Stopped => String::from("stopped"), + Self::Rejected => String::from("rejected"), + Self::Suspended => String::from("suspended"), + Self::Calculated => String::from("calculated"), + } + } +} + +impl Default for OrderStatus { + fn default() -> OrderStatus { + Self::New + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/order_type.rs b/crates/alpaca_openapi/gen/broker/src/models/order_type.rs new file mode 100644 index 0000000..1bf4203 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/order_type.rs @@ -0,0 +1,44 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum OrderType { + #[serde(rename = "market")] + Market, + #[serde(rename = "limit")] + Limit, + #[serde(rename = "stop")] + Stop, + #[serde(rename = "stop_limit")] + StopLimit, + #[serde(rename = "trailing_stop")] + TrailingStop, +} + +impl ToString for OrderType { + fn to_string(&self) -> String { + match self { + Self::Market => String::from("market"), + Self::Limit => String::from("limit"), + Self::Stop => String::from("stop"), + Self::StopLimit => String::from("stop_limit"), + Self::TrailingStop => String::from("trailing_stop"), + } + } +} + +impl Default for OrderType { + fn default() -> OrderType { + Self::Market + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/portfolio_history.rs b/crates/alpaca_openapi/gen/broker/src/models/portfolio_history.rs new file mode 100644 index 0000000..543f431 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/portfolio_history.rs @@ -0,0 +1,55 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// PortfolioHistory : Timeseries data for equity and profit loss information of the account. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PortfolioHistory { + /// time of each data element, left-labeled (the beginning of time window) + #[serde(rename = "timestamp")] + pub timestamp: Vec, + /// equity value of the account in dollar amount as of the end of each time window + #[serde(rename = "equity")] + pub equity: Vec, + /// profit/loss in dollar from the base value + #[serde(rename = "profit_loss")] + pub profit_loss: Vec, + /// profit/loss in percentage from the base value + #[serde(rename = "profit_loss_pct")] + pub profit_loss_pct: Vec, + /// basis in dollar of the profit loss calculation + #[serde(rename = "base_value", deserialize_with = "Option::deserialize")] + pub base_value: Option, + /// time window size of each data element + #[serde(rename = "timeframe", deserialize_with = "Option::deserialize")] + pub timeframe: Option, +} + +impl PortfolioHistory { + /// Timeseries data for equity and profit loss information of the account. + pub fn new( + timestamp: Vec, + equity: Vec, + profit_loss: Vec, + profit_loss_pct: Vec, + base_value: Option, + timeframe: Option, + ) -> PortfolioHistory { + PortfolioHistory { + timestamp, + equity, + profit_loss, + profit_loss_pct, + base_value, + timeframe, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/position.rs b/crates/alpaca_openapi/gen/broker/src/models/position.rs new file mode 100644 index 0000000..4683143 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/position.rs @@ -0,0 +1,121 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Position : +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Position { + /// Asset ID + #[serde(rename = "asset_id")] + pub asset_id: uuid::Uuid, + /// Asset symbol + #[serde(rename = "symbol")] + pub symbol: String, + /// Exchange name of the asset + #[serde(rename = "exchange")] + pub exchange: String, + #[serde(rename = "asset_class")] + pub asset_class: models::AssetClass, + /// Indicates if this asset is marginable + #[serde(rename = "asset_marginable", skip_serializing_if = "Option::is_none")] + pub asset_marginable: Option, + /// Average entry price of the position + #[serde(rename = "avg_entry_price")] + pub avg_entry_price: String, + /// The number of shares + #[serde(rename = "qty")] + pub qty: String, + #[serde(rename = "side")] + pub side: Side, + /// Total dollar amount of the position + #[serde(rename = "market_value")] + pub market_value: String, + /// Total cost basis in dollar + #[serde(rename = "cost_basis")] + pub cost_basis: String, + /// Unrealized profit/loss in dollars + #[serde(rename = "unrealized_pl")] + pub unrealized_pl: String, + /// Unrealized profit/loss percent (by a factor of 1) + #[serde(rename = "unrealized_plpc")] + pub unrealized_plpc: String, + /// Unrealized profit/loss in dollars for the day + #[serde(rename = "unrealized_intraday_pl")] + pub unrealized_intraday_pl: String, + /// Unrealized interday profit/loss percent (by a factor of 1) + #[serde(rename = "unrealized_intraday_plpc")] + pub unrealized_intraday_plpc: String, + /// Current asset price per share + #[serde(rename = "current_price")] + pub current_price: String, + /// Last day’s asset price per share based on the closing value of the last trading day + #[serde(rename = "lastday_price")] + pub lastday_price: String, + /// Percent change from last day price (by a factor of 1) + #[serde(rename = "change_today")] + pub change_today: String, +} + +impl Position { + /// + pub fn new( + asset_id: uuid::Uuid, + symbol: String, + exchange: String, + asset_class: models::AssetClass, + avg_entry_price: String, + qty: String, + side: Side, + market_value: String, + cost_basis: String, + unrealized_pl: String, + unrealized_plpc: String, + unrealized_intraday_pl: String, + unrealized_intraday_plpc: String, + current_price: String, + lastday_price: String, + change_today: String, + ) -> Position { + Position { + asset_id, + symbol, + exchange, + asset_class, + asset_marginable: None, + avg_entry_price, + qty, + side, + market_value, + cost_basis, + unrealized_pl, + unrealized_plpc, + unrealized_intraday_pl, + unrealized_intraday_plpc, + current_price, + lastday_price, + change_today, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Side { + #[serde(rename = "long")] + Long, + #[serde(rename = "short")] + Short, +} + +impl Default for Side { + fn default() -> Side { + Self::Long + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/position_closed_response.rs b/crates/alpaca_openapi/gen/broker/src/models/position_closed_response.rs new file mode 100644 index 0000000..9619ff4 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/position_closed_response.rs @@ -0,0 +1,35 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// PositionClosedResponse : Represents the result of asking the api to close a position. `body` is the Order used to close out the position. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PositionClosedResponse { + /// Symbol name of the asset + #[serde(rename = "symbol")] + pub symbol: String, + /// Http status code for the attempt to close this position + #[serde(rename = "status")] + pub status: i32, + #[serde(rename = "body", skip_serializing_if = "Option::is_none")] + pub body: Option>, +} + +impl PositionClosedResponse { + /// Represents the result of asking the api to close a position. `body` is the Order used to close out the position. + pub fn new(symbol: String, status: i32) -> PositionClosedResponse { + PositionClosedResponse { + symbol, + status, + body: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/tax_id_type.rs b/crates/alpaca_openapi/gen/broker/src/models/tax_id_type.rs new file mode 100644 index 0000000..a52e5fb --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/tax_id_type.rs @@ -0,0 +1,144 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// TaxIdType : An Enum of the various kinds of Tax ID formats Alpaca supports. Possible Values are: - **USA_SSN** USA Social Security Number - **ARG_AR_CUIT** Argentina CUIT - **AUS_TFN** Australian Tax File Number - **AUS_ABN** Australian Business Number - **BOL_NIT** Bolivia NIT - **BRA_CPF** Brazil CPF - **CHL_RUT** Chile RUT - **COL_NIT** Colombia NIT - **CRI_NITE** Costa Rica NITE - **DEU_TAX_ID** Germany Tax ID (Identifikationsnummer) - **DOM_RNC** Dominican Republic RNC - **ECU_RUC** Ecuador RUC - **FRA_SPI** France SPI (Reference Tax Number) - **GBR_UTR** UK UTR (Unique Taxpayer Reference) - **GBR_NINO** UK NINO (National Insurance Number) - **GTM_NIT** Guatemala NIT - **HND_RTN** Honduras RTN - **HUN_TIN** Hungary TIN Number - **IDN_KTP** Indonesia KTP - **IND_PAN** India PAN Number - **ISR_TAX_ID** Israel Tax ID (Teudat Zehut) - **ITA_TAX_ID** Italy Tax ID (Codice Fiscale) - **JPN_TAX_ID** Japan Tax ID (Koijin Bango) - **MEX_RFC** Mexico RFC - **NIC_RUC** Nicaragua RUC - **NLD_TIN** Netherlands TIN Number - **PAN_RUC** Panama RUC - **PER_RUC** Peru RUC - **PRY_RUC** Paraguay RUC - **SGP_NRIC** Singapore NRIC - **SGP_FIN** Singapore FIN - **SGP_ASGD** Singapore ASGD - **SGP_ITR** Singapore ITR - **SLV_NIT** El Salvador NIT - **SWE_TAX_ID** Sweden Tax ID (Personnummer) - **URY_RUT** Uruguay RUT - **VEN_RIF** Venezuela RIF - **NOT_SPECIFIED** Other Tax IDs +/// An Enum of the various kinds of Tax ID formats Alpaca supports. Possible Values are: - **USA_SSN** USA Social Security Number - **ARG_AR_CUIT** Argentina CUIT - **AUS_TFN** Australian Tax File Number - **AUS_ABN** Australian Business Number - **BOL_NIT** Bolivia NIT - **BRA_CPF** Brazil CPF - **CHL_RUT** Chile RUT - **COL_NIT** Colombia NIT - **CRI_NITE** Costa Rica NITE - **DEU_TAX_ID** Germany Tax ID (Identifikationsnummer) - **DOM_RNC** Dominican Republic RNC - **ECU_RUC** Ecuador RUC - **FRA_SPI** France SPI (Reference Tax Number) - **GBR_UTR** UK UTR (Unique Taxpayer Reference) - **GBR_NINO** UK NINO (National Insurance Number) - **GTM_NIT** Guatemala NIT - **HND_RTN** Honduras RTN - **HUN_TIN** Hungary TIN Number - **IDN_KTP** Indonesia KTP - **IND_PAN** India PAN Number - **ISR_TAX_ID** Israel Tax ID (Teudat Zehut) - **ITA_TAX_ID** Italy Tax ID (Codice Fiscale) - **JPN_TAX_ID** Japan Tax ID (Koijin Bango) - **MEX_RFC** Mexico RFC - **NIC_RUC** Nicaragua RUC - **NLD_TIN** Netherlands TIN Number - **PAN_RUC** Panama RUC - **PER_RUC** Peru RUC - **PRY_RUC** Paraguay RUC - **SGP_NRIC** Singapore NRIC - **SGP_FIN** Singapore FIN - **SGP_ASGD** Singapore ASGD - **SGP_ITR** Singapore ITR - **SLV_NIT** El Salvador NIT - **SWE_TAX_ID** Sweden Tax ID (Personnummer) - **URY_RUT** Uruguay RUT - **VEN_RIF** Venezuela RIF - **NOT_SPECIFIED** Other Tax IDs +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TaxIdType { + #[serde(rename = "NOT_SPECIFIED")] + NotSpecified, + #[serde(rename = "USA_SSN")] + UsaSsn, + #[serde(rename = "ARG_AG_CUIT")] + ArgAgCuit, + #[serde(rename = "AUS_TFN")] + AusTfn, + #[serde(rename = "AUS_ABN")] + AusAbn, + #[serde(rename = "BOL_NIT")] + BolNit, + #[serde(rename = "BRA_CPF")] + BraCpf, + #[serde(rename = "CHL_RUT")] + ChlRut, + #[serde(rename = "COL_NIT")] + ColNit, + #[serde(rename = "CRI_NITE")] + CriNite, + #[serde(rename = "DEU_TAX_ID")] + DeuTaxId, + #[serde(rename = "DOM_RNC")] + DomRnc, + #[serde(rename = "ECU_RUC")] + EcuRuc, + #[serde(rename = "FRA_SPI")] + FraSpi, + #[serde(rename = "GBR_UTR")] + GbrUtr, + #[serde(rename = "GBR_NINO")] + GbrNino, + #[serde(rename = "GTM_NIT")] + GtmNit, + #[serde(rename = "HND_RTN")] + HndRtn, + #[serde(rename = "HUN_TIN")] + HunTin, + #[serde(rename = "IDN_KTP")] + IdnKtp, + #[serde(rename = "IND_PAN")] + IndPan, + #[serde(rename = "ISR_TAX_ID")] + IsrTaxId, + #[serde(rename = "ITA_TAX_ID")] + ItaTaxId, + #[serde(rename = "JPN_TAX_ID")] + JpnTaxId, + #[serde(rename = "MEX_RFC")] + MexRfc, + #[serde(rename = "NIC_RUC")] + NicRuc, + #[serde(rename = "NLD_TIN")] + NldTin, + #[serde(rename = "PAN_RUC")] + PanRuc, + #[serde(rename = "PER_RUC")] + PerRuc, + #[serde(rename = "PRY_RUC")] + PryRuc, + #[serde(rename = "SGP_NRIC")] + SgpNric, + #[serde(rename = "SGP_FIN")] + SgpFin, + #[serde(rename = "SGP_ASGD")] + SgpAsgd, + #[serde(rename = "SGP_ITR")] + SgpItr, + #[serde(rename = "SLV_NIT")] + SlvNit, + #[serde(rename = "SWE_TAX_ID")] + SweTaxId, + #[serde(rename = "URY_RUT")] + UryRut, + #[serde(rename = "VEN_RIF")] + VenRif, +} + +impl ToString for TaxIdType { + fn to_string(&self) -> String { + match self { + Self::NotSpecified => String::from("NOT_SPECIFIED"), + Self::UsaSsn => String::from("USA_SSN"), + Self::ArgAgCuit => String::from("ARG_AG_CUIT"), + Self::AusTfn => String::from("AUS_TFN"), + Self::AusAbn => String::from("AUS_ABN"), + Self::BolNit => String::from("BOL_NIT"), + Self::BraCpf => String::from("BRA_CPF"), + Self::ChlRut => String::from("CHL_RUT"), + Self::ColNit => String::from("COL_NIT"), + Self::CriNite => String::from("CRI_NITE"), + Self::DeuTaxId => String::from("DEU_TAX_ID"), + Self::DomRnc => String::from("DOM_RNC"), + Self::EcuRuc => String::from("ECU_RUC"), + Self::FraSpi => String::from("FRA_SPI"), + Self::GbrUtr => String::from("GBR_UTR"), + Self::GbrNino => String::from("GBR_NINO"), + Self::GtmNit => String::from("GTM_NIT"), + Self::HndRtn => String::from("HND_RTN"), + Self::HunTin => String::from("HUN_TIN"), + Self::IdnKtp => String::from("IDN_KTP"), + Self::IndPan => String::from("IND_PAN"), + Self::IsrTaxId => String::from("ISR_TAX_ID"), + Self::ItaTaxId => String::from("ITA_TAX_ID"), + Self::JpnTaxId => String::from("JPN_TAX_ID"), + Self::MexRfc => String::from("MEX_RFC"), + Self::NicRuc => String::from("NIC_RUC"), + Self::NldTin => String::from("NLD_TIN"), + Self::PanRuc => String::from("PAN_RUC"), + Self::PerRuc => String::from("PER_RUC"), + Self::PryRuc => String::from("PRY_RUC"), + Self::SgpNric => String::from("SGP_NRIC"), + Self::SgpFin => String::from("SGP_FIN"), + Self::SgpAsgd => String::from("SGP_ASGD"), + Self::SgpItr => String::from("SGP_ITR"), + Self::SlvNit => String::from("SLV_NIT"), + Self::SweTaxId => String::from("SWE_TAX_ID"), + Self::UryRut => String::from("URY_RUT"), + Self::VenRif => String::from("VEN_RIF"), + } + } +} + +impl Default for TaxIdType { + fn default() -> TaxIdType { + Self::NotSpecified + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/time_in_force.rs b/crates/alpaca_openapi/gen/broker/src/models/time_in_force.rs new file mode 100644 index 0000000..1b185c0 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/time_in_force.rs @@ -0,0 +1,47 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TimeInForce { + #[serde(rename = "day")] + Day, + #[serde(rename = "gtc")] + Gtc, + #[serde(rename = "opg")] + Opg, + #[serde(rename = "cls")] + Cls, + #[serde(rename = "ioc")] + Ioc, + #[serde(rename = "fok")] + Fok, +} + +impl ToString for TimeInForce { + fn to_string(&self) -> String { + match self { + Self::Day => String::from("day"), + Self::Gtc => String::from("gtc"), + Self::Opg => String::from("opg"), + Self::Cls => String::from("cls"), + Self::Ioc => String::from("ioc"), + Self::Fok => String::from("fok"), + } + } +} + +impl Default for TimeInForce { + fn default() -> TimeInForce { + Self::Day + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/trade_account.rs b/crates/alpaca_openapi/gen/broker/src/models/trade_account.rs new file mode 100644 index 0000000..066111f --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/trade_account.rs @@ -0,0 +1,219 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// TradeAccount : This is an extended version of the Account model found [in the trading api](https://alpaca.markets/docs/api-references/trading-api/account/#account-entity). Extra data has been added that would be useful for brokers. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TradeAccount { + /// The account ID + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// The account number + #[serde(rename = "account_number", deserialize_with = "Option::deserialize")] + pub account_number: Option, + #[serde(rename = "status")] + pub status: models::AccountStatus, + /// Always USD + #[serde(rename = "currency")] + pub currency: String, + /// Current available cash buying power. If multiplier = 2 then buying_power = max(equity-initial_margin(0) * 2). If multiplier = 1 then buying_power = cash. + #[serde(rename = "buying_power")] + pub buying_power: String, + /// User’s buying power under Regulation T (excess equity - (equity - margin value) - * margin multiplier) + #[serde(rename = "regt_buying_power", skip_serializing_if = "Option::is_none")] + pub regt_buying_power: Option, + /// Your buying power for day trades (continuously updated value) + #[serde( + rename = "daytrading_buying_power", + skip_serializing_if = "Option::is_none" + )] + pub daytrading_buying_power: Option, + /// Cash balance + #[serde(rename = "cash")] + pub cash: String, + /// Cash available for withdrawl + #[serde(rename = "cash_withdrawable", skip_serializing_if = "Option::is_none")] + pub cash_withdrawable: Option, + /// Cash available for transfer (JNLC) + #[serde(rename = "cash_transferable", skip_serializing_if = "Option::is_none")] + pub cash_transferable: Option, + /// Cash pending transfer out + #[serde( + rename = "pending_transfer_out", + skip_serializing_if = "Option::is_none" + )] + pub pending_transfer_out: Option, + /// Total value of cash + holding positions. (This field is deprecated. It is equivalent to the equity field.) + #[serde(rename = "portfolio_value", skip_serializing_if = "Option::is_none")] + pub portfolio_value: Option, + /// Whether account is flagged as pattern day trader or not + #[serde(rename = "pattern_day_trader", skip_serializing_if = "Option::is_none")] + pub pattern_day_trader: Option, + /// If true, the account is not allowed to place orders. + #[serde(rename = "trading_blocked", skip_serializing_if = "Option::is_none")] + pub trading_blocked: Option, + /// If true, the account is not allowed to request money transfers. + #[serde(rename = "transfers_blocked", skip_serializing_if = "Option::is_none")] + pub transfers_blocked: Option, + /// If true, the account activity by user is prohibited. + #[serde(rename = "account_blocked", skip_serializing_if = "Option::is_none")] + pub account_blocked: Option, + /// Timestamp this account was created at + #[serde(rename = "created_at")] + pub created_at: String, + /// If true, the account is not allowed to place orders. + #[serde( + rename = "trade_suspended_by_user", + skip_serializing_if = "Option::is_none" + )] + pub trade_suspended_by_user: Option, + /// “1”, “2”, \"3\", or \"4\" + #[serde(rename = "multiplier", skip_serializing_if = "Option::is_none")] + pub multiplier: Option, + /// Flag to denote whether or not the account is permitted to short + #[serde(rename = "shorting_enabled", skip_serializing_if = "Option::is_none")] + pub shorting_enabled: Option, + /// cash + long_market_value + short_market_value + #[serde(rename = "equity")] + pub equity: String, + /// Equity as of previous trading day at 16:00:00 ET + #[serde(rename = "last_equity")] + pub last_equity: String, + /// Real-time MtM value of all long positions held in the account + #[serde(rename = "long_market_value", skip_serializing_if = "Option::is_none")] + pub long_market_value: Option, + /// Real-time MtM value of all short positions held in the account + #[serde(rename = "short_market_value", skip_serializing_if = "Option::is_none")] + pub short_market_value: Option, + /// Reg T initial margin requirement (continuously updated value) + #[serde(rename = "initial_margin", skip_serializing_if = "Option::is_none")] + pub initial_margin: Option, + /// Maintenance margin requirement (continuously updated value) + #[serde(rename = "maintenance_margin", skip_serializing_if = "Option::is_none")] + pub maintenance_margin: Option, + /// Maintenance margin requirement on the previous trading day + #[serde( + rename = "last_maintenance_margin", + skip_serializing_if = "Option::is_none" + )] + pub last_maintenance_margin: Option, + /// Value of Special Memorandum Account (will be used at a later date to provide additional buying_power) + #[serde(rename = "sma", skip_serializing_if = "Option::is_none")] + pub sma: Option, + /// The current number of daytrades that have been made in the last 5 trading days (inclusive of today) + #[serde(rename = "daytrade_count", skip_serializing_if = "Option::is_none")] + pub daytrade_count: Option, + /// Previous sessions close time + #[serde(rename = "previous_close", skip_serializing_if = "Option::is_none")] + pub previous_close: Option, + /// Value of all long positions as of previous trading day at 16:00:00 ET + #[serde( + rename = "last_long_market_value", + skip_serializing_if = "Option::is_none" + )] + pub last_long_market_value: Option, + /// Value of all short positions as of previous trading day at 16:00:00 ET + #[serde( + rename = "last_short_market_value", + skip_serializing_if = "Option::is_none" + )] + pub last_short_market_value: Option, + /// Value of all cash as of previous trading day at 16:00:00 ET + #[serde(rename = "last_cash", skip_serializing_if = "Option::is_none")] + pub last_cash: Option, + /// Value of Reg T margin as of previous trading day at 16:00:00 ET + #[serde( + rename = "last_initial_margin", + skip_serializing_if = "Option::is_none" + )] + pub last_initial_margin: Option, + /// Value of Reg T buying power as of previous trading day at 16:00:00 ET + #[serde( + rename = "last_regt_buying_power", + skip_serializing_if = "Option::is_none" + )] + pub last_regt_buying_power: Option, + /// Value of daytrading buying power as of previous trading day at 16:00:00 ET + #[serde( + rename = "last_daytrading_buying_power", + skip_serializing_if = "Option::is_none" + )] + pub last_daytrading_buying_power: Option, + /// Value of buying_power as of previous trading day at 16:00:00 ET + #[serde(rename = "last_buying_power", skip_serializing_if = "Option::is_none")] + pub last_buying_power: Option, + /// Value of daytrade count as of previous trading day at 16:00:00 ET + #[serde( + rename = "last_daytrade_count", + skip_serializing_if = "Option::is_none" + )] + pub last_daytrade_count: Option, + /// Clearing broker + #[serde(rename = "clearing_broker", skip_serializing_if = "Option::is_none")] + pub clearing_broker: Option, +} + +impl TradeAccount { + /// This is an extended version of the Account model found [in the trading api](https://alpaca.markets/docs/api-references/trading-api/account/#account-entity). Extra data has been added that would be useful for brokers. + pub fn new( + id: uuid::Uuid, + account_number: Option, + status: models::AccountStatus, + currency: String, + buying_power: String, + cash: String, + created_at: String, + equity: String, + last_equity: String, + ) -> TradeAccount { + TradeAccount { + id, + account_number, + status, + currency, + buying_power, + regt_buying_power: None, + daytrading_buying_power: None, + cash, + cash_withdrawable: None, + cash_transferable: None, + pending_transfer_out: None, + portfolio_value: None, + pattern_day_trader: None, + trading_blocked: None, + transfers_blocked: None, + account_blocked: None, + created_at, + trade_suspended_by_user: None, + multiplier: None, + shorting_enabled: None, + equity, + last_equity, + long_market_value: None, + short_market_value: None, + initial_margin: None, + maintenance_margin: None, + last_maintenance_margin: None, + sma: None, + daytrade_count: None, + previous_close: None, + last_long_market_value: None, + last_short_market_value: None, + last_cash: None, + last_initial_margin: None, + last_regt_buying_power: None, + last_daytrading_buying_power: None, + last_buying_power: None, + last_daytrade_count: None, + clearing_broker: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/trade_activity.rs b/crates/alpaca_openapi/gen/broker/src/models/trade_activity.rs new file mode 100644 index 0000000..615e412 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/trade_activity.rs @@ -0,0 +1,74 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TradeActivity { + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "transaction_time", skip_serializing_if = "Option::is_none")] + pub transaction_time: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + pub r#type: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "price", skip_serializing_if = "Option::is_none")] + pub price: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "qty", skip_serializing_if = "Option::is_none")] + pub qty: Option, + #[serde(rename = "side", skip_serializing_if = "Option::is_none")] + pub side: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "symbol", skip_serializing_if = "Option::is_none")] + pub symbol: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "leaves_qty", skip_serializing_if = "Option::is_none")] + pub leaves_qty: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "order_id", skip_serializing_if = "Option::is_none")] + pub order_id: Option, + /// Valid only for trading activity types. Null for non-trading activites. + #[serde(rename = "cum_qty", skip_serializing_if = "Option::is_none")] + pub cum_qty: Option, + #[serde(rename = "order_status", skip_serializing_if = "Option::is_none")] + pub order_status: Option, +} + +impl TradeActivity { + pub fn new() -> TradeActivity { + TradeActivity { + transaction_time: None, + r#type: None, + price: None, + qty: None, + side: None, + symbol: None, + leaves_qty: None, + order_id: None, + cum_qty: None, + order_status: None, + } + } +} +/// Valid only for trading activity types. Null for non-trading activites. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Type { + #[serde(rename = "fill")] + Fill, + #[serde(rename = "partial_fill")] + PartialFill, +} + +impl Default for Type { + fn default() -> Type { + Self::Fill + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/trade_update_event.rs b/crates/alpaca_openapi/gen/broker/src/models/trade_update_event.rs new file mode 100644 index 0000000..93cd869 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/trade_update_event.rs @@ -0,0 +1,58 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// TradeUpdateEvent : Represents an update to an order/trade, sent over the events streaming api. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TradeUpdateEvent { + /// Account UUID + #[serde(rename = "account_id")] + pub account_id: uuid::Uuid, + /// Timestamp of event + #[serde(rename = "at")] + pub at: String, + #[serde(rename = "event")] + pub event: models::TradeUpdateEventType, + /// Monotonically increasing 64bit integer + #[serde(rename = "event_id")] + pub event_id: i64, + /// Corresponding execution of an order. If an order gets filled over two executions (a partial_fill for example), you will receive two events with different IDs. + #[serde(rename = "execution_id")] + pub execution_id: uuid::Uuid, + #[serde(rename = "order")] + pub order: Box, + /// Has various different meanings depending on the value of `event`, please see the [Trading Events](https://alpaca.markets/docs/api-references/broker-api/events/#trade-events) Enum in the documentation or the TradeUpdateEventType model for more details on when it means different things. + #[serde(rename = "timestamp")] + pub timestamp: String, +} + +impl TradeUpdateEvent { + /// Represents an update to an order/trade, sent over the events streaming api. + pub fn new( + account_id: uuid::Uuid, + at: String, + event: models::TradeUpdateEventType, + event_id: i64, + execution_id: uuid::Uuid, + order: models::Order, + timestamp: String, + ) -> TradeUpdateEvent { + TradeUpdateEvent { + account_id, + at, + event, + event_id, + execution_id, + order: Box::new(order), + timestamp, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/trade_update_event_type.rs b/crates/alpaca_openapi/gen/broker/src/models/trade_update_event_type.rs new file mode 100644 index 0000000..e2e2e0a --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/trade_update_event_type.rs @@ -0,0 +1,78 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// TradeUpdateEventType : **Common events** These are the events that are the expected results of actions you may have taken by sending API requests. The meaning of the `timestamp` field changes for each type; the meanings have been specified here for which types the timestamp field will be present. - `new`: Sent when an order has been routed to exchanges for execution. - `fill`: Sent when your order has been completely filled. - `timestamp`: The time at which the order was filled. - `partial_fill`: Sent when a number of shares less than the total remaining quantity on your order has been filled. - `timestamp`: The time at which the shares were filled. - `canceled`: Sent when your requested cancellation of an order is processed. - `timestamp`: The time at which the order was canceled. - `expired`: Sent when an order has reached the end of its lifespan, as determined by the order’s time in force value. - `timestamp`: The time at which the order expired. - `done_for_day`: Sent when the order is done executing for the day, and will not receive further updates until the next trading day. - `replaced`: Sent when your requested replacement of an order is processed. - `timestamp`: The time at which the order was replaced. **Rarer events** These are events that may rarely be sent due to unexpected circumstances on the exchanges. It is unlikely you will need to design your code around them, but you may still wish to account for the possibility that they will occur. - `rejected`: Sent when your order has been rejected. - `timestamp`: The time at which the rejection occurred. - `pending_new`: Sent when the order has been received by Alpaca and routed to the exchanges, but has not yet been accepted for execution. - `stopped`: Sent when your order has been stopped, and a trade is guaranteed for the order, usually at a stated price or better, but has not yet occurred. - `pending_cancel`: Sent when the order is awaiting cancellation. Most cancellations will occur without the order entering this state. - `pending_replace`: Sent when the order is awaiting replacement. - `calculated`: Sent when the order has been completed for the day - it is either `filled` or `done_for_day` - but remaining settlement calculations are still pending. - `suspended`: Sent when the order has been suspended and is not eligible for trading. - `order_replace_rejected`: Sent when the order replace has been rejected. - `order_cancel_rejected`: Sent when the order cancel has been rejected. +/// **Common events** These are the events that are the expected results of actions you may have taken by sending API requests. The meaning of the `timestamp` field changes for each type; the meanings have been specified here for which types the timestamp field will be present. - `new`: Sent when an order has been routed to exchanges for execution. - `fill`: Sent when your order has been completely filled. - `timestamp`: The time at which the order was filled. - `partial_fill`: Sent when a number of shares less than the total remaining quantity on your order has been filled. - `timestamp`: The time at which the shares were filled. - `canceled`: Sent when your requested cancellation of an order is processed. - `timestamp`: The time at which the order was canceled. - `expired`: Sent when an order has reached the end of its lifespan, as determined by the order’s time in force value. - `timestamp`: The time at which the order expired. - `done_for_day`: Sent when the order is done executing for the day, and will not receive further updates until the next trading day. - `replaced`: Sent when your requested replacement of an order is processed. - `timestamp`: The time at which the order was replaced. **Rarer events** These are events that may rarely be sent due to unexpected circumstances on the exchanges. It is unlikely you will need to design your code around them, but you may still wish to account for the possibility that they will occur. - `rejected`: Sent when your order has been rejected. - `timestamp`: The time at which the rejection occurred. - `pending_new`: Sent when the order has been received by Alpaca and routed to the exchanges, but has not yet been accepted for execution. - `stopped`: Sent when your order has been stopped, and a trade is guaranteed for the order, usually at a stated price or better, but has not yet occurred. - `pending_cancel`: Sent when the order is awaiting cancellation. Most cancellations will occur without the order entering this state. - `pending_replace`: Sent when the order is awaiting replacement. - `calculated`: Sent when the order has been completed for the day - it is either `filled` or `done_for_day` - but remaining settlement calculations are still pending. - `suspended`: Sent when the order has been suspended and is not eligible for trading. - `order_replace_rejected`: Sent when the order replace has been rejected. - `order_cancel_rejected`: Sent when the order cancel has been rejected. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TradeUpdateEventType { + #[serde(rename = "new")] + New, + #[serde(rename = "fill")] + Fill, + #[serde(rename = "partial_fill")] + PartialFill, + #[serde(rename = "canceled")] + Canceled, + #[serde(rename = "expired")] + Expired, + #[serde(rename = "done_for_day")] + DoneForDay, + #[serde(rename = "replaced")] + Replaced, + #[serde(rename = "rejected")] + Rejected, + #[serde(rename = "pending_new")] + PendingNew, + #[serde(rename = "stopped")] + Stopped, + #[serde(rename = "pending_cancel")] + PendingCancel, + #[serde(rename = "pending_replace")] + PendingReplace, + #[serde(rename = "calculated")] + Calculated, + #[serde(rename = "suspended")] + Suspended, + #[serde(rename = "order_replace_rejected")] + OrderReplaceRejected, + #[serde(rename = "order_cancel_rejected")] + OrderCancelRejected, +} + +impl ToString for TradeUpdateEventType { + fn to_string(&self) -> String { + match self { + Self::New => String::from("new"), + Self::Fill => String::from("fill"), + Self::PartialFill => String::from("partial_fill"), + Self::Canceled => String::from("canceled"), + Self::Expired => String::from("expired"), + Self::DoneForDay => String::from("done_for_day"), + Self::Replaced => String::from("replaced"), + Self::Rejected => String::from("rejected"), + Self::PendingNew => String::from("pending_new"), + Self::Stopped => String::from("stopped"), + Self::PendingCancel => String::from("pending_cancel"), + Self::PendingReplace => String::from("pending_replace"), + Self::Calculated => String::from("calculated"), + Self::Suspended => String::from("suspended"), + Self::OrderReplaceRejected => String::from("order_replace_rejected"), + Self::OrderCancelRejected => String::from("order_cancel_rejected"), + } + } +} + +impl Default for TradeUpdateEventType { + fn default() -> TradeUpdateEventType { + Self::New + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/transfer.rs b/crates/alpaca_openapi/gen/broker/src/models/transfer.rs new file mode 100644 index 0000000..8ffc666 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/transfer.rs @@ -0,0 +1,97 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Transfer : Transfers allow you to transfer money/balance into your end customers' account (deposits) or out (withdrawal). [Main docs here](https://alpaca.markets/docs/api-references/broker-api/funding/transfers/#the-transfer-object) +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Transfer { + /// The transfer ID + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// The ACH relationship ID only present if type = \"ach\" + #[serde(rename = "relationship_id", skip_serializing_if = "Option::is_none")] + pub relationship_id: Option, + /// The ID of the Bank, only present if type = \"wire\" + #[serde(rename = "bank_id", skip_serializing_if = "Option::is_none")] + pub bank_id: Option, + /// The account ID + #[serde(rename = "account_id")] + pub account_id: uuid::Uuid, + #[serde(rename = "type")] + pub r#type: models::TransferType, + #[serde(rename = "status")] + pub status: models::TransferStatus, + /// Cause of the status + #[serde( + rename = "reason", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub reason: Option>, + /// Must be > 0.00 + #[serde(rename = "amount")] + pub amount: String, + #[serde(rename = "direction")] + pub direction: models::TransferDirection, + /// Timedate when transfer was created + #[serde(rename = "created_at")] + pub created_at: String, + /// Timedate when transfer was updated + #[serde(rename = "updated_at", skip_serializing_if = "Option::is_none")] + pub updated_at: Option, + /// Timedate when transfer was expired + #[serde(rename = "expires_at", skip_serializing_if = "Option::is_none")] + pub expires_at: Option, + /// Additional information. Only applies when type = \"wire\". + #[serde( + rename = "additional_information", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub additional_information: Option>, + #[serde(rename = "hold_until", skip_serializing_if = "Option::is_none")] + pub hold_until: Option, + #[serde(rename = "instant_amount", skip_serializing_if = "Option::is_none")] + pub instant_amount: Option, +} + +impl Transfer { + /// Transfers allow you to transfer money/balance into your end customers' account (deposits) or out (withdrawal). [Main docs here](https://alpaca.markets/docs/api-references/broker-api/funding/transfers/#the-transfer-object) + pub fn new( + id: uuid::Uuid, + account_id: uuid::Uuid, + r#type: models::TransferType, + status: models::TransferStatus, + amount: String, + direction: models::TransferDirection, + created_at: String, + ) -> Transfer { + Transfer { + id, + relationship_id: None, + bank_id: None, + account_id, + r#type, + status, + reason: None, + amount, + direction, + created_at, + updated_at: None, + expires_at: None, + additional_information: None, + hold_until: None, + instant_amount: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/transfer_data.rs b/crates/alpaca_openapi/gen/broker/src/models/transfer_data.rs new file mode 100644 index 0000000..78ffa8c --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/transfer_data.rs @@ -0,0 +1,92 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TransferData { + #[serde(rename = "transfer_type")] + pub transfer_type: TransferType, + #[serde(rename = "timing", skip_serializing_if = "Option::is_none")] + pub timing: Option, + #[serde(rename = "amount")] + pub amount: String, + #[serde(rename = "direction")] + pub direction: Direction, + #[serde(rename = "relationship_id")] + pub relationship_id: uuid::Uuid, + #[serde( + rename = "additional_information", + skip_serializing_if = "Option::is_none" + )] + pub additional_information: Option, + #[serde(rename = "bank_id")] + pub bank_id: uuid::Uuid, +} + +impl TransferData { + pub fn new( + transfer_type: TransferType, + amount: String, + direction: Direction, + relationship_id: uuid::Uuid, + bank_id: uuid::Uuid, + ) -> TransferData { + TransferData { + transfer_type, + timing: None, + amount, + direction, + relationship_id, + additional_information: None, + bank_id, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TransferType { + #[serde(rename = "ach")] + Ach, + #[serde(rename = "wire")] + Wire, +} + +impl Default for TransferType { + fn default() -> TransferType { + Self::Ach + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Timing { + #[serde(rename = "immediate")] + Immediate, +} + +impl Default for Timing { + fn default() -> Timing { + Self::Immediate + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Direction { + #[serde(rename = "INCOMING")] + Incoming, + #[serde(rename = "OUTGOING")] + Outgoing, +} + +impl Default for Direction { + fn default() -> Direction { + Self::Incoming + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/transfer_direction.rs b/crates/alpaca_openapi/gen/broker/src/models/transfer_direction.rs new file mode 100644 index 0000000..ed84a61 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/transfer_direction.rs @@ -0,0 +1,36 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// TransferDirection : - **INCOMING** Funds incoming to user’s account (deposit). - **OUTGOING** Funds outgoing from user’s account (withdrawal). +/// - **INCOMING** Funds incoming to user’s account (deposit). - **OUTGOING** Funds outgoing from user’s account (withdrawal). +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TransferDirection { + #[serde(rename = "INCOMING")] + Incoming, + #[serde(rename = "OUTGOING")] + Outgoing, +} + +impl ToString for TransferDirection { + fn to_string(&self) -> String { + match self { + Self::Incoming => String::from("INCOMING"), + Self::Outgoing => String::from("OUTGOING"), + } + } +} + +impl Default for TransferDirection { + fn default() -> TransferDirection { + Self::Incoming + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/transfer_resource.rs b/crates/alpaca_openapi/gen/broker/src/models/transfer_resource.rs new file mode 100644 index 0000000..e6634c7 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/transfer_resource.rs @@ -0,0 +1,139 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TransferResource { + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// Format: 2020-01-01T01:01:01Z + #[serde(rename = "created_at")] + pub created_at: String, + /// Format: 2020-01-01T01:01:01Z + #[serde(rename = "updated_at")] + pub updated_at: String, + #[serde(rename = "type")] + pub r#type: Type, + #[serde(rename = "status")] + pub status: Status, + #[serde(rename = "account_id")] + pub account_id: uuid::Uuid, + #[serde( + rename = "reason", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub reason: Option>, + #[serde(rename = "expires_at")] + pub expires_at: String, + #[serde(rename = "amount")] + pub amount: String, + #[serde(rename = "direction")] + pub direction: Direction, + #[serde(rename = "relationship_id")] + pub relationship_id: uuid::Uuid, + #[serde( + rename = "additional_information", + skip_serializing_if = "Option::is_none" + )] + pub additional_information: Option, + #[serde(rename = "bank_id")] + pub bank_id: uuid::Uuid, +} + +impl TransferResource { + pub fn new( + id: uuid::Uuid, + created_at: String, + updated_at: String, + r#type: Type, + status: Status, + account_id: uuid::Uuid, + expires_at: String, + amount: String, + direction: Direction, + relationship_id: uuid::Uuid, + bank_id: uuid::Uuid, + ) -> TransferResource { + TransferResource { + id, + created_at, + updated_at, + r#type, + status, + account_id, + reason: None, + expires_at, + amount, + direction, + relationship_id, + additional_information: None, + bank_id, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Type { + #[serde(rename = "ach")] + Ach, + #[serde(rename = "wire")] + Wire, +} + +impl Default for Type { + fn default() -> Type { + Self::Ach + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "QUEUED")] + Queued, + #[serde(rename = "APPROVAL_PENDING")] + ApprovalPending, + #[serde(rename = "PENDING")] + Pending, + #[serde(rename = "SENT_TO_CLEARING")] + SentToClearing, + #[serde(rename = "REJECTED")] + Rejected, + #[serde(rename = "CANCELED")] + Canceled, + #[serde(rename = "APPROVED")] + Approved, + #[serde(rename = "COMPLETE")] + Complete, + #[serde(rename = "RETURNED")] + Returned, +} + +impl Default for Status { + fn default() -> Status { + Self::Queued + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Direction { + #[serde(rename = "INCOMING")] + Incoming, + #[serde(rename = "OUTGOING")] + Outgoing, +} + +impl Default for Direction { + fn default() -> Direction { + Self::Incoming + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/transfer_status.rs b/crates/alpaca_openapi/gen/broker/src/models/transfer_status.rs new file mode 100644 index 0000000..ee6437a --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/transfer_status.rs @@ -0,0 +1,57 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// TransferStatus : - **QUEUED** Transfer is in queue to be processed. - **APPROVAL_PENDING** Transfer is pending approval. - **PENDING** Transfer is pending processing. - **SENT_TO_CLEARING** Transfer is being processed by the clearing firm. - **REJECTED** Transfer is rejected. - **CANCELED** Client initiated transfer cancellation. - **APPROVED** Transfer is approved. - **COMPLETE** Transfer is completed. - **RETURNED** The bank issued an ACH return for the transfer. +/// - **QUEUED** Transfer is in queue to be processed. - **APPROVAL_PENDING** Transfer is pending approval. - **PENDING** Transfer is pending processing. - **SENT_TO_CLEARING** Transfer is being processed by the clearing firm. - **REJECTED** Transfer is rejected. - **CANCELED** Client initiated transfer cancellation. - **APPROVED** Transfer is approved. - **COMPLETE** Transfer is completed. - **RETURNED** The bank issued an ACH return for the transfer. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TransferStatus { + #[serde(rename = "QUEUED")] + Queued, + #[serde(rename = "APPROVAL_PENDING")] + ApprovalPending, + #[serde(rename = "PENDING")] + Pending, + #[serde(rename = "SENT_TO_CLEARING")] + SentToClearing, + #[serde(rename = "REJECTED")] + Rejected, + #[serde(rename = "CANCELED")] + Canceled, + #[serde(rename = "APPROVED")] + Approved, + #[serde(rename = "COMPLETE")] + Complete, + #[serde(rename = "RETURNED")] + Returned, +} + +impl ToString for TransferStatus { + fn to_string(&self) -> String { + match self { + Self::Queued => String::from("QUEUED"), + Self::ApprovalPending => String::from("APPROVAL_PENDING"), + Self::Pending => String::from("PENDING"), + Self::SentToClearing => String::from("SENT_TO_CLEARING"), + Self::Rejected => String::from("REJECTED"), + Self::Canceled => String::from("CANCELED"), + Self::Approved => String::from("APPROVED"), + Self::Complete => String::from("COMPLETE"), + Self::Returned => String::from("RETURNED"), + } + } +} + +impl Default for TransferStatus { + fn default() -> TransferStatus { + Self::Queued + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/transfer_status_event.rs b/crates/alpaca_openapi/gen/broker/src/models/transfer_status_event.rs new file mode 100644 index 0000000..a4d53bd --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/transfer_status_event.rs @@ -0,0 +1,53 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// TransferStatusEvent : Represents a change in a Transfer's status, sent over the events streaming api. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TransferStatusEvent { + /// Account UUID + #[serde(rename = "account_id")] + pub account_id: uuid::Uuid, + /// Timedate of when the transfer status changed + #[serde(rename = "at")] + pub at: String, + /// Monotonically increasing 64bit integer + #[serde(rename = "event_id")] + pub event_id: i32, + #[serde(rename = "status_from")] + pub status_from: models::TransferStatus, + #[serde(rename = "status_to")] + pub status_to: models::TransferStatus, + /// Transfer UUID + #[serde(rename = "transfer_id")] + pub transfer_id: uuid::Uuid, +} + +impl TransferStatusEvent { + /// Represents a change in a Transfer's status, sent over the events streaming api. + pub fn new( + account_id: uuid::Uuid, + at: String, + event_id: i32, + status_from: models::TransferStatus, + status_to: models::TransferStatus, + transfer_id: uuid::Uuid, + ) -> TransferStatusEvent { + TransferStatusEvent { + account_id, + at, + event_id, + status_from, + status_to, + transfer_id, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/transfer_timing.rs b/crates/alpaca_openapi/gen/broker/src/models/transfer_timing.rs new file mode 100644 index 0000000..3290f70 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/transfer_timing.rs @@ -0,0 +1,33 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// TransferTiming : Only `immediate` is currently supported. values: - **immediate** - **next_day** +/// Only `immediate` is currently supported. values: - **immediate** - **next_day** +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TransferTiming { + #[serde(rename = "immediate")] + Immediate, +} + +impl ToString for TransferTiming { + fn to_string(&self) -> String { + match self { + Self::Immediate => String::from("immediate"), + } + } +} + +impl Default for TransferTiming { + fn default() -> TransferTiming { + Self::Immediate + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/transfer_type.rs b/crates/alpaca_openapi/gen/broker/src/models/transfer_type.rs new file mode 100644 index 0000000..dd07f09 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/transfer_type.rs @@ -0,0 +1,39 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// TransferType : **NOTE:** The Sandbox environment currently only supports `ach` - **ach** Transfer via ACH (US Only). - **wire** Transfer via wire (international). +/// **NOTE:** The Sandbox environment currently only supports `ach` - **ach** Transfer via ACH (US Only). - **wire** Transfer via wire (international). +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TransferType { + #[serde(rename = "ach")] + Ach, + #[serde(rename = "instant_ach")] + InstantAch, + #[serde(rename = "wire")] + Wire, +} + +impl ToString for TransferType { + fn to_string(&self) -> String { + match self { + Self::Ach => String::from("ach"), + Self::InstantAch => String::from("instant_ach"), + Self::Wire => String::from("wire"), + } + } +} + +impl Default for TransferType { + fn default() -> TransferType { + Self::Ach + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/trusted_contact.rs b/crates/alpaca_openapi/gen/broker/src/models/trusted_contact.rs new file mode 100644 index 0000000..0fadea0 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/trusted_contact.rs @@ -0,0 +1,58 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// TrustedContact : This model input is optional. However, the client should make reasonable effort to obtain the trusted contact information. See more details in [FINRA Notice 17-11](https://www.finra.org/sites/default/files/Regulatory-Notice-17-11.pdf) +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TrustedContact { + #[serde(rename = "given_name")] + pub given_name: String, + #[serde(rename = "family_name")] + pub family_name: String, + /// at least one of `email_address`, `phone_number` or `street_address` is required + #[serde(rename = "email_address", skip_serializing_if = "Option::is_none")] + pub email_address: Option, + /// at least one of `email_address`, `phone_number` or `street_address` is required + #[serde(rename = "phone_number", skip_serializing_if = "Option::is_none")] + pub phone_number: Option, + /// at least one of `email_address`, `phone_number` or `street_address` is required + #[serde(rename = "street_address", skip_serializing_if = "Option::is_none")] + pub street_address: Option>, + /// required if `street_address` is set + #[serde(rename = "city", skip_serializing_if = "Option::is_none")] + pub city: Option, + /// required if `street_address` is set + #[serde(rename = "state", skip_serializing_if = "Option::is_none")] + pub state: Option, + /// required if `street_address` is set + #[serde(rename = "postal_code", skip_serializing_if = "Option::is_none")] + pub postal_code: Option, + /// [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html). required if `street_address` is set + #[serde(rename = "country", skip_serializing_if = "Option::is_none")] + pub country: Option, +} + +impl TrustedContact { + /// This model input is optional. However, the client should make reasonable effort to obtain the trusted contact information. See more details in [FINRA Notice 17-11](https://www.finra.org/sites/default/files/Regulatory-Notice-17-11.pdf) + pub fn new(given_name: String, family_name: String) -> TrustedContact { + TrustedContact { + given_name, + family_name, + email_address: None, + phone_number: None, + street_address: None, + city: None, + state: None, + postal_code: None, + country: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/untyped_ach_transfer_data.rs b/crates/alpaca_openapi/gen/broker/src/models/untyped_ach_transfer_data.rs new file mode 100644 index 0000000..8080862 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/untyped_ach_transfer_data.rs @@ -0,0 +1,49 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UntypedAchTransferData { + #[serde(rename = "amount")] + pub amount: String, + #[serde(rename = "direction")] + pub direction: Direction, + #[serde(rename = "relationship_id")] + pub relationship_id: uuid::Uuid, +} + +impl UntypedAchTransferData { + pub fn new( + amount: String, + direction: Direction, + relationship_id: uuid::Uuid, + ) -> UntypedAchTransferData { + UntypedAchTransferData { + amount, + direction, + relationship_id, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Direction { + #[serde(rename = "INCOMING")] + Incoming, + #[serde(rename = "OUTGOING")] + Outgoing, +} + +impl Default for Direction { + fn default() -> Direction { + Self::Incoming + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/untyped_transfer_data.rs b/crates/alpaca_openapi/gen/broker/src/models/untyped_transfer_data.rs new file mode 100644 index 0000000..8ec7358 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/untyped_transfer_data.rs @@ -0,0 +1,39 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UntypedTransferData { + #[serde(rename = "amount")] + pub amount: String, + #[serde(rename = "direction")] + pub direction: Direction, +} + +impl UntypedTransferData { + pub fn new(amount: String, direction: Direction) -> UntypedTransferData { + UntypedTransferData { amount, direction } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Direction { + #[serde(rename = "INCOMING")] + Incoming, + #[serde(rename = "OUTGOING")] + Outgoing, +} + +impl Default for Direction { + fn default() -> Direction { + Self::Incoming + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/untyped_wire_transfer_data.rs b/crates/alpaca_openapi/gen/broker/src/models/untyped_wire_transfer_data.rs new file mode 100644 index 0000000..1a9c990 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/untyped_wire_transfer_data.rs @@ -0,0 +1,55 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UntypedWireTransferData { + #[serde(rename = "amount")] + pub amount: String, + #[serde(rename = "direction")] + pub direction: Direction, + #[serde( + rename = "additional_information", + skip_serializing_if = "Option::is_none" + )] + pub additional_information: Option, + #[serde(rename = "bank_id")] + pub bank_id: uuid::Uuid, +} + +impl UntypedWireTransferData { + pub fn new( + amount: String, + direction: Direction, + bank_id: uuid::Uuid, + ) -> UntypedWireTransferData { + UntypedWireTransferData { + amount, + direction, + additional_information: None, + bank_id, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Direction { + #[serde(rename = "INCOMING")] + Incoming, + #[serde(rename = "OUTGOING")] + Outgoing, +} + +impl Default for Direction { + fn default() -> Direction { + Self::Incoming + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/update_order_request.rs b/crates/alpaca_openapi/gen/broker/src/models/update_order_request.rs new file mode 100644 index 0000000..dc288c9 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/update_order_request.rs @@ -0,0 +1,46 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// UpdateOrderRequest : Represents the fields that are editable in an order replace/update call. Note: client_order_id is currently not editable on its own, one of the other fields must be changed at the same time to effectively replace the order +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UpdateOrderRequest { + /// You can only patch full shares for now + #[serde(rename = "qty", skip_serializing_if = "Option::is_none")] + pub qty: Option, + #[serde(rename = "time_in_force", skip_serializing_if = "Option::is_none")] + pub time_in_force: Option, + /// Required if original order's `type` field was limit or stop_limit + #[serde(rename = "limit_price", skip_serializing_if = "Option::is_none")] + pub limit_price: Option, + /// Required if original order's `type` field was stop or stop_limit + #[serde(rename = "stop_price", skip_serializing_if = "Option::is_none")] + pub stop_price: Option, + /// The new value of the trail_price or trail_percent + #[serde(rename = "trail", skip_serializing_if = "Option::is_none")] + pub trail: Option, + #[serde(rename = "client_order_id", skip_serializing_if = "Option::is_none")] + pub client_order_id: Option, +} + +impl UpdateOrderRequest { + /// Represents the fields that are editable in an order replace/update call. Note: client_order_id is currently not editable on its own, one of the other fields must be changed at the same time to effectively replace the order + pub fn new() -> UpdateOrderRequest { + UpdateOrderRequest { + qty: None, + time_in_force: None, + limit_price: None, + stop_price: None, + trail: None, + client_order_id: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/broker/src/models/watchlist.rs b/crates/alpaca_openapi/gen/broker/src/models/watchlist.rs new file mode 100644 index 0000000..5244688 --- /dev/null +++ b/crates/alpaca_openapi/gen/broker/src/models/watchlist.rs @@ -0,0 +1,48 @@ +/* + * Broker API + * + * Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Watchlist : Represents a set of securities observed by a user. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Watchlist { + /// Unique identifier of the watchlist itself. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// Unique identifier of the account that owns this watchlist. + #[serde(rename = "account_id", skip_serializing_if = "Option::is_none")] + pub account_id: Option, + /// When watchlist was created + #[serde(rename = "created_at", skip_serializing_if = "Option::is_none")] + pub created_at: Option, + /// When watchlist was last updated + #[serde(rename = "updated_at", skip_serializing_if = "Option::is_none")] + pub updated_at: Option, + /// User friendly Name of watchlist + #[serde(rename = "name")] + pub name: String, + /// The contents of the watchlist, in the order as registered + #[serde(rename = "assets", skip_serializing_if = "Option::is_none")] + pub assets: Option>, +} + +impl Watchlist { + /// Represents a set of securities observed by a user. + pub fn new(id: uuid::Uuid, name: String) -> Watchlist { + Watchlist { + id, + account_id: None, + created_at: None, + updated_at: None, + name, + assets: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/.gitignore b/crates/alpaca_openapi/gen/data/.gitignore new file mode 100644 index 0000000..6aa1064 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/crates/alpaca_openapi/gen/data/.openapi-generator-ignore b/crates/alpaca_openapi/gen/data/.openapi-generator-ignore new file mode 100644 index 0000000..7484ee5 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/crates/alpaca_openapi/gen/data/.openapi-generator/FILES b/crates/alpaca_openapi/gen/data/.openapi-generator/FILES new file mode 100644 index 0000000..5b7a091 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/.openapi-generator/FILES @@ -0,0 +1,64 @@ +.gitignore +.openapi-generator-ignore +.travis.yml +Cargo.toml +README.md +docs/Bar.md +docs/BarsResponse.md +docs/CryptoPricingDataApiApi.md +docs/CryptoSpreadsResponse.md +docs/GetNewsResponse.md +docs/LatestBarResponse.md +docs/LatestMultiBarsResponse.md +docs/LatestMultiQuotesResponse.md +docs/LatestMultiTradesResponse.md +docs/LatestMultiXbboResponse.md +docs/LatestQuoteResponse.md +docs/LatestTradeResponse.md +docs/LatestXbboResponse.md +docs/LogoApi.md +docs/MultiBarsResponse.md +docs/MultiQuotesReponse.md +docs/MultiTradesResponse.md +docs/News.md +docs/NewsApi.md +docs/NewsImage.md +docs/Quote.md +docs/QuotesResponse.md +docs/Snapshot.md +docs/StockPricingDataApiApi.md +docs/Trade.md +docs/TradesResponse.md +docs/Xbbo.md +git_push.sh +src/apis/configuration.rs +src/apis/crypto_pricing_data_api_api.rs +src/apis/logo_api.rs +src/apis/mod.rs +src/apis/news_api.rs +src/apis/stock_pricing_data_api_api.rs +src/lib.rs +src/models/bar.rs +src/models/bars_response.rs +src/models/crypto_spreads_response.rs +src/models/get_news_response.rs +src/models/latest_bar_response.rs +src/models/latest_multi_bars_response.rs +src/models/latest_multi_quotes_response.rs +src/models/latest_multi_trades_response.rs +src/models/latest_multi_xbbo_response.rs +src/models/latest_quote_response.rs +src/models/latest_trade_response.rs +src/models/latest_xbbo_response.rs +src/models/mod.rs +src/models/multi_bars_response.rs +src/models/multi_quotes_reponse.rs +src/models/multi_trades_response.rs +src/models/news.rs +src/models/news_image.rs +src/models/quote.rs +src/models/quotes_response.rs +src/models/snapshot.rs +src/models/trade.rs +src/models/trades_response.rs +src/models/xbbo.rs diff --git a/crates/alpaca_openapi/gen/data/.openapi-generator/VERSION b/crates/alpaca_openapi/gen/data/.openapi-generator/VERSION new file mode 100644 index 0000000..18bb418 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.5.0 diff --git a/crates/alpaca_openapi/gen/data/.travis.yml b/crates/alpaca_openapi/gen/data/.travis.yml new file mode 100644 index 0000000..22761ba --- /dev/null +++ b/crates/alpaca_openapi/gen/data/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/crates/alpaca_openapi/gen/data/Cargo.toml b/crates/alpaca_openapi/gen/data/Cargo.toml new file mode 100644 index 0000000..baec631 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "alpaca_data" +version = "2.0.0" +authors = ["support@alpaca.markets"] +description = "Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News." +# Override this license by providing a License Object in the OpenAPI. +license = "Unlicense" +edition = "2018" + +[dependencies] +serde = "^1.0" +serde_derive = "^1.0" +serde_with = "^2.0" +serde_json = "^1.0" +url = "^2.2" +uuid = { version = "^1.0", features = ["serde", "v4"] } +[dependencies.reqwest] +version = "^0.11" +features = ["json", "multipart"] diff --git a/crates/alpaca_openapi/gen/data/README.md b/crates/alpaca_openapi/gen/data/README.md new file mode 100644 index 0000000..5847bea --- /dev/null +++ b/crates/alpaca_openapi/gen/data/README.md @@ -0,0 +1,103 @@ +# Rust API client for alpaca_data + +Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + +For more information, please visit [https://alpaca.markets/support](https://alpaca.markets/support) + +## Overview + +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 2.0.0 +- Package version: 2.0.0 +- Generator version: 7.5.0 +- Build package: `org.openapitools.codegen.languages.RustClientCodegen` + +## Installation + +Put the package under your project folder in a directory named `alpaca_data` and add the following to `Cargo.toml` under `[dependencies]`: + +``` +alpaca_data = { path = "./alpaca_data" } +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://data.alpaca.markets* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*CryptoPricingDataApiApi* | [**get_bars_for_crypto_symbol**](docs/CryptoPricingDataApiApi.md#get_bars_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/bars | Get Bar data for a crypto symbol +*CryptoPricingDataApiApi* | [**get_bars_for_multiple_crypto_symbols**](docs/CryptoPricingDataApiApi.md#get_bars_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/bars | Get Bars for multiple Crypto symbols +*CryptoPricingDataApiApi* | [**get_crypto_meta_spreads**](docs/CryptoPricingDataApiApi.md#get_crypto_meta_spreads) | **GET** /v1beta1/crypto/meta/spreads | Get list of crypto spreads per exchange +*CryptoPricingDataApiApi* | [**get_latest_bars_for_crypto_symbol**](docs/CryptoPricingDataApiApi.md#get_latest_bars_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/bars/latest | Get Latest Bar data for a Crypto symbol +*CryptoPricingDataApiApi* | [**get_latest_bars_for_multiple_crypto_symbols**](docs/CryptoPricingDataApiApi.md#get_latest_bars_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/bars/latest | Get Latest Bars for multiple Crypto symbols +*CryptoPricingDataApiApi* | [**get_latest_quote_for_crypto_symbol**](docs/CryptoPricingDataApiApi.md#get_latest_quote_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/quotes/latest | Latest Quote +*CryptoPricingDataApiApi* | [**get_latest_quotes_for_multiple_crypto_symbols**](docs/CryptoPricingDataApiApi.md#get_latest_quotes_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/quotes/latest | Get Latest Quotes for multiple Crypto symbols +*CryptoPricingDataApiApi* | [**get_latest_trades_for_crypto_symbol**](docs/CryptoPricingDataApiApi.md#get_latest_trades_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/trades/latest | Latest Trades +*CryptoPricingDataApiApi* | [**get_latest_trades_for_multiple_crypto_symbols**](docs/CryptoPricingDataApiApi.md#get_latest_trades_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/trades/latest | Get Latest Trade data for multiple Crypto symbols +*CryptoPricingDataApiApi* | [**get_latest_xbbo_for_crypto_symbol**](docs/CryptoPricingDataApiApi.md#get_latest_xbbo_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/xbbo/latest | Get Latest XBBO for a single crypto symbol +*CryptoPricingDataApiApi* | [**get_latest_xbbo_for_multiple_crypto_symbols**](docs/CryptoPricingDataApiApi.md#get_latest_xbbo_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/xbbos/latest | Get Latest XBBO for multiple crypto symbols +*CryptoPricingDataApiApi* | [**get_quotes_for_crypto_symbol**](docs/CryptoPricingDataApiApi.md#get_quotes_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/quotes | Get Quotes for crypto symbol +*CryptoPricingDataApiApi* | [**get_quotes_for_multiple_crypto_symbols**](docs/CryptoPricingDataApiApi.md#get_quotes_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/quotes | Get Quotes for multiple crypto symbols +*CryptoPricingDataApiApi* | [**get_snapshot_for_crypto_symbol**](docs/CryptoPricingDataApiApi.md#get_snapshot_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/snapshot | Get a Snapshot for a crypto symbol +*CryptoPricingDataApiApi* | [**get_snapshots_for_multiple_crypto_symbols**](docs/CryptoPricingDataApiApi.md#get_snapshots_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/snapshots | Get Snapshots for multiple crypto symbols +*CryptoPricingDataApiApi* | [**get_trades_for_crypto_symbol**](docs/CryptoPricingDataApiApi.md#get_trades_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/trades | Get Trade data for a crypto symbol +*CryptoPricingDataApiApi* | [**get_trades_for_multiple_crypto_symbols**](docs/CryptoPricingDataApiApi.md#get_trades_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/trades | Get Trade data for multiple crypto symbols +*LogoApi* | [**get_logo_for_symbol**](docs/LogoApi.md#get_logo_for_symbol) | **GET** /v1beta1/logos/{crypto_or_stock_symbol} | Get Logo for symbol +*NewsApi* | [**get_news**](docs/NewsApi.md#get_news) | **GET** /v1beta1/news | News API +*StockPricingDataApiApi* | [**get_bars_for_multiple_stock_symbols**](docs/StockPricingDataApiApi.md#get_bars_for_multiple_stock_symbols) | **GET** /v2/stocks/bars | Get Bar data for multiple stock symbols +*StockPricingDataApiApi* | [**get_bars_for_stock_symbol**](docs/StockPricingDataApiApi.md#get_bars_for_stock_symbol) | **GET** /v2/stocks/{symbol}/bars | Bars +*StockPricingDataApiApi* | [**get_conditions**](docs/StockPricingDataApiApi.md#get_conditions) | **GET** /v2/stocks/meta/conditions/{type} | Get list of Conditions +*StockPricingDataApiApi* | [**get_exchanges**](docs/StockPricingDataApiApi.md#get_exchanges) | **GET** /v2/stocks/meta/exchanges | Get List of supported exchanges +*StockPricingDataApiApi* | [**get_latest_bar_for_stock_symbol**](docs/StockPricingDataApiApi.md#get_latest_bar_for_stock_symbol) | **GET** /v2/stocks/{symbol}/bars/latest | Get Latest Bars for Symbol +*StockPricingDataApiApi* | [**get_latest_bars_for_multiple_stock_symbols**](docs/StockPricingDataApiApi.md#get_latest_bars_for_multiple_stock_symbols) | **GET** /v2/stocks/bars/latest | Get Latest Bar data for multiple stock symbols +*StockPricingDataApiApi* | [**get_latest_quote_for_stock_symbol**](docs/StockPricingDataApiApi.md#get_latest_quote_for_stock_symbol) | **GET** /v2/stocks/{symbol}/quotes/latest | Get Latest Quote for stock symbol +*StockPricingDataApiApi* | [**get_latest_quotes_for_multiple_stock_symbols**](docs/StockPricingDataApiApi.md#get_latest_quotes_for_multiple_stock_symbols) | **GET** /v2/stocks/quotes/latest | Get Latest Quotes for multiple stock symbols +*StockPricingDataApiApi* | [**get_latest_trade_for_stock_symbol**](docs/StockPricingDataApiApi.md#get_latest_trade_for_stock_symbol) | **GET** /v2/stocks/{symbol}/trades/latest | Latest Trade +*StockPricingDataApiApi* | [**get_latest_trades_for_multiple_stock_symbols**](docs/StockPricingDataApiApi.md#get_latest_trades_for_multiple_stock_symbols) | **GET** /v2/stocks/trades/latest | Get Latest Trades data for multiple stock symbols +*StockPricingDataApiApi* | [**get_quotes_for_multiple_stock_symbols**](docs/StockPricingDataApiApi.md#get_quotes_for_multiple_stock_symbols) | **GET** /v2/stocks/quotes | Get Quotes for multiple stock symbols +*StockPricingDataApiApi* | [**get_quotes_for_stock_symbol**](docs/StockPricingDataApiApi.md#get_quotes_for_stock_symbol) | **GET** /v2/stocks/{symbol}/quotes | Get Quotes for stock symbol +*StockPricingDataApiApi* | [**get_snapshot_for_stock_symbol**](docs/StockPricingDataApiApi.md#get_snapshot_for_stock_symbol) | **GET** /v2/stocks/{symbol}/snapshot | Get a Snapshot for a stock symbol +*StockPricingDataApiApi* | [**get_snapshots_for_multiple_stock_symbols**](docs/StockPricingDataApiApi.md#get_snapshots_for_multiple_stock_symbols) | **GET** /v2/stocks/snapshots | Get Snapshots for multiple stock symbols +*StockPricingDataApiApi* | [**get_trades_for_multiple_stock_symbols**](docs/StockPricingDataApiApi.md#get_trades_for_multiple_stock_symbols) | **GET** /v2/stocks/trades | Get Trade data for multiple stock symbols +*StockPricingDataApiApi* | [**get_trades_for_stock_symbol**](docs/StockPricingDataApiApi.md#get_trades_for_stock_symbol) | **GET** /v2/stocks/{symbol}/trades | Trades + + +## Documentation For Models + + - [Bar](docs/Bar.md) + - [BarsResponse](docs/BarsResponse.md) + - [CryptoSpreadsResponse](docs/CryptoSpreadsResponse.md) + - [GetNewsResponse](docs/GetNewsResponse.md) + - [LatestBarResponse](docs/LatestBarResponse.md) + - [LatestMultiBarsResponse](docs/LatestMultiBarsResponse.md) + - [LatestMultiQuotesResponse](docs/LatestMultiQuotesResponse.md) + - [LatestMultiTradesResponse](docs/LatestMultiTradesResponse.md) + - [LatestMultiXbboResponse](docs/LatestMultiXbboResponse.md) + - [LatestQuoteResponse](docs/LatestQuoteResponse.md) + - [LatestTradeResponse](docs/LatestTradeResponse.md) + - [LatestXbboResponse](docs/LatestXbboResponse.md) + - [MultiBarsResponse](docs/MultiBarsResponse.md) + - [MultiQuotesReponse](docs/MultiQuotesReponse.md) + - [MultiTradesResponse](docs/MultiTradesResponse.md) + - [News](docs/News.md) + - [NewsImage](docs/NewsImage.md) + - [Quote](docs/Quote.md) + - [QuotesResponse](docs/QuotesResponse.md) + - [Snapshot](docs/Snapshot.md) + - [Trade](docs/Trade.md) + - [TradesResponse](docs/TradesResponse.md) + - [Xbbo](docs/Xbbo.md) + + +To get access to the crate's generated documentation, use: + +``` +cargo doc --open +``` + +## Author + +support@alpaca.markets + diff --git a/crates/alpaca_openapi/gen/data/docs/Bar.md b/crates/alpaca_openapi/gen/data/docs/Bar.md new file mode 100644 index 0000000..5e9a3c3 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/Bar.md @@ -0,0 +1,19 @@ +# Bar + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**t** | **String** | Timestamp in RFC-3339 format with nanosecond precision. | +**x** | Option<**String**> | Exchange. Only present on Bars for Crypto symbols | [optional] +**o** | **f64** | Open price | +**h** | **f64** | High price. | +**l** | **f64** | Low price. | +**c** | **f64** | Close price. | +**v** | **f64** | Volume. | +**n** | Option<**i64**> | Number of trades. | [optional] +**vw** | Option<**f64**> | Volume weighted average price. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/BarsResponse.md b/crates/alpaca_openapi/gen/data/docs/BarsResponse.md new file mode 100644 index 0000000..87389fd --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/BarsResponse.md @@ -0,0 +1,13 @@ +# BarsResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bars** | [**Vec**](Bar.md) | The array of Bar data | +**symbol** | **String** | the stock ticker or crypto symbol this set of bar data is for | +**next_page_token** | Option<**String**> | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/CryptoPricingDataApiApi.md b/crates/alpaca_openapi/gen/data/docs/CryptoPricingDataApiApi.md new file mode 100644 index 0000000..b833b01 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/CryptoPricingDataApiApi.md @@ -0,0 +1,574 @@ +# \CryptoPricingDataApiApi + +All URIs are relative to *https://data.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_bars_for_crypto_symbol**](CryptoPricingDataApiApi.md#get_bars_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/bars | Get Bar data for a crypto symbol +[**get_bars_for_multiple_crypto_symbols**](CryptoPricingDataApiApi.md#get_bars_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/bars | Get Bars for multiple Crypto symbols +[**get_crypto_meta_spreads**](CryptoPricingDataApiApi.md#get_crypto_meta_spreads) | **GET** /v1beta1/crypto/meta/spreads | Get list of crypto spreads per exchange +[**get_latest_bars_for_crypto_symbol**](CryptoPricingDataApiApi.md#get_latest_bars_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/bars/latest | Get Latest Bar data for a Crypto symbol +[**get_latest_bars_for_multiple_crypto_symbols**](CryptoPricingDataApiApi.md#get_latest_bars_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/bars/latest | Get Latest Bars for multiple Crypto symbols +[**get_latest_quote_for_crypto_symbol**](CryptoPricingDataApiApi.md#get_latest_quote_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/quotes/latest | Latest Quote +[**get_latest_quotes_for_multiple_crypto_symbols**](CryptoPricingDataApiApi.md#get_latest_quotes_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/quotes/latest | Get Latest Quotes for multiple Crypto symbols +[**get_latest_trades_for_crypto_symbol**](CryptoPricingDataApiApi.md#get_latest_trades_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/trades/latest | Latest Trades +[**get_latest_trades_for_multiple_crypto_symbols**](CryptoPricingDataApiApi.md#get_latest_trades_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/trades/latest | Get Latest Trade data for multiple Crypto symbols +[**get_latest_xbbo_for_crypto_symbol**](CryptoPricingDataApiApi.md#get_latest_xbbo_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/xbbo/latest | Get Latest XBBO for a single crypto symbol +[**get_latest_xbbo_for_multiple_crypto_symbols**](CryptoPricingDataApiApi.md#get_latest_xbbo_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/xbbos/latest | Get Latest XBBO for multiple crypto symbols +[**get_quotes_for_crypto_symbol**](CryptoPricingDataApiApi.md#get_quotes_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/quotes | Get Quotes for crypto symbol +[**get_quotes_for_multiple_crypto_symbols**](CryptoPricingDataApiApi.md#get_quotes_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/quotes | Get Quotes for multiple crypto symbols +[**get_snapshot_for_crypto_symbol**](CryptoPricingDataApiApi.md#get_snapshot_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/snapshot | Get a Snapshot for a crypto symbol +[**get_snapshots_for_multiple_crypto_symbols**](CryptoPricingDataApiApi.md#get_snapshots_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/snapshots | Get Snapshots for multiple crypto symbols +[**get_trades_for_crypto_symbol**](CryptoPricingDataApiApi.md#get_trades_for_crypto_symbol) | **GET** /v1beta1/crypto/{symbol}/trades | Get Trade data for a crypto symbol +[**get_trades_for_multiple_crypto_symbols**](CryptoPricingDataApiApi.md#get_trades_for_multiple_crypto_symbols) | **GET** /v1beta1/crypto/trades | Get Trade data for multiple crypto symbols + + + +## get_bars_for_crypto_symbol + +> models::BarsResponse get_bars_for_crypto_symbol(symbol, timeframe, start, end, exchanges, limit, page_token) +Get Bar data for a crypto symbol + +The Bars API returns aggregate historical data for the requested securities.. Returns bars for the queried crypto symbol + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. | [required] | +**timeframe** | **String** | Timeframe for the aggregation. Values are customizeable, frequently used examples: 1Min, 15Min, 1Hour, 1Day. Limits: 1Min-59Min, 1Hour-23Hour. | [required] | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | +**exchanges** | Option<**String**> | A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | | +**limit** | Option<**i32**> | Number of data points to return. Must be in range 1-10000, defaults to 1000. | | +**page_token** | Option<**String**> | Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. | | + +### Return type + +[**models::BarsResponse**](BarsResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_bars_for_multiple_crypto_symbols + +> models::MultiBarsResponse get_bars_for_multiple_crypto_symbols(symbols, timeframe, start, end, page_token, limit, exchanges) +Get Bars for multiple Crypto symbols + +returns aggregate historical data for the requested crypto symbols. Returned results are sorted by symbol first then by Bar timestamp. This means that you are likely to see only one symbol in your first response if there are enough Bars for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Bars were found for them. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH | [required] | +**timeframe** | **String** | Timeframe for the aggregation. Values are customizeable, frequently used examples: 1Min, 15Min, 1Hour, 1Day. Limits: 1Min-59Min, 1Hour-23Hour. | [required] | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | +**page_token** | Option<**String**> | Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. | | +**limit** | Option<**i32**> | Number of data points to return. Must be in range 1-10000, defaults to 1000. | | +**exchanges** | Option<**String**> | A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | | + +### Return type + +[**models::MultiBarsResponse**](MultiBarsResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_crypto_meta_spreads + +> models::CryptoSpreadsResponse get_crypto_meta_spreads() +Get list of crypto spreads per exchange + +Get list of crypto spreads for the different exchanges Alpaca supports in basis points. + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::CryptoSpreadsResponse**](CryptoSpreadsResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_latest_bars_for_crypto_symbol + +> models::LatestBarResponse get_latest_bars_for_crypto_symbol(symbol, exchange) +Get Latest Bar data for a Crypto symbol + +Gets latest historical bar data for the requested crypto symbol for a specific exchange + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. | [required] | +**exchange** | **String** | Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | [required] | + +### Return type + +[**models::LatestBarResponse**](LatestBarResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_latest_bars_for_multiple_crypto_symbols + +> models::LatestMultiBarsResponse get_latest_bars_for_multiple_crypto_symbols(symbols, exchange) +Get Latest Bars for multiple Crypto symbols + +returns latest historical data for the requested crypto symbols for a specific exchange + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH | [required] | +**exchange** | **String** | Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | [required] | + +### Return type + +[**models::LatestMultiBarsResponse**](LatestMultiBarsResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_latest_quote_for_crypto_symbol + +> models::LatestQuoteResponse get_latest_quote_for_crypto_symbol(symbol, exchange) +Latest Quote + +Returns latest quote for the queried crypto symbol + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. | [required] | +**exchange** | **String** | Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | [required] | + +### Return type + +[**models::LatestQuoteResponse**](LatestQuoteResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_latest_quotes_for_multiple_crypto_symbols + +> models::LatestMultiQuotesResponse get_latest_quotes_for_multiple_crypto_symbols(symbols, exchange) +Get Latest Quotes for multiple Crypto symbols + +Provides latest quotes for a list of given crypto symbols. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH | [required] | +**exchange** | **String** | Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | [required] | + +### Return type + +[**models::LatestMultiQuotesResponse**](LatestMultiQuotesResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_latest_trades_for_crypto_symbol + +> models::LatestTradeResponse get_latest_trades_for_crypto_symbol(symbol, exchange) +Latest Trades + +The Latest Trades API provides the latest historical trade data for a given crypto symbol. Returns trades for the queried crypto symbol. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. | [required] | +**exchange** | **String** | Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | [required] | + +### Return type + +[**models::LatestTradeResponse**](LatestTradeResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_latest_trades_for_multiple_crypto_symbols + +> models::LatestMultiTradesResponse get_latest_trades_for_multiple_crypto_symbols(symbols, exchange) +Get Latest Trade data for multiple Crypto symbols + +Provides latest trade data for a list of given crypto symbols. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH | [required] | +**exchange** | **String** | Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | [required] | + +### Return type + +[**models::LatestMultiTradesResponse**](LatestMultiTradesResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_latest_xbbo_for_crypto_symbol + +> models::LatestXbboResponse get_latest_xbbo_for_crypto_symbol(symbol, exchanges) +Get Latest XBBO for a single crypto symbol + +Returns the XBBO for a crypto symbol that calculates the Best Bid and Offer across multiple exchanges. If exchanges is not specified then only the exchanges that can be traded on Alpaca are included in the calculation. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. | [required] | +**exchanges** | Option<**String**> | A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | | + +### Return type + +[**models::LatestXbboResponse**](LatestXBBOResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_latest_xbbo_for_multiple_crypto_symbols + +> models::LatestMultiXbboResponse get_latest_xbbo_for_multiple_crypto_symbols(symbols, exchanges) +Get Latest XBBO for multiple crypto symbols + +Returns the latest XBBO for a given list crypto symbols that calculates the Best Bid and Offer across multiple exchanges. If exchanges is not specified then only the exchanges that can be traded on Alpaca are included in the calculation. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH | [required] | +**exchanges** | Option<**String**> | A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | | + +### Return type + +[**models::LatestMultiXbboResponse**](LatestMultiXBBOResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_quotes_for_crypto_symbol + +> models::QuotesResponse get_quotes_for_crypto_symbol(symbol, start, end, exchanges, limit, page_token) +Get Quotes for crypto symbol + +The Quotes API provides quotes for a given crypto symbol at a specified date. Returns quotes for the queried crypto symbol + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. | [required] | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | +**exchanges** | Option<**String**> | A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | | +**limit** | Option<**i32**> | Number of data points to return. Must be in range 1-10000, defaults to 1000. | | +**page_token** | Option<**String**> | Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. | | + +### Return type + +[**models::QuotesResponse**](QuotesResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_quotes_for_multiple_crypto_symbols + +> models::MultiQuotesReponse get_quotes_for_multiple_crypto_symbols(symbols, start, end, exchanges, limit, page_token) +Get Quotes for multiple crypto symbols + +The Multi Quotes API provides quotes for a list of given crypto symbols at a specified date. Returns quotes for each of the queried crypto symbols. Returned results are sorted by symbol first then by Quote timestamp. This means that you are likely to see only one symbol in your first response if there are enough Quotes for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Quotes were found for them. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH | [required] | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | +**exchanges** | Option<**String**> | A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | | +**limit** | Option<**i32**> | Number of data points to return. Must be in range 1-10000, defaults to 1000. | | +**page_token** | Option<**String**> | Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. | | + +### Return type + +[**models::MultiQuotesReponse**](MultiQuotesReponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_snapshot_for_crypto_symbol + +> models::Snapshot get_snapshot_for_crypto_symbol(symbol, exchange) +Get a Snapshot for a crypto symbol + +The Snapshot API returns the latest trade, latest quote, minute bar daily bar, and previous daily bar data for a given crypto symbol. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. | [required] | +**exchange** | **String** | Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | [required] | + +### Return type + +[**models::Snapshot**](Snapshot.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_snapshots_for_multiple_crypto_symbols + +> std::collections::HashMap get_snapshots_for_multiple_crypto_symbols(exchange, symbols) +Get Snapshots for multiple crypto symbols + +The Multi Snapshot API returns the latest trade, latest quote, minute bar daily bar, and previous daily bar data for list of given crypto symbols. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**exchange** | **String** | Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | [required] | +**symbols** | **String** | The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH | [required] | + +### Return type + +[**std::collections::HashMap**](Snapshot.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json, application/xml, multipart/form-data + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_trades_for_crypto_symbol + +> models::TradesResponse get_trades_for_crypto_symbol(symbol, start, end, exchanges, limit, page_token) +Get Trade data for a crypto symbol + +The Trades API provides historical trade data for a given crypto symbol on a specified date. Returns trades for the queried crypto symbol + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. | [required] | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | +**exchanges** | Option<**String**> | A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | | +**limit** | Option<**i32**> | Number of data points to return. Must be in range 1-10000, defaults to 1000. | | +**page_token** | Option<**String**> | Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. | | + +### Return type + +[**models::TradesResponse**](TradesResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_trades_for_multiple_crypto_symbols + +> models::MultiTradesResponse get_trades_for_multiple_crypto_symbols(symbols, start, end, exchanges, limit, page_token) +Get Trade data for multiple crypto symbols + +The Multi Trades API provides historical trade data for a list of given crypto symbols on a specified date. Returns trades for the queried crypto symbols. Returned results are sorted by symbol first then by Trade timestamp. This means that you are likely to see only one symbol in your first response if there are enough Trades for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Trades were found for them. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH | [required] | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | +**exchanges** | Option<**String**> | A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` | | +**limit** | Option<**i32**> | Number of data points to return. Must be in range 1-10000, defaults to 1000. | | +**page_token** | Option<**String**> | Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. | | + +### Return type + +[**models::MultiTradesResponse**](MultiTradesResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/data/docs/CryptoSpreadsResponse.md b/crates/alpaca_openapi/gen/data/docs/CryptoSpreadsResponse.md new file mode 100644 index 0000000..52f6b3c --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/CryptoSpreadsResponse.md @@ -0,0 +1,11 @@ +# CryptoSpreadsResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**spreads** | **std::collections::HashMap** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/GetNewsResponse.md b/crates/alpaca_openapi/gen/data/docs/GetNewsResponse.md new file mode 100644 index 0000000..a3663ab --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/GetNewsResponse.md @@ -0,0 +1,12 @@ +# GetNewsResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**news** | Option<[**Vec**](News.md)> | | [optional] +**next_page_token** | Option<**String**> | Pagination token for next page | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/LatestBarResponse.md b/crates/alpaca_openapi/gen/data/docs/LatestBarResponse.md new file mode 100644 index 0000000..8d7c296 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/LatestBarResponse.md @@ -0,0 +1,12 @@ +# LatestBarResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**symbol** | **String** | | +**bar** | [**models::Bar**](Bar.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/LatestMultiBarsResponse.md b/crates/alpaca_openapi/gen/data/docs/LatestMultiBarsResponse.md new file mode 100644 index 0000000..7d584b9 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/LatestMultiBarsResponse.md @@ -0,0 +1,11 @@ +# LatestMultiBarsResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bars** | [**std::collections::HashMap**](Bar.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/LatestMultiQuotesResponse.md b/crates/alpaca_openapi/gen/data/docs/LatestMultiQuotesResponse.md new file mode 100644 index 0000000..932f883 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/LatestMultiQuotesResponse.md @@ -0,0 +1,11 @@ +# LatestMultiQuotesResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**quotes** | [**std::collections::HashMap**](Quote.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/LatestMultiTradesResponse.md b/crates/alpaca_openapi/gen/data/docs/LatestMultiTradesResponse.md new file mode 100644 index 0000000..1e39e62 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/LatestMultiTradesResponse.md @@ -0,0 +1,11 @@ +# LatestMultiTradesResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**trades** | [**std::collections::HashMap**](Trade.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/LatestMultiXbboResponse.md b/crates/alpaca_openapi/gen/data/docs/LatestMultiXbboResponse.md new file mode 100644 index 0000000..bbf5294 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/LatestMultiXbboResponse.md @@ -0,0 +1,11 @@ +# LatestMultiXbboResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**xbbos** | [**std::collections::HashMap**](XBBO.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/LatestQuoteResponse.md b/crates/alpaca_openapi/gen/data/docs/LatestQuoteResponse.md new file mode 100644 index 0000000..d2f3edf --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/LatestQuoteResponse.md @@ -0,0 +1,12 @@ +# LatestQuoteResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**quote** | [**models::Quote**](Quote.md) | | +**symbol** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/LatestTradeResponse.md b/crates/alpaca_openapi/gen/data/docs/LatestTradeResponse.md new file mode 100644 index 0000000..72aaf70 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/LatestTradeResponse.md @@ -0,0 +1,12 @@ +# LatestTradeResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**trade** | Option<[**models::Trade**](Trade.md)> | | [optional] +**symbol** | **String** | Symbol that was queried | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/LatestXbboResponse.md b/crates/alpaca_openapi/gen/data/docs/LatestXbboResponse.md new file mode 100644 index 0000000..c2b2522 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/LatestXbboResponse.md @@ -0,0 +1,12 @@ +# LatestXbboResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**symbol** | **String** | | +**xbbo** | [**models::Xbbo**](XBBO.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/LogoApi.md b/crates/alpaca_openapi/gen/data/docs/LogoApi.md new file mode 100644 index 0000000..558b9fb --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/LogoApi.md @@ -0,0 +1,40 @@ +# \LogoApi + +All URIs are relative to *https://data.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_logo_for_symbol**](LogoApi.md#get_logo_for_symbol) | **GET** /v1beta1/logos/{crypto_or_stock_symbol} | Get Logo for symbol + + + +## get_logo_for_symbol + +> std::path::PathBuf get_logo_for_symbol(crypto_or_stock_symbol, placeholder) +Get Logo for symbol + +Returns logo image resource for provided symbol. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**crypto_or_stock_symbol** | **String** | The crypto or stock symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. | [required] | +**placeholder** | Option<**bool**> | If true then the api will generate a placeholder image if no logo was found. Defaults to true | |[default to true] + +### Return type + +[**std::path::PathBuf**](std::path::PathBuf.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: image/* + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/data/docs/MultiBarsResponse.md b/crates/alpaca_openapi/gen/data/docs/MultiBarsResponse.md new file mode 100644 index 0000000..a3bf0da --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/MultiBarsResponse.md @@ -0,0 +1,12 @@ +# MultiBarsResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bars** | [**std::collections::HashMap>**](Vec.md) | | +**next_page_token** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/MultiQuotesReponse.md b/crates/alpaca_openapi/gen/data/docs/MultiQuotesReponse.md new file mode 100644 index 0000000..1410f89 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/MultiQuotesReponse.md @@ -0,0 +1,12 @@ +# MultiQuotesReponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**quotes** | [**std::collections::HashMap>**](Vec.md) | | +**next_page_token** | Option<**String**> | pass this token with your request again to get the next page of results | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/MultiTradesResponse.md b/crates/alpaca_openapi/gen/data/docs/MultiTradesResponse.md new file mode 100644 index 0000000..23a9c7c --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/MultiTradesResponse.md @@ -0,0 +1,12 @@ +# MultiTradesResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**trades** | [**std::collections::HashMap>**](Vec.md) | | +**next_page_token** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/News.md b/crates/alpaca_openapi/gen/data/docs/News.md new file mode 100644 index 0000000..372180b --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/News.md @@ -0,0 +1,21 @@ +# News + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **i64** | News article ID | +**headline** | **String** | Headline or title of the article | +**author** | **String** | Original author of news article | +**created_at** | **String** | Date article was created (RFC 3339) | +**updated_at** | **String** | Date article was updated (RFC 3339) | +**summary** | **String** | Summary text for the article (may be first sentence of content) | +**content** | **String** | Content of the news article (might contain HTML) | +**url** | Option<**String**> | URL of article (if applicable) | [optional] +**images** | [**Vec**](NewsImage.md) | List of images (URLs) related to given article (may be empty) | +**symbols** | **Vec** | List of related or mentioned symbols | +**source** | **String** | Source where the news originated from (e.g. Benzinga) | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/NewsApi.md b/crates/alpaca_openapi/gen/data/docs/NewsApi.md new file mode 100644 index 0000000..52165bc --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/NewsApi.md @@ -0,0 +1,46 @@ +# \NewsApi + +All URIs are relative to *https://data.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_news**](NewsApi.md#get_news) | **GET** /v1beta1/news | News API + + + +## get_news + +> models::GetNewsResponse get_news(symbols, start, end, limit, sort, include_content, exclude_contentless, page_token) +News API + +Returns latest news articles across stocks and crypto. By default returns latest 10 news articles. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH | [required] | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | +**limit** | Option<**i32**> | Number of data points to return. Must be in range 1-10000, defaults to 1000. | | +**sort** | Option<**String**> | Sort articles by updated date. Options: DESC, ASC | | +**include_content** | Option<**bool**> | Boolean indicator to include content for news articles (if available) | | +**exclude_contentless** | Option<**bool**> | Boolean indicator to exclude news articles that do not contain content | | +**page_token** | Option<**String**> | Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. | | + +### Return type + +[**models::GetNewsResponse**](GetNewsResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/data/docs/NewsImage.md b/crates/alpaca_openapi/gen/data/docs/NewsImage.md new file mode 100644 index 0000000..f2de87f --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/NewsImage.md @@ -0,0 +1,12 @@ +# NewsImage + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**size** | **String** | Possible values for size are thumb, small and large. | [readonly] +**url** | **String** | url to image from news article | [readonly] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/Quote.md b/crates/alpaca_openapi/gen/data/docs/Quote.md new file mode 100644 index 0000000..8704d0a --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/Quote.md @@ -0,0 +1,20 @@ +# Quote + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**t** | **String** | Timestamp in RFC-3339 format with nanosecond precision | +**ax** | Option<**String**> | ask exchange (Stock quote only) | [optional] +**ap** | Option<**f64**> | ask price | [optional] +**r#as** | Option<**f64**> | ask size | [optional] +**bx** | Option<**String**> | bid exchange (Stock quote only) | [optional] +**bp** | Option<**f64**> | bid price | [optional] +**bs** | Option<**f64**> | bid size | [optional] +**c** | Option<**Vec**> | quote conditions (Stock quotes only) | [optional] +**x** | Option<**String**> | Exchange (Crypto quote Only) | [optional] +**z** | Option<**String**> | Tape (Stock quote only) | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/QuotesResponse.md b/crates/alpaca_openapi/gen/data/docs/QuotesResponse.md new file mode 100644 index 0000000..a5d9b74 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/QuotesResponse.md @@ -0,0 +1,13 @@ +# QuotesResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**quotes** | Option<[**Vec**](Quote.md)> | | +**symbol** | **String** | | +**next_page_token** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/Snapshot.md b/crates/alpaca_openapi/gen/data/docs/Snapshot.md new file mode 100644 index 0000000..ea9bb7a --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/Snapshot.md @@ -0,0 +1,15 @@ +# Snapshot + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**latest_trade** | Option<[**models::Trade**](Trade.md)> | | [optional] +**latest_quote** | Option<[**models::Quote**](Quote.md)> | | [optional] +**minute_bar** | Option<[**models::Bar**](Bar.md)> | | [optional] +**daily_bar** | Option<[**models::Bar**](Bar.md)> | | [optional] +**prev_daily_bar** | Option<[**models::Bar**](Bar.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/StockPricingDataApiApi.md b/crates/alpaca_openapi/gen/data/docs/StockPricingDataApiApi.md new file mode 100644 index 0000000..6b823d7 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/StockPricingDataApiApi.md @@ -0,0 +1,544 @@ +# \StockPricingDataApiApi + +All URIs are relative to *https://data.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_bars_for_multiple_stock_symbols**](StockPricingDataApiApi.md#get_bars_for_multiple_stock_symbols) | **GET** /v2/stocks/bars | Get Bar data for multiple stock symbols +[**get_bars_for_stock_symbol**](StockPricingDataApiApi.md#get_bars_for_stock_symbol) | **GET** /v2/stocks/{symbol}/bars | Bars +[**get_conditions**](StockPricingDataApiApi.md#get_conditions) | **GET** /v2/stocks/meta/conditions/{type} | Get list of Conditions +[**get_exchanges**](StockPricingDataApiApi.md#get_exchanges) | **GET** /v2/stocks/meta/exchanges | Get List of supported exchanges +[**get_latest_bar_for_stock_symbol**](StockPricingDataApiApi.md#get_latest_bar_for_stock_symbol) | **GET** /v2/stocks/{symbol}/bars/latest | Get Latest Bars for Symbol +[**get_latest_bars_for_multiple_stock_symbols**](StockPricingDataApiApi.md#get_latest_bars_for_multiple_stock_symbols) | **GET** /v2/stocks/bars/latest | Get Latest Bar data for multiple stock symbols +[**get_latest_quote_for_stock_symbol**](StockPricingDataApiApi.md#get_latest_quote_for_stock_symbol) | **GET** /v2/stocks/{symbol}/quotes/latest | Get Latest Quote for stock symbol +[**get_latest_quotes_for_multiple_stock_symbols**](StockPricingDataApiApi.md#get_latest_quotes_for_multiple_stock_symbols) | **GET** /v2/stocks/quotes/latest | Get Latest Quotes for multiple stock symbols +[**get_latest_trade_for_stock_symbol**](StockPricingDataApiApi.md#get_latest_trade_for_stock_symbol) | **GET** /v2/stocks/{symbol}/trades/latest | Latest Trade +[**get_latest_trades_for_multiple_stock_symbols**](StockPricingDataApiApi.md#get_latest_trades_for_multiple_stock_symbols) | **GET** /v2/stocks/trades/latest | Get Latest Trades data for multiple stock symbols +[**get_quotes_for_multiple_stock_symbols**](StockPricingDataApiApi.md#get_quotes_for_multiple_stock_symbols) | **GET** /v2/stocks/quotes | Get Quotes for multiple stock symbols +[**get_quotes_for_stock_symbol**](StockPricingDataApiApi.md#get_quotes_for_stock_symbol) | **GET** /v2/stocks/{symbol}/quotes | Get Quotes for stock symbol +[**get_snapshot_for_stock_symbol**](StockPricingDataApiApi.md#get_snapshot_for_stock_symbol) | **GET** /v2/stocks/{symbol}/snapshot | Get a Snapshot for a stock symbol +[**get_snapshots_for_multiple_stock_symbols**](StockPricingDataApiApi.md#get_snapshots_for_multiple_stock_symbols) | **GET** /v2/stocks/snapshots | Get Snapshots for multiple stock symbols +[**get_trades_for_multiple_stock_symbols**](StockPricingDataApiApi.md#get_trades_for_multiple_stock_symbols) | **GET** /v2/stocks/trades | Get Trade data for multiple stock symbols +[**get_trades_for_stock_symbol**](StockPricingDataApiApi.md#get_trades_for_stock_symbol) | **GET** /v2/stocks/{symbol}/trades | Trades + + + +## get_bars_for_multiple_stock_symbols + +> models::MultiBarsResponse get_bars_for_multiple_stock_symbols(symbols, timeframe, start, end, limit, page_token, adjustment, feed) +Get Bar data for multiple stock symbols + +The Multi Bars API returns aggregate historical data for multiple given ticker symbols over a specified time period. Returned results are sorted by symbol first then by Bar timestamp. This means that you are likely to see only one symbol in your first response if there are enough Bars for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Bars were found for them. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of stock ticker symbols to query for. | [required] | +**timeframe** | **String** | Timeframe for the aggregation. Values are customizeable, frequently used examples: 1Min, 15Min, 1Hour, 1Day. Limits: 1Min-59Min, 1Hour-23Hour. | [required] | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | +**limit** | Option<**i32**> | Number of data points to return. Must be in range 1-10000, defaults to 1000. | | +**page_token** | Option<**String**> | Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. | | +**adjustment** | Option<**String**> | specifies the corporate action adjustment(s) for bars data | | +**feed** | Option<**String**> | Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription | | + +### Return type + +[**models::MultiBarsResponse**](MultiBarsResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_bars_for_stock_symbol + +> models::BarsResponse get_bars_for_stock_symbol(symbol, timeframe, start, end, limit, page_token, feed, adjustment) +Bars + +The Bars API returns aggregate historical data for the requested security. Returns bars for the queried stock symbol. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The stock ticker symbol to query for. | [required] | +**timeframe** | **String** | Timeframe for the aggregation. Values are customizeable, frequently used examples: 1Min, 15Min, 1Hour, 1Day. Limits: 1Min-59Min, 1Hour-23Hour. | [required] | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | +**limit** | Option<**i32**> | Number of data points to return. Must be in range 1-10000, defaults to 1000. | | +**page_token** | Option<**String**> | Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. | | +**feed** | Option<**String**> | Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription | | +**adjustment** | Option<**String**> | specifies the corporate action adjustment(s) for bars data | | + +### Return type + +[**models::BarsResponse**](BarsResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_conditions + +> std::collections::HashMap get_conditions(r#type, tape) +Get list of Conditions + +Each feed/exchange uses its own set of codes to identify trade and quote conditions, so the same condition may have a different code depending on the originator of the data. See [Our documentation](https://alpaca.markets/docs/market-data/#conditions) for more information + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**r#type** | **String** | either \"trade\" or \"quote\" | [required] | +**tape** | **String** | What kind of conditions to retrieve, \"A\" and \"B\" return CTS, where \"C\" will give you UTP | [required] | + +### Return type + +[**std::collections::HashMap**](serde_json::Value.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_exchanges + +> std::collections::HashMap get_exchanges() +Get List of supported exchanges + +Returns a json object representing the exchanges we support. The keys are the short form codes you will see in our responses and the values are their respective full names. + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +**std::collections::HashMap** + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_latest_bar_for_stock_symbol + +> models::LatestBarResponse get_latest_bar_for_stock_symbol(symbol, feed) +Get Latest Bars for Symbol + +The Bars API returns aggregate historical data for the requested security. Returns the latest bar data for the queried stock symbol. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The stock ticker symbol to query for. | [required] | +**feed** | Option<**String**> | Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription | | + +### Return type + +[**models::LatestBarResponse**](LatestBarResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_latest_bars_for_multiple_stock_symbols + +> models::LatestMultiBarsResponse get_latest_bars_for_multiple_stock_symbols(symbols, feed) +Get Latest Bar data for multiple stock symbols + +The Bars API returns aggregate historical data for the requested security. Returns the latest bar data for the queried stock symbols. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of stock ticker symbols to query for. | [required] | +**feed** | Option<**String**> | Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription | | + +### Return type + +[**models::LatestMultiBarsResponse**](LatestMultiBarsResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_latest_quote_for_stock_symbol + +> models::LatestQuoteResponse get_latest_quote_for_stock_symbol(symbol, feed) +Get Latest Quote for stock symbol + +The Latest Quote API provides the latest quote data for a given ticker symbol. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The stock ticker symbol to query for. | [required] | +**feed** | Option<**String**> | Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription | | + +### Return type + +[**models::LatestQuoteResponse**](LatestQuoteResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_latest_quotes_for_multiple_stock_symbols + +> models::LatestMultiQuotesResponse get_latest_quotes_for_multiple_stock_symbols(symbols, feed) +Get Latest Quotes for multiple stock symbols + +Returns the latest quotes data for the queried stock symbols. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of stock ticker symbols to query for. | [required] | +**feed** | Option<**String**> | Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription | | + +### Return type + +[**models::LatestMultiQuotesResponse**](LatestMultiQuotesResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_latest_trade_for_stock_symbol + +> models::LatestTradeResponse get_latest_trade_for_stock_symbol(symbol, feed) +Latest Trade + +The Latest Trade API provides the latest trade data for a given ticker symbol. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The stock ticker symbol to query for. | [required] | +**feed** | Option<**String**> | Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription | | + +### Return type + +[**models::LatestTradeResponse**](LatestTradeResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_latest_trades_for_multiple_stock_symbols + +> models::LatestMultiTradesResponse get_latest_trades_for_multiple_stock_symbols(symbols, feed) +Get Latest Trades data for multiple stock symbols + +Returns the latest trades data for the queried stock symbols. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of stock ticker symbols to query for. | [required] | +**feed** | Option<**String**> | Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription | | + +### Return type + +[**models::LatestMultiTradesResponse**](LatestMultiTradesResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_quotes_for_multiple_stock_symbols + +> models::MultiQuotesReponse get_quotes_for_multiple_stock_symbols(symbols, start, end, limit, page_token, feed) +Get Quotes for multiple stock symbols + +The Multi Quotes API provides NBBO quotes for multiple given ticker symbols over a specified time period. Returned results are sorted by symbol first then by Quote timestamp. This means that you are likely to see only one symbol in your first response if there are enough Quotes for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Quotes were found for them. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of stock ticker symbols to query for. | [required] | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | +**limit** | Option<**i32**> | Number of data points to return. Must be in range 1-10000, defaults to 1000. | | +**page_token** | Option<**String**> | Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. | | +**feed** | Option<**String**> | Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription | | + +### Return type + +[**models::MultiQuotesReponse**](MultiQuotesReponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_quotes_for_stock_symbol + +> models::QuotesResponse get_quotes_for_stock_symbol(symbol, start, end, limit, page_token, feed) +Get Quotes for stock symbol + +The Quotes API provides NBBO quotes for a single given ticker symbol at a specified date. Returns quotes (NBBOs) for the querried stock symbol. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The stock ticker symbol to query for. | [required] | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | +**limit** | Option<**i32**> | Number of data points to return. Must be in range 1-10000, defaults to 1000. | | +**page_token** | Option<**String**> | Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. | | +**feed** | Option<**String**> | Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription | | + +### Return type + +[**models::QuotesResponse**](QuotesResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_snapshot_for_stock_symbol + +> models::Snapshot get_snapshot_for_stock_symbol(symbol, feed) +Get a Snapshot for a stock symbol + +The Snapshot API for one ticker provides the latest trade, latest quote, minute bar daily bar and previous daily bar data for a given ticker symbol. This endpoint returns the snapshot for the requested security. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The stock ticker symbol to query for. | [required] | +**feed** | Option<**String**> | Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription | | + +### Return type + +[**models::Snapshot**](Snapshot.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_snapshots_for_multiple_stock_symbols + +> std::collections::HashMap get_snapshots_for_multiple_stock_symbols(symbols, feed) +Get Snapshots for multiple stock symbols + +The Snapshot API for multiple tickers provides the latest trade, latest quote, minute bar daily bar and previous daily bar data for the given ticker symbols. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of stock ticker symbols to query for. | [required] | +**feed** | Option<**String**> | Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription | | + +### Return type + +[**std::collections::HashMap**](Snapshot.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_trades_for_multiple_stock_symbols + +> models::MultiTradesResponse get_trades_for_multiple_stock_symbols(symbols, start, end, limit, page_token, feed) +Get Trade data for multiple stock symbols + +The Multi Trades API provides historical trade data for multiple given ticker symbols over a specified time period. Returned results are sorted by symbol first then by Trade timestamp. This means that you are likely to see only one symbol in your first response if there are enough Trades for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Trades were found for them. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbols** | **String** | The comma-separated list of stock ticker symbols to query for. | [required] | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | +**limit** | Option<**i32**> | Number of data points to return. Must be in range 1-10000, defaults to 1000. | | +**page_token** | Option<**String**> | Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. | | +**feed** | Option<**String**> | Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription | | + +### Return type + +[**models::MultiTradesResponse**](MultiTradesResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_trades_for_stock_symbol + +> models::TradesResponse get_trades_for_stock_symbol(symbol, start, end, limit, page_token, feed) +Trades + +The Trades API provides historical trade data for a given ticker symbol on a specified date. Returns trades for the queried stock signal. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The stock ticker symbol to query for. | [required] | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | +**limit** | Option<**i32**> | Number of data points to return. Must be in range 1-10000, defaults to 1000. | | +**page_token** | Option<**String**> | Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. | | +**feed** | Option<**String**> | Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription | | + +### Return type + +[**models::TradesResponse**](TradesResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/data/docs/Trade.md b/crates/alpaca_openapi/gen/data/docs/Trade.md new file mode 100644 index 0000000..8c2ce2f --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/Trade.md @@ -0,0 +1,18 @@ +# Trade + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**t** | Option<**String**> | Timestamp in RFC-3339 format with nanosecond precision | [optional] +**x** | **String** | Exchange where the trade happened. | +**p** | Option<**f64**> | Trade price. | [optional] +**s** | Option<**f64**> | Trade Size. | [optional] +**c** | Option<**Vec**> | Trade conditions (Stock trade only) | [optional] +**i** | **i64** | Trade ID | +**z** | Option<**String**> | Tape (Stock trade only) | [optional] +**tks** | Option<**String**> | Taker's side (crypto trade only) | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/TradesResponse.md b/crates/alpaca_openapi/gen/data/docs/TradesResponse.md new file mode 100644 index 0000000..87d77a7 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/TradesResponse.md @@ -0,0 +1,13 @@ +# TradesResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**trades** | [**Vec**](Trade.md) | Array of trades | +**symbol** | **String** | Symbol that was queried | +**next_page_token** | Option<**String**> | Token that can be used to query the next page | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/docs/Xbbo.md b/crates/alpaca_openapi/gen/data/docs/Xbbo.md new file mode 100644 index 0000000..37ed4c1 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/docs/Xbbo.md @@ -0,0 +1,17 @@ +# Xbbo + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**t** | **String** | Timestamp in RFC-3339 format with nanosecond precision. | +**ax** | **String** | Ask exchange. | +**ap** | **f64** | Ask price. | +**r#as** | **f64** | Ask size. | +**bx** | **String** | Bid exchange. | +**bp** | **f64** | Bid price. | +**bs** | **f64** | Bid size. | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/data/git_push.sh b/crates/alpaca_openapi/gen/data/git_push.sh new file mode 100644 index 0000000..f53a75d --- /dev/null +++ b/crates/alpaca_openapi/gen/data/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/crates/alpaca_openapi/gen/data/src/apis/configuration.rs b/crates/alpaca_openapi/gen/data/src/apis/configuration.rs new file mode 100644 index 0000000..4291dc7 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/apis/configuration.rs @@ -0,0 +1,49 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, + // TODO: take an oauth2 token source, similar to the go one +} + +pub type BasicAuth = (String, Option); + +#[derive(Debug, Clone)] +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + +impl Configuration { + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Default for Configuration { + fn default() -> Self { + Configuration { + base_path: "https://data.alpaca.markets".to_owned(), + user_agent: Some("OpenAPI-Generator/2.0.0/rust".to_owned()), + client: reqwest::Client::new(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/apis/crypto_pricing_data_api_api.rs b/crates/alpaca_openapi/gen/data/src/apis/crypto_pricing_data_api_api.rs new file mode 100644 index 0000000..4cdec71 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/apis/crypto_pricing_data_api_api.rs @@ -0,0 +1,1847 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`get_bars_for_crypto_symbol`] +#[derive(Clone, Debug)] +pub struct GetBarsForCryptoSymbolParams { + /// The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. + pub symbol: String, + /// Timeframe for the aggregation. Values are customizeable, frequently used examples: 1Min, 15Min, 1Hour, 1Day. Limits: 1Min-59Min, 1Hour-23Hour. + pub timeframe: String, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, + /// A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchanges: Option, + /// Number of data points to return. Must be in range 1-10000, defaults to 1000. + pub limit: Option, + /// Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. + pub page_token: Option, +} + +/// struct for passing parameters to the method [`get_bars_for_multiple_crypto_symbols`] +#[derive(Clone, Debug)] +pub struct GetBarsForMultipleCryptoSymbolsParams { + /// The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH + pub symbols: String, + /// Timeframe for the aggregation. Values are customizeable, frequently used examples: 1Min, 15Min, 1Hour, 1Day. Limits: 1Min-59Min, 1Hour-23Hour. + pub timeframe: String, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, + /// Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. + pub page_token: Option, + /// Number of data points to return. Must be in range 1-10000, defaults to 1000. + pub limit: Option, + /// A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchanges: Option, +} + +/// struct for passing parameters to the method [`get_latest_bars_for_crypto_symbol`] +#[derive(Clone, Debug)] +pub struct GetLatestBarsForCryptoSymbolParams { + /// The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. + pub symbol: String, + /// Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchange: String, +} + +/// struct for passing parameters to the method [`get_latest_bars_for_multiple_crypto_symbols`] +#[derive(Clone, Debug)] +pub struct GetLatestBarsForMultipleCryptoSymbolsParams { + /// The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH + pub symbols: String, + /// Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchange: String, +} + +/// struct for passing parameters to the method [`get_latest_quote_for_crypto_symbol`] +#[derive(Clone, Debug)] +pub struct GetLatestQuoteForCryptoSymbolParams { + /// The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. + pub symbol: String, + /// Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchange: String, +} + +/// struct for passing parameters to the method [`get_latest_quotes_for_multiple_crypto_symbols`] +#[derive(Clone, Debug)] +pub struct GetLatestQuotesForMultipleCryptoSymbolsParams { + /// The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH + pub symbols: String, + /// Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchange: String, +} + +/// struct for passing parameters to the method [`get_latest_trades_for_crypto_symbol`] +#[derive(Clone, Debug)] +pub struct GetLatestTradesForCryptoSymbolParams { + /// The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. + pub symbol: String, + /// Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchange: String, +} + +/// struct for passing parameters to the method [`get_latest_trades_for_multiple_crypto_symbols`] +#[derive(Clone, Debug)] +pub struct GetLatestTradesForMultipleCryptoSymbolsParams { + /// The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH + pub symbols: String, + /// Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchange: String, +} + +/// struct for passing parameters to the method [`get_latest_xbbo_for_crypto_symbol`] +#[derive(Clone, Debug)] +pub struct GetLatestXbboForCryptoSymbolParams { + /// The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. + pub symbol: String, + /// A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchanges: Option, +} + +/// struct for passing parameters to the method [`get_latest_xbbo_for_multiple_crypto_symbols`] +#[derive(Clone, Debug)] +pub struct GetLatestXbboForMultipleCryptoSymbolsParams { + /// The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH + pub symbols: String, + /// A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchanges: Option, +} + +/// struct for passing parameters to the method [`get_quotes_for_crypto_symbol`] +#[derive(Clone, Debug)] +pub struct GetQuotesForCryptoSymbolParams { + /// The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. + pub symbol: String, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, + /// A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchanges: Option, + /// Number of data points to return. Must be in range 1-10000, defaults to 1000. + pub limit: Option, + /// Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. + pub page_token: Option, +} + +/// struct for passing parameters to the method [`get_quotes_for_multiple_crypto_symbols`] +#[derive(Clone, Debug)] +pub struct GetQuotesForMultipleCryptoSymbolsParams { + /// The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH + pub symbols: String, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, + /// A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchanges: Option, + /// Number of data points to return. Must be in range 1-10000, defaults to 1000. + pub limit: Option, + /// Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. + pub page_token: Option, +} + +/// struct for passing parameters to the method [`get_snapshot_for_crypto_symbol`] +#[derive(Clone, Debug)] +pub struct GetSnapshotForCryptoSymbolParams { + /// The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. + pub symbol: String, + /// Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchange: String, +} + +/// struct for passing parameters to the method [`get_snapshots_for_multiple_crypto_symbols`] +#[derive(Clone, Debug)] +pub struct GetSnapshotsForMultipleCryptoSymbolsParams { + /// Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchange: String, + /// The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH + pub symbols: String, +} + +/// struct for passing parameters to the method [`get_trades_for_crypto_symbol`] +#[derive(Clone, Debug)] +pub struct GetTradesForCryptoSymbolParams { + /// The crypto symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. + pub symbol: String, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, + /// A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchanges: Option, + /// Number of data points to return. Must be in range 1-10000, defaults to 1000. + pub limit: Option, + /// Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. + pub page_token: Option, +} + +/// struct for passing parameters to the method [`get_trades_for_multiple_crypto_symbols`] +#[derive(Clone, Debug)] +pub struct GetTradesForMultipleCryptoSymbolsParams { + /// The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH + pub symbols: String, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, + /// A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU` + pub exchanges: Option, + /// Number of data points to return. Must be in range 1-10000, defaults to 1000. + pub limit: Option, + /// Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. + pub page_token: Option, +} + +/// struct for typed successes of method [`get_bars_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetBarsForCryptoSymbolSuccess { + Status200(models::BarsResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_bars_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetBarsForMultipleCryptoSymbolsSuccess { + Status200(models::MultiBarsResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_crypto_meta_spreads`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetCryptoMetaSpreadsSuccess { + Status200(models::CryptoSpreadsResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_latest_bars_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestBarsForCryptoSymbolSuccess { + Status200(models::LatestBarResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_latest_bars_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestBarsForMultipleCryptoSymbolsSuccess { + Status200(models::LatestMultiBarsResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_latest_quote_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestQuoteForCryptoSymbolSuccess { + Status200(models::LatestQuoteResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_latest_quotes_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestQuotesForMultipleCryptoSymbolsSuccess { + Status200(models::LatestMultiQuotesResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_latest_trades_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestTradesForCryptoSymbolSuccess { + Status200(models::LatestTradeResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_latest_trades_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestTradesForMultipleCryptoSymbolsSuccess { + Status200(models::LatestMultiTradesResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_latest_xbbo_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestXbboForCryptoSymbolSuccess { + Status200(models::LatestXbboResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_latest_xbbo_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestXbboForMultipleCryptoSymbolsSuccess { + Status200(models::LatestMultiXbboResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_quotes_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetQuotesForCryptoSymbolSuccess { + Status200(models::QuotesResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_quotes_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetQuotesForMultipleCryptoSymbolsSuccess { + Status200(models::MultiQuotesReponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_snapshot_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetSnapshotForCryptoSymbolSuccess { + Status200(models::Snapshot), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_snapshots_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetSnapshotsForMultipleCryptoSymbolsSuccess { + Status200(std::collections::HashMap), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_trades_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTradesForCryptoSymbolSuccess { + Status200(models::TradesResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_trades_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTradesForMultipleCryptoSymbolsSuccess { + Status200(models::MultiTradesResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_bars_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetBarsForCryptoSymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_bars_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetBarsForMultipleCryptoSymbolsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_crypto_meta_spreads`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetCryptoMetaSpreadsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_latest_bars_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestBarsForCryptoSymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_latest_bars_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestBarsForMultipleCryptoSymbolsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_latest_quote_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestQuoteForCryptoSymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_latest_quotes_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestQuotesForMultipleCryptoSymbolsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_latest_trades_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestTradesForCryptoSymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_latest_trades_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestTradesForMultipleCryptoSymbolsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_latest_xbbo_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestXbboForCryptoSymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_latest_xbbo_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestXbboForMultipleCryptoSymbolsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_quotes_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetQuotesForCryptoSymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_quotes_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetQuotesForMultipleCryptoSymbolsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_snapshot_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetSnapshotForCryptoSymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_snapshots_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetSnapshotsForMultipleCryptoSymbolsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_trades_for_crypto_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTradesForCryptoSymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_trades_for_multiple_crypto_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTradesForMultipleCryptoSymbolsError { + UnknownValue(serde_json::Value), +} + +/// The Bars API returns aggregate historical data for the requested securities.. Returns bars for the queried crypto symbol +pub async fn get_bars_for_crypto_symbol( + configuration: &configuration::Configuration, + params: GetBarsForCryptoSymbolParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let timeframe = params.timeframe; + let start = params.start; + let end = params.end; + let exchanges = params.exchanges; + let limit = params.limit; + let page_token = params.page_token; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/{symbol}/bars", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("timeframe", &timeframe.to_string())]); + if let Some(ref local_var_str) = exchanges { + local_var_req_builder = + local_var_req_builder.query(&[("exchanges", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// returns aggregate historical data for the requested crypto symbols. Returned results are sorted by symbol first then by Bar timestamp. This means that you are likely to see only one symbol in your first response if there are enough Bars for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Bars were found for them. +pub async fn get_bars_for_multiple_crypto_symbols( + configuration: &configuration::Configuration, + params: GetBarsForMultipleCryptoSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let timeframe = params.timeframe; + let start = params.start; + let end = params.end; + let page_token = params.page_token; + let limit = params.limit; + let exchanges = params.exchanges; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v1beta1/crypto/bars", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("timeframe", &timeframe.to_string())]); + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = exchanges { + local_var_req_builder = + local_var_req_builder.query(&[("exchanges", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Get list of crypto spreads for the different exchanges Alpaca supports in basis points. +pub async fn get_crypto_meta_spreads( + configuration: &configuration::Configuration, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/meta/spreads", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Gets latest historical bar data for the requested crypto symbol for a specific exchange +pub async fn get_latest_bars_for_crypto_symbol( + configuration: &configuration::Configuration, + params: GetLatestBarsForCryptoSymbolParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let exchange = params.exchange; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/{symbol}/bars/latest", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("exchange", &exchange.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// returns latest historical data for the requested crypto symbols for a specific exchange +pub async fn get_latest_bars_for_multiple_crypto_symbols( + configuration: &configuration::Configuration, + params: GetLatestBarsForMultipleCryptoSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let exchange = params.exchange; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/bars/latest", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + local_var_req_builder = local_var_req_builder.query(&[("exchange", &exchange.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns latest quote for the queried crypto symbol +pub async fn get_latest_quote_for_crypto_symbol( + configuration: &configuration::Configuration, + params: GetLatestQuoteForCryptoSymbolParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let exchange = params.exchange; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/{symbol}/quotes/latest", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("exchange", &exchange.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Provides latest quotes for a list of given crypto symbols. +pub async fn get_latest_quotes_for_multiple_crypto_symbols( + configuration: &configuration::Configuration, + params: GetLatestQuotesForMultipleCryptoSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let exchange = params.exchange; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/quotes/latest", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + local_var_req_builder = local_var_req_builder.query(&[("exchange", &exchange.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Latest Trades API provides the latest historical trade data for a given crypto symbol. Returns trades for the queried crypto symbol. +pub async fn get_latest_trades_for_crypto_symbol( + configuration: &configuration::Configuration, + params: GetLatestTradesForCryptoSymbolParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let exchange = params.exchange; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/{symbol}/trades/latest", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("exchange", &exchange.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Provides latest trade data for a list of given crypto symbols. +pub async fn get_latest_trades_for_multiple_crypto_symbols( + configuration: &configuration::Configuration, + params: GetLatestTradesForMultipleCryptoSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let exchange = params.exchange; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/trades/latest", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + local_var_req_builder = local_var_req_builder.query(&[("exchange", &exchange.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns the XBBO for a crypto symbol that calculates the Best Bid and Offer across multiple exchanges. If exchanges is not specified then only the exchanges that can be traded on Alpaca are included in the calculation. +pub async fn get_latest_xbbo_for_crypto_symbol( + configuration: &configuration::Configuration, + params: GetLatestXbboForCryptoSymbolParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let exchanges = params.exchanges; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/{symbol}/xbbo/latest", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = exchanges { + local_var_req_builder = + local_var_req_builder.query(&[("exchanges", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns the latest XBBO for a given list crypto symbols that calculates the Best Bid and Offer across multiple exchanges. If exchanges is not specified then only the exchanges that can be traded on Alpaca are included in the calculation. +pub async fn get_latest_xbbo_for_multiple_crypto_symbols( + configuration: &configuration::Configuration, + params: GetLatestXbboForMultipleCryptoSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let exchanges = params.exchanges; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/xbbos/latest", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + if let Some(ref local_var_str) = exchanges { + local_var_req_builder = + local_var_req_builder.query(&[("exchanges", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Quotes API provides quotes for a given crypto symbol at a specified date. Returns quotes for the queried crypto symbol +pub async fn get_quotes_for_crypto_symbol( + configuration: &configuration::Configuration, + params: GetQuotesForCryptoSymbolParams, +) -> Result, Error> +{ + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let start = params.start; + let end = params.end; + let exchanges = params.exchanges; + let limit = params.limit; + let page_token = params.page_token; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/{symbol}/quotes", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = exchanges { + local_var_req_builder = + local_var_req_builder.query(&[("exchanges", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Multi Quotes API provides quotes for a list of given crypto symbols at a specified date. Returns quotes for each of the queried crypto symbols. Returned results are sorted by symbol first then by Quote timestamp. This means that you are likely to see only one symbol in your first response if there are enough Quotes for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Quotes were found for them. +pub async fn get_quotes_for_multiple_crypto_symbols( + configuration: &configuration::Configuration, + params: GetQuotesForMultipleCryptoSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let start = params.start; + let end = params.end; + let exchanges = params.exchanges; + let limit = params.limit; + let page_token = params.page_token; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/quotes", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = exchanges { + local_var_req_builder = + local_var_req_builder.query(&[("exchanges", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Snapshot API returns the latest trade, latest quote, minute bar daily bar, and previous daily bar data for a given crypto symbol. +pub async fn get_snapshot_for_crypto_symbol( + configuration: &configuration::Configuration, + params: GetSnapshotForCryptoSymbolParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let exchange = params.exchange; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/{symbol}/snapshot", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("exchange", &exchange.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Multi Snapshot API returns the latest trade, latest quote, minute bar daily bar, and previous daily bar data for list of given crypto symbols. +pub async fn get_snapshots_for_multiple_crypto_symbols( + configuration: &configuration::Configuration, + params: GetSnapshotsForMultipleCryptoSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let exchange = params.exchange; + let symbols = params.symbols; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/snapshots", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("exchange", &exchange.to_string())]); + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Trades API provides historical trade data for a given crypto symbol on a specified date. Returns trades for the queried crypto symbol +pub async fn get_trades_for_crypto_symbol( + configuration: &configuration::Configuration, + params: GetTradesForCryptoSymbolParams, +) -> Result, Error> +{ + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let start = params.start; + let end = params.end; + let exchanges = params.exchanges; + let limit = params.limit; + let page_token = params.page_token; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/{symbol}/trades", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = exchanges { + local_var_req_builder = + local_var_req_builder.query(&[("exchanges", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Multi Trades API provides historical trade data for a list of given crypto symbols on a specified date. Returns trades for the queried crypto symbols. Returned results are sorted by symbol first then by Trade timestamp. This means that you are likely to see only one symbol in your first response if there are enough Trades for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Trades were found for them. +pub async fn get_trades_for_multiple_crypto_symbols( + configuration: &configuration::Configuration, + params: GetTradesForMultipleCryptoSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let start = params.start; + let end = params.end; + let exchanges = params.exchanges; + let limit = params.limit; + let page_token = params.page_token; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/crypto/trades", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = exchanges { + local_var_req_builder = + local_var_req_builder.query(&[("exchanges", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/data/src/apis/logo_api.rs b/crates/alpaca_openapi/gen/data/src/apis/logo_api.rs new file mode 100644 index 0000000..bdfab14 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/apis/logo_api.rs @@ -0,0 +1,113 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`get_logo_for_symbol`] +#[derive(Clone, Debug)] +pub struct GetLogoForSymbolParams { + /// The crypto or stock symbol to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD\" would be how you query for BTC. + pub crypto_or_stock_symbol: String, + /// If true then the api will generate a placeholder image if no logo was found. Defaults to true + pub placeholder: Option, +} + +/// struct for typed successes of method [`get_logo_for_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLogoForSymbolSuccess { + Status200(std::path::PathBuf), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_logo_for_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLogoForSymbolError { + Status404(), + UnknownValue(serde_json::Value), +} + +/// Returns logo image resource for provided symbol. +pub async fn get_logo_for_symbol( + configuration: &configuration::Configuration, + params: GetLogoForSymbolParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let crypto_or_stock_symbol = params.crypto_or_stock_symbol; + let placeholder = params.placeholder; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v1beta1/logos/{crypto_or_stock_symbol}", + local_var_configuration.base_path, + crypto_or_stock_symbol = crate::apis::urlencode(crypto_or_stock_symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = placeholder { + local_var_req_builder = + local_var_req_builder.query(&[("placeholder", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/data/src/apis/mod.rs b/crates/alpaca_openapi/gen/data/src/apis/mod.rs new file mode 100644 index 0000000..e917d2b --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/apis/mod.rs @@ -0,0 +1,100 @@ +use std::error; +use std::fmt; + +#[derive(Debug, Clone)] +pub struct ResponseContent { + pub status: reqwest::StatusCode, + pub content: String, + pub entity: Option, +} + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), + ResponseError(ResponseContent), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (module, e) = match self { + Error::Reqwest(e) => ("reqwest", e.to_string()), + Error::Serde(e) => ("serde", e.to_string()), + Error::Io(e) => ("IO", e.to_string()), + Error::ResponseError(e) => ("response", format!("status code {}", e.status)), + }; + write!(f, "error in {}: {}", module, e) + } +} + +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + Some(match self { + Error::Reqwest(e) => e, + Error::Serde(e) => e, + Error::Io(e) => e, + Error::ResponseError(_) => return None, + }) + } +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> { + if let serde_json::Value::Object(object) = value { + let mut params = vec![]; + + for (key, value) in object { + match value { + serde_json::Value::Object(_) => params.append(&mut parse_deep_object( + &format!("{}[{}]", prefix, key), + value, + )), + serde_json::Value::Array(array) => { + for (i, value) in array.iter().enumerate() { + params.append(&mut parse_deep_object( + &format!("{}[{}][{}]", prefix, key, i), + value, + )); + } + } + serde_json::Value::String(s) => { + params.push((format!("{}[{}]", prefix, key), s.clone())) + } + _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), + } + } + + return params; + } + + unimplemented!("Only objects are supported with style=deepObject") +} + +pub mod crypto_pricing_data_api_api; +pub mod logo_api; +pub mod news_api; +pub mod stock_pricing_data_api_api; + +pub mod configuration; diff --git a/crates/alpaca_openapi/gen/data/src/apis/news_api.rs b/crates/alpaca_openapi/gen/data/src/apis/news_api.rs new file mode 100644 index 0000000..80d72b3 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/apis/news_api.rs @@ -0,0 +1,149 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`get_news`] +#[derive(Clone, Debug)] +pub struct GetNewsParams { + /// The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with \"USD\", ie \"BTCUSD,ETHUSD\" would get both BTC and ETH + pub symbols: String, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, + /// Number of data points to return. Must be in range 1-10000, defaults to 1000. + pub limit: Option, + /// Sort articles by updated date. Options: DESC, ASC + pub sort: Option, + /// Boolean indicator to include content for news articles (if available) + pub include_content: Option, + /// Boolean indicator to exclude news articles that do not contain content + pub exclude_contentless: Option, + /// Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. + pub page_token: Option, +} + +/// struct for typed successes of method [`get_news`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetNewsSuccess { + Status200(models::GetNewsResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_news`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetNewsError { + UnknownValue(serde_json::Value), +} + +/// Returns latest news articles across stocks and crypto. By default returns latest 10 news articles. +pub async fn get_news( + configuration: &configuration::Configuration, + params: GetNewsParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let start = params.start; + let end = params.end; + let limit = params.limit; + let sort = params.sort; + let include_content = params.include_content; + let exclude_contentless = params.exclude_contentless; + let page_token = params.page_token; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v1beta1/news", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = sort { + local_var_req_builder = + local_var_req_builder.query(&[("sort", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = include_content { + local_var_req_builder = + local_var_req_builder.query(&[("include_content", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = exclude_contentless { + local_var_req_builder = + local_var_req_builder.query(&[("exclude_contentless", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/data/src/apis/stock_pricing_data_api_api.rs b/crates/alpaca_openapi/gen/data/src/apis/stock_pricing_data_api_api.rs new file mode 100644 index 0000000..3c4fd55 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/apis/stock_pricing_data_api_api.rs @@ -0,0 +1,1761 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`get_bars_for_multiple_stock_symbols`] +#[derive(Clone, Debug)] +pub struct GetBarsForMultipleStockSymbolsParams { + /// The comma-separated list of stock ticker symbols to query for. + pub symbols: String, + /// Timeframe for the aggregation. Values are customizeable, frequently used examples: 1Min, 15Min, 1Hour, 1Day. Limits: 1Min-59Min, 1Hour-23Hour. + pub timeframe: String, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, + /// Number of data points to return. Must be in range 1-10000, defaults to 1000. + pub limit: Option, + /// Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. + pub page_token: Option, + /// specifies the corporate action adjustment(s) for bars data + pub adjustment: Option, + /// Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription + pub feed: Option, +} + +/// struct for passing parameters to the method [`get_bars_for_stock_symbol`] +#[derive(Clone, Debug)] +pub struct GetBarsForStockSymbolParams { + /// The stock ticker symbol to query for. + pub symbol: String, + /// Timeframe for the aggregation. Values are customizeable, frequently used examples: 1Min, 15Min, 1Hour, 1Day. Limits: 1Min-59Min, 1Hour-23Hour. + pub timeframe: String, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, + /// Number of data points to return. Must be in range 1-10000, defaults to 1000. + pub limit: Option, + /// Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. + pub page_token: Option, + /// Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription + pub feed: Option, + /// specifies the corporate action adjustment(s) for bars data + pub adjustment: Option, +} + +/// struct for passing parameters to the method [`get_conditions`] +#[derive(Clone, Debug)] +pub struct GetConditionsParams { + /// either \"trade\" or \"quote\" + pub r#type: String, + /// What kind of conditions to retrieve, \"A\" and \"B\" return CTS, where \"C\" will give you UTP + pub tape: String, +} + +/// struct for passing parameters to the method [`get_latest_bar_for_stock_symbol`] +#[derive(Clone, Debug)] +pub struct GetLatestBarForStockSymbolParams { + /// The stock ticker symbol to query for. + pub symbol: String, + /// Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription + pub feed: Option, +} + +/// struct for passing parameters to the method [`get_latest_bars_for_multiple_stock_symbols`] +#[derive(Clone, Debug)] +pub struct GetLatestBarsForMultipleStockSymbolsParams { + /// The comma-separated list of stock ticker symbols to query for. + pub symbols: String, + /// Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription + pub feed: Option, +} + +/// struct for passing parameters to the method [`get_latest_quote_for_stock_symbol`] +#[derive(Clone, Debug)] +pub struct GetLatestQuoteForStockSymbolParams { + /// The stock ticker symbol to query for. + pub symbol: String, + /// Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription + pub feed: Option, +} + +/// struct for passing parameters to the method [`get_latest_quotes_for_multiple_stock_symbols`] +#[derive(Clone, Debug)] +pub struct GetLatestQuotesForMultipleStockSymbolsParams { + /// The comma-separated list of stock ticker symbols to query for. + pub symbols: String, + /// Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription + pub feed: Option, +} + +/// struct for passing parameters to the method [`get_latest_trade_for_stock_symbol`] +#[derive(Clone, Debug)] +pub struct GetLatestTradeForStockSymbolParams { + /// The stock ticker symbol to query for. + pub symbol: String, + /// Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription + pub feed: Option, +} + +/// struct for passing parameters to the method [`get_latest_trades_for_multiple_stock_symbols`] +#[derive(Clone, Debug)] +pub struct GetLatestTradesForMultipleStockSymbolsParams { + /// The comma-separated list of stock ticker symbols to query for. + pub symbols: String, + /// Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription + pub feed: Option, +} + +/// struct for passing parameters to the method [`get_quotes_for_multiple_stock_symbols`] +#[derive(Clone, Debug)] +pub struct GetQuotesForMultipleStockSymbolsParams { + /// The comma-separated list of stock ticker symbols to query for. + pub symbols: String, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, + /// Number of data points to return. Must be in range 1-10000, defaults to 1000. + pub limit: Option, + /// Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. + pub page_token: Option, + /// Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription + pub feed: Option, +} + +/// struct for passing parameters to the method [`get_quotes_for_stock_symbol`] +#[derive(Clone, Debug)] +pub struct GetQuotesForStockSymbolParams { + /// The stock ticker symbol to query for. + pub symbol: String, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, + /// Number of data points to return. Must be in range 1-10000, defaults to 1000. + pub limit: Option, + /// Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. + pub page_token: Option, + /// Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription + pub feed: Option, +} + +/// struct for passing parameters to the method [`get_snapshot_for_stock_symbol`] +#[derive(Clone, Debug)] +pub struct GetSnapshotForStockSymbolParams { + /// The stock ticker symbol to query for. + pub symbol: String, + /// Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription + pub feed: Option, +} + +/// struct for passing parameters to the method [`get_snapshots_for_multiple_stock_symbols`] +#[derive(Clone, Debug)] +pub struct GetSnapshotsForMultipleStockSymbolsParams { + /// The comma-separated list of stock ticker symbols to query for. + pub symbols: String, + /// Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription + pub feed: Option, +} + +/// struct for passing parameters to the method [`get_trades_for_multiple_stock_symbols`] +#[derive(Clone, Debug)] +pub struct GetTradesForMultipleStockSymbolsParams { + /// The comma-separated list of stock ticker symbols to query for. + pub symbols: String, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, + /// Number of data points to return. Must be in range 1-10000, defaults to 1000. + pub limit: Option, + /// Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. + pub page_token: Option, + /// Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription + pub feed: Option, +} + +/// struct for passing parameters to the method [`get_trades_for_stock_symbol`] +#[derive(Clone, Debug)] +pub struct GetTradesForStockSymbolParams { + /// The stock ticker symbol to query for. + pub symbol: String, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, + /// Number of data points to return. Must be in range 1-10000, defaults to 1000. + pub limit: Option, + /// Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. + pub page_token: Option, + /// Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription + pub feed: Option, +} + +/// struct for typed successes of method [`get_bars_for_multiple_stock_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetBarsForMultipleStockSymbolsSuccess { + Status200(models::MultiBarsResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_bars_for_stock_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetBarsForStockSymbolSuccess { + Status200(models::BarsResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_conditions`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetConditionsSuccess { + Status200(std::collections::HashMap), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_exchanges`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetExchangesSuccess { + Status200(std::collections::HashMap), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_latest_bar_for_stock_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestBarForStockSymbolSuccess { + Status200(models::LatestBarResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_latest_bars_for_multiple_stock_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestBarsForMultipleStockSymbolsSuccess { + Status200(models::LatestMultiBarsResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_latest_quote_for_stock_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestQuoteForStockSymbolSuccess { + Status200(models::LatestQuoteResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_latest_quotes_for_multiple_stock_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestQuotesForMultipleStockSymbolsSuccess { + Status200(models::LatestMultiQuotesResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_latest_trade_for_stock_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestTradeForStockSymbolSuccess { + Status200(models::LatestTradeResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_latest_trades_for_multiple_stock_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestTradesForMultipleStockSymbolsSuccess { + Status200(models::LatestMultiTradesResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_quotes_for_multiple_stock_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetQuotesForMultipleStockSymbolsSuccess { + Status200(models::MultiQuotesReponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_quotes_for_stock_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetQuotesForStockSymbolSuccess { + Status200(models::QuotesResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_snapshot_for_stock_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetSnapshotForStockSymbolSuccess { + Status200(models::Snapshot), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_snapshots_for_multiple_stock_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetSnapshotsForMultipleStockSymbolsSuccess { + Status200(std::collections::HashMap), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_trades_for_multiple_stock_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTradesForMultipleStockSymbolsSuccess { + Status200(models::MultiTradesResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_trades_for_stock_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTradesForStockSymbolSuccess { + Status200(models::TradesResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_bars_for_multiple_stock_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetBarsForMultipleStockSymbolsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_bars_for_stock_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetBarsForStockSymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_conditions`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetConditionsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_exchanges`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetExchangesError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_latest_bar_for_stock_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestBarForStockSymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_latest_bars_for_multiple_stock_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestBarsForMultipleStockSymbolsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_latest_quote_for_stock_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestQuoteForStockSymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_latest_quotes_for_multiple_stock_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestQuotesForMultipleStockSymbolsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_latest_trade_for_stock_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestTradeForStockSymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_latest_trades_for_multiple_stock_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLatestTradesForMultipleStockSymbolsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_quotes_for_multiple_stock_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetQuotesForMultipleStockSymbolsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_quotes_for_stock_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetQuotesForStockSymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_snapshot_for_stock_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetSnapshotForStockSymbolError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_snapshots_for_multiple_stock_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetSnapshotsForMultipleStockSymbolsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_trades_for_multiple_stock_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTradesForMultipleStockSymbolsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_trades_for_stock_symbol`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTradesForStockSymbolError { + UnknownValue(serde_json::Value), +} + +/// The Multi Bars API returns aggregate historical data for multiple given ticker symbols over a specified time period. Returned results are sorted by symbol first then by Bar timestamp. This means that you are likely to see only one symbol in your first response if there are enough Bars for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Bars were found for them. +pub async fn get_bars_for_multiple_stock_symbols( + configuration: &configuration::Configuration, + params: GetBarsForMultipleStockSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let timeframe = params.timeframe; + let start = params.start; + let end = params.end; + let limit = params.limit; + let page_token = params.page_token; + let adjustment = params.adjustment; + let feed = params.feed; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/stocks/bars", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("timeframe", &timeframe.to_string())]); + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = adjustment { + local_var_req_builder = + local_var_req_builder.query(&[("adjustment", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = feed { + local_var_req_builder = + local_var_req_builder.query(&[("feed", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Bars API returns aggregate historical data for the requested security. Returns bars for the queried stock symbol. +pub async fn get_bars_for_stock_symbol( + configuration: &configuration::Configuration, + params: GetBarsForStockSymbolParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let timeframe = params.timeframe; + let start = params.start; + let end = params.end; + let limit = params.limit; + let page_token = params.page_token; + let feed = params.feed; + let adjustment = params.adjustment; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/stocks/{symbol}/bars", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + local_var_req_builder = local_var_req_builder.query(&[("timeframe", &timeframe.to_string())]); + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = feed { + local_var_req_builder = + local_var_req_builder.query(&[("feed", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = adjustment { + local_var_req_builder = + local_var_req_builder.query(&[("adjustment", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Each feed/exchange uses its own set of codes to identify trade and quote conditions, so the same condition may have a different code depending on the originator of the data. See [Our documentation](https://alpaca.markets/docs/market-data/#conditions) for more information +pub async fn get_conditions( + configuration: &configuration::Configuration, + params: GetConditionsParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let r#type = params.r#type; + let tape = params.tape; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/stocks/meta/conditions/{type}", local_var_configuration.base_path, type=crate::apis::urlencode(r#type)); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("tape", &tape.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns a json object representing the exchanges we support. The keys are the short form codes you will see in our responses and the values are their respective full names. +pub async fn get_exchanges( + configuration: &configuration::Configuration, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/stocks/meta/exchanges", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Bars API returns aggregate historical data for the requested security. Returns the latest bar data for the queried stock symbol. +pub async fn get_latest_bar_for_stock_symbol( + configuration: &configuration::Configuration, + params: GetLatestBarForStockSymbolParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let feed = params.feed; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/stocks/{symbol}/bars/latest", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = feed { + local_var_req_builder = + local_var_req_builder.query(&[("feed", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Bars API returns aggregate historical data for the requested security. Returns the latest bar data for the queried stock symbols. +pub async fn get_latest_bars_for_multiple_stock_symbols( + configuration: &configuration::Configuration, + params: GetLatestBarsForMultipleStockSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let feed = params.feed; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/stocks/bars/latest", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + if let Some(ref local_var_str) = feed { + local_var_req_builder = + local_var_req_builder.query(&[("feed", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Latest Quote API provides the latest quote data for a given ticker symbol. +pub async fn get_latest_quote_for_stock_symbol( + configuration: &configuration::Configuration, + params: GetLatestQuoteForStockSymbolParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let feed = params.feed; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/stocks/{symbol}/quotes/latest", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = feed { + local_var_req_builder = + local_var_req_builder.query(&[("feed", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns the latest quotes data for the queried stock symbols. +pub async fn get_latest_quotes_for_multiple_stock_symbols( + configuration: &configuration::Configuration, + params: GetLatestQuotesForMultipleStockSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let feed = params.feed; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/stocks/quotes/latest", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + if let Some(ref local_var_str) = feed { + local_var_req_builder = + local_var_req_builder.query(&[("feed", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Latest Trade API provides the latest trade data for a given ticker symbol. +pub async fn get_latest_trade_for_stock_symbol( + configuration: &configuration::Configuration, + params: GetLatestTradeForStockSymbolParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let feed = params.feed; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/stocks/{symbol}/trades/latest", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = feed { + local_var_req_builder = + local_var_req_builder.query(&[("feed", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns the latest trades data for the queried stock symbols. +pub async fn get_latest_trades_for_multiple_stock_symbols( + configuration: &configuration::Configuration, + params: GetLatestTradesForMultipleStockSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let feed = params.feed; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/stocks/trades/latest", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + if let Some(ref local_var_str) = feed { + local_var_req_builder = + local_var_req_builder.query(&[("feed", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Multi Quotes API provides NBBO quotes for multiple given ticker symbols over a specified time period. Returned results are sorted by symbol first then by Quote timestamp. This means that you are likely to see only one symbol in your first response if there are enough Quotes for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Quotes were found for them. +pub async fn get_quotes_for_multiple_stock_symbols( + configuration: &configuration::Configuration, + params: GetQuotesForMultipleStockSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let start = params.start; + let end = params.end; + let limit = params.limit; + let page_token = params.page_token; + let feed = params.feed; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/stocks/quotes", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = feed { + local_var_req_builder = + local_var_req_builder.query(&[("feed", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Quotes API provides NBBO quotes for a single given ticker symbol at a specified date. Returns quotes (NBBOs) for the querried stock symbol. +pub async fn get_quotes_for_stock_symbol( + configuration: &configuration::Configuration, + params: GetQuotesForStockSymbolParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let start = params.start; + let end = params.end; + let limit = params.limit; + let page_token = params.page_token; + let feed = params.feed; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/stocks/{symbol}/quotes", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = feed { + local_var_req_builder = + local_var_req_builder.query(&[("feed", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Snapshot API for one ticker provides the latest trade, latest quote, minute bar daily bar and previous daily bar data for a given ticker symbol. This endpoint returns the snapshot for the requested security. +pub async fn get_snapshot_for_stock_symbol( + configuration: &configuration::Configuration, + params: GetSnapshotForStockSymbolParams, +) -> Result, Error> +{ + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let feed = params.feed; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/stocks/{symbol}/snapshot", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = feed { + local_var_req_builder = + local_var_req_builder.query(&[("feed", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Snapshot API for multiple tickers provides the latest trade, latest quote, minute bar daily bar and previous daily bar data for the given ticker symbols. +pub async fn get_snapshots_for_multiple_stock_symbols( + configuration: &configuration::Configuration, + params: GetSnapshotsForMultipleStockSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let feed = params.feed; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/stocks/snapshots", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + if let Some(ref local_var_str) = feed { + local_var_req_builder = + local_var_req_builder.query(&[("feed", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Multi Trades API provides historical trade data for multiple given ticker symbols over a specified time period. Returned results are sorted by symbol first then by Trade timestamp. This means that you are likely to see only one symbol in your first response if there are enough Trades for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Trades were found for them. +pub async fn get_trades_for_multiple_stock_symbols( + configuration: &configuration::Configuration, + params: GetTradesForMultipleStockSymbolsParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbols = params.symbols; + let start = params.start; + let end = params.end; + let limit = params.limit; + let page_token = params.page_token; + let feed = params.feed; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/stocks/trades", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("symbols", &symbols.to_string())]); + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = feed { + local_var_req_builder = + local_var_req_builder.query(&[("feed", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Trades API provides historical trade data for a given ticker symbol on a specified date. Returns trades for the queried stock signal. +pub async fn get_trades_for_stock_symbol( + configuration: &configuration::Configuration, + params: GetTradesForStockSymbolParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let start = params.start; + let end = params.end; + let limit = params.limit; + let page_token = params.page_token; + let feed = params.feed; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/stocks/{symbol}/trades", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = feed { + local_var_req_builder = + local_var_req_builder.query(&[("feed", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/data/src/lib.rs b/crates/alpaca_openapi/gen/data/src/lib.rs new file mode 100644 index 0000000..92760eb --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/lib.rs @@ -0,0 +1,12 @@ +#![allow(unused_imports)] + +#[macro_use] +extern crate serde_derive; + +extern crate reqwest; +extern crate serde; +extern crate serde_json; +extern crate url; + +pub mod apis; +pub mod models; diff --git a/crates/alpaca_openapi/gen/data/src/models/bar.rs b/crates/alpaca_openapi/gen/data/src/models/bar.rs new file mode 100644 index 0000000..72dc15f --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/bar.rs @@ -0,0 +1,76 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Bar : The bars API returns aggregate historical data for the requested securities. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Bar { + /// Timestamp in RFC-3339 format with nanosecond precision. + #[serde(rename = "t")] + pub t: String, + /// Exchange. Only present on Bars for Crypto symbols + #[serde(rename = "x", skip_serializing_if = "Option::is_none")] + pub x: Option, + /// Open price + #[serde(rename = "o")] + pub o: f64, + /// High price. + #[serde(rename = "h")] + pub h: f64, + /// Low price. + #[serde(rename = "l")] + pub l: f64, + /// Close price. + #[serde(rename = "c")] + pub c: f64, + /// Volume. + #[serde(rename = "v")] + pub v: f64, + /// Number of trades. + #[serde(rename = "n", skip_serializing_if = "Option::is_none")] + pub n: Option, + /// Volume weighted average price. + #[serde(rename = "vw", skip_serializing_if = "Option::is_none")] + pub vw: Option, +} + +impl Bar { + /// The bars API returns aggregate historical data for the requested securities. + pub fn new(t: String, o: f64, h: f64, l: f64, c: f64, v: f64) -> Bar { + Bar { + t, + x: None, + o, + h, + l, + c, + v, + n: None, + vw: None, + } + } +} +/// Exchange. Only present on Bars for Crypto symbols +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum X { + #[serde(rename = "FTXU")] + Ftxu, + #[serde(rename = "ERSX")] + Ersx, + #[serde(rename = "CBSE")] + Cbse, +} + +impl Default for X { + fn default() -> X { + Self::Ftxu + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/bars_response.rs b/crates/alpaca_openapi/gen/data/src/models/bars_response.rs new file mode 100644 index 0000000..dbc2ef4 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/bars_response.rs @@ -0,0 +1,39 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// BarsResponse : +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct BarsResponse { + /// The array of Bar data + #[serde(rename = "bars")] + pub bars: Vec, + /// the stock ticker or crypto symbol this set of bar data is for + #[serde(rename = "symbol")] + pub symbol: String, + #[serde(rename = "next_page_token", deserialize_with = "Option::deserialize")] + pub next_page_token: Option, +} + +impl BarsResponse { + /// + pub fn new( + bars: Vec, + symbol: String, + next_page_token: Option, + ) -> BarsResponse { + BarsResponse { + bars, + symbol, + next_page_token, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/crypto_spreads_response.rs b/crates/alpaca_openapi/gen/data/src/models/crypto_spreads_response.rs new file mode 100644 index 0000000..c8dbe73 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/crypto_spreads_response.rs @@ -0,0 +1,25 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// CryptoSpreadsResponse : +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CryptoSpreadsResponse { + #[serde(rename = "spreads")] + pub spreads: std::collections::HashMap, +} + +impl CryptoSpreadsResponse { + /// + pub fn new(spreads: std::collections::HashMap) -> CryptoSpreadsResponse { + CryptoSpreadsResponse { spreads } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/get_news_response.rs b/crates/alpaca_openapi/gen/data/src/models/get_news_response.rs new file mode 100644 index 0000000..6fdc194 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/get_news_response.rs @@ -0,0 +1,29 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct GetNewsResponse { + #[serde(rename = "news", skip_serializing_if = "Option::is_none")] + pub news: Option>, + /// Pagination token for next page + #[serde(rename = "next_page_token", skip_serializing_if = "Option::is_none")] + pub next_page_token: Option, +} + +impl GetNewsResponse { + pub fn new() -> GetNewsResponse { + GetNewsResponse { + news: None, + next_page_token: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/latest_bar_response.rs b/crates/alpaca_openapi/gen/data/src/models/latest_bar_response.rs new file mode 100644 index 0000000..f74d376 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/latest_bar_response.rs @@ -0,0 +1,30 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// LatestBarResponse : A model representing the result of hitting one of the Latest Bar api endpoints. Represents a single Bar that should be the latest Bar data for a given ticker symbol +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct LatestBarResponse { + #[serde(rename = "symbol")] + pub symbol: String, + #[serde(rename = "bar")] + pub bar: Box, +} + +impl LatestBarResponse { + /// A model representing the result of hitting one of the Latest Bar api endpoints. Represents a single Bar that should be the latest Bar data for a given ticker symbol + pub fn new(symbol: String, bar: models::Bar) -> LatestBarResponse { + LatestBarResponse { + symbol, + bar: Box::new(bar), + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/latest_multi_bars_response.rs b/crates/alpaca_openapi/gen/data/src/models/latest_multi_bars_response.rs new file mode 100644 index 0000000..83b78e1 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/latest_multi_bars_response.rs @@ -0,0 +1,25 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// LatestMultiBarsResponse : A model representing the result of hitting the Latest Multi Bars api; represents the latest Bars for multiple symbols. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct LatestMultiBarsResponse { + #[serde(rename = "bars")] + pub bars: std::collections::HashMap, +} + +impl LatestMultiBarsResponse { + /// A model representing the result of hitting the Latest Multi Bars api; represents the latest Bars for multiple symbols. + pub fn new(bars: std::collections::HashMap) -> LatestMultiBarsResponse { + LatestMultiBarsResponse { bars } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/latest_multi_quotes_response.rs b/crates/alpaca_openapi/gen/data/src/models/latest_multi_quotes_response.rs new file mode 100644 index 0000000..0bc10b3 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/latest_multi_quotes_response.rs @@ -0,0 +1,27 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// LatestMultiQuotesResponse : +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct LatestMultiQuotesResponse { + #[serde(rename = "quotes")] + pub quotes: std::collections::HashMap, +} + +impl LatestMultiQuotesResponse { + /// + pub fn new( + quotes: std::collections::HashMap, + ) -> LatestMultiQuotesResponse { + LatestMultiQuotesResponse { quotes } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/latest_multi_trades_response.rs b/crates/alpaca_openapi/gen/data/src/models/latest_multi_trades_response.rs new file mode 100644 index 0000000..f1970a3 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/latest_multi_trades_response.rs @@ -0,0 +1,27 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// LatestMultiTradesResponse : +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct LatestMultiTradesResponse { + #[serde(rename = "trades")] + pub trades: std::collections::HashMap, +} + +impl LatestMultiTradesResponse { + /// + pub fn new( + trades: std::collections::HashMap, + ) -> LatestMultiTradesResponse { + LatestMultiTradesResponse { trades } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/latest_multi_xbbo_response.rs b/crates/alpaca_openapi/gen/data/src/models/latest_multi_xbbo_response.rs new file mode 100644 index 0000000..5760cfd --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/latest_multi_xbbo_response.rs @@ -0,0 +1,25 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// LatestMultiXbboResponse : +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct LatestMultiXbboResponse { + #[serde(rename = "xbbos")] + pub xbbos: std::collections::HashMap, +} + +impl LatestMultiXbboResponse { + /// + pub fn new(xbbos: std::collections::HashMap) -> LatestMultiXbboResponse { + LatestMultiXbboResponse { xbbos } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/latest_quote_response.rs b/crates/alpaca_openapi/gen/data/src/models/latest_quote_response.rs new file mode 100644 index 0000000..5cedf92 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/latest_quote_response.rs @@ -0,0 +1,30 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// LatestQuoteResponse : A model representing the result of hitting the Latest Quote api. Represents a single Quote that should be the latest quote data for a given ticker symbol +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct LatestQuoteResponse { + #[serde(rename = "quote")] + pub quote: Box, + #[serde(rename = "symbol")] + pub symbol: String, +} + +impl LatestQuoteResponse { + /// A model representing the result of hitting the Latest Quote api. Represents a single Quote that should be the latest quote data for a given ticker symbol + pub fn new(quote: models::Quote, symbol: String) -> LatestQuoteResponse { + LatestQuoteResponse { + quote: Box::new(quote), + symbol, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/latest_trade_response.rs b/crates/alpaca_openapi/gen/data/src/models/latest_trade_response.rs new file mode 100644 index 0000000..8e22e69 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/latest_trade_response.rs @@ -0,0 +1,31 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// LatestTradeResponse : A model representing the result of hitting the Latest Trade api. Represents a single Trade that should be the latest trade data for a given ticker symbol +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct LatestTradeResponse { + #[serde(rename = "trade", skip_serializing_if = "Option::is_none")] + pub trade: Option>, + /// Symbol that was queried + #[serde(rename = "symbol")] + pub symbol: String, +} + +impl LatestTradeResponse { + /// A model representing the result of hitting the Latest Trade api. Represents a single Trade that should be the latest trade data for a given ticker symbol + pub fn new(symbol: String) -> LatestTradeResponse { + LatestTradeResponse { + trade: None, + symbol, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/latest_xbbo_response.rs b/crates/alpaca_openapi/gen/data/src/models/latest_xbbo_response.rs new file mode 100644 index 0000000..5262136 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/latest_xbbo_response.rs @@ -0,0 +1,30 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// LatestXbboResponse : Represents the Latest XBBO for a crypto symbol that calculates the Best Bid and Offer across multiple exchanges. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct LatestXbboResponse { + #[serde(rename = "symbol")] + pub symbol: String, + #[serde(rename = "xbbo")] + pub xbbo: Box, +} + +impl LatestXbboResponse { + /// Represents the Latest XBBO for a crypto symbol that calculates the Best Bid and Offer across multiple exchanges. + pub fn new(symbol: String, xbbo: models::Xbbo) -> LatestXbboResponse { + LatestXbboResponse { + symbol, + xbbo: Box::new(xbbo), + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/mod.rs b/crates/alpaca_openapi/gen/data/src/models/mod.rs new file mode 100644 index 0000000..6725f32 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/mod.rs @@ -0,0 +1,46 @@ +pub mod bar; +pub use self::bar::Bar; +pub mod bars_response; +pub use self::bars_response::BarsResponse; +pub mod crypto_spreads_response; +pub use self::crypto_spreads_response::CryptoSpreadsResponse; +pub mod get_news_response; +pub use self::get_news_response::GetNewsResponse; +pub mod latest_bar_response; +pub use self::latest_bar_response::LatestBarResponse; +pub mod latest_multi_bars_response; +pub use self::latest_multi_bars_response::LatestMultiBarsResponse; +pub mod latest_multi_quotes_response; +pub use self::latest_multi_quotes_response::LatestMultiQuotesResponse; +pub mod latest_multi_trades_response; +pub use self::latest_multi_trades_response::LatestMultiTradesResponse; +pub mod latest_multi_xbbo_response; +pub use self::latest_multi_xbbo_response::LatestMultiXbboResponse; +pub mod latest_quote_response; +pub use self::latest_quote_response::LatestQuoteResponse; +pub mod latest_trade_response; +pub use self::latest_trade_response::LatestTradeResponse; +pub mod latest_xbbo_response; +pub use self::latest_xbbo_response::LatestXbboResponse; +pub mod multi_bars_response; +pub use self::multi_bars_response::MultiBarsResponse; +pub mod multi_quotes_reponse; +pub use self::multi_quotes_reponse::MultiQuotesReponse; +pub mod multi_trades_response; +pub use self::multi_trades_response::MultiTradesResponse; +pub mod news; +pub use self::news::News; +pub mod news_image; +pub use self::news_image::NewsImage; +pub mod quote; +pub use self::quote::Quote; +pub mod quotes_response; +pub use self::quotes_response::QuotesResponse; +pub mod snapshot; +pub use self::snapshot::Snapshot; +pub mod trade; +pub use self::trade::Trade; +pub mod trades_response; +pub use self::trades_response::TradesResponse; +pub mod xbbo; +pub use self::xbbo::Xbbo; diff --git a/crates/alpaca_openapi/gen/data/src/models/multi_bars_response.rs b/crates/alpaca_openapi/gen/data/src/models/multi_bars_response.rs new file mode 100644 index 0000000..c62a735 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/multi_bars_response.rs @@ -0,0 +1,35 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// MultiBarsResponse : A model representing the result of hitting the Multi Bars api; represents multiple Bars for multiple symbols. Returned results are sorted by symbol first then by Bar timestamp. This means that you are likely to see only one symbol in your first response if there are enough Bars in the duration you specified for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Bars were found for them in the timeframe. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct MultiBarsResponse { + #[serde(rename = "bars")] + pub bars: std::collections::HashMap>, + #[serde( + rename = "next_page_token", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub next_page_token: Option>, +} + +impl MultiBarsResponse { + /// A model representing the result of hitting the Multi Bars api; represents multiple Bars for multiple symbols. Returned results are sorted by symbol first then by Bar timestamp. This means that you are likely to see only one symbol in your first response if there are enough Bars in the duration you specified for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Bars were found for them in the timeframe. + pub fn new(bars: std::collections::HashMap>) -> MultiBarsResponse { + MultiBarsResponse { + bars, + next_page_token: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/multi_quotes_reponse.rs b/crates/alpaca_openapi/gen/data/src/models/multi_quotes_reponse.rs new file mode 100644 index 0000000..e7d9b97 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/multi_quotes_reponse.rs @@ -0,0 +1,38 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// MultiQuotesReponse : A model representing the result of hitting the Multi Quotes api; represents multiple Quotes for multiple symbols. Returned results are sorted by symbol first then by Quote timestamp. This means that you are likely to see only one symbol in your first response if there are enough Quotes for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Quotes were found for them. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct MultiQuotesReponse { + #[serde(rename = "quotes")] + pub quotes: std::collections::HashMap>, + /// pass this token with your request again to get the next page of results + #[serde( + rename = "next_page_token", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub next_page_token: Option>, +} + +impl MultiQuotesReponse { + /// A model representing the result of hitting the Multi Quotes api; represents multiple Quotes for multiple symbols. Returned results are sorted by symbol first then by Quote timestamp. This means that you are likely to see only one symbol in your first response if there are enough Quotes for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Quotes were found for them. + pub fn new( + quotes: std::collections::HashMap>, + ) -> MultiQuotesReponse { + MultiQuotesReponse { + quotes, + next_page_token: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/multi_trades_response.rs b/crates/alpaca_openapi/gen/data/src/models/multi_trades_response.rs new file mode 100644 index 0000000..244a0b3 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/multi_trades_response.rs @@ -0,0 +1,37 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// MultiTradesResponse : A model representing the result of hitting the Multi Trades api; represents multiple trades for multiple symbols. Returned results are sorted by symbol first then by Trade timestamp. This means that you are likely to see only one symbol in your first response if there are enough Trades for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Trades were found for them. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct MultiTradesResponse { + #[serde(rename = "trades")] + pub trades: std::collections::HashMap>, + #[serde( + rename = "next_page_token", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub next_page_token: Option>, +} + +impl MultiTradesResponse { + /// A model representing the result of hitting the Multi Trades api; represents multiple trades for multiple symbols. Returned results are sorted by symbol first then by Trade timestamp. This means that you are likely to see only one symbol in your first response if there are enough Trades for that symbol to hit the limit you requested on that request. In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Trades were found for them. + pub fn new( + trades: std::collections::HashMap>, + ) -> MultiTradesResponse { + MultiTradesResponse { + trades, + next_page_token: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/news.rs b/crates/alpaca_openapi/gen/data/src/models/news.rs new file mode 100644 index 0000000..4aefab5 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/news.rs @@ -0,0 +1,84 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// News : Model representing a news article from the Alpaca Market Data API +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct News { + /// News article ID + #[serde(rename = "id")] + pub id: i64, + /// Headline or title of the article + #[serde(rename = "headline")] + pub headline: String, + /// Original author of news article + #[serde(rename = "author")] + pub author: String, + /// Date article was created (RFC 3339) + #[serde(rename = "created_at")] + pub created_at: String, + /// Date article was updated (RFC 3339) + #[serde(rename = "updated_at")] + pub updated_at: String, + /// Summary text for the article (may be first sentence of content) + #[serde(rename = "summary")] + pub summary: String, + /// Content of the news article (might contain HTML) + #[serde(rename = "content")] + pub content: String, + /// URL of article (if applicable) + #[serde( + rename = "url", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub url: Option>, + /// List of images (URLs) related to given article (may be empty) + #[serde(rename = "images")] + pub images: Vec, + /// List of related or mentioned symbols + #[serde(rename = "symbols")] + pub symbols: Vec, + /// Source where the news originated from (e.g. Benzinga) + #[serde(rename = "source")] + pub source: String, +} + +impl News { + /// Model representing a news article from the Alpaca Market Data API + pub fn new( + id: i64, + headline: String, + author: String, + created_at: String, + updated_at: String, + summary: String, + content: String, + images: Vec, + symbols: Vec, + source: String, + ) -> News { + News { + id, + headline, + author, + created_at, + updated_at, + summary, + content, + url: None, + images, + symbols, + source, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/news_image.rs b/crates/alpaca_openapi/gen/data/src/models/news_image.rs new file mode 100644 index 0000000..9fd7dfa --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/news_image.rs @@ -0,0 +1,45 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// NewsImage : A model representing images for news article. simply a url to the image along with a size parameter suggesting the display size of the image +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct NewsImage { + /// Possible values for size are thumb, small and large. + #[serde(rename = "size")] + pub size: Size, + /// url to image from news article + #[serde(rename = "url")] + pub url: String, +} + +impl NewsImage { + /// A model representing images for news article. simply a url to the image along with a size parameter suggesting the display size of the image + pub fn new(size: Size, url: String) -> NewsImage { + NewsImage { size, url } + } +} +/// Possible values for size are thumb, small and large. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Size { + #[serde(rename = "thumb")] + Thumb, + #[serde(rename = "small")] + Small, + #[serde(rename = "large")] + Large, +} + +impl Default for Size { + fn default() -> Size { + Self::Thumb + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/quote.rs b/crates/alpaca_openapi/gen/data/src/models/quote.rs new file mode 100644 index 0000000..5e9db3c --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/quote.rs @@ -0,0 +1,64 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Quote : The Quotes API provides NBBO quotes for a given ticker symbol at a specified date. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Quote { + /// Timestamp in RFC-3339 format with nanosecond precision + #[serde(rename = "t")] + pub t: String, + /// ask exchange (Stock quote only) + #[serde(rename = "ax", skip_serializing_if = "Option::is_none")] + pub ax: Option, + /// ask price + #[serde(rename = "ap", skip_serializing_if = "Option::is_none")] + pub ap: Option, + /// ask size + #[serde(rename = "as", skip_serializing_if = "Option::is_none")] + pub r#as: Option, + /// bid exchange (Stock quote only) + #[serde(rename = "bx", skip_serializing_if = "Option::is_none")] + pub bx: Option, + /// bid price + #[serde(rename = "bp", skip_serializing_if = "Option::is_none")] + pub bp: Option, + /// bid size + #[serde(rename = "bs", skip_serializing_if = "Option::is_none")] + pub bs: Option, + /// quote conditions (Stock quotes only) + #[serde(rename = "c", skip_serializing_if = "Option::is_none")] + pub c: Option>, + /// Exchange (Crypto quote Only) + #[serde(rename = "x", skip_serializing_if = "Option::is_none")] + pub x: Option, + /// Tape (Stock quote only) + #[serde(rename = "z", skip_serializing_if = "Option::is_none")] + pub z: Option, +} + +impl Quote { + /// The Quotes API provides NBBO quotes for a given ticker symbol at a specified date. + pub fn new(t: String) -> Quote { + Quote { + t, + ax: None, + ap: None, + r#as: None, + bx: None, + bp: None, + bs: None, + c: None, + x: None, + z: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/quotes_response.rs b/crates/alpaca_openapi/gen/data/src/models/quotes_response.rs new file mode 100644 index 0000000..21bb31e --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/quotes_response.rs @@ -0,0 +1,38 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// QuotesResponse : The Quotes API provides NBBO quotes for a given ticker symbol at a specified date. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct QuotesResponse { + #[serde(rename = "quotes", deserialize_with = "Option::deserialize")] + pub quotes: Option>, + #[serde(rename = "symbol")] + pub symbol: String, + #[serde( + rename = "next_page_token", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub next_page_token: Option>, +} + +impl QuotesResponse { + /// The Quotes API provides NBBO quotes for a given ticker symbol at a specified date. + pub fn new(quotes: Option>, symbol: String) -> QuotesResponse { + QuotesResponse { + quotes, + symbol, + next_page_token: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/snapshot.rs b/crates/alpaca_openapi/gen/data/src/models/snapshot.rs new file mode 100644 index 0000000..c432e52 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/snapshot.rs @@ -0,0 +1,39 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Snapshot : The Snapshot API for one ticker provides the latest trade, latest quote, minute bar daily bar and previous daily bar data for a given ticker symbol. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Snapshot { + #[serde(rename = "latestTrade", skip_serializing_if = "Option::is_none")] + pub latest_trade: Option>, + #[serde(rename = "latestQuote", skip_serializing_if = "Option::is_none")] + pub latest_quote: Option>, + #[serde(rename = "minuteBar", skip_serializing_if = "Option::is_none")] + pub minute_bar: Option>, + #[serde(rename = "dailyBar", skip_serializing_if = "Option::is_none")] + pub daily_bar: Option>, + #[serde(rename = "prevDailyBar", skip_serializing_if = "Option::is_none")] + pub prev_daily_bar: Option>, +} + +impl Snapshot { + /// The Snapshot API for one ticker provides the latest trade, latest quote, minute bar daily bar and previous daily bar data for a given ticker symbol. + pub fn new() -> Snapshot { + Snapshot { + latest_trade: None, + latest_quote: None, + minute_bar: None, + daily_bar: None, + prev_daily_bar: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/trade.rs b/crates/alpaca_openapi/gen/data/src/models/trade.rs new file mode 100644 index 0000000..c87a840 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/trade.rs @@ -0,0 +1,56 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Trade : A model representing a trade +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Trade { + /// Timestamp in RFC-3339 format with nanosecond precision + #[serde(rename = "t", skip_serializing_if = "Option::is_none")] + pub t: Option, + /// Exchange where the trade happened. + #[serde(rename = "x")] + pub x: String, + /// Trade price. + #[serde(rename = "p", skip_serializing_if = "Option::is_none")] + pub p: Option, + /// Trade Size. + #[serde(rename = "s", skip_serializing_if = "Option::is_none")] + pub s: Option, + /// Trade conditions (Stock trade only) + #[serde(rename = "c", skip_serializing_if = "Option::is_none")] + pub c: Option>, + /// Trade ID + #[serde(rename = "i")] + pub i: i64, + /// Tape (Stock trade only) + #[serde(rename = "z", skip_serializing_if = "Option::is_none")] + pub z: Option, + /// Taker's side (crypto trade only) + #[serde(rename = "tks", skip_serializing_if = "Option::is_none")] + pub tks: Option, +} + +impl Trade { + /// A model representing a trade + pub fn new(x: String, i: i64) -> Trade { + Trade { + t: None, + x, + p: None, + s: None, + c: None, + i, + z: None, + tks: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/trades_response.rs b/crates/alpaca_openapi/gen/data/src/models/trades_response.rs new file mode 100644 index 0000000..252b58b --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/trades_response.rs @@ -0,0 +1,41 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// TradesResponse : A model representing the result of hitting the Trades api. Represents multiple Trades for a single symbol with support for paging. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TradesResponse { + /// Array of trades + #[serde(rename = "trades")] + pub trades: Vec, + /// Symbol that was queried + #[serde(rename = "symbol")] + pub symbol: String, + /// Token that can be used to query the next page + #[serde( + rename = "next_page_token", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub next_page_token: Option>, +} + +impl TradesResponse { + /// A model representing the result of hitting the Trades api. Represents multiple Trades for a single symbol with support for paging. + pub fn new(trades: Vec, symbol: String) -> TradesResponse { + TradesResponse { + trades, + symbol, + next_page_token: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/data/src/models/xbbo.rs b/crates/alpaca_openapi/gen/data/src/models/xbbo.rs new file mode 100644 index 0000000..2ee9121 --- /dev/null +++ b/crates/alpaca_openapi/gen/data/src/models/xbbo.rs @@ -0,0 +1,52 @@ +/* + * Market Data API + * + * Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Xbbo : XBBO or Cross Best Bid and Offer represents the Best Bid and Offer for an exchange +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Xbbo { + /// Timestamp in RFC-3339 format with nanosecond precision. + #[serde(rename = "t")] + pub t: String, + /// Ask exchange. + #[serde(rename = "ax")] + pub ax: String, + /// Ask price. + #[serde(rename = "ap")] + pub ap: f64, + /// Ask size. + #[serde(rename = "as")] + pub r#as: f64, + /// Bid exchange. + #[serde(rename = "bx")] + pub bx: String, + /// Bid price. + #[serde(rename = "bp")] + pub bp: f64, + /// Bid size. + #[serde(rename = "bs")] + pub bs: f64, +} + +impl Xbbo { + /// XBBO or Cross Best Bid and Offer represents the Best Bid and Offer for an exchange + pub fn new(t: String, ax: String, ap: f64, r#as: f64, bx: String, bp: f64, bs: f64) -> Xbbo { + Xbbo { + t, + ax, + ap, + r#as, + bx, + bp, + bs, + } + } +} diff --git a/crates/alpaca_openapi/gen/oauth/.gitignore b/crates/alpaca_openapi/gen/oauth/.gitignore new file mode 100644 index 0000000..6aa1064 --- /dev/null +++ b/crates/alpaca_openapi/gen/oauth/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/crates/alpaca_openapi/gen/oauth/.openapi-generator-ignore b/crates/alpaca_openapi/gen/oauth/.openapi-generator-ignore new file mode 100644 index 0000000..7484ee5 --- /dev/null +++ b/crates/alpaca_openapi/gen/oauth/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/crates/alpaca_openapi/gen/oauth/.openapi-generator/FILES b/crates/alpaca_openapi/gen/oauth/.openapi-generator/FILES new file mode 100644 index 0000000..11410a6 --- /dev/null +++ b/crates/alpaca_openapi/gen/oauth/.openapi-generator/FILES @@ -0,0 +1,12 @@ +.gitignore +.openapi-generator-ignore +.travis.yml +Cargo.toml +README.md +docs/StockPricingDataApiApi.md +git_push.sh +src/apis/configuration.rs +src/apis/mod.rs +src/apis/stock_pricing_data_api_api.rs +src/lib.rs +src/models/mod.rs diff --git a/crates/alpaca_openapi/gen/oauth/.openapi-generator/VERSION b/crates/alpaca_openapi/gen/oauth/.openapi-generator/VERSION new file mode 100644 index 0000000..18bb418 --- /dev/null +++ b/crates/alpaca_openapi/gen/oauth/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.5.0 diff --git a/crates/alpaca_openapi/gen/oauth/.travis.yml b/crates/alpaca_openapi/gen/oauth/.travis.yml new file mode 100644 index 0000000..22761ba --- /dev/null +++ b/crates/alpaca_openapi/gen/oauth/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/crates/alpaca_openapi/gen/oauth/Cargo.toml b/crates/alpaca_openapi/gen/oauth/Cargo.toml new file mode 100644 index 0000000..f138979 --- /dev/null +++ b/crates/alpaca_openapi/gen/oauth/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "alpaca_oauth" +version = "1.0.0" +authors = ["support@alpaca.markets"] +description = "The OAuth API allows you to request market data and manage portfolios on behalf of your end-users. For more information, visit https://alpaca.markets/docs/build-apps_services-with-alpaca/oauth-guide/." +# Override this license by providing a License Object in the OpenAPI. +license = "Unlicense" +edition = "2018" + +[dependencies] +serde = "^1.0" +serde_derive = "^1.0" +serde_json = "^1.0" +url = "^2.2" +uuid = { version = "^1.0", features = ["serde", "v4"] } +[dependencies.reqwest] +version = "^0.11" +features = ["json", "multipart"] diff --git a/crates/alpaca_openapi/gen/oauth/README.md b/crates/alpaca_openapi/gen/oauth/README.md new file mode 100644 index 0000000..280b426 --- /dev/null +++ b/crates/alpaca_openapi/gen/oauth/README.md @@ -0,0 +1,49 @@ +# Rust API client for alpaca_oauth + +The OAuth API allows you to request market data and manage portfolios on behalf of your end-users. + +For more information, visit https://alpaca.markets/docs/build-apps_services-with-alpaca/oauth-guide/. + +For more information, please visit [https://alpaca.markets/support](https://alpaca.markets/support) + +## Overview + +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 1.0.0 +- Package version: 1.0.0 +- Generator version: 7.5.0 +- Build package: `org.openapitools.codegen.languages.RustClientCodegen` + +## Installation + +Put the package under your project folder in a directory named `alpaca_oauth` and add the following to `Cargo.toml` under `[dependencies]`: + +``` +alpaca_oauth = { path = "./alpaca_oauth" } +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://data.alpaca.markets/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*StockPricingDataApiApi* | [**get_bars_stocks**](docs/StockPricingDataApiApi.md#get_bars_stocks) | **GET** /v2/stocks/{symbol}/bars | Bars +*StockPricingDataApiApi* | [**get_trades_stocks**](docs/StockPricingDataApiApi.md#get_trades_stocks) | **GET** /v2/stocks/{symbol}/trades | Trades + + +## Documentation For Models + + + +To get access to the crate's generated documentation, use: + +``` +cargo doc --open +``` + +## Author + +support@alpaca.markets + diff --git a/crates/alpaca_openapi/gen/oauth/docs/StockPricingDataApiApi.md b/crates/alpaca_openapi/gen/oauth/docs/StockPricingDataApiApi.md new file mode 100644 index 0000000..42cbe78 --- /dev/null +++ b/crates/alpaca_openapi/gen/oauth/docs/StockPricingDataApiApi.md @@ -0,0 +1,79 @@ +# \StockPricingDataApiApi + +All URIs are relative to *https://data.alpaca.markets/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_bars_stocks**](StockPricingDataApiApi.md#get_bars_stocks) | **GET** /v2/stocks/{symbol}/bars | Bars +[**get_trades_stocks**](StockPricingDataApiApi.md#get_trades_stocks) | **GET** /v2/stocks/{symbol}/trades | Trades + + + +## get_bars_stocks + +> get_bars_stocks(symbol, apca_api_key_id, apca_api_secret_key, start, end, timeframe) +Bars + +The bars API returns aggregate historical data for the requested securities + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The symbol to query for | [required] | +**apca_api_key_id** | Option<**String**> | | | +**apca_api_secret_key** | Option<**String**> | | | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | +**timeframe** | Option<**String**> | Timeframe for the aggregation. Values are customizeable, frequently used examples: 1Min, 15Min, 1Hour, 1Day. | | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_trades_stocks + +> get_trades_stocks(symbol, apca_api_key_id, apca_api_secret_key, start, end) +Trades + +The Trades API provides historcial trade data for a given ticker symbol on a specified date. Returns trades for the queried stock signal. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol** | **String** | The symbol to query for | [required] | +**apca_api_key_id** | Option<**String**> | | | +**apca_api_secret_key** | Option<**String**> | | | +**start** | Option<**String**> | Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. | | +**end** | Option<**String**> | Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. | | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/oauth/git_push.sh b/crates/alpaca_openapi/gen/oauth/git_push.sh new file mode 100644 index 0000000..f53a75d --- /dev/null +++ b/crates/alpaca_openapi/gen/oauth/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/crates/alpaca_openapi/gen/oauth/src/apis/configuration.rs b/crates/alpaca_openapi/gen/oauth/src/apis/configuration.rs new file mode 100644 index 0000000..3d5c8da --- /dev/null +++ b/crates/alpaca_openapi/gen/oauth/src/apis/configuration.rs @@ -0,0 +1,49 @@ +/* + * OAuth API + * + * The OAuth API allows you to request market data and manage portfolios on behalf of your end-users. For more information, visit https://alpaca.markets/docs/build-apps_services-with-alpaca/oauth-guide/. + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, + // TODO: take an oauth2 token source, similar to the go one +} + +pub type BasicAuth = (String, Option); + +#[derive(Debug, Clone)] +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + +impl Configuration { + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Default for Configuration { + fn default() -> Self { + Configuration { + base_path: "https://data.alpaca.markets/v2".to_owned(), + user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()), + client: reqwest::Client::new(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/oauth/src/apis/mod.rs b/crates/alpaca_openapi/gen/oauth/src/apis/mod.rs new file mode 100644 index 0000000..63dc6e3 --- /dev/null +++ b/crates/alpaca_openapi/gen/oauth/src/apis/mod.rs @@ -0,0 +1,97 @@ +use std::error; +use std::fmt; + +#[derive(Debug, Clone)] +pub struct ResponseContent { + pub status: reqwest::StatusCode, + pub content: String, + pub entity: Option, +} + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), + ResponseError(ResponseContent), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (module, e) = match self { + Error::Reqwest(e) => ("reqwest", e.to_string()), + Error::Serde(e) => ("serde", e.to_string()), + Error::Io(e) => ("IO", e.to_string()), + Error::ResponseError(e) => ("response", format!("status code {}", e.status)), + }; + write!(f, "error in {}: {}", module, e) + } +} + +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + Some(match self { + Error::Reqwest(e) => e, + Error::Serde(e) => e, + Error::Io(e) => e, + Error::ResponseError(_) => return None, + }) + } +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> { + if let serde_json::Value::Object(object) = value { + let mut params = vec![]; + + for (key, value) in object { + match value { + serde_json::Value::Object(_) => params.append(&mut parse_deep_object( + &format!("{}[{}]", prefix, key), + value, + )), + serde_json::Value::Array(array) => { + for (i, value) in array.iter().enumerate() { + params.append(&mut parse_deep_object( + &format!("{}[{}][{}]", prefix, key, i), + value, + )); + } + } + serde_json::Value::String(s) => { + params.push((format!("{}[{}]", prefix, key), s.clone())) + } + _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), + } + } + + return params; + } + + unimplemented!("Only objects are supported with style=deepObject") +} + +pub mod stock_pricing_data_api_api; + +pub mod configuration; diff --git a/crates/alpaca_openapi/gen/oauth/src/apis/stock_pricing_data_api_api.rs b/crates/alpaca_openapi/gen/oauth/src/apis/stock_pricing_data_api_api.rs new file mode 100644 index 0000000..5290c9a --- /dev/null +++ b/crates/alpaca_openapi/gen/oauth/src/apis/stock_pricing_data_api_api.rs @@ -0,0 +1,219 @@ +/* + * OAuth API + * + * The OAuth API allows you to request market data and manage portfolios on behalf of your end-users. For more information, visit https://alpaca.markets/docs/build-apps_services-with-alpaca/oauth-guide/. + * + * The version of the OpenAPI document: 1.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`get_bars_stocks`] +#[derive(Clone, Debug)] +pub struct GetBarsStocksParams { + /// The symbol to query for + pub symbol: String, + pub apca_api_key_id: Option, + pub apca_api_secret_key: Option, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, + /// Timeframe for the aggregation. Values are customizeable, frequently used examples: 1Min, 15Min, 1Hour, 1Day. + pub timeframe: Option, +} + +/// struct for passing parameters to the method [`get_trades_stocks`] +#[derive(Clone, Debug)] +pub struct GetTradesStocksParams { + /// The symbol to query for + pub symbol: String, + pub apca_api_key_id: Option, + pub apca_api_secret_key: Option, + /// Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + pub start: Option, + /// Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + pub end: Option, +} + +/// struct for typed successes of method [`get_bars_stocks`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetBarsStocksSuccess { + Status200(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_trades_stocks`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTradesStocksSuccess { + Status200(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_bars_stocks`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetBarsStocksError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_trades_stocks`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTradesStocksError { + UnknownValue(serde_json::Value), +} + +/// The bars API returns aggregate historical data for the requested securities +pub async fn get_bars_stocks( + configuration: &configuration::Configuration, + params: GetBarsStocksParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let apca_api_key_id = params.apca_api_key_id; + let apca_api_secret_key = params.apca_api_secret_key; + let start = params.start; + let end = params.end; + let timeframe = params.timeframe; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/stocks/{symbol}/bars", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = timeframe { + local_var_req_builder = + local_var_req_builder.query(&[("timeframe", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(local_var_param_value) = apca_api_key_id { + local_var_req_builder = + local_var_req_builder.header("Apca-Api-Key-Id", local_var_param_value.to_string()); + } + if let Some(local_var_param_value) = apca_api_secret_key { + local_var_req_builder = + local_var_req_builder.header("Apca-Api-Secret-Key", local_var_param_value.to_string()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The Trades API provides historcial trade data for a given ticker symbol on a specified date. Returns trades for the queried stock signal. +pub async fn get_trades_stocks( + configuration: &configuration::Configuration, + params: GetTradesStocksParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol = params.symbol; + let apca_api_key_id = params.apca_api_key_id; + let apca_api_secret_key = params.apca_api_secret_key; + let start = params.start; + let end = params.end; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/stocks/{symbol}/trades", + local_var_configuration.base_path, + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(local_var_param_value) = apca_api_key_id { + local_var_req_builder = + local_var_req_builder.header("Apca-Api-Key-Id", local_var_param_value.to_string()); + } + if let Some(local_var_param_value) = apca_api_secret_key { + local_var_req_builder = + local_var_req_builder.header("Apca-Api-Secret-Key", local_var_param_value.to_string()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/oauth/src/lib.rs b/crates/alpaca_openapi/gen/oauth/src/lib.rs new file mode 100644 index 0000000..92760eb --- /dev/null +++ b/crates/alpaca_openapi/gen/oauth/src/lib.rs @@ -0,0 +1,12 @@ +#![allow(unused_imports)] + +#[macro_use] +extern crate serde_derive; + +extern crate reqwest; +extern crate serde; +extern crate serde_json; +extern crate url; + +pub mod apis; +pub mod models; diff --git a/crates/alpaca_openapi/gen/oauth/src/models/mod.rs b/crates/alpaca_openapi/gen/oauth/src/models/mod.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/crates/alpaca_openapi/gen/oauth/src/models/mod.rs @@ -0,0 +1 @@ + diff --git a/crates/alpaca_openapi/gen/trading/.gitignore b/crates/alpaca_openapi/gen/trading/.gitignore new file mode 100644 index 0000000..6aa1064 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/crates/alpaca_openapi/gen/trading/.openapi-generator-ignore b/crates/alpaca_openapi/gen/trading/.openapi-generator-ignore new file mode 100644 index 0000000..7484ee5 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/crates/alpaca_openapi/gen/trading/.openapi-generator/FILES b/crates/alpaca_openapi/gen/trading/.openapi-generator/FILES new file mode 100644 index 0000000..a2f702f --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/.openapi-generator/FILES @@ -0,0 +1,82 @@ +.gitignore +.openapi-generator-ignore +.travis.yml +Cargo.toml +README.md +docs/Account.md +docs/AccountActivitiesApi.md +docs/AccountConfigurations.md +docs/AccountConfigurationsApi.md +docs/AccountStatus.md +docs/AccountsApi.md +docs/ActivityType.md +docs/AddAssetToWatchlistRequest.md +docs/AssetClass.md +docs/Assets.md +docs/Calendar.md +docs/CalendarApi.md +docs/CanceledOrderResponse.md +docs/Clock.md +docs/ClockApi.md +docs/Exchange.md +docs/GetAccountActivities200ResponseInner.md +docs/GetAccountActivitiesByActivityType200ResponseInner.md +docs/NonTradeActivities.md +docs/Order.md +docs/OrderClass.md +docs/OrderSide.md +docs/OrderStatus.md +docs/OrderType.md +docs/OrdersApi.md +docs/PatchOrderRequest.md +docs/PortfolioHistory.md +docs/PortfolioHistoryApi.md +docs/Position.md +docs/PositionClosedReponse.md +docs/PositionsApi.md +docs/TimeInForce.md +docs/TradingActivities.md +docs/UpdateWatchlistRequest.md +docs/Watchlist.md +docs/WatchlistsApi.md +git_push.sh +src/apis/account_activities_api.rs +src/apis/account_configurations_api.rs +src/apis/accounts_api.rs +src/apis/calendar_api.rs +src/apis/clock_api.rs +src/apis/configuration.rs +src/apis/mod.rs +src/apis/orders_api.rs +src/apis/portfolio_history_api.rs +src/apis/positions_api.rs +src/apis/watchlists_api.rs +src/lib.rs +src/models/account.rs +src/models/account_configurations.rs +src/models/account_status.rs +src/models/activity_type.rs +src/models/add_asset_to_watchlist_request.rs +src/models/asset_class.rs +src/models/assets.rs +src/models/calendar.rs +src/models/canceled_order_response.rs +src/models/clock.rs +src/models/exchange.rs +src/models/get_account_activities_200_response_inner.rs +src/models/get_account_activities_by_activity_type_200_response_inner.rs +src/models/mod.rs +src/models/non_trade_activities.rs +src/models/order.rs +src/models/order_class.rs +src/models/order_side.rs +src/models/order_status.rs +src/models/order_type.rs +src/models/patch_order_request.rs +src/models/portfolio_history.rs +src/models/position.rs +src/models/position_closed_reponse.rs +src/models/time_in_force.rs +src/models/trading_activities.rs +src/models/update_watchlist_request.rs +src/models/watchlist.rs diff --git a/crates/alpaca_openapi/gen/trading/.openapi-generator/VERSION b/crates/alpaca_openapi/gen/trading/.openapi-generator/VERSION new file mode 100644 index 0000000..18bb418 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.5.0 diff --git a/crates/alpaca_openapi/gen/trading/.travis.yml b/crates/alpaca_openapi/gen/trading/.travis.yml new file mode 100644 index 0000000..22761ba --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/crates/alpaca_openapi/gen/trading/Cargo.toml b/crates/alpaca_openapi/gen/trading/Cargo.toml new file mode 100644 index 0000000..7497d2a --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "alpaca_trading" +version = "2.0.0" +authors = ["support@alpaca.markets"] +description = "Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started." +# Override this license by providing a License Object in the OpenAPI. +license = "Unlicense" +edition = "2018" + +[dependencies] +serde = "^1.0" +serde_derive = "^1.0" +serde_with = "^2.0" +serde_json = "^1.0" +url = "^2.2" +uuid = { version = "^1.0", features = ["serde", "v4"] } +[dependencies.reqwest] +version = "^0.11" +features = ["json", "multipart"] diff --git a/crates/alpaca_openapi/gen/trading/README.md b/crates/alpaca_openapi/gen/trading/README.md new file mode 100644 index 0000000..eeb21ea --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/README.md @@ -0,0 +1,103 @@ +# Rust API client for alpaca_trading + +Alpaca's Trading API is a modern platform for algorithmic trading. + +For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + +For more information, please visit [https://alpaca.markets/support](https://alpaca.markets/support) + +## Overview + +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 2.0.0 +- Package version: 2.0.0 +- Generator version: 7.5.0 +- Build package: `org.openapitools.codegen.languages.RustClientCodegen` + +## Installation + +Put the package under your project folder in a directory named `alpaca_trading` and add the following to `Cargo.toml` under `[dependencies]`: + +``` +alpaca_trading = { path = "./alpaca_trading" } +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://paper-api.alpaca.markets* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*AccountActivitiesApi* | [**get_account_activities**](docs/AccountActivitiesApi.md#get_account_activities) | **GET** /v2/account/activities | Get account activities of one type +*AccountActivitiesApi* | [**get_account_activities_by_activity_type**](docs/AccountActivitiesApi.md#get_account_activities_by_activity_type) | **GET** /v2/account/activities/{activity_type} | Get account activities of one type +*AccountConfigurationsApi* | [**get_account_config**](docs/AccountConfigurationsApi.md#get_account_config) | **GET** /v2/account/configurations | Account Configurations +*AccountConfigurationsApi* | [**patch_account_config**](docs/AccountConfigurationsApi.md#patch_account_config) | **PATCH** /v2/account/configurations | Account Configurations +*AccountsApi* | [**get_account**](docs/AccountsApi.md#get_account) | **GET** /v2/account | Get account +*CalendarApi* | [**get_calendar**](docs/CalendarApi.md#get_calendar) | **GET** /v2/calendar | Get Market Calendar info +*ClockApi* | [**get_clock**](docs/ClockApi.md#get_clock) | **GET** /v2/clock | Get Market Clock info +*OrdersApi* | [**delete_all_orders**](docs/OrdersApi.md#delete_all_orders) | **DELETE** /v2/orders | All Orders +*OrdersApi* | [**delete_order_by_order_id**](docs/OrdersApi.md#delete_order_by_order_id) | **DELETE** /v2/orders/{order_id} | Order by Order ID +*OrdersApi* | [**get_all_orders**](docs/OrdersApi.md#get_all_orders) | **GET** /v2/orders | All Orders +*OrdersApi* | [**get_order_by_order_id**](docs/OrdersApi.md#get_order_by_order_id) | **GET** /v2/orders/{order_id} | Order by Order ID +*OrdersApi* | [**patch_order_by_order_id**](docs/OrdersApi.md#patch_order_by_order_id) | **PATCH** /v2/orders/{order_id} | Order +*OrdersApi* | [**post_order**](docs/OrdersApi.md#post_order) | **POST** /v2/orders | Order +*PortfolioHistoryApi* | [**get_account_portfolio_history**](docs/PortfolioHistoryApi.md#get_account_portfolio_history) | **GET** /v2/account/portfolio/history | Account Portfolio History +*PositionsApi* | [**delete_all_open_positions**](docs/PositionsApi.md#delete_all_open_positions) | **DELETE** /v2/positions | All Positions +*PositionsApi* | [**delete_open_position**](docs/PositionsApi.md#delete_open_position) | **DELETE** /v2/positions/{symbol_or_asset_id} | Position +*PositionsApi* | [**get_all_open_positions**](docs/PositionsApi.md#get_all_open_positions) | **GET** /v2/positions | All Open Positions +*PositionsApi* | [**get_open_position**](docs/PositionsApi.md#get_open_position) | **GET** /v2/positions/{symbol_or_asset_id} | Open Position +*WatchlistsApi* | [**add_asset_to_watchlist**](docs/WatchlistsApi.md#add_asset_to_watchlist) | **POST** /v2/watchlists/{watchlist_id} | Add Asset to Watchlist +*WatchlistsApi* | [**add_asset_to_watchlist_by_name**](docs/WatchlistsApi.md#add_asset_to_watchlist_by_name) | **POST** /v2/watchlists:by_name | Add Asset to Watchlist By Name +*WatchlistsApi* | [**delete_watchlist_by_id**](docs/WatchlistsApi.md#delete_watchlist_by_id) | **DELETE** /v2/watchlists/{watchlist_id} | Delete Watchlist By Id +*WatchlistsApi* | [**delete_watchlist_by_name**](docs/WatchlistsApi.md#delete_watchlist_by_name) | **DELETE** /v2/watchlists:by_name | Delete Watchlist By Name +*WatchlistsApi* | [**get_watchlist_by_id**](docs/WatchlistsApi.md#get_watchlist_by_id) | **GET** /v2/watchlists/{watchlist_id} | Get Watchlist by ID +*WatchlistsApi* | [**get_watchlist_by_name**](docs/WatchlistsApi.md#get_watchlist_by_name) | **GET** /v2/watchlists:by_name | Get Watchlist by Name +*WatchlistsApi* | [**get_watchlists**](docs/WatchlistsApi.md#get_watchlists) | **GET** /v2/watchlists | Watchlists +*WatchlistsApi* | [**post_watchlist**](docs/WatchlistsApi.md#post_watchlist) | **POST** /v2/watchlists | Watchlist +*WatchlistsApi* | [**remove_asset_from_watchlist**](docs/WatchlistsApi.md#remove_asset_from_watchlist) | **DELETE** /v2/watchlists/{watchlist_id}/{symbol} | Symbol from Watchlist +*WatchlistsApi* | [**update_watchlist_by_id**](docs/WatchlistsApi.md#update_watchlist_by_id) | **PUT** /v2/watchlists/{watchlist_id} | Update Watchlist By Id +*WatchlistsApi* | [**update_watchlist_by_name**](docs/WatchlistsApi.md#update_watchlist_by_name) | **PUT** /v2/watchlists:by_name | Update Watchlist By Name + + +## Documentation For Models + + - [Account](docs/Account.md) + - [AccountConfigurations](docs/AccountConfigurations.md) + - [AccountStatus](docs/AccountStatus.md) + - [ActivityType](docs/ActivityType.md) + - [AddAssetToWatchlistRequest](docs/AddAssetToWatchlistRequest.md) + - [AssetClass](docs/AssetClass.md) + - [Assets](docs/Assets.md) + - [Calendar](docs/Calendar.md) + - [CanceledOrderResponse](docs/CanceledOrderResponse.md) + - [Clock](docs/Clock.md) + - [Exchange](docs/Exchange.md) + - [GetAccountActivities200ResponseInner](docs/GetAccountActivities200ResponseInner.md) + - [GetAccountActivitiesByActivityType200ResponseInner](docs/GetAccountActivitiesByActivityType200ResponseInner.md) + - [NonTradeActivities](docs/NonTradeActivities.md) + - [Order](docs/Order.md) + - [OrderClass](docs/OrderClass.md) + - [OrderSide](docs/OrderSide.md) + - [OrderStatus](docs/OrderStatus.md) + - [OrderType](docs/OrderType.md) + - [PatchOrderRequest](docs/PatchOrderRequest.md) + - [PortfolioHistory](docs/PortfolioHistory.md) + - [Position](docs/Position.md) + - [PositionClosedReponse](docs/PositionClosedReponse.md) + - [TimeInForce](docs/TimeInForce.md) + - [TradingActivities](docs/TradingActivities.md) + - [UpdateWatchlistRequest](docs/UpdateWatchlistRequest.md) + - [Watchlist](docs/Watchlist.md) + + +To get access to the crate's generated documentation, use: + +``` +cargo doc --open +``` + +## Author + +support@alpaca.markets + diff --git a/crates/alpaca_openapi/gen/trading/docs/Account.md b/crates/alpaca_openapi/gen/trading/docs/Account.md new file mode 100644 index 0000000..47f17cf --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/Account.md @@ -0,0 +1,36 @@ +# Account + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | Account Id. | +**account_number** | Option<**String**> | Account number. | [optional] +**status** | [**models::AccountStatus**](AccountStatus.md) | | +**currency** | Option<**String**> | USD | [optional] +**cash** | Option<**String**> | Cash Balance | [optional] +**portfolio_value** | Option<**String**> | Total value of cash + holding positions (This field is deprecated. It is equivalent to the equity field.) | [optional] +**pattern_day_trader** | Option<**bool**> | Whether or not the account has been flagged as a pattern day trader | [optional] +**trade_suspended_by_user** | Option<**bool**> | User setting. If true, the account is not allowed to place orders. | [optional] +**trading_blocked** | Option<**bool**> | If true, the account is not allowed to place orders. | [optional] +**transfers_blocked** | Option<**bool**> | If true, the account is not allowed to request money transfers. | [optional] +**account_blocked** | Option<**bool**> | If true, the account activity by user is prohibited. | [optional] +**created_at** | Option<**String**> | Timestamp this account was created at | [optional] +**shorting_enabled** | Option<**bool**> | Flag to denote whether or not the account is permitted to short | [optional] +**long_market_value** | Option<**String**> | Real-time MtM value of all long positions held in the account | [optional] +**short_market_value** | Option<**String**> | Real-time MtM value of all short positions held in the account | [optional] +**equity** | Option<**String**> | Cash + long_market_value + short_market_value | [optional] +**last_equity** | Option<**String**> | Equity as of previous trading day at 16:00:00 ET | [optional] +**multiplier** | Option<**String**> | Buying power multiplier that represents account margin classification; valid values 1 (standard limited margin account with 1x buying power), 2 (reg T margin account with 2x intraday and overnight buying power; this is the default for all non-PDT accounts with $2,000 or more equity), 4 (PDT account with 4x intraday buying power and 2x reg T overnight buying power) | [optional] +**buying_power** | Option<**String**> | Current available $ buying power; If multiplier = 4, this is your daytrade buying power which is calculated as (last_equity - (last) maintenance_margin) * 4; If multiplier = 2, buying_power = max(equity – initial_margin,0) * 2; If multiplier = 1, buying_power = cash | [optional] +**initial_margin** | Option<**String**> | Reg T initial margin requirement (continuously updated value) | [optional] +**maintenance_margin** | Option<**String**> | Maintenance margin requirement (continuously updated value) | [optional] +**sma** | Option<**String**> | Value of special memorandum account (will be used at a later date to provide additional buying_power) | [optional] +**daytrade_count** | Option<**i32**> | The current number of daytrades that have been made in the last 5 trading days (inclusive of today) | [optional] +**last_maintenance_margin** | Option<**String**> | Your maintenance margin requirement on the previous trading day | [optional] +**daytrading_buying_power** | Option<**String**> | Your buying power for day trades (continuously updated value) | [optional] +**regt_buying_power** | Option<**String**> | Your buying power under Regulation T (your excess equity - equity minus margin value - times your margin multiplier) | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/AccountActivitiesApi.md b/crates/alpaca_openapi/gen/trading/docs/AccountActivitiesApi.md new file mode 100644 index 0000000..ed9bff4 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/AccountActivitiesApi.md @@ -0,0 +1,82 @@ +# \AccountActivitiesApi + +All URIs are relative to *https://paper-api.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_account_activities**](AccountActivitiesApi.md#get_account_activities) | **GET** /v2/account/activities | Get account activities of one type +[**get_account_activities_by_activity_type**](AccountActivitiesApi.md#get_account_activities_by_activity_type) | **GET** /v2/account/activities/{activity_type} | Get account activities of one type + + + +## get_account_activities + +> Vec get_account_activities(date, until, after, direction, page_size, page_token, activity_types) +Get account activities of one type + +Returns account activity entries for many types of activities. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**date** | Option<**String**> | The date for which you want to see activities. | | +**until** | Option<**String**> | The response will contain only activities submitted before this date. (Cannot be used with date.) | | +**after** | Option<**String**> | The response will contain only activities submitted after this date. (Cannot be used with date.) | | +**direction** | Option<**String**> | asc or desc (default desc if unspecified.) | | +**page_size** | Option<**i32**> | The maximum number of entries to return in the response. (See the section on paging above.) | | +**page_token** | Option<**String**> | The ID of the end of your current page of results. | | +**activity_types** | Option<**String**> | A comma-separated list of the activity types to include in the response. If unspecified, activities of all types will be returned. See ActivityType model for values | | + +### Return type + +[**Vec**](getAccountActivities_200_response_inner.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_account_activities_by_activity_type + +> Vec get_account_activities_by_activity_type(activity_type, date, until, after, direction, page_size, page_token) +Get account activities of one type + +Returns account activity entries for a specific type of activity. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**activity_type** | **String** | The activity type you want to view entries for. A list of valid activity types can be found at the bottom of this page. | [required] | +**date** | Option<**String**> | The date for which you want to see activities. | | +**until** | Option<**String**> | The response will contain only activities submitted before this date. (Cannot be used with date.) | | +**after** | Option<**String**> | The response will contain only activities submitted after this date. (Cannot be used with date.) | | +**direction** | Option<**String**> | asc or desc (default desc if unspecified.) | | +**page_size** | Option<**i32**> | The maximum number of entries to return in the response. (See the section on paging above.) | | +**page_token** | Option<**String**> | The ID of the end of your current page of results. | | + +### Return type + +[**Vec**](getAccountActivitiesByActivityType_200_response_inner.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/trading/docs/AccountConfigurations.md b/crates/alpaca_openapi/gen/trading/docs/AccountConfigurations.md new file mode 100644 index 0000000..bd0d4ed --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/AccountConfigurations.md @@ -0,0 +1,17 @@ +# AccountConfigurations + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dtbp_check** | Option<**String**> | both, entry, or exit. Controls Day Trading Margin Call (DTMC) checks. | [optional] +**trade_confirm_email** | Option<**String**> | all or none. If none, emails for order fills are not sent. | [optional] +**suspend_trade** | Option<**bool**> | If true, new orders are blocked. | [optional] +**no_shorting** | Option<**bool**> | If true, account becomes long-only mode. | [optional] +**fractional_trading** | Option<**bool**> | If true, account is able to participate in fractional trading | [optional] +**max_margin_multiplier** | Option<**String**> | Can be \"1\" or \"2\" | [optional] +**pdt_check** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/AccountConfigurationsApi.md b/crates/alpaca_openapi/gen/trading/docs/AccountConfigurationsApi.md new file mode 100644 index 0000000..664b324 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/AccountConfigurationsApi.md @@ -0,0 +1,67 @@ +# \AccountConfigurationsApi + +All URIs are relative to *https://paper-api.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_account_config**](AccountConfigurationsApi.md#get_account_config) | **GET** /v2/account/configurations | Account Configurations +[**patch_account_config**](AccountConfigurationsApi.md#patch_account_config) | **PATCH** /v2/account/configurations | Account Configurations + + + +## get_account_config + +> models::AccountConfigurations get_account_config() +Account Configurations + +gets the current account configuration values + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::AccountConfigurations**](AccountConfigurations.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## patch_account_config + +> models::AccountConfigurations patch_account_config(account_configurations) +Account Configurations + +Updates and returns the current account configuration values + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**account_configurations** | Option<[**AccountConfigurations**](AccountConfigurations.md)> | | | + +### Return type + +[**models::AccountConfigurations**](AccountConfigurations.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/trading/docs/AccountStatus.md b/crates/alpaca_openapi/gen/trading/docs/AccountStatus.md new file mode 100644 index 0000000..fb76f85 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/AccountStatus.md @@ -0,0 +1,18 @@ +# AccountStatus + +## Enum Variants + +| Name | Value | +|---- | -----| +| Onboarding | ONBOARDING | +| SubmissionFailed | SUBMISSION_FAILED | +| Submitted | SUBMITTED | +| AccountUpdated | ACCOUNT_UPDATED | +| ApprovalPending | APPROVAL_PENDING | +| Active | ACTIVE | +| Rejected | REJECTED | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/AccountsApi.md b/crates/alpaca_openapi/gen/trading/docs/AccountsApi.md new file mode 100644 index 0000000..5860ec2 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/AccountsApi.md @@ -0,0 +1,36 @@ +# \AccountsApi + +All URIs are relative to *https://paper-api.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_account**](AccountsApi.md#get_account) | **GET** /v2/account | Get account + + + +## get_account + +> models::Account get_account() +Get account + +Returns the account associated with the API key. + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::Account**](Account.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/trading/docs/ActivityType.md b/crates/alpaca_openapi/gen/trading/docs/ActivityType.md new file mode 100644 index 0000000..2d6b7ee --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/ActivityType.md @@ -0,0 +1,46 @@ +# ActivityType + +## Enum Variants + +| Name | Value | +|---- | -----| +| Fill | FILL | +| Trans | TRANS | +| Misc | MISC | +| Acatc | ACATC | +| Acats | ACATS | +| Csd | CSD | +| Csw | CSW | +| Div | DIV | +| Divcgl | DIVCGL | +| Divcgs | DIVCGS | +| Divfee | DIVFEE | +| Divft | DIVFT | +| Divnra | DIVNRA | +| Divroc | DIVROC | +| Divtw | DIVTW | +| Divtxex | DIVTXEX | +| Int | INT | +| Intnra | INTNRA | +| Inttw | INTTW | +| Jnl | JNL | +| Jnlc | JNLC | +| Jnls | JNLS | +| Ma | MA | +| Nc | NC | +| Opasn | OPASN | +| Opexp | OPEXP | +| Opxrc | OPXRC | +| Ptc | PTC | +| Ptr | PTR | +| Reorg | REORG | +| Sc | SC | +| Sso | SSO | +| Ssp | SSP | +| Cfee | CFEE | +| Fee | FEE | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/AddAssetToWatchlistRequest.md b/crates/alpaca_openapi/gen/trading/docs/AddAssetToWatchlistRequest.md new file mode 100644 index 0000000..244edae --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/AddAssetToWatchlistRequest.md @@ -0,0 +1,11 @@ +# AddAssetToWatchlistRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**symbol** | Option<**String**> | symbol name to append to watchlist | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/AssetClass.md b/crates/alpaca_openapi/gen/trading/docs/AssetClass.md new file mode 100644 index 0000000..1877fdb --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/AssetClass.md @@ -0,0 +1,13 @@ +# AssetClass + +## Enum Variants + +| Name | Value | +|---- | -----| +| UsEquity | us_equity | +| Crypto | crypto | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/Assets.md b/crates/alpaca_openapi/gen/trading/docs/Assets.md new file mode 100644 index 0000000..90d7cdb --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/Assets.md @@ -0,0 +1,21 @@ +# Assets + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | Asset ID | +**class** | [**models::AssetClass**](AssetClass.md) | | +**exchange** | [**models::Exchange**](Exchange.md) | | +**symbol** | **String** | The symbol of the asset | +**name** | **String** | The official name of the asset | +**status** | **String** | active or inactive | +**tradable** | **bool** | Asset is tradable on Alpaca or not | +**marginable** | **bool** | Asset is marginable or not | +**shortable** | **bool** | Asset is shortable or not | +**easy_to_borrow** | **bool** | Asset is easy-to-borrow or not (filtering for easy_to_borrow = True is the best way to check whether the name is currently available to short at Alpaca). | +**fractionable** | **bool** | Asset is fractionable or not | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/Calendar.md b/crates/alpaca_openapi/gen/trading/docs/Calendar.md new file mode 100644 index 0000000..a3e7051 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/Calendar.md @@ -0,0 +1,15 @@ +# Calendar + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**date** | **String** | Date string in “%Y-%m-%d” format | +**open** | **String** | The time the market opens at on this date in “%H:%M” format | +**close** | **String** | The time the market closes at on this date in “%H:%M” format | +**session_open** | **String** | | +**session_close** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/CalendarApi.md b/crates/alpaca_openapi/gen/trading/docs/CalendarApi.md new file mode 100644 index 0000000..4d76e46 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/CalendarApi.md @@ -0,0 +1,40 @@ +# \CalendarApi + +All URIs are relative to *https://paper-api.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_calendar**](CalendarApi.md#get_calendar) | **GET** /v2/calendar | Get Market Calendar info + + + +## get_calendar + +> Vec get_calendar(start, end) +Get Market Calendar info + +Returns the market calendar. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**start** | Option<**String**> | The first date to retrieve data for (inclusive) | | +**end** | Option<**String**> | The last date to retrieve data for (inclusive) | | + +### Return type + +[**Vec**](Calendar.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/trading/docs/CanceledOrderResponse.md b/crates/alpaca_openapi/gen/trading/docs/CanceledOrderResponse.md new file mode 100644 index 0000000..85b29db --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/CanceledOrderResponse.md @@ -0,0 +1,12 @@ +# CanceledOrderResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | orderId | [optional] +**status** | Option<**i32**> | http response code | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/Clock.md b/crates/alpaca_openapi/gen/trading/docs/Clock.md new file mode 100644 index 0000000..140ac31 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/Clock.md @@ -0,0 +1,14 @@ +# Clock + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**timestamp** | Option<**String**> | Current timestamp | [optional] +**is_open** | Option<**bool**> | Whether or not the market is open | [optional] +**next_open** | Option<**String**> | Next Market open timestamp | [optional] +**next_close** | Option<**String**> | Next market close timestamp | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/ClockApi.md b/crates/alpaca_openapi/gen/trading/docs/ClockApi.md new file mode 100644 index 0000000..fb249e7 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/ClockApi.md @@ -0,0 +1,36 @@ +# \ClockApi + +All URIs are relative to *https://paper-api.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_clock**](ClockApi.md#get_clock) | **GET** /v2/clock | Get Market Clock info + + + +## get_clock + +> models::Clock get_clock() +Get Market Clock info + +The clock API serves the current market timestamp, whether or not the market is currently open, as well as the times of the next market open and close. Returns the market clock. + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::Clock**](Clock.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/trading/docs/Exchange.md b/crates/alpaca_openapi/gen/trading/docs/Exchange.md new file mode 100644 index 0000000..733d03d --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/Exchange.md @@ -0,0 +1,18 @@ +# Exchange + +## Enum Variants + +| Name | Value | +|---- | -----| +| Amex | AMEX | +| Arca | ARCA | +| Bats | BATS | +| Nyse | NYSE | +| Nasdaq | NASDAQ | +| Nysearca | NYSEARCA | +| Otc | OTC | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/GetAccountActivities200ResponseInner.md b/crates/alpaca_openapi/gen/trading/docs/GetAccountActivities200ResponseInner.md new file mode 100644 index 0000000..368e9b0 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/GetAccountActivities200ResponseInner.md @@ -0,0 +1,25 @@ +# GetAccountActivities200ResponseInner + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**activity_type** | Option<[**models::ActivityType**](ActivityType.md)> | | [optional] +**id** | Option<**String**> | An ID for the activity, always in “::” format. Can be sent as page_token in requests to facilitate the paging of results. | [optional] +**cum_qty** | Option<**String**> | The cumulative quantity of shares involved in the execution. | [optional] +**leaves_qty** | Option<**String**> | For partially_filled orders, the quantity of shares that are left to be filled. | [optional] +**price** | Option<**String**> | The per-share price that the trade was executed at. | [optional] +**qty** | Option<**String**> | For dividend activities, the number of shares that contributed to the payment. Not present for other activity types. | [optional] +**side** | Option<**String**> | buy or sell | [optional] +**symbol** | Option<**String**> | The symbol of the security involved with the activity. Not present for all activity types. | [optional] +**transaction_time** | Option<**String**> | The time at which the execution occurred. | [optional] +**order_id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | The id for the order that filled. | [optional] +**r#type** | Option<**String**> | fill or partial_fill | [optional] +**order_status** | Option<[**models::OrderStatus**](OrderStatus.md)> | | [optional] +**date** | Option<**String**> | The date on which the activity occurred or on which the transaction associated with the activity settled. | [optional] +**net_amount** | Option<**String**> | The net amount of money (positive or negative) associated with the activity. | [optional] +**per_share_amount** | Option<**String**> | For dividend activities, the average amount paid per share. Not present for other activity types. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/GetAccountActivitiesByActivityType200ResponseInner.md b/crates/alpaca_openapi/gen/trading/docs/GetAccountActivitiesByActivityType200ResponseInner.md new file mode 100644 index 0000000..1a2af9d --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/GetAccountActivitiesByActivityType200ResponseInner.md @@ -0,0 +1,12 @@ +# GetAccountActivitiesByActivityType200ResponseInner + +## Enum Variants + +| Name | Description | +|---- | -----| +| NonTradeActivities | Will be one of a TradingActivity or NonTradeActivity based on activity_type used in path | +| TradingActivities | Will be one of a TradingActivity or NonTradeActivity based on activity_type used in path | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/NonTradeActivities.md b/crates/alpaca_openapi/gen/trading/docs/NonTradeActivities.md new file mode 100644 index 0000000..5bbd04d --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/NonTradeActivities.md @@ -0,0 +1,17 @@ +# NonTradeActivities + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**activity_type** | Option<[**models::ActivityType**](ActivityType.md)> | | [optional] +**id** | Option<**String**> | An ID for the activity, always in “::” format. Can be sent as page_token in requests to facilitate the paging of results. | [optional] +**date** | Option<**String**> | The date on which the activity occurred or on which the transaction associated with the activity settled. | [optional] +**net_amount** | Option<**String**> | The net amount of money (positive or negative) associated with the activity. | [optional] +**symbol** | Option<**String**> | The symbol of the security involved with the activity. Not present for all activity types. | [optional] +**qty** | Option<**String**> | For dividend activities, the number of shares that contributed to the payment. Not present for other activity types. | [optional] +**per_share_amount** | Option<**String**> | For dividend activities, the average amount paid per share. Not present for other activity types. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/Order.md b/crates/alpaca_openapi/gen/trading/docs/Order.md new file mode 100644 index 0000000..6e1e9e1 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/Order.md @@ -0,0 +1,42 @@ +# Order + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**String**> | Order ID | [optional] +**client_order_id** | Option<**String**> | Client unique order ID | [optional] +**created_at** | Option<**String**> | | [optional] +**updated_at** | Option<**String**> | | [optional] +**submitted_at** | Option<**String**> | | [optional] +**filled_at** | Option<**String**> | | [optional] +**expired_at** | Option<**String**> | | [optional] +**canceled_at** | Option<**String**> | | [optional] +**failed_at** | Option<**String**> | | [optional] +**replaced_at** | Option<**String**> | | [optional] +**replaced_by** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | The order ID that this order was replaced by | [optional] +**replaces** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | The order ID that this order replaces | [optional] +**asset_id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | Asset ID | [optional] +**symbol** | **String** | Asset symbol | +**asset_class** | Option<[**models::AssetClass**](AssetClass.md)> | | [optional] +**notional** | Option<**String**> | Ordered notional amount. If entered, qty will be null. Can take up to 9 decimal points. | +**qty** | Option<**String**> | Ordered quantity. If entered, notional will be null. Can take up to 9 decimal points. | +**filled_qty** | Option<**String**> | Filled quantity | [optional] +**filled_avg_price** | Option<**String**> | Filled average price | [optional] +**order_class** | Option<[**models::OrderClass**](OrderClass.md)> | | [optional] +**order_type** | Option<**String**> | Deprecated in favour of the field \"type\" | [optional] +**r#type** | [**models::OrderType**](OrderType.md) | | +**side** | [**models::OrderSide**](OrderSide.md) | | +**time_in_force** | [**models::TimeInForce**](TimeInForce.md) | | +**limit_price** | Option<**String**> | Limit price | [optional] +**stop_price** | Option<**String**> | Stop price | [optional] +**status** | Option<[**models::OrderStatus**](OrderStatus.md)> | | [optional] +**extended_hours** | Option<**bool**> | If true, eligible for execution outside regular trading hours. | [optional] +**legs** | Option<[**Vec**](Order.md)> | When querying non-simple order_class orders in a nested style, an array of Order entities associated with this order. Otherwise, null. | [optional] +**trail_percent** | Option<**String**> | The percent value away from the high water mark for trailing stop orders. | [optional] +**trail_price** | Option<**String**> | The dollar value away from the high water mark for trailing stop orders. | [optional] +**hwm** | Option<**String**> | The highest (lowest) market price seen since the trailing stop order was submitted. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/OrderClass.md b/crates/alpaca_openapi/gen/trading/docs/OrderClass.md new file mode 100644 index 0000000..98d5cf4 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/OrderClass.md @@ -0,0 +1,16 @@ +# OrderClass + +## Enum Variants + +| Name | Value | +|---- | -----| +| Simple | simple | +| Bracket | bracket | +| Oco | oco | +| Oto | oto | +| Empty | | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/OrderSide.md b/crates/alpaca_openapi/gen/trading/docs/OrderSide.md new file mode 100644 index 0000000..230830e --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/OrderSide.md @@ -0,0 +1,13 @@ +# OrderSide + +## Enum Variants + +| Name | Value | +|---- | -----| +| Buy | buy | +| Sell | sell | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/OrderStatus.md b/crates/alpaca_openapi/gen/trading/docs/OrderStatus.md new file mode 100644 index 0000000..e5c3b1b --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/OrderStatus.md @@ -0,0 +1,27 @@ +# OrderStatus + +## Enum Variants + +| Name | Value | +|---- | -----| +| New | new | +| PartiallyFilled | partially_filled | +| Filled | filled | +| DoneForDay | done_for_day | +| Canceled | canceled | +| Expired | expired | +| Replaced | replaced | +| PendingCancel | pending_cancel | +| PendingReplace | pending_replace | +| Accepted | accepted | +| PendingNew | pending_new | +| AcceptedForBidding | accepted_for_bidding | +| Stopped | stopped | +| Rejected | rejected | +| Suspended | suspended | +| Calculated | calculated | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/OrderType.md b/crates/alpaca_openapi/gen/trading/docs/OrderType.md new file mode 100644 index 0000000..0c42e20 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/OrderType.md @@ -0,0 +1,16 @@ +# OrderType + +## Enum Variants + +| Name | Value | +|---- | -----| +| Market | market | +| Limit | limit | +| Stop | stop | +| StopLimit | stop_limit | +| TrailingStop | trailing_stop | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/OrdersApi.md b/crates/alpaca_openapi/gen/trading/docs/OrdersApi.md new file mode 100644 index 0000000..a2e8573 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/OrdersApi.md @@ -0,0 +1,199 @@ +# \OrdersApi + +All URIs are relative to *https://paper-api.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_all_orders**](OrdersApi.md#delete_all_orders) | **DELETE** /v2/orders | All Orders +[**delete_order_by_order_id**](OrdersApi.md#delete_order_by_order_id) | **DELETE** /v2/orders/{order_id} | Order by Order ID +[**get_all_orders**](OrdersApi.md#get_all_orders) | **GET** /v2/orders | All Orders +[**get_order_by_order_id**](OrdersApi.md#get_order_by_order_id) | **GET** /v2/orders/{order_id} | Order by Order ID +[**patch_order_by_order_id**](OrdersApi.md#patch_order_by_order_id) | **PATCH** /v2/orders/{order_id} | Order +[**post_order**](OrdersApi.md#post_order) | **POST** /v2/orders | Order + + + +## delete_all_orders + +> Vec delete_all_orders() +All Orders + +Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request. + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Vec**](CanceledOrderResponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_order_by_order_id + +> delete_order_by_order_id(order_id) +Order by Order ID + +Attempts to cancel an Open Order. If the order is no longer cancelable, the request will be rejected with status 422; otherwise accepted with return status 204. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order_id** | **uuid::Uuid** | order id | [required] | + +### Return type + + (empty response body) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_all_orders + +> Vec get_all_orders(status, limit, after, until, direction, nested, symbols) +All Orders + +Retrieves a list of orders for the account, filtered by the supplied query parameters. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | Option<**String**> | Order status to be queried. open, closed or all. Defaults to open. | | +**limit** | Option<**i32**> | The maximum number of orders in response. Defaults to 50 and max is 500. | | +**after** | Option<**String**> | The response will include only ones submitted after this timestamp (exclusive.) | | +**until** | Option<**String**> | The response will include only ones submitted until this timestamp (exclusive.) | | +**direction** | Option<**String**> | The chronological order of response based on the submission time. asc or desc. Defaults to desc. | | +**nested** | Option<**bool**> | If true, the result will roll up multi-leg orders under the legs field of primary order. | | +**symbols** | Option<**String**> | A comma-separated list of symbols to filter by (ex. “AAPL,TSLA,MSFT”). A currency pair is required for crypto orders (ex. “BTCUSD,BCHUSD,LTCUSD,ETCUSD”). | | + +### Return type + +[**Vec**](Order.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_order_by_order_id + +> models::Order get_order_by_order_id(order_id, nested) +Order by Order ID + +Retrieves a single order for the given order_id. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order_id** | **uuid::Uuid** | order id | [required] | +**nested** | Option<**bool**> | If true, the result will roll up multi-leg orders under the legs field of primary order. | | + +### Return type + +[**models::Order**](Order.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## patch_order_by_order_id + +> models::Order patch_order_by_order_id(order_id, patch_order_request) +Order + +Replaces a single order with updated parameters. Each parameter overrides the corresponding attribute of the existing order. The other attributes remain the same as the existing order. A success return code from a replaced order does NOT guarantee the existing open order has been replaced. If the existing open order is filled before the replacing (new) order reaches the execution venue, the replacing (new) order is rejected, and these events are sent in the trade_updates stream channel. While an order is being replaced, buying power is reduced by the larger of the two orders that have been placed (the old order being replaced, and the newly placed order to replace it). If you are replacing a buy entry order with a higher limit price than the original order, the buying power is calculated based on the newly placed order. If you are replacing it with a lower limit price, the buying power is calculated based on the old order. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order_id** | **uuid::Uuid** | order id | [required] | +**patch_order_request** | [**PatchOrderRequest**](PatchOrderRequest.md) | | [required] | + +### Return type + +[**models::Order**](Order.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## post_order + +> models::Order post_order(order) +Order + +Places a new order for the given account. An order request may be rejected if the account is not authorized for trading, or if the tradable balance is insufficient to fill the order.. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order** | [**Order**](Order.md) | | [required] | + +### Return type + +[**models::Order**](Order.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/trading/docs/PatchOrderRequest.md b/crates/alpaca_openapi/gen/trading/docs/PatchOrderRequest.md new file mode 100644 index 0000000..af7e4b3 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/PatchOrderRequest.md @@ -0,0 +1,16 @@ +# PatchOrderRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**qty** | Option<**String**> | number of shares to trade | [optional] +**time_in_force** | Option<[**models::TimeInForce**](TimeInForce.md)> | | [optional] +**limit_price** | Option<**String**> | required if original order type is limit or stop_limit | [optional] +**stop_price** | Option<**String**> | required if original order type is limit or stop_limit | [optional] +**trail** | Option<**String**> | the new value of the trail_price or trail_percent value (works only for type=“trailing_stop”) | [optional] +**client_order_id** | Option<**String**> | A unique identifier for the order. Automatically generated if not sent. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/PortfolioHistory.md b/crates/alpaca_openapi/gen/trading/docs/PortfolioHistory.md new file mode 100644 index 0000000..baf9218 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/PortfolioHistory.md @@ -0,0 +1,16 @@ +# PortfolioHistory + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**timestamp** | Option<**Vec**> | time of each data element, left-labeled (the beginning of time window) | [optional] +**equity** | Option<**Vec**> | equity value of the account in dollar amount as of the end of each time window | [optional] +**profit_loss** | Option<**Vec**> | profit/loss in dollar from the base value | [optional] +**profit_loss_pct** | Option<**Vec**> | profit/loss in percentage from the base value | [optional] +**base_value** | Option<**f64**> | basis in dollar of the profit loss calculation | [optional] +**timeframe** | Option<**String**> | time window size of each data element | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/PortfolioHistoryApi.md b/crates/alpaca_openapi/gen/trading/docs/PortfolioHistoryApi.md new file mode 100644 index 0000000..eb7f16b --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/PortfolioHistoryApi.md @@ -0,0 +1,42 @@ +# \PortfolioHistoryApi + +All URIs are relative to *https://paper-api.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_account_portfolio_history**](PortfolioHistoryApi.md#get_account_portfolio_history) | **GET** /v2/account/portfolio/history | Account Portfolio History + + + +## get_account_portfolio_history + +> models::PortfolioHistory get_account_portfolio_history(period, timeframe, date_end, extended_hours) +Account Portfolio History + +Returns timeseries data about equity and profit/loss (P/L) of the account in requested timespan. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**period** | Option<**String**> | The duration of the data in + , such as 1D, where can be D for day, W for week, M for month and A for year. Defaults to 1M. | | +**timeframe** | Option<**String**> | The resolution of time window. 1Min, 5Min, 15Min, 1H, or 1D. If omitted, 1Min for less than 7 days period, 15Min for less than 30 days, or otherwise 1D. | | +**date_end** | Option<**String**> | The date the data is returned up to, in “YYYY-MM-DD” format. Defaults to the current market date (rolls over at the market open if extended_hours is false, otherwise at 7am ET) | | +**extended_hours** | Option<**String**> | If true, include extended hours in the result. This is effective only for timeframe less than 1D. | | + +### Return type + +[**models::PortfolioHistory**](PortfolioHistory.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/trading/docs/Position.md b/crates/alpaca_openapi/gen/trading/docs/Position.md new file mode 100644 index 0000000..1ff5517 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/Position.md @@ -0,0 +1,28 @@ +# Position + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**asset_id** | [**uuid::Uuid**](uuid::Uuid.md) | Asset ID | +**symbol** | **String** | Symbol name of the asset | +**exchange** | [**models::Exchange**](Exchange.md) | | +**asset_class** | [**models::AssetClass**](AssetClass.md) | | +**avg_entry_price** | **String** | Average entry price of the position | +**qty** | **String** | The number of shares | +**qty_available** | Option<**String**> | Total number of shares available minus open orders | [optional] +**side** | **String** | “long” | +**market_value** | **String** | Total dollar amount of the position | +**cost_basis** | **String** | Total cost basis in dollar | +**unrealized_pl** | **String** | Unrealized profit/loss in dollars | +**unrealized_plpc** | **String** | Unrealized profit/loss percent (by a factor of 1) | +**unrealized_intraday_pl** | **String** | Unrealized profit/loss in dollars for the day | +**unrealized_intraday_plpc** | **String** | Unrealized profit/loss percent (by a factor of 1) | +**current_price** | **String** | Current asset price per share | +**lastday_price** | **String** | Last day’s asset price per share based on the closing value of the last trading day | +**change_today** | **String** | Percent change from last day price (by a factor of 1) | +**asset_marginable** | **bool** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/PositionClosedReponse.md b/crates/alpaca_openapi/gen/trading/docs/PositionClosedReponse.md new file mode 100644 index 0000000..91e2ff8 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/PositionClosedReponse.md @@ -0,0 +1,13 @@ +# PositionClosedReponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**symbol** | **String** | Symbol name of the asset | +**status** | **String** | Http status code for the attempt to close this position | +**body** | Option<[**models::Order**](Order.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/PositionsApi.md b/crates/alpaca_openapi/gen/trading/docs/PositionsApi.md new file mode 100644 index 0000000..d5edf71 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/PositionsApi.md @@ -0,0 +1,131 @@ +# \PositionsApi + +All URIs are relative to *https://paper-api.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_all_open_positions**](PositionsApi.md#delete_all_open_positions) | **DELETE** /v2/positions | All Positions +[**delete_open_position**](PositionsApi.md#delete_open_position) | **DELETE** /v2/positions/{symbol_or_asset_id} | Position +[**get_all_open_positions**](PositionsApi.md#get_all_open_positions) | **GET** /v2/positions | All Open Positions +[**get_open_position**](PositionsApi.md#get_open_position) | **GET** /v2/positions/{symbol_or_asset_id} | Open Position + + + +## delete_all_open_positions + +> Vec delete_all_open_positions(cancel_orders) +All Positions + +Closes (liquidates) all of the account’s open long and short positions. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**cancel_orders** | Option<**bool**> | If true is specified, cancel all open orders before liquidating all positions. | | + +### Return type + +[**Vec**](PositionClosedReponse.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_open_position + +> models::Order delete_open_position(symbol_or_asset_id, qty, percentage) +Position + +Closes (liquidates) the account’s open position for the given symbol. Works for both long and short positions. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol_or_asset_id** | **String** | symbol or assetId | [required] | +**qty** | Option<**f64**> | the number of shares to liquidate. Can accept up to 9 decimal points. Cannot work with percentage | | +**percentage** | Option<**f64**> | percentage of position to liquidate. Must be between 0 and 100. Would only sell fractional if position is originally fractional. Can accept up to 9 decimal points. Cannot work with qty | | + +### Return type + +[**models::Order**](Order.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_all_open_positions + +> Vec get_all_open_positions() +All Open Positions + +The positions API provides information about an account’s current open positions. The response will include information such as cost basis, shares traded, and market value, which will be updated live as price information is updated. Once a position is closed, it will no longer be queryable through this API Retrieves a list of the account’s open positions + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Vec**](Position.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_open_position + +> models::Position get_open_position(symbol_or_asset_id) +Open Position + +Retrieves the account’s open position for the given symbol or assetId. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**symbol_or_asset_id** | **String** | symbol or assetId | [required] | + +### Return type + +[**models::Position**](Position.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/trading/docs/TimeInForce.md b/crates/alpaca_openapi/gen/trading/docs/TimeInForce.md new file mode 100644 index 0000000..78b433a --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/TimeInForce.md @@ -0,0 +1,17 @@ +# TimeInForce + +## Enum Variants + +| Name | Value | +|---- | -----| +| Day | day | +| Gtc | gtc | +| Opg | opg | +| Cls | cls | +| Ioc | ioc | +| Fok | fok | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/TradingActivities.md b/crates/alpaca_openapi/gen/trading/docs/TradingActivities.md new file mode 100644 index 0000000..bde5641 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/TradingActivities.md @@ -0,0 +1,22 @@ +# TradingActivities + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**activity_type** | Option<[**models::ActivityType**](ActivityType.md)> | | [optional] +**id** | Option<**String**> | An id for the activity. Always in “::” format. Can be sent as page_token in requests to facilitate the paging of results. | [optional] +**cum_qty** | Option<**String**> | The cumulative quantity of shares involved in the execution. | [optional] +**leaves_qty** | Option<**String**> | For partially_filled orders, the quantity of shares that are left to be filled. | [optional] +**price** | Option<**String**> | The per-share price that the trade was executed at. | [optional] +**qty** | Option<**String**> | The number of shares involved in the trade execution. | [optional] +**side** | Option<**String**> | buy or sell | [optional] +**symbol** | Option<**String**> | The symbol of the security being traded. | [optional] +**transaction_time** | Option<**String**> | The time at which the execution occurred. | [optional] +**order_id** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | The id for the order that filled. | [optional] +**r#type** | Option<**String**> | fill or partial_fill | [optional] +**order_status** | Option<[**models::OrderStatus**](OrderStatus.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/UpdateWatchlistRequest.md b/crates/alpaca_openapi/gen/trading/docs/UpdateWatchlistRequest.md new file mode 100644 index 0000000..04f0920 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/UpdateWatchlistRequest.md @@ -0,0 +1,12 @@ +# UpdateWatchlistRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **String** | | +**symbols** | Option<**Vec**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/Watchlist.md b/crates/alpaca_openapi/gen/trading/docs/Watchlist.md new file mode 100644 index 0000000..183b929 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/Watchlist.md @@ -0,0 +1,16 @@ +# Watchlist + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | [**uuid::Uuid**](uuid::Uuid.md) | watchlist id | +**account_id** | [**uuid::Uuid**](uuid::Uuid.md) | account ID | +**created_at** | **String** | | +**updated_at** | **String** | | +**name** | **String** | user-defined watchlist name (up to 64 characters) | +**assets** | Option<[**Vec**](Assets.md)> | the content of this watchlist, in the order as registered by the client | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/alpaca_openapi/gen/trading/docs/WatchlistsApi.md b/crates/alpaca_openapi/gen/trading/docs/WatchlistsApi.md new file mode 100644 index 0000000..a4682fc --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/docs/WatchlistsApi.md @@ -0,0 +1,351 @@ +# \WatchlistsApi + +All URIs are relative to *https://paper-api.alpaca.markets* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_asset_to_watchlist**](WatchlistsApi.md#add_asset_to_watchlist) | **POST** /v2/watchlists/{watchlist_id} | Add Asset to Watchlist +[**add_asset_to_watchlist_by_name**](WatchlistsApi.md#add_asset_to_watchlist_by_name) | **POST** /v2/watchlists:by_name | Add Asset to Watchlist By Name +[**delete_watchlist_by_id**](WatchlistsApi.md#delete_watchlist_by_id) | **DELETE** /v2/watchlists/{watchlist_id} | Delete Watchlist By Id +[**delete_watchlist_by_name**](WatchlistsApi.md#delete_watchlist_by_name) | **DELETE** /v2/watchlists:by_name | Delete Watchlist By Name +[**get_watchlist_by_id**](WatchlistsApi.md#get_watchlist_by_id) | **GET** /v2/watchlists/{watchlist_id} | Get Watchlist by ID +[**get_watchlist_by_name**](WatchlistsApi.md#get_watchlist_by_name) | **GET** /v2/watchlists:by_name | Get Watchlist by Name +[**get_watchlists**](WatchlistsApi.md#get_watchlists) | **GET** /v2/watchlists | Watchlists +[**post_watchlist**](WatchlistsApi.md#post_watchlist) | **POST** /v2/watchlists | Watchlist +[**remove_asset_from_watchlist**](WatchlistsApi.md#remove_asset_from_watchlist) | **DELETE** /v2/watchlists/{watchlist_id}/{symbol} | Symbol from Watchlist +[**update_watchlist_by_id**](WatchlistsApi.md#update_watchlist_by_id) | **PUT** /v2/watchlists/{watchlist_id} | Update Watchlist By Id +[**update_watchlist_by_name**](WatchlistsApi.md#update_watchlist_by_name) | **PUT** /v2/watchlists:by_name | Update Watchlist By Name + + + +## add_asset_to_watchlist + +> models::Watchlist add_asset_to_watchlist(watchlist_id, add_asset_to_watchlist_request) +Add Asset to Watchlist + +Append an asset for the symbol to the end of watchlist asset list + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**watchlist_id** | **uuid::Uuid** | watchlist id | [required] | +**add_asset_to_watchlist_request** | Option<[**AddAssetToWatchlistRequest**](AddAssetToWatchlistRequest.md)> | | | + +### Return type + +[**models::Watchlist**](Watchlist.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## add_asset_to_watchlist_by_name + +> models::Watchlist add_asset_to_watchlist_by_name(name, add_asset_to_watchlist_request) +Add Asset to Watchlist By Name + +Append an asset for the symbol to the end of watchlist asset list + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**name** | **String** | name of the watchlist | [required] | +**add_asset_to_watchlist_request** | Option<[**AddAssetToWatchlistRequest**](AddAssetToWatchlistRequest.md)> | | | + +### Return type + +[**models::Watchlist**](Watchlist.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_watchlist_by_id + +> delete_watchlist_by_id(watchlist_id) +Delete Watchlist By Id + +Delete a watchlist. This is a permanent deletion. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**watchlist_id** | **uuid::Uuid** | watchlist id | [required] | + +### Return type + + (empty response body) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_watchlist_by_name + +> delete_watchlist_by_name(name) +Delete Watchlist By Name + +Delete a watchlist. This is a permanent deletion. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**name** | **String** | name of the watchlist | [required] | + +### Return type + + (empty response body) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_watchlist_by_id + +> models::Watchlist get_watchlist_by_id(watchlist_id) +Get Watchlist by ID + +Returns a watchlist identified by the ID. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**watchlist_id** | **uuid::Uuid** | watchlist id | [required] | + +### Return type + +[**models::Watchlist**](Watchlist.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_watchlist_by_name + +> models::Watchlist get_watchlist_by_name(name) +Get Watchlist by Name + +Returns a watchlist by name + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**name** | **String** | name of the watchlist | [required] | + +### Return type + +[**models::Watchlist**](Watchlist.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_watchlists + +> Vec get_watchlists() +Watchlists + +Returns the list of watchlists registered under the account. + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Vec**](Watchlist.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## post_watchlist + +> models::Watchlist post_watchlist(update_watchlist_request) +Watchlist + +Create a new watchlist with initial set of assets. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**update_watchlist_request** | [**UpdateWatchlistRequest**](UpdateWatchlistRequest.md) | | [required] | + +### Return type + +[**models::Watchlist**](Watchlist.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## remove_asset_from_watchlist + +> models::Watchlist remove_asset_from_watchlist(watchlist_id, symbol) +Symbol from Watchlist + +Delete one entry for an asset by symbol name + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**watchlist_id** | **uuid::Uuid** | Watchlist ID | [required] | +**symbol** | **String** | symbol name to remove from the watchlist content | [required] | + +### Return type + +[**models::Watchlist**](Watchlist.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## update_watchlist_by_id + +> models::Watchlist update_watchlist_by_id(watchlist_id, update_watchlist_request) +Update Watchlist By Id + +Update the name and/or content of watchlist + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**watchlist_id** | **uuid::Uuid** | watchlist id | [required] | +**update_watchlist_request** | Option<[**UpdateWatchlistRequest**](UpdateWatchlistRequest.md)> | | | + +### Return type + +[**models::Watchlist**](Watchlist.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## update_watchlist_by_name + +> models::Watchlist update_watchlist_by_name(name, update_watchlist_request) +Update Watchlist By Name + +Update the name and/or content of watchlist + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**name** | **String** | name of the watchlist | [required] | +**update_watchlist_request** | Option<[**UpdateWatchlistRequest**](UpdateWatchlistRequest.md)> | | | + +### Return type + +[**models::Watchlist**](Watchlist.md) + +### Authorization + +[API_Key](../README.md#API_Key), [API_Secret](../README.md#API_Secret) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/alpaca_openapi/gen/trading/git_push.sh b/crates/alpaca_openapi/gen/trading/git_push.sh new file mode 100644 index 0000000..f53a75d --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/crates/alpaca_openapi/gen/trading/src/apis/account_activities_api.rs b/crates/alpaca_openapi/gen/trading/src/apis/account_activities_api.rs new file mode 100644 index 0000000..89e6c7a --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/apis/account_activities_api.rs @@ -0,0 +1,286 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`get_account_activities`] +#[derive(Clone, Debug)] +pub struct GetAccountActivitiesParams { + /// The date for which you want to see activities. + pub date: Option, + /// The response will contain only activities submitted before this date. (Cannot be used with date.) + pub until: Option, + /// The response will contain only activities submitted after this date. (Cannot be used with date.) + pub after: Option, + /// asc or desc (default desc if unspecified.) + pub direction: Option, + /// The maximum number of entries to return in the response. (See the section on paging above.) + pub page_size: Option, + /// The ID of the end of your current page of results. + pub page_token: Option, + /// A comma-separated list of the activity types to include in the response. If unspecified, activities of all types will be returned. See ActivityType model for values + pub activity_types: Option, +} + +/// struct for passing parameters to the method [`get_account_activities_by_activity_type`] +#[derive(Clone, Debug)] +pub struct GetAccountActivitiesByActivityTypeParams { + /// The activity type you want to view entries for. A list of valid activity types can be found at the bottom of this page. + pub activity_type: String, + /// The date for which you want to see activities. + pub date: Option, + /// The response will contain only activities submitted before this date. (Cannot be used with date.) + pub until: Option, + /// The response will contain only activities submitted after this date. (Cannot be used with date.) + pub after: Option, + /// asc or desc (default desc if unspecified.) + pub direction: Option, + /// The maximum number of entries to return in the response. (See the section on paging above.) + pub page_size: Option, + /// The ID of the end of your current page of results. + pub page_token: Option, +} + +/// struct for typed successes of method [`get_account_activities`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountActivitiesSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_account_activities_by_activity_type`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountActivitiesByActivityTypeSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_account_activities`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountActivitiesError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_account_activities_by_activity_type`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountActivitiesByActivityTypeError { + UnknownValue(serde_json::Value), +} + +/// Returns account activity entries for many types of activities. +pub async fn get_account_activities( + configuration: &configuration::Configuration, + params: GetAccountActivitiesParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let date = params.date; + let until = params.until; + let after = params.after; + let direction = params.direction; + let page_size = params.page_size; + let page_token = params.page_token; + let activity_types = params.activity_types; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/account/activities", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = date { + local_var_req_builder = + local_var_req_builder.query(&[("date", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until { + local_var_req_builder = + local_var_req_builder.query(&[("until", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = after { + local_var_req_builder = + local_var_req_builder.query(&[("after", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = direction { + local_var_req_builder = + local_var_req_builder.query(&[("direction", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_size { + local_var_req_builder = + local_var_req_builder.query(&[("page_size", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = activity_types { + local_var_req_builder = + local_var_req_builder.query(&[("activity_types", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns account activity entries for a specific type of activity. +pub async fn get_account_activities_by_activity_type( + configuration: &configuration::Configuration, + params: GetAccountActivitiesByActivityTypeParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let activity_type = params.activity_type; + let date = params.date; + let until = params.until; + let after = params.after; + let direction = params.direction; + let page_size = params.page_size; + let page_token = params.page_token; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/account/activities/{activity_type}", + local_var_configuration.base_path, + activity_type = crate::apis::urlencode(activity_type) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = date { + local_var_req_builder = + local_var_req_builder.query(&[("date", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until { + local_var_req_builder = + local_var_req_builder.query(&[("until", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = after { + local_var_req_builder = + local_var_req_builder.query(&[("after", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = direction { + local_var_req_builder = + local_var_req_builder.query(&[("direction", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_size { + local_var_req_builder = + local_var_req_builder.query(&[("page_size", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = page_token { + local_var_req_builder = + local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/apis/account_configurations_api.rs b/crates/alpaca_openapi/gen/trading/src/apis/account_configurations_api.rs new file mode 100644 index 0000000..d051332 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/apis/account_configurations_api.rs @@ -0,0 +1,185 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`patch_account_config`] +#[derive(Clone, Debug)] +pub struct PatchAccountConfigParams { + pub account_configurations: Option, +} + +/// struct for typed successes of method [`get_account_config`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountConfigSuccess { + Status200(models::AccountConfigurations), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`patch_account_config`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PatchAccountConfigSuccess { + Status200(models::AccountConfigurations), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_account_config`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountConfigError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`patch_account_config`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PatchAccountConfigError { + UnknownValue(serde_json::Value), +} + +/// gets the current account configuration values +pub async fn get_account_config( + configuration: &configuration::Configuration, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/account/configurations", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Updates and returns the current account configuration values +pub async fn patch_account_config( + configuration: &configuration::Configuration, + params: PatchAccountConfigParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let account_configurations = params.account_configurations; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/account/configurations", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + local_var_req_builder = local_var_req_builder.json(&account_configurations); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/apis/accounts_api.rs b/crates/alpaca_openapi/gen/trading/src/apis/accounts_api.rs new file mode 100644 index 0000000..da70332 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/apis/accounts_api.rs @@ -0,0 +1,92 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for typed successes of method [`get_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountSuccess { + Status200(models::Account), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_account`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountError { + UnknownValue(serde_json::Value), +} + +/// Returns the account associated with the API key. +pub async fn get_account( + configuration: &configuration::Configuration, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/account", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/apis/calendar_api.rs b/crates/alpaca_openapi/gen/trading/src/apis/calendar_api.rs new file mode 100644 index 0000000..189bf16 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/apis/calendar_api.rs @@ -0,0 +1,111 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`get_calendar`] +#[derive(Clone, Debug)] +pub struct GetCalendarParams { + /// The first date to retrieve data for (inclusive) + pub start: Option, + /// The last date to retrieve data for (inclusive) + pub end: Option, +} + +/// struct for typed successes of method [`get_calendar`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetCalendarSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_calendar`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetCalendarError { + UnknownValue(serde_json::Value), +} + +/// Returns the market calendar. +pub async fn get_calendar( + configuration: &configuration::Configuration, + params: GetCalendarParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let start = params.start; + let end = params.end; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/calendar", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = start { + local_var_req_builder = + local_var_req_builder.query(&[("start", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = end { + local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/apis/clock_api.rs b/crates/alpaca_openapi/gen/trading/src/apis/clock_api.rs new file mode 100644 index 0000000..867d4d2 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/apis/clock_api.rs @@ -0,0 +1,91 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for typed successes of method [`get_clock`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetClockSuccess { + Status200(models::Clock), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_clock`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetClockError { + UnknownValue(serde_json::Value), +} + +/// The clock API serves the current market timestamp, whether or not the market is currently open, as well as the times of the next market open and close. Returns the market clock. +pub async fn get_clock( + configuration: &configuration::Configuration, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/clock", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/apis/configuration.rs b/crates/alpaca_openapi/gen/trading/src/apis/configuration.rs new file mode 100644 index 0000000..7b57914 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/apis/configuration.rs @@ -0,0 +1,49 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, + // TODO: take an oauth2 token source, similar to the go one +} + +pub type BasicAuth = (String, Option); + +#[derive(Debug, Clone)] +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + +impl Configuration { + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Default for Configuration { + fn default() -> Self { + Configuration { + base_path: "https://paper-api.alpaca.markets".to_owned(), + user_agent: Some("OpenAPI-Generator/2.0.0/rust".to_owned()), + client: reqwest::Client::new(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/apis/mod.rs b/crates/alpaca_openapi/gen/trading/src/apis/mod.rs new file mode 100644 index 0000000..f6f3676 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/apis/mod.rs @@ -0,0 +1,105 @@ +use std::error; +use std::fmt; + +#[derive(Debug, Clone)] +pub struct ResponseContent { + pub status: reqwest::StatusCode, + pub content: String, + pub entity: Option, +} + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), + ResponseError(ResponseContent), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (module, e) = match self { + Error::Reqwest(e) => ("reqwest", e.to_string()), + Error::Serde(e) => ("serde", e.to_string()), + Error::Io(e) => ("IO", e.to_string()), + Error::ResponseError(e) => ("response", format!("status code {}", e.status)), + }; + write!(f, "error in {}: {}", module, e) + } +} + +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + Some(match self { + Error::Reqwest(e) => e, + Error::Serde(e) => e, + Error::Io(e) => e, + Error::ResponseError(_) => return None, + }) + } +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> { + if let serde_json::Value::Object(object) = value { + let mut params = vec![]; + + for (key, value) in object { + match value { + serde_json::Value::Object(_) => params.append(&mut parse_deep_object( + &format!("{}[{}]", prefix, key), + value, + )), + serde_json::Value::Array(array) => { + for (i, value) in array.iter().enumerate() { + params.append(&mut parse_deep_object( + &format!("{}[{}][{}]", prefix, key, i), + value, + )); + } + } + serde_json::Value::String(s) => { + params.push((format!("{}[{}]", prefix, key), s.clone())) + } + _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), + } + } + + return params; + } + + unimplemented!("Only objects are supported with style=deepObject") +} + +pub mod account_activities_api; +pub mod account_configurations_api; +pub mod accounts_api; +pub mod calendar_api; +pub mod clock_api; +pub mod orders_api; +pub mod portfolio_history_api; +pub mod positions_api; +pub mod watchlists_api; + +pub mod configuration; diff --git a/crates/alpaca_openapi/gen/trading/src/apis/orders_api.rs b/crates/alpaca_openapi/gen/trading/src/apis/orders_api.rs new file mode 100644 index 0000000..2275904 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/apis/orders_api.rs @@ -0,0 +1,600 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`delete_order_by_order_id`] +#[derive(Clone, Debug)] +pub struct DeleteOrderByOrderIdParams { + /// order id + pub order_id: String, +} + +/// struct for passing parameters to the method [`get_all_orders`] +#[derive(Clone, Debug)] +pub struct GetAllOrdersParams { + /// Order status to be queried. open, closed or all. Defaults to open. + pub status: Option, + /// The maximum number of orders in response. Defaults to 50 and max is 500. + pub limit: Option, + /// The response will include only ones submitted after this timestamp (exclusive.) + pub after: Option, + /// The response will include only ones submitted until this timestamp (exclusive.) + pub until: Option, + /// The chronological order of response based on the submission time. asc or desc. Defaults to desc. + pub direction: Option, + /// If true, the result will roll up multi-leg orders under the legs field of primary order. + pub nested: Option, + /// A comma-separated list of symbols to filter by (ex. “AAPL,TSLA,MSFT”). A currency pair is required for crypto orders (ex. “BTCUSD,BCHUSD,LTCUSD,ETCUSD”). + pub symbols: Option, +} + +/// struct for passing parameters to the method [`get_order_by_order_id`] +#[derive(Clone, Debug)] +pub struct GetOrderByOrderIdParams { + /// order id + pub order_id: String, + /// If true, the result will roll up multi-leg orders under the legs field of primary order. + pub nested: Option, +} + +/// struct for passing parameters to the method [`patch_order_by_order_id`] +#[derive(Clone, Debug)] +pub struct PatchOrderByOrderIdParams { + /// order id + pub order_id: String, + pub patch_order_request: models::PatchOrderRequest, +} + +/// struct for passing parameters to the method [`post_order`] +#[derive(Clone, Debug)] +pub struct PostOrderParams { + /// + pub order: models::Order, +} + +/// struct for typed successes of method [`delete_all_orders`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAllOrdersSuccess { + Status207(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_order_by_order_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteOrderByOrderIdSuccess { + Status204(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_all_orders`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAllOrdersSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_order_by_order_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOrderByOrderIdSuccess { + Status200(models::Order), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`patch_order_by_order_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PatchOrderByOrderIdSuccess { + Status200(models::Order), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`post_order`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PostOrderSuccess { + Status200(models::Order), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_all_orders`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAllOrdersError { + Status500(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_order_by_order_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteOrderByOrderIdError { + Status422(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_all_orders`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAllOrdersError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_order_by_order_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOrderByOrderIdError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`patch_order_by_order_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PatchOrderByOrderIdError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`post_order`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PostOrderError { + Status403(), + Status422(), + UnknownValue(serde_json::Value), +} + +/// Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request. +pub async fn delete_all_orders( + configuration: &configuration::Configuration, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/orders", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Attempts to cancel an Open Order. If the order is no longer cancelable, the request will be rejected with status 422; otherwise accepted with return status 204. +pub async fn delete_order_by_order_id( + configuration: &configuration::Configuration, + params: DeleteOrderByOrderIdParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let order_id = params.order_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/orders/{order_id}", + local_var_configuration.base_path, + order_id = crate::apis::urlencode(order_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Retrieves a list of orders for the account, filtered by the supplied query parameters. +pub async fn get_all_orders( + configuration: &configuration::Configuration, + params: GetAllOrdersParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let status = params.status; + let limit = params.limit; + let after = params.after; + let until = params.until; + let direction = params.direction; + let nested = params.nested; + let symbols = params.symbols; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/orders", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = status { + local_var_req_builder = + local_var_req_builder.query(&[("status", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = limit { + local_var_req_builder = + local_var_req_builder.query(&[("limit", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = after { + local_var_req_builder = + local_var_req_builder.query(&[("after", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = until { + local_var_req_builder = + local_var_req_builder.query(&[("until", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = direction { + local_var_req_builder = + local_var_req_builder.query(&[("direction", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = nested { + local_var_req_builder = + local_var_req_builder.query(&[("nested", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = symbols { + local_var_req_builder = + local_var_req_builder.query(&[("symbols", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Retrieves a single order for the given order_id. +pub async fn get_order_by_order_id( + configuration: &configuration::Configuration, + params: GetOrderByOrderIdParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let order_id = params.order_id; + let nested = params.nested; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/orders/{order_id}", + local_var_configuration.base_path, + order_id = crate::apis::urlencode(order_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = nested { + local_var_req_builder = + local_var_req_builder.query(&[("nested", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Replaces a single order with updated parameters. Each parameter overrides the corresponding attribute of the existing order. The other attributes remain the same as the existing order. A success return code from a replaced order does NOT guarantee the existing open order has been replaced. If the existing open order is filled before the replacing (new) order reaches the execution venue, the replacing (new) order is rejected, and these events are sent in the trade_updates stream channel. While an order is being replaced, buying power is reduced by the larger of the two orders that have been placed (the old order being replaced, and the newly placed order to replace it). If you are replacing a buy entry order with a higher limit price than the original order, the buying power is calculated based on the newly placed order. If you are replacing it with a lower limit price, the buying power is calculated based on the old order. +pub async fn patch_order_by_order_id( + configuration: &configuration::Configuration, + params: PatchOrderByOrderIdParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let order_id = params.order_id; + let patch_order_request = params.patch_order_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/orders/{order_id}", + local_var_configuration.base_path, + order_id = crate::apis::urlencode(order_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + local_var_req_builder = local_var_req_builder.json(&patch_order_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Places a new order for the given account. An order request may be rejected if the account is not authorized for trading, or if the tradable balance is insufficient to fill the order.. +pub async fn post_order( + configuration: &configuration::Configuration, + params: PostOrderParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let order = params.order; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/orders", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + local_var_req_builder = local_var_req_builder.json(&order); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/apis/portfolio_history_api.rs b/crates/alpaca_openapi/gen/trading/src/apis/portfolio_history_api.rs new file mode 100644 index 0000000..3882844 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/apis/portfolio_history_api.rs @@ -0,0 +1,132 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`get_account_portfolio_history`] +#[derive(Clone, Debug)] +pub struct GetAccountPortfolioHistoryParams { + /// The duration of the data in + , such as 1D, where can be D for day, W for week, M for month and A for year. Defaults to 1M. + pub period: Option, + /// The resolution of time window. 1Min, 5Min, 15Min, 1H, or 1D. If omitted, 1Min for less than 7 days period, 15Min for less than 30 days, or otherwise 1D. + pub timeframe: Option, + /// The date the data is returned up to, in “YYYY-MM-DD” format. Defaults to the current market date (rolls over at the market open if extended_hours is false, otherwise at 7am ET) + pub date_end: Option, + /// If true, include extended hours in the result. This is effective only for timeframe less than 1D. + pub extended_hours: Option, +} + +/// struct for typed successes of method [`get_account_portfolio_history`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountPortfolioHistorySuccess { + Status200(models::PortfolioHistory), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_account_portfolio_history`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountPortfolioHistoryError { + UnknownValue(serde_json::Value), +} + +/// Returns timeseries data about equity and profit/loss (P/L) of the account in requested timespan. +pub async fn get_account_portfolio_history( + configuration: &configuration::Configuration, + params: GetAccountPortfolioHistoryParams, +) -> Result< + ResponseContent, + Error, +> { + let local_var_configuration = configuration; + + // unbox the parameters + let period = params.period; + let timeframe = params.timeframe; + let date_end = params.date_end; + let extended_hours = params.extended_hours; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/account/portfolio/history", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = period { + local_var_req_builder = + local_var_req_builder.query(&[("period", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = timeframe { + local_var_req_builder = + local_var_req_builder.query(&[("timeframe", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = date_end { + local_var_req_builder = + local_var_req_builder.query(&[("date_end", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = extended_hours { + local_var_req_builder = + local_var_req_builder.query(&[("extended_hours", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/apis/positions_api.rs b/crates/alpaca_openapi/gen/trading/src/apis/positions_api.rs new file mode 100644 index 0000000..cc9dac6 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/apis/positions_api.rs @@ -0,0 +1,379 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`delete_all_open_positions`] +#[derive(Clone, Debug)] +pub struct DeleteAllOpenPositionsParams { + /// If true is specified, cancel all open orders before liquidating all positions. + pub cancel_orders: Option, +} + +/// struct for passing parameters to the method [`delete_open_position`] +#[derive(Clone, Debug)] +pub struct DeleteOpenPositionParams { + /// symbol or assetId + pub symbol_or_asset_id: String, + /// the number of shares to liquidate. Can accept up to 9 decimal points. Cannot work with percentage + pub qty: Option, + /// percentage of position to liquidate. Must be between 0 and 100. Would only sell fractional if position is originally fractional. Can accept up to 9 decimal points. Cannot work with qty + pub percentage: Option, +} + +/// struct for passing parameters to the method [`get_open_position`] +#[derive(Clone, Debug)] +pub struct GetOpenPositionParams { + /// symbol or assetId + pub symbol_or_asset_id: String, +} + +/// struct for typed successes of method [`delete_all_open_positions`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAllOpenPositionsSuccess { + Status207(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_open_position`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteOpenPositionSuccess { + Status200(models::Order), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_all_open_positions`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAllOpenPositionsSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_open_position`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOpenPositionSuccess { + Status200(models::Position), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_all_open_positions`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAllOpenPositionsError { + Status500(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_open_position`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteOpenPositionError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_all_open_positions`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAllOpenPositionsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_open_position`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOpenPositionError { + UnknownValue(serde_json::Value), +} + +/// Closes (liquidates) all of the account’s open long and short positions. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request. +pub async fn delete_all_open_positions( + configuration: &configuration::Configuration, + params: DeleteAllOpenPositionsParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let cancel_orders = params.cancel_orders; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/positions", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = cancel_orders { + local_var_req_builder = + local_var_req_builder.query(&[("cancel_orders", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Closes (liquidates) the account’s open position for the given symbol. Works for both long and short positions. +pub async fn delete_open_position( + configuration: &configuration::Configuration, + params: DeleteOpenPositionParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol_or_asset_id = params.symbol_or_asset_id; + let qty = params.qty; + let percentage = params.percentage; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/positions/{symbol_or_asset_id}", + local_var_configuration.base_path, + symbol_or_asset_id = crate::apis::urlencode(symbol_or_asset_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = qty { + local_var_req_builder = local_var_req_builder.query(&[("qty", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = percentage { + local_var_req_builder = + local_var_req_builder.query(&[("percentage", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// The positions API provides information about an account’s current open positions. The response will include information such as cost basis, shares traded, and market value, which will be updated live as price information is updated. Once a position is closed, it will no longer be queryable through this API Retrieves a list of the account’s open positions +pub async fn get_all_open_positions( + configuration: &configuration::Configuration, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/positions", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Retrieves the account’s open position for the given symbol or assetId. +pub async fn get_open_position( + configuration: &configuration::Configuration, + params: GetOpenPositionParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let symbol_or_asset_id = params.symbol_or_asset_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/positions/{symbol_or_asset_id}", + local_var_configuration.base_path, + symbol_or_asset_id = crate::apis::urlencode(symbol_or_asset_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/apis/watchlists_api.rs b/crates/alpaca_openapi/gen/trading/src/apis/watchlists_api.rs new file mode 100644 index 0000000..2fe916c --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/apis/watchlists_api.rs @@ -0,0 +1,1016 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use reqwest; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for passing parameters to the method [`add_asset_to_watchlist`] +#[derive(Clone, Debug)] +pub struct AddAssetToWatchlistParams { + /// watchlist id + pub watchlist_id: String, + pub add_asset_to_watchlist_request: Option, +} + +/// struct for passing parameters to the method [`add_asset_to_watchlist_by_name`] +#[derive(Clone, Debug)] +pub struct AddAssetToWatchlistByNameParams { + /// name of the watchlist + pub name: String, + pub add_asset_to_watchlist_request: Option, +} + +/// struct for passing parameters to the method [`delete_watchlist_by_id`] +#[derive(Clone, Debug)] +pub struct DeleteWatchlistByIdParams { + /// watchlist id + pub watchlist_id: String, +} + +/// struct for passing parameters to the method [`delete_watchlist_by_name`] +#[derive(Clone, Debug)] +pub struct DeleteWatchlistByNameParams { + /// name of the watchlist + pub name: String, +} + +/// struct for passing parameters to the method [`get_watchlist_by_id`] +#[derive(Clone, Debug)] +pub struct GetWatchlistByIdParams { + /// watchlist id + pub watchlist_id: String, +} + +/// struct for passing parameters to the method [`get_watchlist_by_name`] +#[derive(Clone, Debug)] +pub struct GetWatchlistByNameParams { + /// name of the watchlist + pub name: String, +} + +/// struct for passing parameters to the method [`post_watchlist`] +#[derive(Clone, Debug)] +pub struct PostWatchlistParams { + pub update_watchlist_request: models::UpdateWatchlistRequest, +} + +/// struct for passing parameters to the method [`remove_asset_from_watchlist`] +#[derive(Clone, Debug)] +pub struct RemoveAssetFromWatchlistParams { + /// Watchlist ID + pub watchlist_id: String, + /// symbol name to remove from the watchlist content + pub symbol: String, +} + +/// struct for passing parameters to the method [`update_watchlist_by_id`] +#[derive(Clone, Debug)] +pub struct UpdateWatchlistByIdParams { + /// watchlist id + pub watchlist_id: String, + pub update_watchlist_request: Option, +} + +/// struct for passing parameters to the method [`update_watchlist_by_name`] +#[derive(Clone, Debug)] +pub struct UpdateWatchlistByNameParams { + /// name of the watchlist + pub name: String, + pub update_watchlist_request: Option, +} + +/// struct for typed successes of method [`add_asset_to_watchlist`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AddAssetToWatchlistSuccess { + Status200(models::Watchlist), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`add_asset_to_watchlist_by_name`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AddAssetToWatchlistByNameSuccess { + Status200(models::Watchlist), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_watchlist_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteWatchlistByIdSuccess { + Status204(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_watchlist_by_name`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteWatchlistByNameSuccess { + Status204(), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_watchlist_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetWatchlistByIdSuccess { + Status200(models::Watchlist), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_watchlist_by_name`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetWatchlistByNameSuccess { + Status200(models::Watchlist), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_watchlists`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetWatchlistsSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`post_watchlist`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PostWatchlistSuccess { + Status200(models::Watchlist), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`remove_asset_from_watchlist`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RemoveAssetFromWatchlistSuccess { + Status200(models::Watchlist), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`update_watchlist_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateWatchlistByIdSuccess { + Status200(models::Watchlist), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`update_watchlist_by_name`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateWatchlistByNameSuccess { + Status200(models::Watchlist), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`add_asset_to_watchlist`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AddAssetToWatchlistError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`add_asset_to_watchlist_by_name`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AddAssetToWatchlistByNameError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_watchlist_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteWatchlistByIdError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_watchlist_by_name`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteWatchlistByNameError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_watchlist_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetWatchlistByIdError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_watchlist_by_name`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetWatchlistByNameError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_watchlists`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetWatchlistsError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`post_watchlist`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PostWatchlistError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`remove_asset_from_watchlist`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RemoveAssetFromWatchlistError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_watchlist_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateWatchlistByIdError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_watchlist_by_name`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateWatchlistByNameError { + UnknownValue(serde_json::Value), +} + +/// Append an asset for the symbol to the end of watchlist asset list +pub async fn add_asset_to_watchlist( + configuration: &configuration::Configuration, + params: AddAssetToWatchlistParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let watchlist_id = params.watchlist_id; + let add_asset_to_watchlist_request = params.add_asset_to_watchlist_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/watchlists/{watchlist_id}", + local_var_configuration.base_path, + watchlist_id = crate::apis::urlencode(watchlist_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + local_var_req_builder = local_var_req_builder.json(&add_asset_to_watchlist_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Append an asset for the symbol to the end of watchlist asset list +pub async fn add_asset_to_watchlist_by_name( + configuration: &configuration::Configuration, + params: AddAssetToWatchlistByNameParams, +) -> Result, Error> +{ + let local_var_configuration = configuration; + + // unbox the parameters + let name = params.name; + let add_asset_to_watchlist_request = params.add_asset_to_watchlist_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/watchlists:by_name", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("name", &name.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + local_var_req_builder = local_var_req_builder.json(&add_asset_to_watchlist_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Delete a watchlist. This is a permanent deletion. +pub async fn delete_watchlist_by_id( + configuration: &configuration::Configuration, + params: DeleteWatchlistByIdParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let watchlist_id = params.watchlist_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/watchlists/{watchlist_id}", + local_var_configuration.base_path, + watchlist_id = crate::apis::urlencode(watchlist_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Delete a watchlist. This is a permanent deletion. +pub async fn delete_watchlist_by_name( + configuration: &configuration::Configuration, + params: DeleteWatchlistByNameParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let name = params.name; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/watchlists:by_name", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("name", &name.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns a watchlist identified by the ID. +pub async fn get_watchlist_by_id( + configuration: &configuration::Configuration, + params: GetWatchlistByIdParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let watchlist_id = params.watchlist_id; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/watchlists/{watchlist_id}", + local_var_configuration.base_path, + watchlist_id = crate::apis::urlencode(watchlist_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns a watchlist by name +pub async fn get_watchlist_by_name( + configuration: &configuration::Configuration, + params: GetWatchlistByNameParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let name = params.name; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/watchlists:by_name", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("name", &name.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns the list of watchlists registered under the account. +pub async fn get_watchlists( + configuration: &configuration::Configuration, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/watchlists", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Create a new watchlist with initial set of assets. +pub async fn post_watchlist( + configuration: &configuration::Configuration, + params: PostWatchlistParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let update_watchlist_request = params.update_watchlist_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/v2/watchlists", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + local_var_req_builder = local_var_req_builder.json(&update_watchlist_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Delete one entry for an asset by symbol name +pub async fn remove_asset_from_watchlist( + configuration: &configuration::Configuration, + params: RemoveAssetFromWatchlistParams, +) -> Result, Error> +{ + let local_var_configuration = configuration; + + // unbox the parameters + let watchlist_id = params.watchlist_id; + let symbol = params.symbol; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/watchlists/{watchlist_id}/{symbol}", + local_var_configuration.base_path, + watchlist_id = crate::apis::urlencode(watchlist_id), + symbol = crate::apis::urlencode(symbol) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Update the name and/or content of watchlist +pub async fn update_watchlist_by_id( + configuration: &configuration::Configuration, + params: UpdateWatchlistByIdParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let watchlist_id = params.watchlist_id; + let update_watchlist_request = params.update_watchlist_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/watchlists/{watchlist_id}", + local_var_configuration.base_path, + watchlist_id = crate::apis::urlencode(watchlist_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + local_var_req_builder = local_var_req_builder.json(&update_watchlist_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Update the name and/or content of watchlist +pub async fn update_watchlist_by_name( + configuration: &configuration::Configuration, + params: UpdateWatchlistByNameParams, +) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let name = params.name; + let update_watchlist_request = params.update_watchlist_request; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/v2/watchlists:by_name", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("name", &name.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = local_var_req_builder.header("APCA-API-KEY-ID", local_var_value); + }; + if let Some(ref local_var_apikey) = local_var_configuration.api_key { + let local_var_key = local_var_apikey.key.clone(); + let local_var_value = match local_var_apikey.prefix { + Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), + None => local_var_key, + }; + local_var_req_builder = + local_var_req_builder.header("APCA-API-SECRET-KEY", local_var_value); + }; + local_var_req_builder = local_var_req_builder.json(&update_watchlist_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Ok(local_var_result) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/lib.rs b/crates/alpaca_openapi/gen/trading/src/lib.rs new file mode 100644 index 0000000..92760eb --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/lib.rs @@ -0,0 +1,12 @@ +#![allow(unused_imports)] + +#[macro_use] +extern crate serde_derive; + +extern crate reqwest; +extern crate serde; +extern crate serde_json; +extern crate url; + +pub mod apis; +pub mod models; diff --git a/crates/alpaca_openapi/gen/trading/src/models/account.rs b/crates/alpaca_openapi/gen/trading/src/models/account.rs new file mode 100644 index 0000000..e709b21 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/account.rs @@ -0,0 +1,136 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Account : The account API serves important information related to an account, including account status, funds available for trade, funds available for withdrawal, and various flags relevant to an account’s ability to trade. An account maybe be blocked for just for trades (trades_blocked flag) or for both trades and transfers (account_blocked flag) if Alpaca identifies the account to engaging in any suspicious activity. Also, in accordance with FINRA’s pattern day trading rule, an account may be flagged for pattern day trading (pattern_day_trader flag), which would inhibit an account from placing any further day-trades. Please note that cryptocurrencies are not eligible assets to be used as collateral for margin accounts and will require the asset be traded using cash only. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Account { + /// Account Id. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// Account number. + #[serde(rename = "account_number", skip_serializing_if = "Option::is_none")] + pub account_number: Option, + #[serde(rename = "status")] + pub status: models::AccountStatus, + /// USD + #[serde(rename = "currency", skip_serializing_if = "Option::is_none")] + pub currency: Option, + /// Cash Balance + #[serde(rename = "cash", skip_serializing_if = "Option::is_none")] + pub cash: Option, + /// Total value of cash + holding positions (This field is deprecated. It is equivalent to the equity field.) + #[serde(rename = "portfolio_value", skip_serializing_if = "Option::is_none")] + pub portfolio_value: Option, + /// Whether or not the account has been flagged as a pattern day trader + #[serde(rename = "pattern_day_trader", skip_serializing_if = "Option::is_none")] + pub pattern_day_trader: Option, + /// User setting. If true, the account is not allowed to place orders. + #[serde( + rename = "trade_suspended_by_user", + skip_serializing_if = "Option::is_none" + )] + pub trade_suspended_by_user: Option, + /// If true, the account is not allowed to place orders. + #[serde(rename = "trading_blocked", skip_serializing_if = "Option::is_none")] + pub trading_blocked: Option, + /// If true, the account is not allowed to request money transfers. + #[serde(rename = "transfers_blocked", skip_serializing_if = "Option::is_none")] + pub transfers_blocked: Option, + /// If true, the account activity by user is prohibited. + #[serde(rename = "account_blocked", skip_serializing_if = "Option::is_none")] + pub account_blocked: Option, + /// Timestamp this account was created at + #[serde(rename = "created_at", skip_serializing_if = "Option::is_none")] + pub created_at: Option, + /// Flag to denote whether or not the account is permitted to short + #[serde(rename = "shorting_enabled", skip_serializing_if = "Option::is_none")] + pub shorting_enabled: Option, + /// Real-time MtM value of all long positions held in the account + #[serde(rename = "long_market_value", skip_serializing_if = "Option::is_none")] + pub long_market_value: Option, + /// Real-time MtM value of all short positions held in the account + #[serde(rename = "short_market_value", skip_serializing_if = "Option::is_none")] + pub short_market_value: Option, + /// Cash + long_market_value + short_market_value + #[serde(rename = "equity", skip_serializing_if = "Option::is_none")] + pub equity: Option, + /// Equity as of previous trading day at 16:00:00 ET + #[serde(rename = "last_equity", skip_serializing_if = "Option::is_none")] + pub last_equity: Option, + /// Buying power multiplier that represents account margin classification; valid values 1 (standard limited margin account with 1x buying power), 2 (reg T margin account with 2x intraday and overnight buying power; this is the default for all non-PDT accounts with $2,000 or more equity), 4 (PDT account with 4x intraday buying power and 2x reg T overnight buying power) + #[serde(rename = "multiplier", skip_serializing_if = "Option::is_none")] + pub multiplier: Option, + /// Current available $ buying power; If multiplier = 4, this is your daytrade buying power which is calculated as (last_equity - (last) maintenance_margin) * 4; If multiplier = 2, buying_power = max(equity – initial_margin,0) * 2; If multiplier = 1, buying_power = cash + #[serde(rename = "buying_power", skip_serializing_if = "Option::is_none")] + pub buying_power: Option, + /// Reg T initial margin requirement (continuously updated value) + #[serde(rename = "initial_margin", skip_serializing_if = "Option::is_none")] + pub initial_margin: Option, + /// Maintenance margin requirement (continuously updated value) + #[serde(rename = "maintenance_margin", skip_serializing_if = "Option::is_none")] + pub maintenance_margin: Option, + /// Value of special memorandum account (will be used at a later date to provide additional buying_power) + #[serde(rename = "sma", skip_serializing_if = "Option::is_none")] + pub sma: Option, + /// The current number of daytrades that have been made in the last 5 trading days (inclusive of today) + #[serde(rename = "daytrade_count", skip_serializing_if = "Option::is_none")] + pub daytrade_count: Option, + /// Your maintenance margin requirement on the previous trading day + #[serde( + rename = "last_maintenance_margin", + skip_serializing_if = "Option::is_none" + )] + pub last_maintenance_margin: Option, + /// Your buying power for day trades (continuously updated value) + #[serde( + rename = "daytrading_buying_power", + skip_serializing_if = "Option::is_none" + )] + pub daytrading_buying_power: Option, + /// Your buying power under Regulation T (your excess equity - equity minus margin value - times your margin multiplier) + #[serde(rename = "regt_buying_power", skip_serializing_if = "Option::is_none")] + pub regt_buying_power: Option, +} + +impl Account { + /// The account API serves important information related to an account, including account status, funds available for trade, funds available for withdrawal, and various flags relevant to an account’s ability to trade. An account maybe be blocked for just for trades (trades_blocked flag) or for both trades and transfers (account_blocked flag) if Alpaca identifies the account to engaging in any suspicious activity. Also, in accordance with FINRA’s pattern day trading rule, an account may be flagged for pattern day trading (pattern_day_trader flag), which would inhibit an account from placing any further day-trades. Please note that cryptocurrencies are not eligible assets to be used as collateral for margin accounts and will require the asset be traded using cash only. + pub fn new(id: uuid::Uuid, status: models::AccountStatus) -> Account { + Account { + id, + account_number: None, + status, + currency: None, + cash: None, + portfolio_value: None, + pattern_day_trader: None, + trade_suspended_by_user: None, + trading_blocked: None, + transfers_blocked: None, + account_blocked: None, + created_at: None, + shorting_enabled: None, + long_market_value: None, + short_market_value: None, + equity: None, + last_equity: None, + multiplier: None, + buying_power: None, + initial_margin: None, + maintenance_margin: None, + sma: None, + daytrade_count: None, + last_maintenance_margin: None, + daytrading_buying_power: None, + regt_buying_power: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/account_configurations.rs b/crates/alpaca_openapi/gen/trading/src/models/account_configurations.rs new file mode 100644 index 0000000..6596a01 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/account_configurations.rs @@ -0,0 +1,73 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AccountConfigurations : The account configuration API provides custom configurations about your trading account settings. These configurations control various allow you to modify settings to suit your trading needs. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AccountConfigurations { + /// both, entry, or exit. Controls Day Trading Margin Call (DTMC) checks. + #[serde(rename = "dtbp_check", skip_serializing_if = "Option::is_none")] + pub dtbp_check: Option, + /// all or none. If none, emails for order fills are not sent. + #[serde( + rename = "trade_confirm_email", + skip_serializing_if = "Option::is_none" + )] + pub trade_confirm_email: Option, + /// If true, new orders are blocked. + #[serde(rename = "suspend_trade", skip_serializing_if = "Option::is_none")] + pub suspend_trade: Option, + /// If true, account becomes long-only mode. + #[serde(rename = "no_shorting", skip_serializing_if = "Option::is_none")] + pub no_shorting: Option, + /// If true, account is able to participate in fractional trading + #[serde(rename = "fractional_trading", skip_serializing_if = "Option::is_none")] + pub fractional_trading: Option, + /// Can be \"1\" or \"2\" + #[serde( + rename = "max_margin_multiplier", + skip_serializing_if = "Option::is_none" + )] + pub max_margin_multiplier: Option, + #[serde(rename = "pdt_check", skip_serializing_if = "Option::is_none")] + pub pdt_check: Option, +} + +impl AccountConfigurations { + /// The account configuration API provides custom configurations about your trading account settings. These configurations control various allow you to modify settings to suit your trading needs. + pub fn new() -> AccountConfigurations { + AccountConfigurations { + dtbp_check: None, + trade_confirm_email: None, + suspend_trade: None, + no_shorting: None, + fractional_trading: None, + max_margin_multiplier: None, + pdt_check: None, + } + } +} +/// both, entry, or exit. Controls Day Trading Margin Call (DTMC) checks. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum DtbpCheck { + #[serde(rename = "both")] + Both, + #[serde(rename = "entry")] + Entry, + #[serde(rename = "exit")] + Exit, +} + +impl Default for DtbpCheck { + fn default() -> DtbpCheck { + Self::Both + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/account_status.rs b/crates/alpaca_openapi/gen/trading/src/models/account_status.rs new file mode 100644 index 0000000..ea20329 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/account_status.rs @@ -0,0 +1,51 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AccountStatus : An enum representing the various possible account status values. Most likely, the account status is ACTIVE unless there is any problem. The account status may get in ACCOUNT_UPDATED when personal information is being updated from the dashboard, in which case you may not be allowed trading for a short period of time until the change is approved. - ONBOARDING The account is onboarding. - SUBMISSION_FAILED The account application submission failed for some reason. - SUBMITTED The account application has been submitted for review. - ACCOUNT_UPDATED The account information is being updated. - APPROVAL_PENDING The final account approval is pending. - ACTIVE The account is active for trading. - REJECTED The account application has been rejected. +/// An enum representing the various possible account status values. Most likely, the account status is ACTIVE unless there is any problem. The account status may get in ACCOUNT_UPDATED when personal information is being updated from the dashboard, in which case you may not be allowed trading for a short period of time until the change is approved. - ONBOARDING The account is onboarding. - SUBMISSION_FAILED The account application submission failed for some reason. - SUBMITTED The account application has been submitted for review. - ACCOUNT_UPDATED The account information is being updated. - APPROVAL_PENDING The final account approval is pending. - ACTIVE The account is active for trading. - REJECTED The account application has been rejected. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum AccountStatus { + #[serde(rename = "ONBOARDING")] + Onboarding, + #[serde(rename = "SUBMISSION_FAILED")] + SubmissionFailed, + #[serde(rename = "SUBMITTED")] + Submitted, + #[serde(rename = "ACCOUNT_UPDATED")] + AccountUpdated, + #[serde(rename = "APPROVAL_PENDING")] + ApprovalPending, + #[serde(rename = "ACTIVE")] + Active, + #[serde(rename = "REJECTED")] + Rejected, +} + +impl ToString for AccountStatus { + fn to_string(&self) -> String { + match self { + Self::Onboarding => String::from("ONBOARDING"), + Self::SubmissionFailed => String::from("SUBMISSION_FAILED"), + Self::Submitted => String::from("SUBMITTED"), + Self::AccountUpdated => String::from("ACCOUNT_UPDATED"), + Self::ApprovalPending => String::from("APPROVAL_PENDING"), + Self::Active => String::from("ACTIVE"), + Self::Rejected => String::from("REJECTED"), + } + } +} + +impl Default for AccountStatus { + fn default() -> AccountStatus { + Self::Onboarding + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/activity_type.rs b/crates/alpaca_openapi/gen/trading/src/models/activity_type.rs new file mode 100644 index 0000000..2ca8094 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/activity_type.rs @@ -0,0 +1,135 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// ActivityType : - FILL Order fills (both partial and full fills) - TRANS Cash transactions (both CSD and CSW) - MISC Miscellaneous or rarely used activity types (All types except those in TRANS, DIV, or FILL) - ACATC ACATS IN/OUT (Cash) - ACATS ACATS IN/OUT (Securities) - CFEE Crypto fee - CSD Cash deposit(+) - CSW Cash withdrawal(-) - DIV Dividends - DIVCGL Dividend (capital gain long term) - DIVCGS Dividend (capital gain short term) - DIVFEE Dividend fee - DIVFT Dividend adjusted (Foreign Tax Withheld) - DIVNRA Dividend adjusted (NRA Withheld) - DIVROC Dividend return of capital - DIVTW Dividend adjusted (Tefra Withheld) - DIVTXEX Dividend (tax exempt) - FEE Fee denominated in USD - INT Interest (credit/margin) - INTNRA Interest adjusted (NRA Withheld) - INTTW Interest adjusted (Tefra Withheld) - JNL Journal entry - JNLC Journal entry (cash) - JNLS Journal entry (stock) - MA Merger/Acquisition - NC Name change - OPASN Option assignment - OPEXP Option expiration - OPXRC Option exercise - PTC Pass Thru Charge - PTR Pass Thru Rebate - REORG Reorg CA - SC Symbol change - SSO Stock spinoff - SSP Stock split +/// - FILL Order fills (both partial and full fills) - TRANS Cash transactions (both CSD and CSW) - MISC Miscellaneous or rarely used activity types (All types except those in TRANS, DIV, or FILL) - ACATC ACATS IN/OUT (Cash) - ACATS ACATS IN/OUT (Securities) - CFEE Crypto fee - CSD Cash deposit(+) - CSW Cash withdrawal(-) - DIV Dividends - DIVCGL Dividend (capital gain long term) - DIVCGS Dividend (capital gain short term) - DIVFEE Dividend fee - DIVFT Dividend adjusted (Foreign Tax Withheld) - DIVNRA Dividend adjusted (NRA Withheld) - DIVROC Dividend return of capital - DIVTW Dividend adjusted (Tefra Withheld) - DIVTXEX Dividend (tax exempt) - FEE Fee denominated in USD - INT Interest (credit/margin) - INTNRA Interest adjusted (NRA Withheld) - INTTW Interest adjusted (Tefra Withheld) - JNL Journal entry - JNLC Journal entry (cash) - JNLS Journal entry (stock) - MA Merger/Acquisition - NC Name change - OPASN Option assignment - OPEXP Option expiration - OPXRC Option exercise - PTC Pass Thru Charge - PTR Pass Thru Rebate - REORG Reorg CA - SC Symbol change - SSO Stock spinoff - SSP Stock split +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum ActivityType { + #[serde(rename = "FILL")] + Fill, + #[serde(rename = "TRANS")] + Trans, + #[serde(rename = "MISC")] + Misc, + #[serde(rename = "ACATC")] + Acatc, + #[serde(rename = "ACATS")] + Acats, + #[serde(rename = "CSD")] + Csd, + #[serde(rename = "CSW")] + Csw, + #[serde(rename = "DIV")] + Div, + #[serde(rename = "DIVCGL")] + Divcgl, + #[serde(rename = "DIVCGS")] + Divcgs, + #[serde(rename = "DIVFEE")] + Divfee, + #[serde(rename = "DIVFT")] + Divft, + #[serde(rename = "DIVNRA")] + Divnra, + #[serde(rename = "DIVROC")] + Divroc, + #[serde(rename = "DIVTW")] + Divtw, + #[serde(rename = "DIVTXEX")] + Divtxex, + #[serde(rename = "INT")] + Int, + #[serde(rename = "INTNRA")] + Intnra, + #[serde(rename = "INTTW")] + Inttw, + #[serde(rename = "JNL")] + Jnl, + #[serde(rename = "JNLC")] + Jnlc, + #[serde(rename = "JNLS")] + Jnls, + #[serde(rename = "MA")] + Ma, + #[serde(rename = "NC")] + Nc, + #[serde(rename = "OPASN")] + Opasn, + #[serde(rename = "OPEXP")] + Opexp, + #[serde(rename = "OPXRC")] + Opxrc, + #[serde(rename = "PTC")] + Ptc, + #[serde(rename = "PTR")] + Ptr, + #[serde(rename = "REORG")] + Reorg, + #[serde(rename = "SC")] + Sc, + #[serde(rename = "SSO")] + Sso, + #[serde(rename = "SSP")] + Ssp, + #[serde(rename = "CFEE")] + Cfee, + #[serde(rename = "FEE")] + Fee, +} + +impl ToString for ActivityType { + fn to_string(&self) -> String { + match self { + Self::Fill => String::from("FILL"), + Self::Trans => String::from("TRANS"), + Self::Misc => String::from("MISC"), + Self::Acatc => String::from("ACATC"), + Self::Acats => String::from("ACATS"), + Self::Csd => String::from("CSD"), + Self::Csw => String::from("CSW"), + Self::Div => String::from("DIV"), + Self::Divcgl => String::from("DIVCGL"), + Self::Divcgs => String::from("DIVCGS"), + Self::Divfee => String::from("DIVFEE"), + Self::Divft => String::from("DIVFT"), + Self::Divnra => String::from("DIVNRA"), + Self::Divroc => String::from("DIVROC"), + Self::Divtw => String::from("DIVTW"), + Self::Divtxex => String::from("DIVTXEX"), + Self::Int => String::from("INT"), + Self::Intnra => String::from("INTNRA"), + Self::Inttw => String::from("INTTW"), + Self::Jnl => String::from("JNL"), + Self::Jnlc => String::from("JNLC"), + Self::Jnls => String::from("JNLS"), + Self::Ma => String::from("MA"), + Self::Nc => String::from("NC"), + Self::Opasn => String::from("OPASN"), + Self::Opexp => String::from("OPEXP"), + Self::Opxrc => String::from("OPXRC"), + Self::Ptc => String::from("PTC"), + Self::Ptr => String::from("PTR"), + Self::Reorg => String::from("REORG"), + Self::Sc => String::from("SC"), + Self::Sso => String::from("SSO"), + Self::Ssp => String::from("SSP"), + Self::Cfee => String::from("CFEE"), + Self::Fee => String::from("FEE"), + } + } +} + +impl Default for ActivityType { + fn default() -> ActivityType { + Self::Fill + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/add_asset_to_watchlist_request.rs b/crates/alpaca_openapi/gen/trading/src/models/add_asset_to_watchlist_request.rs new file mode 100644 index 0000000..472a085 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/add_asset_to_watchlist_request.rs @@ -0,0 +1,26 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AddAssetToWatchlistRequest : Append an asset for the symbol to the end of watchlist asset list +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AddAssetToWatchlistRequest { + /// symbol name to append to watchlist + #[serde(rename = "symbol", skip_serializing_if = "Option::is_none")] + pub symbol: Option, +} + +impl AddAssetToWatchlistRequest { + /// Append an asset for the symbol to the end of watchlist asset list + pub fn new() -> AddAssetToWatchlistRequest { + AddAssetToWatchlistRequest { symbol: None } + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/asset_class.rs b/crates/alpaca_openapi/gen/trading/src/models/asset_class.rs new file mode 100644 index 0000000..8461085 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/asset_class.rs @@ -0,0 +1,36 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// AssetClass : Represents what class of asset this is. Currently only supports `us_equity` or `crypto` +/// Represents what class of asset this is. Currently only supports `us_equity` or `crypto` +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum AssetClass { + #[serde(rename = "us_equity")] + UsEquity, + #[serde(rename = "crypto")] + Crypto, +} + +impl ToString for AssetClass { + fn to_string(&self) -> String { + match self { + Self::UsEquity => String::from("us_equity"), + Self::Crypto => String::from("crypto"), + } + } +} + +impl Default for AssetClass { + fn default() -> AssetClass { + Self::UsEquity + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/assets.rs b/crates/alpaca_openapi/gen/trading/src/models/assets.rs new file mode 100644 index 0000000..971acfe --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/assets.rs @@ -0,0 +1,92 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Assets : The assets API serves as the master list of assets available for trade and data consumption from Alpaca. Assets are sorted by asset class, exchange and symbol. Some assets are only available for data consumption via Polygon, and are not tradable with Alpaca. These assets will be marked with the flag tradable=false. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Assets { + /// Asset ID + #[serde(rename = "id")] + pub id: uuid::Uuid, + #[serde(rename = "class")] + pub class: models::AssetClass, + #[serde(rename = "exchange")] + pub exchange: models::Exchange, + /// The symbol of the asset + #[serde(rename = "symbol")] + pub symbol: String, + /// The official name of the asset + #[serde(rename = "name")] + pub name: String, + /// active or inactive + #[serde(rename = "status")] + pub status: Status, + /// Asset is tradable on Alpaca or not + #[serde(rename = "tradable")] + pub tradable: bool, + /// Asset is marginable or not + #[serde(rename = "marginable")] + pub marginable: bool, + /// Asset is shortable or not + #[serde(rename = "shortable")] + pub shortable: bool, + /// Asset is easy-to-borrow or not (filtering for easy_to_borrow = True is the best way to check whether the name is currently available to short at Alpaca). + #[serde(rename = "easy_to_borrow")] + pub easy_to_borrow: bool, + /// Asset is fractionable or not + #[serde(rename = "fractionable")] + pub fractionable: bool, +} + +impl Assets { + /// The assets API serves as the master list of assets available for trade and data consumption from Alpaca. Assets are sorted by asset class, exchange and symbol. Some assets are only available for data consumption via Polygon, and are not tradable with Alpaca. These assets will be marked with the flag tradable=false. + pub fn new( + id: uuid::Uuid, + class: models::AssetClass, + exchange: models::Exchange, + symbol: String, + name: String, + status: Status, + tradable: bool, + marginable: bool, + shortable: bool, + easy_to_borrow: bool, + fractionable: bool, + ) -> Assets { + Assets { + id, + class, + exchange, + symbol, + name, + status, + tradable, + marginable, + shortable, + easy_to_borrow, + fractionable, + } + } +} +/// active or inactive +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "active")] + Active, + #[serde(rename = "inactive")] + Inactive, +} + +impl Default for Status { + fn default() -> Status { + Self::Active + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/calendar.rs b/crates/alpaca_openapi/gen/trading/src/models/calendar.rs new file mode 100644 index 0000000..452e41c --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/calendar.rs @@ -0,0 +1,48 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Calendar : +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Calendar { + /// Date string in “%Y-%m-%d” format + #[serde(rename = "date")] + pub date: String, + /// The time the market opens at on this date in “%H:%M” format + #[serde(rename = "open")] + pub open: String, + /// The time the market closes at on this date in “%H:%M” format + #[serde(rename = "close")] + pub close: String, + #[serde(rename = "session_open")] + pub session_open: String, + #[serde(rename = "session_close")] + pub session_close: String, +} + +impl Calendar { + /// + pub fn new( + date: String, + open: String, + close: String, + session_open: String, + session_close: String, + ) -> Calendar { + Calendar { + date, + open, + close, + session_open, + session_close, + } + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/canceled_order_response.rs b/crates/alpaca_openapi/gen/trading/src/models/canceled_order_response.rs new file mode 100644 index 0000000..78fe4aa --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/canceled_order_response.rs @@ -0,0 +1,32 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// CanceledOrderResponse : Represents the result of a request to cancel and order +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CanceledOrderResponse { + /// orderId + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// http response code + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, +} + +impl CanceledOrderResponse { + /// Represents the result of a request to cancel and order + pub fn new() -> CanceledOrderResponse { + CanceledOrderResponse { + id: None, + status: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/clock.rs b/crates/alpaca_openapi/gen/trading/src/models/clock.rs new file mode 100644 index 0000000..d2ec0ff --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/clock.rs @@ -0,0 +1,38 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Clock { + /// Current timestamp + #[serde(rename = "timestamp", skip_serializing_if = "Option::is_none")] + pub timestamp: Option, + /// Whether or not the market is open + #[serde(rename = "is_open", skip_serializing_if = "Option::is_none")] + pub is_open: Option, + /// Next Market open timestamp + #[serde(rename = "next_open", skip_serializing_if = "Option::is_none")] + pub next_open: Option, + /// Next market close timestamp + #[serde(rename = "next_close", skip_serializing_if = "Option::is_none")] + pub next_close: Option, +} + +impl Clock { + pub fn new() -> Clock { + Clock { + timestamp: None, + is_open: None, + next_open: None, + next_close: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/exchange.rs b/crates/alpaca_openapi/gen/trading/src/models/exchange.rs new file mode 100644 index 0000000..8cc4460 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/exchange.rs @@ -0,0 +1,51 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Exchange : Represents the current exchanges Alpaca supports. List is currently: - AMEX - ARCA - BATS - NYSE - NASDAQ - NYSEARCA - OTC +/// Represents the current exchanges Alpaca supports. List is currently: - AMEX - ARCA - BATS - NYSE - NASDAQ - NYSEARCA - OTC +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Exchange { + #[serde(rename = "AMEX")] + Amex, + #[serde(rename = "ARCA")] + Arca, + #[serde(rename = "BATS")] + Bats, + #[serde(rename = "NYSE")] + Nyse, + #[serde(rename = "NASDAQ")] + Nasdaq, + #[serde(rename = "NYSEARCA")] + Nysearca, + #[serde(rename = "OTC")] + Otc, +} + +impl ToString for Exchange { + fn to_string(&self) -> String { + match self { + Self::Amex => String::from("AMEX"), + Self::Arca => String::from("ARCA"), + Self::Bats => String::from("BATS"), + Self::Nyse => String::from("NYSE"), + Self::Nasdaq => String::from("NASDAQ"), + Self::Nysearca => String::from("NYSEARCA"), + Self::Otc => String::from("OTC"), + } + } +} + +impl Default for Exchange { + fn default() -> Exchange { + Self::Amex + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/get_account_activities_200_response_inner.rs b/crates/alpaca_openapi/gen/trading/src/models/get_account_activities_200_response_inner.rs new file mode 100644 index 0000000..8aaff9f --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/get_account_activities_200_response_inner.rs @@ -0,0 +1,96 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// GetAccountActivities200ResponseInner : Will be a mix of TradingActivity or NonTradeActivity objects based on what is passed in the activity_types parameter +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct GetAccountActivities200ResponseInner { + #[serde(rename = "activity_type", skip_serializing_if = "Option::is_none")] + pub activity_type: Option, + /// An ID for the activity, always in “::” format. Can be sent as page_token in requests to facilitate the paging of results. + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// The cumulative quantity of shares involved in the execution. + #[serde(rename = "cum_qty", skip_serializing_if = "Option::is_none")] + pub cum_qty: Option, + /// For partially_filled orders, the quantity of shares that are left to be filled. + #[serde(rename = "leaves_qty", skip_serializing_if = "Option::is_none")] + pub leaves_qty: Option, + /// The per-share price that the trade was executed at. + #[serde(rename = "price", skip_serializing_if = "Option::is_none")] + pub price: Option, + /// For dividend activities, the number of shares that contributed to the payment. Not present for other activity types. + #[serde(rename = "qty", skip_serializing_if = "Option::is_none")] + pub qty: Option, + /// buy or sell + #[serde(rename = "side", skip_serializing_if = "Option::is_none")] + pub side: Option, + /// The symbol of the security involved with the activity. Not present for all activity types. + #[serde(rename = "symbol", skip_serializing_if = "Option::is_none")] + pub symbol: Option, + /// The time at which the execution occurred. + #[serde(rename = "transaction_time", skip_serializing_if = "Option::is_none")] + pub transaction_time: Option, + /// The id for the order that filled. + #[serde(rename = "order_id", skip_serializing_if = "Option::is_none")] + pub order_id: Option, + /// fill or partial_fill + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + pub r#type: Option, + #[serde(rename = "order_status", skip_serializing_if = "Option::is_none")] + pub order_status: Option, + /// The date on which the activity occurred or on which the transaction associated with the activity settled. + #[serde(rename = "date", skip_serializing_if = "Option::is_none")] + pub date: Option, + /// The net amount of money (positive or negative) associated with the activity. + #[serde(rename = "net_amount", skip_serializing_if = "Option::is_none")] + pub net_amount: Option, + /// For dividend activities, the average amount paid per share. Not present for other activity types. + #[serde(rename = "per_share_amount", skip_serializing_if = "Option::is_none")] + pub per_share_amount: Option, +} + +impl GetAccountActivities200ResponseInner { + /// Will be a mix of TradingActivity or NonTradeActivity objects based on what is passed in the activity_types parameter + pub fn new() -> GetAccountActivities200ResponseInner { + GetAccountActivities200ResponseInner { + activity_type: None, + id: None, + cum_qty: None, + leaves_qty: None, + price: None, + qty: None, + side: None, + symbol: None, + transaction_time: None, + order_id: None, + r#type: None, + order_status: None, + date: None, + net_amount: None, + per_share_amount: None, + } + } +} +/// fill or partial_fill +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Type { + #[serde(rename = "fill")] + Fill, + #[serde(rename = "partial_fill")] + PartialFill, +} + +impl Default for Type { + fn default() -> Type { + Self::Fill + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/get_account_activities_by_activity_type_200_response_inner.rs b/crates/alpaca_openapi/gen/trading/src/models/get_account_activities_by_activity_type_200_response_inner.rs new file mode 100644 index 0000000..eb60268 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/get_account_activities_by_activity_type_200_response_inner.rs @@ -0,0 +1,40 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// GetAccountActivitiesByActivityType200ResponseInner : Will be one of a TradingActivity or NonTradeActivity based on activity_type used in path +/// Will be one of a TradingActivity or NonTradeActivity based on activity_type used in path +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAccountActivitiesByActivityType200ResponseInner { + TradingActivities(Box), + NonTradeActivities(Box), +} + +impl Default for GetAccountActivitiesByActivityType200ResponseInner { + fn default() -> Self { + Self::TradingActivities(Default::default()) + } +} +/// fill or partial_fill +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Type { + #[serde(rename = "fill")] + Fill, + #[serde(rename = "partial_fill")] + PartialFill, +} + +impl Default for Type { + fn default() -> Type { + Self::Fill + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/mod.rs b/crates/alpaca_openapi/gen/trading/src/models/mod.rs new file mode 100644 index 0000000..5d8b41d --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/mod.rs @@ -0,0 +1,54 @@ +pub mod account; +pub use self::account::Account; +pub mod account_configurations; +pub use self::account_configurations::AccountConfigurations; +pub mod account_status; +pub use self::account_status::AccountStatus; +pub mod activity_type; +pub use self::activity_type::ActivityType; +pub mod add_asset_to_watchlist_request; +pub use self::add_asset_to_watchlist_request::AddAssetToWatchlistRequest; +pub mod asset_class; +pub use self::asset_class::AssetClass; +pub mod assets; +pub use self::assets::Assets; +pub mod calendar; +pub use self::calendar::Calendar; +pub mod canceled_order_response; +pub use self::canceled_order_response::CanceledOrderResponse; +pub mod clock; +pub use self::clock::Clock; +pub mod exchange; +pub use self::exchange::Exchange; +pub mod get_account_activities_200_response_inner; +pub use self::get_account_activities_200_response_inner::GetAccountActivities200ResponseInner; +pub mod get_account_activities_by_activity_type_200_response_inner; +pub use self::get_account_activities_by_activity_type_200_response_inner::GetAccountActivitiesByActivityType200ResponseInner; +pub mod non_trade_activities; +pub use self::non_trade_activities::NonTradeActivities; +pub mod order; +pub use self::order::Order; +pub mod order_class; +pub use self::order_class::OrderClass; +pub mod order_side; +pub use self::order_side::OrderSide; +pub mod order_status; +pub use self::order_status::OrderStatus; +pub mod order_type; +pub use self::order_type::OrderType; +pub mod patch_order_request; +pub use self::patch_order_request::PatchOrderRequest; +pub mod portfolio_history; +pub use self::portfolio_history::PortfolioHistory; +pub mod position; +pub use self::position::Position; +pub mod position_closed_reponse; +pub use self::position_closed_reponse::PositionClosedReponse; +pub mod time_in_force; +pub use self::time_in_force::TimeInForce; +pub mod trading_activities; +pub use self::trading_activities::TradingActivities; +pub mod update_watchlist_request; +pub use self::update_watchlist_request::UpdateWatchlistRequest; +pub mod watchlist; +pub use self::watchlist::Watchlist; diff --git a/crates/alpaca_openapi/gen/trading/src/models/non_trade_activities.rs b/crates/alpaca_openapi/gen/trading/src/models/non_trade_activities.rs new file mode 100644 index 0000000..53553b7 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/non_trade_activities.rs @@ -0,0 +1,49 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct NonTradeActivities { + #[serde(rename = "activity_type", skip_serializing_if = "Option::is_none")] + pub activity_type: Option, + /// An ID for the activity, always in “::” format. Can be sent as page_token in requests to facilitate the paging of results. + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// The date on which the activity occurred or on which the transaction associated with the activity settled. + #[serde(rename = "date", skip_serializing_if = "Option::is_none")] + pub date: Option, + /// The net amount of money (positive or negative) associated with the activity. + #[serde(rename = "net_amount", skip_serializing_if = "Option::is_none")] + pub net_amount: Option, + /// The symbol of the security involved with the activity. Not present for all activity types. + #[serde(rename = "symbol", skip_serializing_if = "Option::is_none")] + pub symbol: Option, + /// For dividend activities, the number of shares that contributed to the payment. Not present for other activity types. + #[serde(rename = "qty", skip_serializing_if = "Option::is_none")] + pub qty: Option, + /// For dividend activities, the average amount paid per share. Not present for other activity types. + #[serde(rename = "per_share_amount", skip_serializing_if = "Option::is_none")] + pub per_share_amount: Option, +} + +impl NonTradeActivities { + pub fn new() -> NonTradeActivities { + NonTradeActivities { + activity_type: None, + id: None, + date: None, + net_amount: None, + symbol: None, + qty: None, + per_share_amount: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/order.rs b/crates/alpaca_openapi/gen/trading/src/models/order.rs new file mode 100644 index 0000000..84e0e28 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/order.rs @@ -0,0 +1,210 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Order : The Orders API allows a user to monitor, place and cancel their orders with Alpaca. Each order has a unique identifier provided by the client. This client-side unique order ID will be automatically generated by the system if not provided by the client, and will be returned as part of the order object along with the rest of the fields described below. Once an order is placed, it can be queried using the client-side order ID to check the status. Updates on open orders at Alpaca will also be sent over the streaming interface, which is the recommended method of maintaining order state. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Order { + /// Order ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Client unique order ID + #[serde(rename = "client_order_id", skip_serializing_if = "Option::is_none")] + pub client_order_id: Option, + #[serde(rename = "created_at", skip_serializing_if = "Option::is_none")] + pub created_at: Option, + #[serde( + rename = "updated_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub updated_at: Option>, + #[serde( + rename = "submitted_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub submitted_at: Option>, + #[serde( + rename = "filled_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub filled_at: Option>, + #[serde( + rename = "expired_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub expired_at: Option>, + #[serde( + rename = "canceled_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub canceled_at: Option>, + #[serde( + rename = "failed_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub failed_at: Option>, + #[serde( + rename = "replaced_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub replaced_at: Option>, + /// The order ID that this order was replaced by + #[serde( + rename = "replaced_by", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub replaced_by: Option>, + /// The order ID that this order replaces + #[serde( + rename = "replaces", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub replaces: Option>, + /// Asset ID + #[serde(rename = "asset_id", skip_serializing_if = "Option::is_none")] + pub asset_id: Option, + /// Asset symbol + #[serde(rename = "symbol")] + pub symbol: String, + #[serde(rename = "asset_class", skip_serializing_if = "Option::is_none")] + pub asset_class: Option, + /// Ordered notional amount. If entered, qty will be null. Can take up to 9 decimal points. + #[serde(rename = "notional", deserialize_with = "Option::deserialize")] + pub notional: Option, + /// Ordered quantity. If entered, notional will be null. Can take up to 9 decimal points. + #[serde(rename = "qty", deserialize_with = "Option::deserialize")] + pub qty: Option, + /// Filled quantity + #[serde(rename = "filled_qty", skip_serializing_if = "Option::is_none")] + pub filled_qty: Option, + /// Filled average price + #[serde( + rename = "filled_avg_price", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub filled_avg_price: Option>, + #[serde(rename = "order_class", skip_serializing_if = "Option::is_none")] + pub order_class: Option, + /// Deprecated in favour of the field \"type\" + #[serde(rename = "order_type", skip_serializing_if = "Option::is_none")] + pub order_type: Option, + #[serde(rename = "type")] + pub r#type: models::OrderType, + #[serde(rename = "side")] + pub side: models::OrderSide, + #[serde(rename = "time_in_force")] + pub time_in_force: models::TimeInForce, + /// Limit price + #[serde( + rename = "limit_price", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub limit_price: Option>, + /// Stop price + #[serde( + rename = "stop_price", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub stop_price: Option>, + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + /// If true, eligible for execution outside regular trading hours. + #[serde(rename = "extended_hours", skip_serializing_if = "Option::is_none")] + pub extended_hours: Option, + /// When querying non-simple order_class orders in a nested style, an array of Order entities associated with this order. Otherwise, null. + #[serde( + rename = "legs", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub legs: Option>>, + /// The percent value away from the high water mark for trailing stop orders. + #[serde(rename = "trail_percent", skip_serializing_if = "Option::is_none")] + pub trail_percent: Option, + /// The dollar value away from the high water mark for trailing stop orders. + #[serde(rename = "trail_price", skip_serializing_if = "Option::is_none")] + pub trail_price: Option, + /// The highest (lowest) market price seen since the trailing stop order was submitted. + #[serde(rename = "hwm", skip_serializing_if = "Option::is_none")] + pub hwm: Option, +} + +impl Order { + /// The Orders API allows a user to monitor, place and cancel their orders with Alpaca. Each order has a unique identifier provided by the client. This client-side unique order ID will be automatically generated by the system if not provided by the client, and will be returned as part of the order object along with the rest of the fields described below. Once an order is placed, it can be queried using the client-side order ID to check the status. Updates on open orders at Alpaca will also be sent over the streaming interface, which is the recommended method of maintaining order state. + pub fn new( + symbol: String, + notional: Option, + qty: Option, + r#type: models::OrderType, + side: models::OrderSide, + time_in_force: models::TimeInForce, + ) -> Order { + Order { + id: None, + client_order_id: None, + created_at: None, + updated_at: None, + submitted_at: None, + filled_at: None, + expired_at: None, + canceled_at: None, + failed_at: None, + replaced_at: None, + replaced_by: None, + replaces: None, + asset_id: None, + symbol, + asset_class: None, + notional, + qty, + filled_qty: None, + filled_avg_price: None, + order_class: None, + order_type: None, + r#type, + side, + time_in_force, + limit_price: None, + stop_price: None, + status: None, + extended_hours: None, + legs: None, + trail_percent: None, + trail_price: None, + hwm: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/order_class.rs b/crates/alpaca_openapi/gen/trading/src/models/order_class.rs new file mode 100644 index 0000000..a3c0b80 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/order_class.rs @@ -0,0 +1,45 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// OrderClass : This will either be the empty string \"\", \"simple\", \"bracket\", \"oco\", or \"oto\". +/// This will either be the empty string \"\", \"simple\", \"bracket\", \"oco\", or \"oto\". +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum OrderClass { + #[serde(rename = "simple")] + Simple, + #[serde(rename = "bracket")] + Bracket, + #[serde(rename = "oco")] + Oco, + #[serde(rename = "oto")] + Oto, + #[serde(rename = "")] + Empty, +} + +impl ToString for OrderClass { + fn to_string(&self) -> String { + match self { + Self::Simple => String::from("simple"), + Self::Bracket => String::from("bracket"), + Self::Oco => String::from("oco"), + Self::Oto => String::from("oto"), + Self::Empty => String::from(""), + } + } +} + +impl Default for OrderClass { + fn default() -> OrderClass { + Self::Simple + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/order_side.rs b/crates/alpaca_openapi/gen/trading/src/models/order_side.rs new file mode 100644 index 0000000..d46b396 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/order_side.rs @@ -0,0 +1,36 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// OrderSide : Represents which side this order was on: - buy - sell +/// Represents which side this order was on: - buy - sell +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum OrderSide { + #[serde(rename = "buy")] + Buy, + #[serde(rename = "sell")] + Sell, +} + +impl ToString for OrderSide { + fn to_string(&self) -> String { + match self { + Self::Buy => String::from("buy"), + Self::Sell => String::from("sell"), + } + } +} + +impl Default for OrderSide { + fn default() -> OrderSide { + Self::Buy + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/order_status.rs b/crates/alpaca_openapi/gen/trading/src/models/order_status.rs new file mode 100644 index 0000000..3996158 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/order_status.rs @@ -0,0 +1,78 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// OrderStatus : An order executed through Alpaca can experience several status changes during its lifecycle. The most common statuses are described in detail below: - new The order has been received by Alpaca, and routed to exchanges for execution. This is the usual initial state of an order. - partially_filled The order has been partially filled. - filled The order has been filled, and no further updates will occur for the order. - done_for_day The order is done executing for the day, and will not receive further updates until the next trading day. - canceled The order has been canceled, and no further updates will occur for the order. This can be either due to a cancel request by the user, or the order has been canceled by the exchanges due to its time-in-force. - expired The order has expired, and no further updates will occur for the order. - replaced The order was replaced by another order, or was updated due to a market event such as corporate action. - pending_cancel The order is waiting to be canceled. - pending_replace The order is waiting to be replaced by another order. The order will reject cancel request while in this state. Less common states are described below. Note that these states only occur on very rare occasions, and most users will likely never see their orders reach these states: - accepted The order has been received by Alpaca, but hasn’t yet been routed to the execution venue. This could be seen often out side of trading session hours. - pending_new The order has been received by Alpaca, and routed to the exchanges, but has not yet been accepted for execution. This state only occurs on rare occasions. - accepted_for_bidding The order has been received by exchanges, and is evaluated for pricing. This state only occurs on rare occasions. - stopped The order has been stopped, and a trade is guaranteed for the order, usually at a stated price or better, but has not yet occurred. This state only occurs on rare occasions. - rejected The order has been rejected, and no further updates will occur for the order. This state occurs on rare occasions and may occur based on various conditions decided by the exchanges. - suspended The order has been suspended, and is not eligible for trading. This state only occurs on rare occasions. - calculated The order has been completed for the day (either filled or done for day), but remaining settlement calculations are still pending. This state only occurs on rare occasions. An order may be canceled through the API up until the point it reaches a state of either filled, canceled, or expired. +/// An order executed through Alpaca can experience several status changes during its lifecycle. The most common statuses are described in detail below: - new The order has been received by Alpaca, and routed to exchanges for execution. This is the usual initial state of an order. - partially_filled The order has been partially filled. - filled The order has been filled, and no further updates will occur for the order. - done_for_day The order is done executing for the day, and will not receive further updates until the next trading day. - canceled The order has been canceled, and no further updates will occur for the order. This can be either due to a cancel request by the user, or the order has been canceled by the exchanges due to its time-in-force. - expired The order has expired, and no further updates will occur for the order. - replaced The order was replaced by another order, or was updated due to a market event such as corporate action. - pending_cancel The order is waiting to be canceled. - pending_replace The order is waiting to be replaced by another order. The order will reject cancel request while in this state. Less common states are described below. Note that these states only occur on very rare occasions, and most users will likely never see their orders reach these states: - accepted The order has been received by Alpaca, but hasn’t yet been routed to the execution venue. This could be seen often out side of trading session hours. - pending_new The order has been received by Alpaca, and routed to the exchanges, but has not yet been accepted for execution. This state only occurs on rare occasions. - accepted_for_bidding The order has been received by exchanges, and is evaluated for pricing. This state only occurs on rare occasions. - stopped The order has been stopped, and a trade is guaranteed for the order, usually at a stated price or better, but has not yet occurred. This state only occurs on rare occasions. - rejected The order has been rejected, and no further updates will occur for the order. This state occurs on rare occasions and may occur based on various conditions decided by the exchanges. - suspended The order has been suspended, and is not eligible for trading. This state only occurs on rare occasions. - calculated The order has been completed for the day (either filled or done for day), but remaining settlement calculations are still pending. This state only occurs on rare occasions. An order may be canceled through the API up until the point it reaches a state of either filled, canceled, or expired. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum OrderStatus { + #[serde(rename = "new")] + New, + #[serde(rename = "partially_filled")] + PartiallyFilled, + #[serde(rename = "filled")] + Filled, + #[serde(rename = "done_for_day")] + DoneForDay, + #[serde(rename = "canceled")] + Canceled, + #[serde(rename = "expired")] + Expired, + #[serde(rename = "replaced")] + Replaced, + #[serde(rename = "pending_cancel")] + PendingCancel, + #[serde(rename = "pending_replace")] + PendingReplace, + #[serde(rename = "accepted")] + Accepted, + #[serde(rename = "pending_new")] + PendingNew, + #[serde(rename = "accepted_for_bidding")] + AcceptedForBidding, + #[serde(rename = "stopped")] + Stopped, + #[serde(rename = "rejected")] + Rejected, + #[serde(rename = "suspended")] + Suspended, + #[serde(rename = "calculated")] + Calculated, +} + +impl ToString for OrderStatus { + fn to_string(&self) -> String { + match self { + Self::New => String::from("new"), + Self::PartiallyFilled => String::from("partially_filled"), + Self::Filled => String::from("filled"), + Self::DoneForDay => String::from("done_for_day"), + Self::Canceled => String::from("canceled"), + Self::Expired => String::from("expired"), + Self::Replaced => String::from("replaced"), + Self::PendingCancel => String::from("pending_cancel"), + Self::PendingReplace => String::from("pending_replace"), + Self::Accepted => String::from("accepted"), + Self::PendingNew => String::from("pending_new"), + Self::AcceptedForBidding => String::from("accepted_for_bidding"), + Self::Stopped => String::from("stopped"), + Self::Rejected => String::from("rejected"), + Self::Suspended => String::from("suspended"), + Self::Calculated => String::from("calculated"), + } + } +} + +impl Default for OrderStatus { + fn default() -> OrderStatus { + Self::New + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/order_type.rs b/crates/alpaca_openapi/gen/trading/src/models/order_type.rs new file mode 100644 index 0000000..78d34de --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/order_type.rs @@ -0,0 +1,45 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// OrderType : Represents the types of orders Alpaca currently supports - market - limit - stop - stop_limit - trailing_stop +/// Represents the types of orders Alpaca currently supports - market - limit - stop - stop_limit - trailing_stop +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum OrderType { + #[serde(rename = "market")] + Market, + #[serde(rename = "limit")] + Limit, + #[serde(rename = "stop")] + Stop, + #[serde(rename = "stop_limit")] + StopLimit, + #[serde(rename = "trailing_stop")] + TrailingStop, +} + +impl ToString for OrderType { + fn to_string(&self) -> String { + match self { + Self::Market => String::from("market"), + Self::Limit => String::from("limit"), + Self::Stop => String::from("stop"), + Self::StopLimit => String::from("stop_limit"), + Self::TrailingStop => String::from("trailing_stop"), + } + } +} + +impl Default for OrderType { + fn default() -> OrderType { + Self::Market + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/patch_order_request.rs b/crates/alpaca_openapi/gen/trading/src/models/patch_order_request.rs new file mode 100644 index 0000000..d656457 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/patch_order_request.rs @@ -0,0 +1,47 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// PatchOrderRequest : Represents a request to patch an order. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PatchOrderRequest { + /// number of shares to trade + #[serde(rename = "qty", skip_serializing_if = "Option::is_none")] + pub qty: Option, + #[serde(rename = "time_in_force", skip_serializing_if = "Option::is_none")] + pub time_in_force: Option, + /// required if original order type is limit or stop_limit + #[serde(rename = "limit_price", skip_serializing_if = "Option::is_none")] + pub limit_price: Option, + /// required if original order type is limit or stop_limit + #[serde(rename = "stop_price", skip_serializing_if = "Option::is_none")] + pub stop_price: Option, + /// the new value of the trail_price or trail_percent value (works only for type=“trailing_stop”) + #[serde(rename = "trail", skip_serializing_if = "Option::is_none")] + pub trail: Option, + /// A unique identifier for the order. Automatically generated if not sent. + #[serde(rename = "client_order_id", skip_serializing_if = "Option::is_none")] + pub client_order_id: Option, +} + +impl PatchOrderRequest { + /// Represents a request to patch an order. + pub fn new() -> PatchOrderRequest { + PatchOrderRequest { + qty: None, + time_in_force: None, + limit_price: None, + stop_price: None, + trail: None, + client_order_id: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/portfolio_history.rs b/crates/alpaca_openapi/gen/trading/src/models/portfolio_history.rs new file mode 100644 index 0000000..61e77f8 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/portfolio_history.rs @@ -0,0 +1,46 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PortfolioHistory { + /// time of each data element, left-labeled (the beginning of time window) + #[serde(rename = "timestamp", skip_serializing_if = "Option::is_none")] + pub timestamp: Option>, + /// equity value of the account in dollar amount as of the end of each time window + #[serde(rename = "equity", skip_serializing_if = "Option::is_none")] + pub equity: Option>, + /// profit/loss in dollar from the base value + #[serde(rename = "profit_loss", skip_serializing_if = "Option::is_none")] + pub profit_loss: Option>, + /// profit/loss in percentage from the base value + #[serde(rename = "profit_loss_pct", skip_serializing_if = "Option::is_none")] + pub profit_loss_pct: Option>, + /// basis in dollar of the profit loss calculation + #[serde(rename = "base_value", skip_serializing_if = "Option::is_none")] + pub base_value: Option, + /// time window size of each data element + #[serde(rename = "timeframe", skip_serializing_if = "Option::is_none")] + pub timeframe: Option, +} + +impl PortfolioHistory { + pub fn new() -> PortfolioHistory { + PortfolioHistory { + timestamp: None, + equity: None, + profit_loss: None, + profit_loss_pct: None, + base_value: None, + timeframe: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/position.rs b/crates/alpaca_openapi/gen/trading/src/models/position.rs new file mode 100644 index 0000000..416619e --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/position.rs @@ -0,0 +1,111 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Position : The positions API provides information about an account’s current open positions. The response will include information such as cost basis, shares traded, and market value, which will be updated live as price information is updated. Once a position is closed, it will no longer be queryable through this API. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Position { + /// Asset ID + #[serde(rename = "asset_id")] + pub asset_id: uuid::Uuid, + /// Symbol name of the asset + #[serde(rename = "symbol")] + pub symbol: String, + #[serde(rename = "exchange")] + pub exchange: models::Exchange, + #[serde(rename = "asset_class")] + pub asset_class: models::AssetClass, + /// Average entry price of the position + #[serde(rename = "avg_entry_price")] + pub avg_entry_price: String, + /// The number of shares + #[serde(rename = "qty")] + pub qty: String, + /// Total number of shares available minus open orders + #[serde(rename = "qty_available", skip_serializing_if = "Option::is_none")] + pub qty_available: Option, + /// “long” + #[serde(rename = "side")] + pub side: String, + /// Total dollar amount of the position + #[serde(rename = "market_value")] + pub market_value: String, + /// Total cost basis in dollar + #[serde(rename = "cost_basis")] + pub cost_basis: String, + /// Unrealized profit/loss in dollars + #[serde(rename = "unrealized_pl")] + pub unrealized_pl: String, + /// Unrealized profit/loss percent (by a factor of 1) + #[serde(rename = "unrealized_plpc")] + pub unrealized_plpc: String, + /// Unrealized profit/loss in dollars for the day + #[serde(rename = "unrealized_intraday_pl")] + pub unrealized_intraday_pl: String, + /// Unrealized profit/loss percent (by a factor of 1) + #[serde(rename = "unrealized_intraday_plpc")] + pub unrealized_intraday_plpc: String, + /// Current asset price per share + #[serde(rename = "current_price")] + pub current_price: String, + /// Last day’s asset price per share based on the closing value of the last trading day + #[serde(rename = "lastday_price")] + pub lastday_price: String, + /// Percent change from last day price (by a factor of 1) + #[serde(rename = "change_today")] + pub change_today: String, + #[serde(rename = "asset_marginable")] + pub asset_marginable: bool, +} + +impl Position { + /// The positions API provides information about an account’s current open positions. The response will include information such as cost basis, shares traded, and market value, which will be updated live as price information is updated. Once a position is closed, it will no longer be queryable through this API. + pub fn new( + asset_id: uuid::Uuid, + symbol: String, + exchange: models::Exchange, + asset_class: models::AssetClass, + avg_entry_price: String, + qty: String, + side: String, + market_value: String, + cost_basis: String, + unrealized_pl: String, + unrealized_plpc: String, + unrealized_intraday_pl: String, + unrealized_intraday_plpc: String, + current_price: String, + lastday_price: String, + change_today: String, + asset_marginable: bool, + ) -> Position { + Position { + asset_id, + symbol, + exchange, + asset_class, + avg_entry_price, + qty, + qty_available: None, + side, + market_value, + cost_basis, + unrealized_pl, + unrealized_plpc, + unrealized_intraday_pl, + unrealized_intraday_plpc, + current_price, + lastday_price, + change_today, + asset_marginable, + } + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/position_closed_reponse.rs b/crates/alpaca_openapi/gen/trading/src/models/position_closed_reponse.rs new file mode 100644 index 0000000..c981f38 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/position_closed_reponse.rs @@ -0,0 +1,35 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// PositionClosedReponse : Represents the result of asking the api to close a position. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PositionClosedReponse { + /// Symbol name of the asset + #[serde(rename = "symbol")] + pub symbol: String, + /// Http status code for the attempt to close this position + #[serde(rename = "status")] + pub status: String, + #[serde(rename = "body", skip_serializing_if = "Option::is_none")] + pub body: Option>, +} + +impl PositionClosedReponse { + /// Represents the result of asking the api to close a position. + pub fn new(symbol: String, status: String) -> PositionClosedReponse { + PositionClosedReponse { + symbol, + status, + body: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/time_in_force.rs b/crates/alpaca_openapi/gen/trading/src/models/time_in_force.rs new file mode 100644 index 0000000..c3665b7 --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/time_in_force.rs @@ -0,0 +1,48 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// TimeInForce : Note: For Crypto Trading, Alpaca supports the following Time-In-Force designations: day, gtc, ioc and fok. OPG and CLS are not supported. Alpaca supports the following Time-In-Force designations: - day A day order is eligible for execution only on the day it is live. By default, the order is only valid during Regular Trading Hours (9:30am - 4:00pm ET). If unfilled after the closing auction, it is automatically canceled. If submitted after the close, it is queued and submitted the following trading day. However, if marked as eligible for extended hours, the order can also execute during supported extended hours. - gtc The order is good until canceled. Non-marketable GTC limit orders are subject to price adjustments to offset corporate actions affecting the issue. We do not currently support Do Not Reduce(DNR) orders to opt out of such price adjustments. - opg Use this TIF with a market/limit order type to submit “market on open” (MOO) and “limit on open” (LOO) orders. This order is eligible to execute only in the market opening auction. Any unfilled orders after the open will be cancelled. OPG orders submitted after 9:28am but before 7:00pm ET will be rejected. OPG orders submitted after 7:00pm will be queued and routed to the following day’s opening auction. On open/on close orders are routed to the primary exchange. Such orders do not necessarily execute exactly at 9:30am / 4:00pm ET but execute per the exchange’s auction rules. - cls Use this TIF with a market/limit order type to submit “market on close” (MOC) and “limit on close” (LOC) orders. This order is eligible to execute only in the market closing auction. Any unfilled orders after the close will be cancelled. CLS orders submitted after 3:50pm but before 7:00pm ET will be rejected. CLS orders submitted after 7:00pm will be queued and routed to the following day’s closing auction. Only available with API v2. - ioc An Immediate Or Cancel (IOC) order requires all or part of the order to be executed immediately. Any unfilled portion of the order is canceled. Only available with API v2. Most market makers who receive IOC orders will attempt to fill the order on a principal basis only, and cancel any unfilled balance. On occasion, this can result in the entire order being cancelled if the market maker does not have any existing inventory of the security in question. - fok A Fill or Kill (FOK) order is only executed if the entire order quantity can be filled, otherwise the order is canceled. Only available with API v2. +/// Note: For Crypto Trading, Alpaca supports the following Time-In-Force designations: day, gtc, ioc and fok. OPG and CLS are not supported. Alpaca supports the following Time-In-Force designations: - day A day order is eligible for execution only on the day it is live. By default, the order is only valid during Regular Trading Hours (9:30am - 4:00pm ET). If unfilled after the closing auction, it is automatically canceled. If submitted after the close, it is queued and submitted the following trading day. However, if marked as eligible for extended hours, the order can also execute during supported extended hours. - gtc The order is good until canceled. Non-marketable GTC limit orders are subject to price adjustments to offset corporate actions affecting the issue. We do not currently support Do Not Reduce(DNR) orders to opt out of such price adjustments. - opg Use this TIF with a market/limit order type to submit “market on open” (MOO) and “limit on open” (LOO) orders. This order is eligible to execute only in the market opening auction. Any unfilled orders after the open will be cancelled. OPG orders submitted after 9:28am but before 7:00pm ET will be rejected. OPG orders submitted after 7:00pm will be queued and routed to the following day’s opening auction. On open/on close orders are routed to the primary exchange. Such orders do not necessarily execute exactly at 9:30am / 4:00pm ET but execute per the exchange’s auction rules. - cls Use this TIF with a market/limit order type to submit “market on close” (MOC) and “limit on close” (LOC) orders. This order is eligible to execute only in the market closing auction. Any unfilled orders after the close will be cancelled. CLS orders submitted after 3:50pm but before 7:00pm ET will be rejected. CLS orders submitted after 7:00pm will be queued and routed to the following day’s closing auction. Only available with API v2. - ioc An Immediate Or Cancel (IOC) order requires all or part of the order to be executed immediately. Any unfilled portion of the order is canceled. Only available with API v2. Most market makers who receive IOC orders will attempt to fill the order on a principal basis only, and cancel any unfilled balance. On occasion, this can result in the entire order being cancelled if the market maker does not have any existing inventory of the security in question. - fok A Fill or Kill (FOK) order is only executed if the entire order quantity can be filled, otherwise the order is canceled. Only available with API v2. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TimeInForce { + #[serde(rename = "day")] + Day, + #[serde(rename = "gtc")] + Gtc, + #[serde(rename = "opg")] + Opg, + #[serde(rename = "cls")] + Cls, + #[serde(rename = "ioc")] + Ioc, + #[serde(rename = "fok")] + Fok, +} + +impl ToString for TimeInForce { + fn to_string(&self) -> String { + match self { + Self::Day => String::from("day"), + Self::Gtc => String::from("gtc"), + Self::Opg => String::from("opg"), + Self::Cls => String::from("cls"), + Self::Ioc => String::from("ioc"), + Self::Fok => String::from("fok"), + } + } +} + +impl Default for TimeInForce { + fn default() -> TimeInForce { + Self::Day + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/trading_activities.rs b/crates/alpaca_openapi/gen/trading/src/models/trading_activities.rs new file mode 100644 index 0000000..426ef7c --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/trading_activities.rs @@ -0,0 +1,82 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TradingActivities { + #[serde(rename = "activity_type", skip_serializing_if = "Option::is_none")] + pub activity_type: Option, + /// An id for the activity. Always in “::” format. Can be sent as page_token in requests to facilitate the paging of results. + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// The cumulative quantity of shares involved in the execution. + #[serde(rename = "cum_qty", skip_serializing_if = "Option::is_none")] + pub cum_qty: Option, + /// For partially_filled orders, the quantity of shares that are left to be filled. + #[serde(rename = "leaves_qty", skip_serializing_if = "Option::is_none")] + pub leaves_qty: Option, + /// The per-share price that the trade was executed at. + #[serde(rename = "price", skip_serializing_if = "Option::is_none")] + pub price: Option, + /// The number of shares involved in the trade execution. + #[serde(rename = "qty", skip_serializing_if = "Option::is_none")] + pub qty: Option, + /// buy or sell + #[serde(rename = "side", skip_serializing_if = "Option::is_none")] + pub side: Option, + /// The symbol of the security being traded. + #[serde(rename = "symbol", skip_serializing_if = "Option::is_none")] + pub symbol: Option, + /// The time at which the execution occurred. + #[serde(rename = "transaction_time", skip_serializing_if = "Option::is_none")] + pub transaction_time: Option, + /// The id for the order that filled. + #[serde(rename = "order_id", skip_serializing_if = "Option::is_none")] + pub order_id: Option, + /// fill or partial_fill + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + pub r#type: Option, + #[serde(rename = "order_status", skip_serializing_if = "Option::is_none")] + pub order_status: Option, +} + +impl TradingActivities { + pub fn new() -> TradingActivities { + TradingActivities { + activity_type: None, + id: None, + cum_qty: None, + leaves_qty: None, + price: None, + qty: None, + side: None, + symbol: None, + transaction_time: None, + order_id: None, + r#type: None, + order_status: None, + } + } +} +/// fill or partial_fill +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Type { + #[serde(rename = "fill")] + Fill, + #[serde(rename = "partial_fill")] + PartialFill, +} + +impl Default for Type { + fn default() -> Type { + Self::Fill + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/update_watchlist_request.rs b/crates/alpaca_openapi/gen/trading/src/models/update_watchlist_request.rs new file mode 100644 index 0000000..f96a02c --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/update_watchlist_request.rs @@ -0,0 +1,30 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// UpdateWatchlistRequest : Request format used for creating a new watchlist or updating an existing watchlist with a set of assets and name. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UpdateWatchlistRequest { + #[serde(rename = "name")] + pub name: String, + #[serde(rename = "symbols", skip_serializing_if = "Option::is_none")] + pub symbols: Option>, +} + +impl UpdateWatchlistRequest { + /// Request format used for creating a new watchlist or updating an existing watchlist with a set of assets and name. + pub fn new(name: String) -> UpdateWatchlistRequest { + UpdateWatchlistRequest { + name, + symbols: None, + } + } +} diff --git a/crates/alpaca_openapi/gen/trading/src/models/watchlist.rs b/crates/alpaca_openapi/gen/trading/src/models/watchlist.rs new file mode 100644 index 0000000..f1bea2a --- /dev/null +++ b/crates/alpaca_openapi/gen/trading/src/models/watchlist.rs @@ -0,0 +1,52 @@ +/* + * Trader API + * + * Alpaca's Trading API is a modern platform for algorithmic trading. For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + * + * The version of the OpenAPI document: 2.0.0 + * Contact: support@alpaca.markets + * Generated by: https://openapi-generator.tech + */ + +use crate::models; + +/// Watchlist : The watchlist API provides CRUD operation for the account’s watchlist. An account can have multiple watchlists and each is uniquely identified by id but can also be addressed by user-defined name. Each watchlist is an ordered list of assets. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Watchlist { + /// watchlist id + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// account ID + #[serde(rename = "account_id")] + pub account_id: uuid::Uuid, + #[serde(rename = "created_at")] + pub created_at: String, + #[serde(rename = "updated_at")] + pub updated_at: String, + /// user-defined watchlist name (up to 64 characters) + #[serde(rename = "name")] + pub name: String, + /// the content of this watchlist, in the order as registered by the client + #[serde(rename = "assets", skip_serializing_if = "Option::is_none")] + pub assets: Option>, +} + +impl Watchlist { + /// The watchlist API provides CRUD operation for the account’s watchlist. An account can have multiple watchlists and each is uniquely identified by id but can also be addressed by user-defined name. Each watchlist is an ordered list of assets. + pub fn new( + id: uuid::Uuid, + account_id: uuid::Uuid, + created_at: String, + updated_at: String, + name: String, + ) -> Watchlist { + Watchlist { + id, + account_id, + created_at, + updated_at, + name, + assets: None, + } + } +} diff --git a/crates/alpaca_openapi/gen_alpaca.sh b/crates/alpaca_openapi/gen_alpaca.sh new file mode 100755 index 0000000..086e5e9 --- /dev/null +++ b/crates/alpaca_openapi/gen_alpaca.sh @@ -0,0 +1,18 @@ +set -euo pipefail + +if [ $# -eq 1 ] && [ -f openapi/$1/openapi.yaml ]; then + spec=openapi/$1/openapi.yaml + if [ -f $spec ]; then + echo "regen $1 ($spec)" + rm -rf ./gen/$1 + openapi-generator-cli generate -i $spec -g rust -o ./gen/$1 --additional-properties=packageName=alpaca_$1,library=reqwest,supportMultipleResponses=true,useSingleRequestParameter=true + fi +else + for i in $(ls openapi); do + spec=openapi/$i/openapi.yaml + if [ -f $spec ]; then + echo "gen from $i ($spec)" + openapi-generator-cli generate -i $spec -g rust -o ./gen/$i --additional-properties=packageName=alpaca_$i,library=reqwest,supportMultipleResponses=true,useSingleRequestParameter=true + fi + done +fi diff --git a/crates/alpaca_openapi/openapi/README.md b/crates/alpaca_openapi/openapi/README.md new file mode 100644 index 0000000..6d6d168 --- /dev/null +++ b/crates/alpaca_openapi/openapi/README.md @@ -0,0 +1,52 @@ +# alpaca-oas + +Alpaca [OpenAPI specifcations (OAS)](https://swagger.io/docs/specification/about/). + +--- +# ⚠️ These specs are still a work in progress and might not at this time accurately reflect the latest state of our apis. ⚠️ + +We are currently working on making these specs accurate but currently some inaccuracies or missing endpoints are expected. + +--- +## Getting started + +Install packages / tools for working with the OAS project + +``` +npm i +``` + +## Validate an OpenAPI spec + +`npm run validate broker/openapi.yaml` + +You can also optionally run the `./scripts/validate-all.sh` to validate all the spec files + +## Lint an OpenAPI spec + +`npm run lint broker/openapi.yaml` + +You can also optionally run the `./scripts/lint-all.sh` to lint all the spec files + +## Serve an OpenAPI doc preview + +`npm run serve broker/openapi.yaml --options.onlyRequiredInSamples` + +## Generate API clients for a given language + +View list of potential generators: `npx openapi-generator-cli list` + +Below example generates packages for Java and R from Broker API OpenAPI spec. + +``` +npx openapi-generator-cli generate -i broker/openapi.yaml -g java -o build/java +npx openapi-generator-cli generate -i broker/openapi.yaml -g r -o build/r +``` + +While we include this in our dependencies, documenting how to use openapi-generator-cli is a bit out of scope for this document, +please see [their github page](https://github.com/OpenAPITools/openapi-generator-cli) for more information on how to use it. + + +## Generate Postman Collection + +`npx openapi2postmanv2 -s broker/openapi.yaml -o build/collection.json -p -O folderStrategy=paths,includeAuthInfoInExample=true` diff --git a/crates/alpaca_openapi/openapi/broker/openapi.yaml b/crates/alpaca_openapi/openapi/broker/openapi.yaml new file mode 100644 index 0000000..2512990 --- /dev/null +++ b/crates/alpaca_openapi/openapi/broker/openapi.yaml @@ -0,0 +1,5809 @@ +openapi: 3.0.0 +info: + title: Broker API + description: 'Open brokerage accounts, enable crypto and stock trading, and manage the ongoing user experience with Alpaca Broker API' + version: 1.0.0 + contact: + name: Alpaca Support + email: support@alpaca.markets + url: 'https://alpaca.markets/support' + termsOfService: 'https://s3.amazonaws.com/files.alpaca.markets/disclosures/library/TermsAndConditions.pdf' +servers: + - url: 'https://broker-api.sandbox.alpaca.markets' + description: Sandbox endpoint + - url: 'https://broker-api.alpaca.markets' + description: Production endpoint +tags: + - name: Accounts + - name: Documents + - name: Trading + - name: Assets + - name: Calendar + - name: Events + - name: Funding + - name: OAuth + - name: Clock + - name: Journals + - name: Corporate Actions + - name: Watchlist +components: + securitySchemes: + BasicAuth: + type: http + scheme: basic + parameters: + ActivityType: + in: path + name: activity_type + required: true + schema: + type: string + enum: + - FILL + - ACATC + - ACATS + - CIL + - CSD + - CSW + - DIV + - DIVCGL + - DIVCGS + - DIVNRA + - DIVROC + - DIVTXEX + - FEE + - INT + - JNLC + - JNLS + - MA + - PTC + - REORG + - SPIN + - SPLIT + description: see ActivityType model for details about what the different types mean + Status: + name: status + in: query + description: Status of the orders to list. + schema: + type: string + enum: + - open + - closed + - all + Limit: + name: limit + in: query + description: The maximum number of orders in response. + schema: + type: integer + example: 500 + After: + name: after + in: query + description: The response will include only ones submitted after this timestamp (exclusive.) + schema: + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + Until: + name: until + in: query + description: The response will include only ones submitted until this timestamp (exclusive.) + schema: + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + Direction: + name: direction + in: query + description: The chronological order of response based on the submission time. asc or desc. Defaults to desc. + schema: + type: string + enum: + - asc + - desc + example: desc + Sort: + name: sort + in: query + description: The chronological order of response based on the submission time. asc or desc. Defaults to desc. + schema: + type: string + enum: + - asc + - desc + example: desc + Nested: + name: nested + in: query + description: 'If true, the result will roll up multi-leg orders under the legs field of primary order.' + schema: + type: boolean + example: false + Symbols: + name: symbols + in: query + description: A comma-separated list of symbols to filter by. + schema: + type: string + example: 'AAPL,TSLA,MSFT' + AccountID: + name: account_id + in: path + required: true + description: Account identifier. + schema: + type: string + format: uuid + OrderID: + name: order_id + in: path + required: true + description: Order identifier. + schema: + type: string + DocumentID: + name: document_id + in: path + required: true + description: Document identifier. + schema: + type: string + format: uuid + DocumentType: + name: type + in: query + required: false + description: See DocumentType model for reference and explanation of values + schema: + example: identity_verification + type: string + enum: + - identity_verification + - address_verification + - date_of_birth_verification + - tax_id_verification + - account_approval_letter + - cip_result + PageToken: + name: page_token + in: query + required: false + schema: + type: string + description: 'TODO: find a good way to generalize the description of page_tokens' + schemas: + Account: + type: object + title: '' + description: Represents high level account info. Used when returning entire account information would not be useful like the getAllAccounts operation + x-examples: + example-1: + id: 0d18ae51-3c94-4511-b209-101e1666416b + account_number: '9034005019' + status: APPROVED + currency: USD + created_at: '2019-09-30T23:55:31.185998Z' + last_equity: '1500.65' + properties: + id: + type: string + format: uuid + account_number: + type: string + nullable: true + status: + $ref: '#/components/schemas/AccountStatus' + crypto_status: + $ref: '#/components/schemas/AccountStatus' + currency: + type: string + description: Always "USD" + example: USD + created_at: + type: string + format: date-time + last_equity: + type: string + format: decimal + kyc_results: + $ref: '#/components/schemas/KYCResult' + account_type: + $ref: '#/components/schemas/AccountType' + required: + - id + - account_number + - status + - currency + - created_at + - last_equity + TradeAccount: + type: object + x-examples: + example-1: + id: c8f1ef5d-edc0-4f23-9ee4-378f19cb92a4 + account_number: '927584925' + status: ACTIVE + currency: USD + buying_power: '103556.8572572922' + regt_buying_power: '52921.2982330664' + daytrading_buying_power: '103556.8572572922' + cash: '24861.91' + cash_withdrawable: '17861.91' + cash_transferable: '24861.91' + accrued_fees: '0' + pending_transfer_out: '0' + portfolio_value: '28059.3882330664' + pattern_day_trader: true + trading_blocked: false + transfers_blocked: false + account_blocked: false + created_at: '2021-03-01T13:28:49.270232Z' + trade_suspended_by_user: false + multiplier: '2' + shorting_enabled: true + equity: '28059.3882330664' + last_equity: '26977.323677655' + long_market_value: '3197.4782330664' + short_market_value: '0' + initial_margin: '1598.7391165332' + maintenance_margin: '959.24346991992' + last_maintenance_margin: '934.6241032965' + sma: '26758.0590204615' + daytrade_count: 0 + previous_close: '2021-04-01T19:00:00-04:00' + last_long_market_value: '3115.413677655' + last_short_market_value: '0' + last_cash: '23861.91' + last_initial_margin: '1557.7068388275' + last_regt_buying_power: '50839.233677655' + last_daytrading_buying_power: '104433.9158860662' + last_buying_power: '104433.9158860662' + last_daytrade_count: 0 + clearing_broker: VELOX + example-2: + id: 56712986-9ff7-4d8f-8e52-077e099e533e + account_number: '601612064' + status: ACTIVE + crypto_status: PAPER_ONLY + currency: USD + buying_power: '83567.42' + regt_buying_power: '83567.42' + daytrading_buying_power: '0' + non_marginable_buying_power: '41783.71' + cash: '83567.42' + cash_withdrawable: '0' + cash_transferable: '41783.71' + accrued_fees: '0' + pending_transfer_out: '0' + pending_transfer_in: '0' + portfolio_value: '83567.42' + pattern_day_trader: false + trading_blocked: false + transfers_blocked: false + account_blocked: false + created_at: '2022-01-21T21:25:26.713802Z' + trade_suspended_by_user: false + multiplier: '1' + shorting_enabled: false + equity: '83567.42' + last_equity: '41783.71' + long_market_value: '0' + short_market_value: '0' + initial_margin: '0' + maintenance_margin: '0' + last_maintenance_margin: '0' + sma: '0' + daytrade_count: 0 + previous_close: '2022-02-08T19:00:00-05:00' + last_long_market_value: '0' + last_short_market_value: '0' + last_cash: '41783.71' + last_initial_margin: '0' + last_regt_buying_power: '41783.71' + last_daytrading_buying_power: '0' + last_buying_power: '41783.71' + last_daytrade_count: 0 + clearing_broker: VELOX + description: |- + This is an extended version of the Account model found [in the trading api](https://alpaca.markets/docs/api-references/trading-api/account/#account-entity). + + Extra data has been added that would be useful for brokers. + properties: + id: + type: string + example: c8f1ef5d-edc0-4f23-9ee4-378f19cb92a4 + format: uuid + description: The account ID + account_number: + type: string + example: '927584925' + description: The account number + nullable: true + status: + $ref: '#/components/schemas/AccountStatus' + currency: + type: string + example: USD + description: Always USD + buying_power: + type: string + example: '12345.6789' + format: decimal + description: Current available cash buying power. If multiplier = 2 then buying_power = max(equity-initial_margin(0) * 2). If multiplier = 1 then buying_power = cash. + regt_buying_power: + type: string + example: '12345.6789' + format: decimal + description: User’s buying power under Regulation T (excess equity - (equity - margin value) - * margin multiplier) + daytrading_buying_power: + type: string + example: '12345.6789' + format: decimal + description: Your buying power for day trades (continuously updated value) + cash: + type: string + example: '12345.6789' + format: decimal + description: Cash balance + cash_withdrawable: + type: string + example: '12345.6789' + format: decimal + description: Cash available for withdrawl + cash_transferable: + type: string + example: '12345.6789' + description: Cash available for transfer (JNLC) + pending_transfer_out: + type: string + example: '12345.6789' + description: Cash pending transfer out + portfolio_value: + type: string + example: '12345.6789' + format: decimal + description: Total value of cash + holding positions. (This field is deprecated. It is equivalent to the equity field.) + pattern_day_trader: + type: boolean + example: false + description: Whether account is flagged as pattern day trader or not + trading_blocked: + type: boolean + example: false + description: 'If true, the account is not allowed to place orders.' + transfers_blocked: + type: boolean + example: false + description: 'If true, the account is not allowed to request money transfers.' + account_blocked: + type: boolean + example: false + description: 'If true, the account activity by user is prohibited.' + created_at: + type: string + example: '2021-03-01T13:28:49.270232Z' + description: Timestamp this account was created at + trade_suspended_by_user: + type: boolean + example: false + description: 'If true, the account is not allowed to place orders.' + multiplier: + type: string + format: decimal + example: '2' + description: '“1”, “2”, "3", or "4"' + shorting_enabled: + type: boolean + example: false + description: Flag to denote whether or not the account is permitted to short + equity: + type: string + example: '12345.6789' + format: decimal + description: cash + long_market_value + short_market_value + last_equity: + type: string + example: '12345.6789' + format: decimal + description: 'Equity as of previous trading day at 16:00:00 ET' + long_market_value: + type: string + example: '12345.6789' + format: decimal + description: Real-time MtM value of all long positions held in the account + short_market_value: + type: string + example: '0' + format: decimal + description: Real-time MtM value of all short positions held in the account + initial_margin: + type: string + example: '12345.6789' + format: decimal + description: Reg T initial margin requirement (continuously updated value) + maintenance_margin: + type: string + example: '12345.6789' + format: decimal + description: Maintenance margin requirement (continuously updated value) + last_maintenance_margin: + type: string + example: '12345.6789' + format: decimal + description: Maintenance margin requirement on the previous trading day + sma: + type: string + example: '12345.6789' + format: decimal + description: Value of Special Memorandum Account (will be used at a later date to provide additional buying_power) + daytrade_count: + type: integer + example: 0 + description: The current number of daytrades that have been made in the last 5 trading days (inclusive of today) + previous_close: + type: string + example: '2021-04-01T19:00:00-04:00' + description: Previous sessions close time + last_long_market_value: + type: string + example: '12345.6789' + description: 'Value of all long positions as of previous trading day at 16:00:00 ET' + last_short_market_value: + type: string + example: '0' + description: 'Value of all short positions as of previous trading day at 16:00:00 ET' + last_cash: + type: string + example: '12345.6789' + description: 'Value of all cash as of previous trading day at 16:00:00 ET' + last_initial_margin: + type: string + example: '12345.6789' + description: 'Value of Reg T margin as of previous trading day at 16:00:00 ET' + last_regt_buying_power: + type: string + example: '12345.6789' + description: 'Value of Reg T buying power as of previous trading day at 16:00:00 ET' + last_daytrading_buying_power: + type: string + example: '12345.6789' + description: 'Value of daytrading buying power as of previous trading day at 16:00:00 ET' + last_buying_power: + type: string + example: '12345.6789' + description: 'Value of buying_power as of previous trading day at 16:00:00 ET' + last_daytrade_count: + type: integer + example: 0 + description: 'Value of daytrade count as of previous trading day at 16:00:00 ET' + clearing_broker: + type: string + example: Velox + description: Clearing broker + required: + - id + - account_number + - status + - currency + - created_at + - last_equity + - equity + - cash + - buying_power + AccountStatus: + type: string + example: ACTIVE + enum: + - ONBOARDING + - SUBMITTED + - RESUBMITTED + - SUBMISSION_FAILED + - ACTION_REQUIRED + - EDITED + - ACCOUNT_UPDATED + - APPROVAL_PENDING + - REAPPROVAL_PENDING + - SIGNED_UP + - KYC_SUBMITTED + - LIMITED + - AML_REVIEW + - APPROVED + - REJECTED + - ACTIVE + - DISABLED + - DISABLE_PENDING + - ACCOUNT_CLOSED + - PAPER_ONLY + description: | + Designates the current status of this account + + Possible Values: + - **ONBOARDING** + An application is expected for this user, but has not been submitted yet. + - **SUBMITTED** + The application has been submitted and in process. + - **RESUBMITTED** + Resubmitted is used to display when request has been re-submitted to Apex after account update + - **SUBMISSION_FAILED** + Used to display if failure on submission + - **ACTION_REQUIRED** + The application requires manual action. + - **EDITED** + Application was edited (e.g. to match info from uploaded docs). This is a transient status. + - **ACCOUNT_UPDATED** + Used to display when Account has been modified by user + - **APPROVAL_PENDING** + Initial value. The application approval process is in process. + - **REAPPROVAL_PENDING** + This is a transient status used to display once apex approves a re-submission + - **SIGNED_UP** + Users who were directed to and competed the [first stage](https://app.alpaca.markets/signup) of v2 registration + - **KYC_SUBMITTED** + Users that have had their KYC submitted to the routed KYC Provider + - **LIMITED** + Limited Users that pass KYC but are missing financial_information and employment_details + - **AML_REVIEW** + Users that pass KYC but from a restricted/high risk country and need manual AML approval + - **APPROVED** + The account application has been approved, and waiting to be ACTIVE + - **REJECTED** + The account application is rejected for some reason + - **ACTIVE** + The account is fully active. Trading and funding are processed under this status. + - **DISABLED** + The account is disabled after ACTIVE status. + - **DISABLE_PENDING** + DisablePending is used for accounts which requested to be disabled, but have not been processed yet. + - **ACCOUNT_CLOSED** + The account is closed. + - **PAPER_ONLY** + Used to display when only paper trading is allowed for this account + AccountType: + type: string + title: AccountType + description: |- + Possible values are: + + - trading + - custodial + - donor_advised + enum: + - trading + - custodial + - donor_advised + example: trading + AccountExtended: + type: object + description: 'Represents an account with all data available. If your api response is missing some of these fields, there is a good chance you are using a route that returns `Account` instances instead of these.' + x-examples: + example-1: + id: 3dcb795c-3ccc-402a-abb9-07e26a1b1326 + account_number: '601842165' + status: ACTIVE + crypto_status: PAPER_ONLY + currency: USD + last_equity: '40645.13' + created_at: '2022-01-21T21:25:26.583576Z' + contact: + email_address: strange_elbakyan_97324509@example.com + phone_number: 614-555-0697 + street_address: + - 20 N San Mateo Dr + city: San Mateo + state: CA + postal_code: '94401' + identity: + given_name: Strange + family_name: Elbakyan + date_of_birth: '1970-01-01' + tax_id_type: USA_SNN + country_of_citizenship: USA + country_of_birth: USA + country_of_tax_residence: USA + funding_source: + - employment_income + visa_type: null + visa_expiration_date: null + date_of_departure_from_usa: null + permanent_resident: null + disclosures: + is_control_person: false + is_affiliated_exchange_or_finra: false + is_politically_exposed: false + immediate_family_exposed: false + is_discretionary: false + agreements: + - agreement: margin_agreement + signed_at: '2022-01-21T21:25:26.579487214Z' + ip_address: 127.0.0.1 + revision: null + - agreement: customer_agreement + signed_at: '2022-01-21T21:25:26.579487214Z' + ip_address: 127.0.0.1 + revision: null + - agreement: account_agreement + signed_at: '2022-01-21T21:25:26.579487214Z' + ip_address: 127.0.0.1 + revision: null + documents: + - document_type: identity_verification + document_sub_type: passport + id: d5af1585-6c60-494d-9ea5-c5df62704229 + content: 'https://s3.amazonaws.com/stg.alpaca.markets/documents/accounts/3dcb795c-3ccc-402a-abb9-07e26a1b1326/2490f5d9-8988-4405-a3e0-d76e65de13c2.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJLDF4SCWSL6HUQKA%2F20220210%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220210T162205Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=bc6cc0f541d569623f3973fb83734d7960a69886e8b175a9d472f666b87419f1' + created_at: '2022-01-21T21:25:28.184231Z' + trusted_contact: + given_name: Jane + family_name: Doe + email_address: strange_elbakyan_97324509@example.com + account_type: trading + trading_configurations: null + properties: + id: + type: string + format: uuid + account_number: + type: string + nullable: true + status: + $ref: '#/components/schemas/AccountStatus' + crypto_status: + $ref: '#/components/schemas/AccountStatus' + kyc_result: + $ref: '#/components/schemas/KYCResult' + currency: + type: string + description: Always "USD" + example: USD + last_equity: + type: string + format: decimal + created_at: + type: string + format: date-time + contact: + $ref: '#/components/schemas/Contact' + identity: + $ref: '#/components/schemas/Identity' + disclosures: + $ref: '#/components/schemas/Disclosures' + agreements: + type: array + items: + $ref: '#/components/schemas/Agreement' + documents: + type: array + items: + $ref: '#/components/schemas/ApplicationDocument' + trusted_contact: + $ref: '#/components/schemas/TrustedContact' + account_name: + type: string + account_type: + $ref: '#/components/schemas/AccountType' + custodial_account_type: + type: string + enum: + - UTMA + - UGMA + description: '"UGMA" or "UTMA" only used when account_type is "custodial"' + minor_identity: + $ref: '#/components/schemas/CustodialAccountMinorIdentity' + trading_configurations: + $ref: '#/components/schemas/AccountConfigurations' + required: + - id + - account_number + - status + - currency + - last_equity + - created_at + - account_type + AccountUpdateRequest: + type: object + x-examples: + example-1: + contact: + email_address: john.doe@example.com + phone_number: '+15556667788' + street_address: + - 20 N San Mateo Dr + city: San Mateo + state: CA + postal_code: '94401' + identity: + given_name: John + family_name: Doe + date_of_birth: '1990-01-01' + tax_id: 666-55-4321 + tax_id_type: USA_SSN + country_of_citizenship: AUS + country_of_birth: AUS + country_of_tax_residence: USA + funding_source: + - employment_income + disclosures: + is_control_person: false + is_affiliated_exchange_or_finra: false + is_politically_exposed: false + immediate_family_exposed: false + trustedContact: + given_name: Jane + family_name: Doe + email_address: jane.doe@example.com + properties: + contact: + $ref: '#/components/schemas/Contact' + identity: + $ref: '#/components/schemas/Identity' + disclosures: + $ref: '#/components/schemas/Disclosures' + trustedContact: + $ref: '#/components/schemas/TrustedContact' + AccountDocument: + type: object + description: | + If an account has documents on the application submission, + it has the ApplicationDocument model in exchange with + DocumentUploadRequest. + properties: + id: + type: string + format: uuid + document_type: + $ref: '#/components/schemas/DocumentType' + document_sub_type: + type: string + mime_type: + type: string + created_at: + type: string + format: date-time + required: + - id + - document_type + - created_at + example: + id: 0d18ae51-3c94-4511-b209-101e1666416b + document_type: identity_verification + document_sub_type: passport + mime_type: image/jpeg + created_at: '2019-09-30T23:55:31.185998Z' + CustodialAccountMinorIdentity: + description: Represents Identity information for a minor that an account of type "custodial" is for + type: object + x-examples: {} + properties: + given_name: + type: string + family_name: + type: string + date_of_birth: + type: string + format: date + tax_id: + type: string + tax_id_type: + $ref: '#/components/schemas/TaxIdType' + country_of_citizenship: + type: string + country_of_birth: + type: string + country_of_tax_residence: + type: string + state: + type: string + email: + type: string + format: email + required: + - given_name + - family_name + - date_of_birth + - country_of_tax_residence + - state + - email + AccountConfigurations: + title: AccountConfigurations + type: object + description: Represents additional configuration settings for an account + properties: + dtbp_check: + type: string + description: 'both, entry, or exit. Controls Day Trading Margin Call (DTMC) checks.' + example: both + enum: + - both + - entry + - exit + trade_confirm_email: + type: string + description: 'all or none. If none, emails for order fills are not sent.' + enum: + - all + - none + suspend_trade: + type: boolean + description: 'If true, new orders are blocked.' + no_shorting: + type: boolean + description: 'If true, account becomes long-only mode.' + fractional_trading: + type: boolean + description: 'If true, account is able to participate in fractional trading' + max_margin_multiplier: + type: string + description: Can be "1" or "2" + pdt_check: + type: string + example: entry + required: + - dtbp_check + - trade_confirm_email + - suspend_trade + - no_shorting + - fractional_trading + - max_margin_multiplier + - pdt_check + AccountCreationRequest: + type: object + title: AccountCreationRequest + description: Represents the fields required to create a new account + properties: + contact: + $ref: '#/components/schemas/Contact' + identity: + $ref: '#/components/schemas/Identity' + disclosures: + $ref: '#/components/schemas/Disclosures' + agreements: + type: array + description: 'The client has to present the Alpaca Account and Margin Agreements to the end user, and have them read full sentences.' + items: + $ref: '#/components/schemas/Agreement' + documents: + type: array + items: + $ref: '#/components/schemas/DocumentUploadRequest' + trusted_contact: + $ref: '#/components/schemas/TrustedContact' + required: + - contact + - identity + - disclosures + - agreements + TaxIdType: + type: string + title: TaxIdType + enum: + - NOT_SPECIFIED + - USA_SSN + - ARG_AG_CUIT + - AUS_TFN + - AUS_ABN + - BOL_NIT + - BRA_CPF + - CHL_RUT + - COL_NIT + - CRI_NITE + - DEU_TAX_ID + - DOM_RNC + - ECU_RUC + - FRA_SPI + - GBR_UTR + - GBR_NINO + - GTM_NIT + - HND_RTN + - HUN_TIN + - IDN_KTP + - IND_PAN + - ISR_TAX_ID + - ITA_TAX_ID + - JPN_TAX_ID + - MEX_RFC + - NIC_RUC + - NLD_TIN + - PAN_RUC + - PER_RUC + - PRY_RUC + - SGP_NRIC + - SGP_FIN + - SGP_ASGD + - SGP_ITR + - SLV_NIT + - SWE_TAX_ID + - URY_RUT + - VEN_RIF + description: |- + An Enum of the various kinds of Tax ID formats Alpaca supports. + + Possible Values are: + + + - **USA_SSN** + USA Social Security Number + + - **ARG_AR_CUIT** + Argentina CUIT + + - **AUS_TFN** + Australian Tax File Number + + - **AUS_ABN** + Australian Business Number + + - **BOL_NIT** + Bolivia NIT + + - **BRA_CPF** + Brazil CPF + + - **CHL_RUT** + Chile RUT + + - **COL_NIT** + Colombia NIT + + - **CRI_NITE** + Costa Rica NITE + + - **DEU_TAX_ID** + Germany Tax ID (Identifikationsnummer) + + - **DOM_RNC** + Dominican Republic RNC + + - **ECU_RUC** + Ecuador RUC + + - **FRA_SPI** + France SPI (Reference Tax Number) + + - **GBR_UTR** + UK UTR (Unique Taxpayer Reference) + + - **GBR_NINO** + UK NINO (National Insurance Number) + + - **GTM_NIT** + Guatemala NIT + + - **HND_RTN** + Honduras RTN + + - **HUN_TIN** + Hungary TIN Number + + - **IDN_KTP** + Indonesia KTP + + - **IND_PAN** + India PAN Number + + - **ISR_TAX_ID** + Israel Tax ID (Teudat Zehut) + + - **ITA_TAX_ID** + Italy Tax ID (Codice Fiscale) + + - **JPN_TAX_ID** + Japan Tax ID (Koijin Bango) + + - **MEX_RFC** + Mexico RFC + + - **NIC_RUC** + Nicaragua RUC + + - **NLD_TIN** + Netherlands TIN Number + + - **PAN_RUC** + Panama RUC + + - **PER_RUC** + Peru RUC + + - **PRY_RUC** + Paraguay RUC + + - **SGP_NRIC** + Singapore NRIC + + - **SGP_FIN** + Singapore FIN + + - **SGP_ASGD** + Singapore ASGD + + - **SGP_ITR** + Singapore ITR + + - **SLV_NIT** + El Salvador NIT + + - **SWE_TAX_ID** + Sweden Tax ID (Personnummer) + + - **URY_RUT** + Uruguay RUT + + - **VEN_RIF** + Venezuela RIF + + - **NOT_SPECIFIED** + Other Tax IDs + example: USA_SSN + ApplicationDocument: + type: object + description: | + If an account has documents on the application submission, + it has the ApplicationDocument model in exchange with + DocumentUpload. + properties: + id: + type: string + format: uuid + document_type: + $ref: '#/components/schemas/DocumentType' + document_sub_type: + type: string + mime_type: + type: string + created_at: + type: string + format: date-time + required: + - id + - document_type + - created_at + example: + id: 0d18ae51-3c94-4511-b209-101e1666416b + document_type: identity_verification + document_sub_type: passport + mime_type: image/jpeg + created_at: '2019-09-30T23:55:31.185998Z' + DocumentUpload: + type: object + description: | + If an account has documents after the submission, it has + the Document model in exchange with DocumentUpload. + properties: + document_type: + $ref: '#/components/schemas/DocumentType' + document_sub_type: + type: string + example: passport + content: + type: string + format: base64 + example: /9j/Cg== + mime_type: + type: string + example: image/jpeg + required: + - document_type + - content + - mime_type + example: + document_type: identity_verification + document_sub_type: passport + content: /9j/Cg== + mime_type: image/jpeg + Activity: + title: Activity + description: Base for activity types + allOf: + - type: object + properties: + id: + type: string + example: '20220208125959696::88b5f678-fef5-447b-af15-f21e367e6d8c' + account_id: + type: string + format: uuid + example: c8f1ef5d-edc0-4f23-9ee4-378f19cb92a4 + activity_type: + $ref: '#/components/schemas/ActivityType' + - oneOf: + - $ref: '#/components/schemas/TradeActivity' + - $ref: '#/components/schemas/NonTradeActivity' + required: + - id + - activity_type + ActivityType: + title: ActivityType + type: string + enum: + - FILL + - ACATC + - ACATS + - CIL + - CSD + - CSW + - DIV + - DIVCGL + - DIVCGS + - DIVNRA + - DIVROC + - DIVTXEX + - FEE + - INT + - JNLC + - JNLS + - MA + - PTC + - REORG + - SPIN + - SPLIT + description: |- + Represents the various kinds of activity. + + TradeActivity's will always have the type `FILL` + + - **FILL** + Order Fills (Partial/Full) + - **ACATC** + ACATS IN/OUT (Cash) + - **ACATS** + ACATS IN/OUT (Securities) + - **CIL** + Cash in Lieu of Stock + - **CSD** + Cash Disbursement (+) + - **CSW** + Cash Withdrawable + - **DIV** + Dividend + - **DIVCGL** + Dividend (Capital Gain Long Term) + - **DIVCGS** + Dividend (Capital Gain Short Term) + - **DIVNRA** + Dividend Adjusted (NRA Withheld) + - **DIVROC** + Dividend Return of Capital + - **DIVTXEX** + Dividend (Tax Exempt) + - **FEE** + REG and TAF Fees + - **INT** + Interest (Credit/Margin) + - **JNLC** + Journal Entry (Cash) + - **JNLS** + Journal Entry (Stock) + - **MA** + Merger/Acquisition + - **PTC** + Pass Thru Change + - **REORG** + Reorg CA + - **SPIN** + Stock Spinoff + - **SPLIT** + Stock Split + TradeActivity: + title: TradeActivity + type: object + properties: + transaction_time: + type: string + format: date-time + example: '2021-05-10T14:01:04.650275Z' + description: Valid only for trading activity types. Null for non-trading activites. + type: + type: string + enum: + - fill + - partial_fill + example: fill + description: Valid only for trading activity types. Null for non-trading activites. + price: + type: string + format: decimal + example: '3.1415' + description: Valid only for trading activity types. Null for non-trading activites. + qty: + type: string + format: decimal + example: '0.38921' + description: Valid only for trading activity types. Null for non-trading activites. + side: + $ref: '#/components/schemas/OrderSide' + symbol: + type: string + example: AAPL + description: Valid only for trading activity types. Null for non-trading activites. + leaves_qty: + type: string + format: decimal + example: '0.5123' + description: Valid only for trading activity types. Null for non-trading activites. + order_id: + type: string + format: uuid + example: fe060a1b-5b45-4eba-ba46-c3a3345d8255 + description: Valid only for trading activity types. Null for non-trading activites. + cum_qty: + type: string + format: decimal + example: '0.9723' + description: Valid only for trading activity types. Null for non-trading activites. + order_status: + $ref: '#/components/schemas/OrderStatus' + NonTradeActivity: + title: NonTradeActivity + type: object + properties: + date: + type: string + format: date + example: '2021-05-21' + description: Valid only for non-trading activity types. Null for trading activites. + net_amount: + type: string + format: decimal + example: '1234' + description: Valid only for non-trading activity types. Null for trading activites. + description: + type: string + example: Example description + description: Valid only for non-trading activity types. Null for trading activites. + status: + type: string + enum: + - executed + - correct + - canceled + example: executed + description: Valid only for non-trading activity types. Null for trading activites. + symbol: + type: string + example: AAPL + description: Valid only for non-trading activity types. Null for trading activites. + qty: + type: string + format: decimal + example: '0.38921' + description: Valid only for non-trading activity types. Null for trading activites. + per_share_amount: + type: string + format: decimal + example: '0.38921' + description: Valid only for non-trading activity types. Null for trading activites. + ActivityItem: + title: ActivityItem + anyOf: + - $ref: '#/components/schemas/TradeActivity' + - $ref: '#/components/schemas/NonTradeActivity' + DocumentType: + type: string + enum: + - identity_verification + - address_verification + - date_of_birth_verification + - tax_id_verification + - account_approval_letter + - cip_result + description: | + - identity_verification: + identity verification document + + - address_verification: + address verification document + + - date_of_birth_verification: + date of birth verification document + + - tax_id_verification: + tax ID verification document + + - account_approval_letter: + 407 approval letter + + - cip_result: + initial CIP result + example: identity_verification + DocumentUploadRequest: + type: object + description: | + If an account has documents after the submission, it has + the Document model in exchange with DocumentUploadRequest. + properties: + document_type: + $ref: '#/components/schemas/DocumentType' + document_sub_type: + type: string + example: passport + content: + type: string + format: base64 + example: /9j/Cg== + mime_type: + type: string + example: image/jpeg + required: + - document_type + - content + - mime_type + example: + document_type: identity_verification + document_sub_type: passport + content: /9j/Cg== + mime_type: image/jpeg + title: DocumentUploadRequest + x-examples: + example-1: + document_type: identity_verification + document_sub_type: passport + content: /9j/Cg== + mime_type: image/jpeg + KYCResult: + type: object + description: 'Hold information about the result of KYC. Please see the documentation [here](https://alpaca.markets/docs/api-references/broker-api/events/#kyc-results) for more indepth details' + properties: + reject: + type: object + accept: + type: object + indeterminate: + type: object + addidional_information: + type: string + StreetAddress: + type: string + example: 20 N San Mateo Dr + Contact: + type: object + description: | + Contact is the model for the account owner contact information. + properties: + email_address: + type: string + format: email + example: john.doe@example.com + phone_number: + type: string + description: 'with country code, no hyphen or space' + example: '+15556667788' + street_address: + type: array + items: + $ref: '#/components/schemas/StreetAddress' + city: + type: string + example: San Mateo + state: + type: string + example: CA + postal_code: + type: string + example: '94401' + Identity: + type: object + description: | + Identity is the model to provide account owner’s identity information. + example: + given_name: John + family_name: Doe + date_of_birth: '1990-01-01' + tax_id: 666-55-4321 + tax_id_type: USA_SSN + country_of_citizenship: AUS + country_of_birth: AUS + country_of_tax_residence: USA + funding_source: + - employment_income + properties: + given_name: + type: string + example: John + family_name: + type: string + example: Doe + date_of_birth: + type: string + format: date + example: '1990-01-01' + tax_id: + type: string + example: 666-55-4321 + tax_id_type: + $ref: '#/components/schemas/TaxIdType' + country_of_citizenship: + type: string + description: | + [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html). + example: USA + country_of_birth: + type: string + description: | + [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html). + example: USA + country_of_tax_residence: + type: string + description: | + [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html). + example: USA + funding_source: + type: array + items: + type: string + enum: + - employment_income + - investments + - inheritance + - business_income + - savings + - family + annual_income_min: + type: number + annual_income_max: + type: number + liquid_net_worth_min: + type: number + liquid_net_worth_max: + type: number + total_net_worth_min: + type: number + total_net_worth_max: + type: number + extra: + type: object + description: | + any extra information used for KYC purposes + required: + - given_name + - family_name + - date_of_birth + - country_of_tax_residence + - funding_source + Disclosures: + type: object + description: | + Disclosures fields denote if the account owner falls under + each category defined by FINRA rule. The client has to ask + questions for the end user and the values should reflect + their answers. + If one of the answers is true (yes), the account goes into + ACTION_REQUIRED status. + example: + is_control_person: false + is_affiliated_exchange_or_finra: false + is_politically_exposed: false + immediate_family_exposed: false + properties: + employment_status: + type: string + enum: + - unemployed + - employed + - student + - retired + employer_name: + type: string + employer_address: + type: string + employment_position: + type: string + is_control_person: + type: boolean + is_affiliated_exchange_or_finra: + type: boolean + is_politically_exposed: + type: boolean + immediate_family_exposed: + type: boolean + context: + type: array + description: 'Array of annotations describing the rational for marking `is_control_person`, `is_affiliated_exchange_or_finra`, and/or `immediate_family_exposed` as true' + nullable: true + items: + $ref: '#/components/schemas/DisclosureContextAnnotation' + required: + - is_control_person + - is_affiliated_exchange_or_finra + - is_politically_exposed + - immediate_family_exposed + Agreement: + type: object + properties: + agreement: + $ref: '#/components/schemas/AgreementType' + signed_at: + type: string + example: '2019-09-11T18:09:33Z' + format: date-time + ip_address: + type: string + format: ipv4 + example: 185.13.21.99 + revision: + type: string + required: + - agreement + - signed_at + - ip_address + AgreementType: + type: string + title: AgreementType + description: | + - margin_agreement: Alpaca Margin Agreement + - account_agreement: Alpaca Account Agreement + - customer_agreement: Alpaca Customer Agreement + - crypto_agreement: Alpaca Crypto agreement + enum: + - margin_agreement + - account_agreement + - customer_agreement + - crypto_agreement + example: customer_agreement + Agreements: + type: array + description: 'The client has to present Alpaca Account Agreement and Margin Agreement to the end user, and have them read full sentences.' + items: + $ref: '#/components/schemas/Agreement' + TrustedContact: + type: object + description: | + This model input is optional. However, the client should + make reasonable effort to obtain the trusted contact information. + See more details in [FINRA Notice 17-11](https://www.finra.org/sites/default/files/Regulatory-Notice-17-11.pdf) + properties: + given_name: + type: string + example: Jane + family_name: + type: string + example: Doe + email_address: + type: string + format: email + description: | + at least one of `email_address`, `phone_number` or + `street_address` is required + example: jane.doe@example.com + phone_number: + type: string + description: | + at least one of `email_address`, `phone_number` or + `street_address` is required + street_address: + type: array + items: + type: string + description: | + at least one of `email_address`, `phone_number` or + `street_address` is required + city: + type: string + description: | + required if `street_address` is set + state: + type: string + description: | + required if `street_address` is set + postal_code: + type: string + description: | + required if `street_address` is set + country: + type: string + description: | + [ISO 3166-1 alpha-3](https://www.iso.org/iso-3166-country-codes.html). + required if `street_address` is set + required: + - given_name + - family_name + example: + given_name: Jane + family_name: Doe + email_address: jane.doe@example.com + CreateOrderRequest: + type: object + description: '' + properties: + symbol: + type: string + example: AAPL + description: Symbol or asset ID to identify the asset to trade + qty: + type: string + format: decimal + example: '4.124' + description: Number of shares to trade. Can be fractionable for only market and day order types. + notional: + type: string + format: decimal + example: '3' + description: Dollar amount to trade. Cannot work with qty. Can only work for market order types and time_in_force = day. + side: + $ref: '#/components/schemas/OrderSide' + type: + $ref: '#/components/schemas/OrderType' + time_in_force: + $ref: '#/components/schemas/TimeInForce' + limit_price: + type: string + format: decimal + example: '3.14' + description: Required if type is limit or stop_limit + stop_price: + type: string + format: decimal + example: '3.14' + description: Required if type is stop or stop_limit + trail_price: + type: string + format: decimal + example: '3.14' + description: 'If type is trailing_stop, then one of trail_price or trail_percent is required' + trail_percent: + type: string + format: decimal + example: '5.0' + description: 'If type is trailing_stop, then one of trail_price or trail_percent is required' + extended_hours: + type: boolean + example: false + description: 'Defaults to false. If true, order will be eligible to execute in premarket/afterhours. Only works with type limit and time_in_force = day.' + client_order_id: + type: string + example: eb9e2aaa-f71a-4f51-b5b4-52a6c565dad4 + description: A unique identifier for the order. Automatically generated if not sent. (<= 48 characters) + maxLength: 48 + order_class: + $ref: '#/components/schemas/OrderClass' + take_profit: + type: object + description: Takes in a string/number value for limit_price + properties: + limit_price: + type: string + format: decimal + example: '3.14' + stop_loss: + description: Takes in a string/number values for stop_price and limit_price + type: object + properties: + stop_price: + type: string + format: decimal + example: '3.14' + limit_price: + type: string + format: decimal + example: '3.14' + commission: + type: string + format: decimal + example: '1.0' + description: The commission you want to collect from the user. + required: + - symbol + - side + - type + - time_in_force + AssetClass: + type: string + enum: + - us_equity + - crypto + OrderType: + type: string + enum: + - market + - limit + - stop + - stop_limit + - trailing_stop + example: stop + OrderSide: + type: string + enum: + - buy + - sell + - buy_minus + - sell_plus + - sell_short + - sell_short_exempt + - undisclosed + - cross + - cross_short + example: buy + description: Represents what side of the transaction an order was on. + OrderClass: + type: string + enum: + - simple + - bracket + - oco + - oto + example: bracket + TimeInForce: + type: string + enum: + - day + - gtc + - opg + - cls + - ioc + - fok + example: gtc + OrderStatus: + type: string + enum: + - new + - partially_filled + - filled + - done_for_day + - canceled + - expired + - replaced + - pending_cancel + - pending_replace + - accepted + - pending_new + - accepted_for_bidding + - stopped + - rejected + - suspended + - calculated + example: filled + Order: + type: object + properties: + id: + type: string + format: uuid + example: 61e69015-8549-4bfd-b9c3-01e75843f47d + client_order_id: + type: string + example: 61e69015-8549-4bfd-b9c3-01e75843f47d + created_at: + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + updated_at: + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + submitted_at: + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + filled_at: + nullable: true + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + expired_at: + nullable: true + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + canceled_at: + nullable: true + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + failed_at: + nullable: true + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + replaced_at: + nullable: true + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + replaced_by: + nullable: true + type: string + format: uuid + example: 61e69015-8549-4bfd-b9c3-01e75843f47d + replaces: + nullable: true + type: string + format: uuid + example: 61e69015-8549-4bfd-b9c3-01e75843f47d + asset_id: + type: string + format: uuid + example: 61e69015-8549-4bfd-b9c3-01e75843f47d + symbol: + type: string + example: AALP + asset_class: + $ref: '#/components/schemas/AssetClass' + notional: + nullable: true + type: string + format: decimal + example: '4.2' + qty: + nullable: true + type: string + format: decimal + example: '4.2' + filled_qty: + type: string + format: decimal + example: '4.2' + filled_avg_price: + nullable: true + type: string + format: decimal + example: '4.2' + order_class: + $ref: '#/components/schemas/OrderClass' + order_type: + $ref: '#/components/schemas/OrderType' + type: + $ref: '#/components/schemas/OrderType' + side: + $ref: '#/components/schemas/OrderSide' + time_in_force: + $ref: '#/components/schemas/TimeInForce' + limit_price: + nullable: true + type: string + format: decimal + example: '3.14' + stop_price: + nullable: true + type: string + format: decimal + example: '3.14' + status: + $ref: '#/components/schemas/OrderStatus' + extended_hours: + type: boolean + example: true + legs: + nullable: true + type: array + items: + $ref: '#/components/schemas/Order' + trail_price: + nullable: true + type: string + format: decimal + example: '3.14' + trail_percent: + nullable: true + type: string + format: decimal + example: '5.0' + hwm: + nullable: true + type: string + format: decimal + example: '3.14' + commission: + type: string + format: decimal + example: '3.14' + required: + - id + - symbol + UpdateOrderRequest: + type: object + title: OrderUpdateRequest + description: |- + Represents the fields that are editable in an order replace/update call. + + Note: client_order_id is currently not editable on its own, one of the other fields must be changed at the same time to effectively replace the order + properties: + qty: + type: string + format: decimal + example: '4.2' + description: You can only patch full shares for now + time_in_force: + $ref: '#/components/schemas/TimeInForce' + limit_price: + type: string + format: decimal + example: '3.14' + description: Required if original order's `type` field was limit or stop_limit + stop_price: + type: string + format: decimal + example: '3.14' + description: Required if original order's `type` field was stop or stop_limit + trail: + type: string + format: decimal + example: '3.14' + description: The new value of the trail_price or trail_percent + client_order_id: + type: string + example: 61e69015-8549-4bfd-b9c3-01e75843f47d + Bank: + type: object + x-examples: + example-1: + id: 8475c676-68e3-4cfc-a683-9ca2f47a6172 + account_id: 56712986-9ff7-4d8f-8e52-077e099e533e + name: Bank XYZ + status: QUEUED + country: '' + state_province: '' + postal_code: '' + city: '' + street_address: '' + account_number: 123456789abc + bank_code: '123456789' + bank_code_type: ABA + created_at: '2022-02-11T21:35:19.268681613Z' + updated_at: '2022-02-11T21:35:19.268681613Z' + properties: + id: + type: string + format: uuid + example: 61e69015-8549-4bfd-b9c3-01e75843f47d + created_at: + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + description: 'Format: 2020-01-01T01:01:01Z' + updated_at: + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + description: 'Format: 2020-01-01T01:01:01Z' + account_id: + type: string + format: uuid + status: + type: string + enum: + - QUEUED + - SENT_TO_CLEARING + - APPROVED + - CANCELED + description: 'QUEUED, SENT_TO_CLEARING, APPROVED, CANCELED' + name: + type: string + description: Name of recipient bank + bank_code: + type: string + description: 9-Digit ABA RTN (Routing Number) or BIC + bank_code_type: + type: string + enum: + - ABA + - BIC + description: ABA (Domestic) or BIC (International) + country: + type: string + description: Only for international banks + state_province: + type: string + description: Only for international banks + postal_code: + type: string + description: Only for international banks + city: + type: string + description: Only for international banks + street_address: + type: string + description: Only for international banks + account_number: + type: string + required: + - id + - created_at + - updated_at + - name + - bank_code + - bank_code_type + - account_number + CreateBankRequest: + title: CreateBankRequest + type: object + properties: + name: + type: string + description: Name of recipient bank + bank_code: + type: string + description: 9-Digit ABA RTN (Routing Number) or BIC + bank_code_type: + type: string + enum: + - ABA + - BIC + description: ABA (Domestic) or BIC (International) + country: + type: string + description: Only for international banks + state_province: + type: string + description: Only for international banks + postal_code: + type: string + description: Only for international banks + city: + type: string + description: Only for international banks + street_address: + type: string + description: Only for international banks + account_number: + type: string + required: + - name + - bank_code + - bank_code_type + - account_number + description: Represents the possible fields to send when creating a new associated Bank resource for an account + IdentifiedResource: + title: IdentifiedResource + type: object + x-examples: + example-1: + id: 61e69015-8549-4bfd-b9c3-01e75843f47d + created_at: '2021-03-16T18:38:01.942282Z' + updated_at: '2021-03-16T18:38:01.942282Z' + properties: + id: + type: string + format: uuid + example: 61e69015-8549-4bfd-b9c3-01e75843f47d + created_at: + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + description: 'Format: 2020-01-01T01:01:01Z' + updated_at: + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + description: 'Format: 2020-01-01T01:01:01Z' + required: + - id + - created_at + - updated_at + description: 'TODO: Remove this model' + x-internal: true + ACHRelationship: + title: ACHRelationship + type: object + properties: + id: + type: string + format: uuid + example: 61e69015-8549-4bfd-b9c3-01e75843f47d + created_at: + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + description: 'Format: 2020-01-01T01:01:01Z' + updated_at: + type: string + format: date-time + example: '2021-03-16T18:38:01.942282Z' + description: 'Format: 2020-01-01T01:01:01Z' + account_id: + type: string + format: uuid + status: + type: string + enum: + - QUEUED + - APPROVED + - PENDING + - CANCEL_REQUESTED + account_owner_name: + type: string + minLength: 1 + description: Name of the account owner + bank_account_type: + type: string + minLength: 1 + enum: + - CHECKING + - SAVINGS + description: Must be CHECKING or SAVINGS + bank_account_number: + type: string + minLength: 1 + bank_routing_number: + type: string + minLength: 1 + nickname: + type: string + minLength: 1 + required: + - id + - created_at + - updated_at + - account_id + - status + - account_owner_name + CreateACHRelationshipRequest: + description: |- + Represents the fields used in creation of a new ACHRelationship. + + You can create an ACHRelationship by passing the required fields here or if you have an account with Plaid you can use our integration with Plaid to create a relationship. + + Please see the documentation [here](https://alpaca.markets/docs/api-references/broker-api/funding/ach/#plaid-integration-for-bank-transfers) for more info on using Plaid with Alpaca + type: object + title: CreateACHRelationshipRequest + properties: + account_owner_name: + type: string + minLength: 1 + bank_account_type: + type: string + minLength: 1 + enum: + - CHECKING + - SAVINGS + description: Must be CHECKING or SAVINGS + bank_account_number: + type: string + minLength: 1 + description: 'In sandbox, this still must be a valid format' + bank_routing_number: + type: string + minLength: 1 + description: 'In sandbox, this still must be a valid format' + nickname: + type: string + minLength: 1 + processor_token: + type: string + description: 'If using Plaid, you can specify a Plaid processor token here ' + required: + - account_owner_name + - bank_account_type + - bank_account_number + - bank_routing_number + UntypedACHTransferData: + title: UntypedACHTransferData + allOf: + - $ref: '#/components/schemas/UntypedTransferData' + - type: object + properties: + relationship_id: + type: string + format: uuid + required: + - relationship_id + TransferResource: + title: TransferResource + allOf: + - $ref: '#/components/schemas/IdentifiedResource' + - type: object + properties: + type: + type: string + enum: + - ach + - wire + status: + type: string + enum: + - QUEUED + - APPROVAL_PENDING + - PENDING + - SENT_TO_CLEARING + - REJECTED + - CANCELED + - APPROVED + - COMPLETE + - RETURNED + account_id: + type: string + format: uuid + reason: + type: string + nullable: true + expires_at: + type: string + format: date-time + required: + - type + - status + - account_id + - expires_at + - oneOf: + - $ref: '#/components/schemas/UntypedACHTransferData' + - $ref: '#/components/schemas/UntypedWireTransferData' + discriminator: + propertyName: type + mapping: + ach: '#/components/schemas/UntypedACHTransferData' + wire: '#/components/schemas/UntypedWireTransferData' + TransferData: + title: TransferData + allOf: + - type: object + properties: + transfer_type: + type: string + enum: + - ach + - wire + timing: + type: string + enum: + - immediate + required: + - transfer_type + - oneOf: + - $ref: '#/components/schemas/UntypedACHTransferData' + - $ref: '#/components/schemas/UntypedWireTransferData' + discriminator: + propertyName: transfer_type + mapping: + ach: '#/components/schemas/UntypedACHTransferData' + wire: '#/components/schemas/UntypedWireTransferData' + UntypedWireTransferData: + allOf: + - $ref: '#/components/schemas/UntypedTransferData' + - type: object + properties: + additional_information: + type: string + bank_id: + type: string + format: uuid + required: + - bank_id + title: UntypedWireTransferData + UntypedTransferData: + title: UntypedTransferData + type: object + properties: + amount: + type: string + format: decimal + direction: + type: string + enum: + - INCOMING + - OUTGOING + required: + - amount + - direction + CreateTransferRequest: + title: CreateTransferRequest + type: object + properties: + transfer_type: + $ref: '#/components/schemas/TransferType' + relationship_id: + type: string + format: uuid + description: |- + Required if type = `ach` + + The ach_relationship created for the account_id [here](https://alpaca.markets/docs/api-references/broker-api/funding/ach/#creating-an-ach-relationship) + bank_id: + type: string + format: uuid + description: |- + Required if type = `wire` + + The bank_relationship created for the account_id [here](https://alpaca.markets/docs/api-references/broker-api/funding/bank/#creating-a-new-bank-relationship) + amount: + type: string + format: decimal + description: Must be > 0.00 + direction: + $ref: '#/components/schemas/TransferDirection' + timing: + $ref: '#/components/schemas/TransferTiming' + additional_information: + type: string + description: Additional details for when type = `wire` + nullable: true + required: + - transfer_type + - amount + - direction + - timing + description: '[See main docs here](https://alpaca.markets/docs/api-references/broker-api/funding/transfers/#creating-a-transfer-entity)' + Transfer: + title: Transfer + type: object + x-examples: + example-1: + id: 497f6eca-6276-4993-bfeb-53cbbbba6f08 + relationship_id: 81412018-ffa2-43f9-a3eb-d39f1c5e0f87 + bank_id: f1ae96de-94c1-468e-93a3-6b7213930ca8 + account_id: 449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65 + type: ach + status: QUEUED + reason: string + amount: string + direction: INCOMING + created_at: '2019-08-24T14:15:22Z' + updated_at: '2019-08-24T14:15:22Z' + expires_at: '2019-08-24T14:15:22Z' + additional_information: string + description: |- + Transfers allow you to transfer money/balance into your end customers' account (deposits) or out (withdrawal). + + [Main docs here](https://alpaca.markets/docs/api-references/broker-api/funding/transfers/#the-transfer-object) + properties: + id: + type: string + format: uuid + description: The transfer ID + relationship_id: + type: string + format: uuid + description: The ACH relationship ID only present if type = "ach" + bank_id: + type: string + format: uuid + description: 'The ID of the Bank, only present if type = "wire"' + account_id: + type: string + format: uuid + description: The account ID + type: + $ref: '#/components/schemas/TransferType' + status: + $ref: '#/components/schemas/TransferStatus' + reason: + type: string + description: Cause of the status + nullable: true + amount: + type: string + description: Must be > 0.00 + format: decimal + direction: + $ref: '#/components/schemas/TransferDirection' + created_at: + type: string + format: date-time + description: Timedate when transfer was created + updated_at: + type: string + format: date-time + description: Timedate when transfer was updated + expires_at: + type: string + format: date-time + description: Timedate when transfer was expired + additional_information: + type: string + description: Additional information. Only applies when type = "wire". + nullable: true + hold_until: + type: string + format: date-time + instant_amount: + type: string + required: + - id + - account_id + - type + - status + - amount + - direction + - created_at + TransferType: + type: string + example: ach + enum: + - ach + - instant_ach + - wire + description: | + **NOTE:** The Sandbox environment currently only supports `ach` + + - **ach** + Transfer via ACH (US Only). + - **wire** + Transfer via wire (international). + title: TransferType + TransferDirection: + type: string + example: INCOMING + enum: + - INCOMING + - OUTGOING + description: | + - **INCOMING** + Funds incoming to user’s account (deposit). + - **OUTGOING** + Funds outgoing from user’s account (withdrawal). + TransferTiming: + type: string + example: immediate + enum: + - immediate + description: |- + Only `immediate` is currently supported. + + values: + + - **immediate** + + - **next_day** + TransferStatus: + type: string + example: QUEUED + enum: + - QUEUED + - APPROVAL_PENDING + - PENDING + - SENT_TO_CLEARING + - REJECTED + - CANCELED + - APPROVED + - COMPLETE + - RETURNED + description: | + - **QUEUED** + Transfer is in queue to be processed. + - **APPROVAL_PENDING** + Transfer is pending approval. + - **PENDING** + Transfer is pending processing. + - **SENT_TO_CLEARING** + Transfer is being processed by the clearing firm. + - **REJECTED** + Transfer is rejected. + - **CANCELED** + Client initiated transfer cancellation. + - **APPROVED** + Transfer is approved. + - **COMPLETE** + Transfer is completed. + - **RETURNED** + The bank issued an ACH return for the transfer. + Journal: + title: Journal + example: + id: h7h5g33f-ef01-4458-9a4b-9598727a406f + entry_type: JNLS + from_account: 8fjkjn-4483-4199-840f-6c5fe0b7ca24 + to_account: 3gtt65jd-6f2a-433c-8c33-17b66b8941fa + status: executed + symbol: AAPL + qty: '2' + price: '128.23' + x-examples: + example: + id: h7h5g33f-ef01-4458-9a4b-9598727a406f + entry_type: JNLS + from_account: 8fjkjn-4483-4199-840f-6c5fe0b7ca24 + to_account: 3gtt65jd-6f2a-433c-8c33-17b66b8941fa + status: executed + symbol: AAPL + qty: '2' + settle_date: '2020-12-24' + price: '128.23' + example-pending: + id: 6d2cba43-cb57-4534-9603-a6e159167c0a + entry_type: JNLC + from_account: 3dcb795c-3ccc-402a-abb9-07e26a1b1326 + to_account: 2a87c088-ffb6-472b-a4a3-cd9305c8605c + symbol: null + qty: null + price: '0' + status: pending + settle_date: '2022-02-17' + system_date: '2022-02-17' + net_amount: '645' + description: '' + example-queued: + id: 6d2cba43-cb57-4534-9603-a6e159167c0a + entry_type: JNLC + from_account: 3dcb795c-3ccc-402a-abb9-07e26a1b1326 + to_account: 2a87c088-ffb6-472b-a4a3-cd9305c8605c + symbol: '' + qty: null + price: '0' + status: queued + settle_date: null + system_date: null + net_amount: '645' + description: '' + description: 'Represents a cash or security transfer between accounts, as specified by the `entry_type` parameter.' + allOf: + - type: object + properties: + id: + type: string + format: uuid + description: journal ID + entry_type: + $ref: '#/components/schemas/JournalEntryType' + from_account: + type: string + format: uuid + description: account ID the shares go from + to_account: + type: string + format: uuid + description: account ID the shares go to + settle_date: + type: string + format: date + status: + $ref: '#/components/schemas/JournalStatus' + required: + - id + - entry_type + - from_account + - to_account + - settle_date + - oneOf: + - $ref: '#/components/schemas/JNLS' + - $ref: '#/components/schemas/JNLC' + JournalStatus: + type: string + enum: + - pending + - canceled + - executed + - queued + - rejected + - deleted + description: |- + Represents the status that a Journal instance can be in. + + Current Values: + - pending + - canceled + - executed + - queued + - rejected + - deleted + JournalEntryType: + type: string + title: '' + description: |- + This enum represents the various kinds of Journal alpaca supports. + + Current values are: + + - **JNLC** + + Journal Cash between accounts + + - **JNLS** + + Journal Securities between accounts + enum: + - JNLC + - JNLS + JNLS: + example: + id: h7h5g33f-ef01-4458-9a4b-9598727a406s + entry_type: JNLS + from_account: 8fjkjn-4483-4199-840f-6c5fe0b7ca24 + to_account: 3gtt65jd-6f2a-433c-8c33-17b66b8941fa + status: executed + symbol: AAPL + qty: '2' + price: '128.23' + x-examples: + example-1: + id: h7h5g33f-ef01-4458-9a4b-9598727a406f + entry_type: JNLS + from_account: 8fjkjn-4483-4199-840f-6c5fe0b7ca24 + to_account: 3gtt65jd-6f2a-433c-8c33-17b66b8941fa + status: executed + symbol: AAPL + qty: '2' + price: '128.23' + title: JNLS + type: object + description: 'Journal information specific to securities transfers. This field is required for `Journal`s with an `entry_type` of `jnls` (securities transfers), but will be null for those with `jnlc` (cash transfers).' + properties: + symbol: + type: string + description: Only valid for JNLS journals. Null for JNLC. + qty: + type: string + format: decimal + description: Only valid for JNLS journals. Null for JNLC. + price: + type: string + format: decimal + description: Only valid for JNLS journals. Null for JNLC. + required: + - symbol + - qty + - price + JNLC: + example: + id: f45g67h8-d1fc-4136-aa4f-cf4460aecdfc + entry_type: JNLC + from_account: 8fjkjn-4483-4199-840f-6c5fe0b7ca24 + to_account: 3gtt65jd-6f2a-433c-8c33-17b66b8941fa + status: pending + net_amount: '115.5' + description: 'Journal information specific to cash transfers. This field is required for `Journal`s with an `entry_type` of `jnlc` (cash transfers), but will be null for those with `jnls` (securities transfers).' + type: object + title: JNLC + properties: + description: + type: string + description: ID the amount goes to. Only valid for JNLC journals. Null for JNLS. + net_amount: + type: string + format: decimal + description: Only valid for JNLC journals. Null for JNLS. + transmitter_name: + type: string + description: Only valid for JNLC journals. Null for JNLS. Max 255 characters. + transmitter_account_number: + type: string + description: Only valid for JNLC journals. Null for JNLS.max 255 characters + transmitter_address: + type: string + description: Only valid for JNLC journals. Null for JNLS.max 255 characters + transmitter_financial_institution: + type: string + description: Only valid for JNLC journals. Null for JNLS.max 255 characters + transmitter_timestamp: + type: string + format: date-time + description: Only valid for JNLC journals. Null for JNLS. + required: + - net_amount + x-examples: {} + JournalData: + title: JournalData + type: object + properties: + entry_type: + $ref: '#/components/schemas/JournalEntryType' + from_account: + type: string + format: uuid + to_account: + type: string + format: uuid + amount: + type: string + format: decimal + description: | + Required for JNLC. + The dollar amount to move. It has to be + a positive value. + symbol: + type: string + description: | + Required for JNLS. + qty: + type: string + format: decimal + description: | + Required for JNLS. + The number of shares to move. It has to be + a positive value. + required: + - entry_type + - from_account + - to_account + JournalResource: + title: JournalResource + oneOf: + - $ref: '#/components/schemas/JNLC' + - $ref: '#/components/schemas/JNLS' + discriminator: + propertyName: entry_type + mapping: + JNLC: '#/components/schemas/JNLC' + JNLS: '#/components/schemas/JNLS' + CreateJournalRequest: + description: |- + Journals API allows you to move cash or securities from one account to another. + + This model represents the fields you can specify when creating a Journal + + Fixture Rules + + - No Fixtures + - anything below limit is executed immediately + - anything above limit is pending until executed at EOD, + - With Fixtures + - any status = rejected will be rejected EOD + - any status = pending will be pending forever + type: object + x-examples: + example-1: + from_account: c94bu7rn-4483-4199-840f-6c5fe0b7ca24 + entry_type: JNLC + to_account: fn68sbrk-6f2a-433c-8c33-17b66b8941fa + amount: '51' + description: test text /fixtures/status=rejected/fixtures/ + properties: + to_account: + type: string + minLength: 1 + format: uuid + description: The account_id you wish to journal to + from_account: + type: string + minLength: 1 + format: uuid + description: The account_id you wish to journal from + entry_type: + $ref: '#/components/schemas/JournalEntryType' + amount: + type: string + description: Required if `entry_type` = `JNLC` + symbol: + type: string + description: Required if `entry_type` = `JNLS` + qty: + type: string + description: Required if `entry_type` = `JNLS` + description: + type: string + description: Max 1024 characters. Can include fixtures for amounts that are above the transaction limit + maxLength: 1024 + transmitter_name: + type: string + maxLength: 255 + description: 'Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.' + transmitter_account_number: + type: string + maxLength: 255 + description: 'Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.' + transmitter_address: + type: string + maxLength: 255 + description: 'Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.' + transmitter_financial_institution: + type: string + maxLength: 255 + description: 'Max 255 characters. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.' + transmitter_timestamp: + type: string + description: 'RFC 3339 format. See more details about [Travel Rule](https://alpaca.markets/docs/broker/integration/funding/#travel-rule) in our main documentation.' + format: date-time + required: + - to_account + - from_account + - entry_type + BatchJournalRequest: + title: BatchJournalRequest + type: object + description: |- + Journals API allows you to move cash or securities from one account to another. + + This model represents the fields you can specify when creating a request of many Journals out of one account to many others at once. + properties: + entry_type: + type: string + enum: + - JNLC + description: Only supports `JNLC` for now + from_account: + type: string + format: uuid + description: The account id that is the originator of the funds being moved. Most likely is your Sweep Firm Account + description: + type: string + description: 'Journal description, gets returned in the response' + entries: + type: array + minItems: 1 + description: An array of objects describing to what accounts you want to move funds into and how much to move into for each account + items: + type: object + properties: + to_account: + type: string + format: uuid + description: The ID of the account that you want to journal funds into + amount: + type: string + description: Journal amount in USD + required: + - to_account + - amount + required: + - entry_type + - from_account + - entries + BatchJournalResponse: + title: BatchJournalResponse + description: A Journal object with an extra attribute error_message in the case when a specific account fails to receive a journal. + allOf: + - $ref: '#/components/schemas/Journal' + - type: object + properties: + error_message: + type: string + description: Description of why this journal transaction failed + required: + - error_message + x-examples: + example-1: + error_message: '' + id: 56f106e5-25a4-4eee-96fa-25bb05dc86bc + entry_type: JNLC + from_account: 8f8c8cee-2591-4f83-be12-82c659b5e748 + to_account: 399f85f1-cbbd-4eaa-a934-70027fb5c1de + symbol: '' + qty: null + price: null + status: pending + settle_date: null + system_date: null + net_amount: '1000' + description: '' + Asset: + title: Asset + type: object + description: 'Assets are sorted by asset class, exchange and symbol. Some assets are not tradable with Alpaca. These assets will be marked with the flag tradable=false' + properties: + id: + type: string + example: 904837e3-3b76-47ec-b432-046db621571b + format: uuid + description: Asset ID + class: + $ref: '#/components/schemas/AssetClass' + exchange: + $ref: '#/components/schemas/Exchange' + symbol: + type: string + example: AAPL + description: The symbol of the asset + name: + type: string + example: Apple Inc. Common Stock + description: The official name of the asset + status: + type: string + enum: + - active + - inactive + description: active or inactive + example: active + tradable: + type: boolean + example: true + description: Asset is tradable on Alpaca or not + marginable: + type: boolean + example: true + description: Asset is marginable or not + shortable: + type: boolean + example: true + description: Asset is shortable or not + easy_to_borrow: + type: boolean + example: true + description: Asset is easy-to-borrow or not (filtering for easy_to_borrow = True is the best way to check whether the name is currently available to short at Alpaca). + fractionable: + type: boolean + example: true + description: Asset is fractionable or not + last_close_pct_change: + type: string + format: decimal + description: 'Percent change for the trading day as of last market closure. NOTE: This field is currently in this spec however it may not be present in the production environment at time of publishing. It will be coming in a future update at which point this spec should be updated.' + last_price: + type: string + format: decimal + description: 'Most recent available price for this asset on the market. NOTE: This field is currently in this spec however it may not be present in the production environment at time of publishing. It will be coming in a future update at which point this spec should be updated.' + last_close: + type: string + description: 'Last price of the asset upon market closure on the most recent trading day. NOTE: This field is currently in this spec however it may not be present in the production environment at time of publishing. It will be coming in a future update at which point this spec should be updated.' + format: decimal + required: + - id + - class + - symbol + Exchange: + type: string + title: Exchange + example: NASDAQ + description: |- + Represents the exchange where an asset is traded. + + For Stocks: + - AMEX + - ARCA + - BATS + - NYSE + - NASDAQ + - NYSEARCA + - OTC + + For Crypto: + - ERSX + - FTXU + enum: + - AMEX + - ARCA + - BATS + - NYSE + - NASDAQ + - NYSEARCA + - OTC + - ERSX + - FTXU + Position: + description: '' + type: object + x-examples: + example-1: + asset_id: 93f58d0b-6c53-432d-b8ce-2bad264dbd94 + symbol: AAPL + exchange: NASDAQ + asset_class: us_equity + asset_marginable: false + qty: '4' + avg_entry_price: '172.08' + side: long + market_value: '688.32' + cost_basis: '688.32' + unrealized_pl: '0' + unrealized_plpc: '0' + unrealized_intraday_pl: '0' + unrealized_intraday_plpc: '0' + current_price: '172.08' + lastday_price: '168.88' + change_today: '0.0189483657034581' + properties: + asset_id: + type: string + example: 904837e3-3b76-47ec-b432-046db621571b + format: uuid + description: Asset ID + symbol: + type: string + example: AAPL + description: Asset symbol + exchange: + type: string + example: NASDAQ + description: Exchange name of the asset + asset_class: + $ref: '#/components/schemas/AssetClass' + asset_marginable: + type: boolean + description: Indicates if this asset is marginable + avg_entry_price: + type: string + example: '100.0' + description: Average entry price of the position + qty: + type: string + example: '5' + description: The number of shares + side: + type: string + example: long + enum: + - long + - short + market_value: + type: string + format: decimal + example: '600.0' + description: Total dollar amount of the position + cost_basis: + type: string + format: decimal + example: '500.0' + description: Total cost basis in dollar + unrealized_pl: + type: string + format: decimal + example: '100.0' + description: Unrealized profit/loss in dollars + unrealized_plpc: + type: string + format: decimal + example: '0.20' + description: Unrealized profit/loss percent (by a factor of 1) + unrealized_intraday_pl: + type: string + format: decimal + example: '10.0' + description: Unrealized profit/loss in dollars for the day + unrealized_intraday_plpc: + type: string + format: decimal + example: '0.0084' + description: Unrealized interday profit/loss percent (by a factor of 1) + current_price: + type: string + format: decimal + example: '120.0' + description: Current asset price per share + lastday_price: + type: string + format: decimal + example: '119.0' + description: Last day’s asset price per share based on the closing value of the last trading day + change_today: + type: string + format: decimal + example: '0.0084' + description: Percent change from last day price (by a factor of 1) + required: + - asset_id + - symbol + - exchange + - asset_class + - avg_entry_price + - qty + - side + - market_value + - cost_basis + - unrealized_pl + - unrealized_plpc + - unrealized_intraday_pl + - unrealized_intraday_plpc + - current_price + - lastday_price + - change_today + OrderClosedResponse: + title: OrderClosedResponse + type: object + description: | + Represents the result of asking the api to cancel an Order. + x-examples: {} + properties: + id: + type: string + description: UUID of the order that was canceled + format: uuid + status: + type: integer + description: Http status code for the attempt to close this Order + body: + $ref: '#/components/schemas/Order' + required: + - id + - status + PositionClosedResponse: + title: PositionClosedResponse + type: object + description: |- + Represents the result of asking the api to close a position. + + `body` is the Order used to close out the position. + x-examples: + example-1: + symbol: AAPL + status: 200 + body: + id: f7f25e89-939a-4587-aaf6-414a6b3c341d + client_order_id: 52f8574c-96d5-49b6-94c1-2570a268434e + created_at: '2022-02-04T16:53:29.53427917Z' + updated_at: '2022-02-04T16:53:29.53427917Z' + submitted_at: '2022-02-04T16:53:29.533738219Z' + filled_at: null + expired_at: null + canceled_at: null + failed_at: null + replaced_at: null + replaced_by: null + replaces: null + asset_id: b0b6dd9d-8b9b-48a9-ba46-b9d54906e415 + symbol: AAPL + asset_class: us_equity + notional: null + qty: '2' + filled_qty: '0' + filled_avg_price: null + order_class: '' + order_type: market + type: market + side: sell + time_in_force: day + limit_price: null + stop_price: null + status: accepted + extended_hours: false + legs: null + trail_percent: null + trail_price: null + hwm: null + commision: '1.0' + properties: + symbol: + type: string + description: Symbol name of the asset + status: + type: integer + description: Http status code for the attempt to close this position + body: + $ref: '#/components/schemas/Order' + required: + - symbol + - status + PortfolioHistory: + description: Timeseries data for equity and profit loss information of the account. + type: object + x-examples: + example-1: + timestamp: + - 1580826600000 + - 1580827500000 + - 1580828400000 + equity: + - 27423.73 + - 27408.19 + - 27515.97 + profit_loss: + - 11.8 + - -3.74 + - 104.04 + profit_loss_pct: + - 0.000430469507254688 + - -0.0001364369455197062 + - 0.0037954277571845543 + base_value: 27411.93 + timeframe: 15Min + title: '' + properties: + timestamp: + type: array + description: 'time of each data element, left-labeled (the beginning of time window)' + items: + type: integer + equity: + type: array + description: equity value of the account in dollar amount as of the end of each time window + items: + type: number + nullable: true + profit_loss: + type: array + description: profit/loss in dollar from the base value + items: + type: number + nullable: true + profit_loss_pct: + type: array + description: profit/loss in percentage from the base value + items: + type: number + nullable: true + base_value: + type: number + description: basis in dollar of the profit loss calculation + nullable: true + timeframe: + type: string + description: time window size of each data element + nullable: true + required: + - timestamp + - equity + - profit_loss + - profit_loss_pct + - base_value + - timeframe + Calendar: + title: Calendar + type: object + description: 'The calendar API serves the full list of market days from 1970 to 2029. It can also be queried by specifying a start and/or end time to narrow down the results. In addition to the dates, the response also contains the specific open and close times for the market days, taking into account early closures.' + properties: + date: + type: string + example: '2021-04-06' + format: date + description: Date string in YYYY-MM-DD format + open: + type: string + example: '09:30' + description: 'The time the market opens at on this date in HH:MM format' + close: + type: string + example: '16:00' + description: 'The time the market closes at on this date in HH:MM format' + session_open: + type: string + example: '0700' + deprecated: true + description: this field has been deprecated please ignore + session_close: + type: string + example: '1900' + deprecated: true + description: this field has been deprecated please ignore + required: + - date + - open + - close + Error: + title: Error + type: object + properties: + code: + type: number + message: + type: string + required: + - code + - message + Clock: + description: Represents the current market time and open/close events. + type: object + x-examples: + example: + timestamp: '2018-04-01T12:00:00.000Z' + is_open: true + next_open: '2018-04-01T12:00:00.000Z' + next_close: '2018-04-01T12:00:00.000Z' + example-1: + timestamp: '2022-02-16T13:06:05.210563128-05:00' + is_open: true + next_open: '2022-02-17T09:30:00-05:00' + next_close: '2022-02-16T16:00:00-05:00' + title: Clock + properties: + timestamp: + type: string + minLength: 1 + format: date-time + description: Current timestamp + example: '2022-02-16T13:06:05.210563128-05:00' + is_open: + type: boolean + description: Whether the market is open or not + next_open: + type: string + minLength: 1 + format: date-time + description: Next market open timestamp + next_close: + type: string + minLength: 1 + format: date-time + description: Next market close timestamp + required: + - timestamp + - is_open + - next_open + - next_close + Document: + type: array + description: '' + minItems: 1 + uniqueItems: true + x-examples: + example: + - document_id: b792e8ae-2cb4-4209-85b9-32be4c2fcdd6 + document_type: account_statement + document_date: '2019-08-24' + items: + type: object + properties: + document_id: + type: string + minLength: 1 + format: uuid + document_type: + $ref: '#/components/schemas/DocumentType' + document_date: + type: string + minLength: 1 + format: date-time + required: + - document_id + - document_type + - document_date + AccountStatusEvent: + description: |- + Represents a change in an Account's status, sent over the events streaming api. + + For partners who utilize Alpaca’s KYC service for opening brokerage accounts an additional `kyc_results` object is represented in the account status update events. + type: object + x-examples: + example-1: + account_id: 4db36989-6565-4011-9126-39fe6b3d9bf6 + account_number: '' + at: '2021-06-14T09:59:15.232782Z' + event_id: 122039 + kyc_results: null + status_from: '' + status_to: APPROVED + title: AccountStatusEvent + properties: + account_id: + type: string + minLength: 1 + account_number: + type: string + minLength: 1 + status_from: + $ref: '#/components/schemas/AccountStatus' + status_to: + $ref: '#/components/schemas/AccountStatus' + reason: + type: string + minLength: 1 + description: Optional + at: + type: string + minLength: 1 + description: Timestamp of event + kyc_result: + $ref: '#/components/schemas/KYCResult' + event_id: + type: integer + description: monotonically increasing 64bit integer + required: + - account_id + - account_number + - status_from + - status_to + - reason + - at + - event_id + JournalStatusEvent: + description: | + Represents a change in a Journal's status, sent over the events streaming api. + type: object + x-examples: + example-1: + at: '2021-05-07T10:28:23.163857Z' + entry_type: JNLC + event_id: 1406 + journal_id: 2f144d2a-91e6-46ff-8e37-959a701cc58d + status_from: '' + status_to: queued + title: JournalStatusEvent + properties: + at: + type: string + minLength: 1 + description: Timestamp of event + format: date-time + entry_type: + $ref: '#/components/schemas/JournalEntryType' + event_id: + type: integer + description: Monotonically increasing 64bit integer + journal_id: + type: string + description: The UUID of the related Journal + format: uuid + status_from: + $ref: '#/components/schemas/JournalStatus' + status_to: + $ref: '#/components/schemas/JournalStatus' + required: + - at + - entry_type + - event_id + - journal_id + - status_from + - status_to + TransferStatusEvent: + description: 'Represents a change in a Transfer''s status, sent over the events streaming api.' + type: object + x-examples: + example-1: + account_id: 8e00606a-c9ac-409a-ba45-f55e8f77984a + at: '2021-06-10T19:52:24.066998Z' + event_id: 15961 + status_from: QUEUED + status_to: SENT_TO_CLEARING + transfer_id: c4ed4206-697b-4859-ab71-b9de6649859d + example-2: + account_id: 8e00606a-c9ac-409a-ba45-f55e8f77984a + at: '2021-06-10T20:02:24.280178Z' + event_id: 15962 + status_from: SENT_TO_CLEARING + status_to: COMPLETE + transfer_id: c4ed4206-697b-4859-ab71-b9de6649859d + title: TransferStatusEvent + properties: + account_id: + type: string + minLength: 1 + description: Account UUID + format: uuid + at: + type: string + minLength: 1 + description: Timedate of when the transfer status changed + format: date-time + event_id: + type: integer + description: Monotonically increasing 64bit integer + status_from: + $ref: '#/components/schemas/TransferStatus' + status_to: + $ref: '#/components/schemas/TransferStatus' + transfer_id: + type: string + minLength: 1 + description: Transfer UUID + format: uuid + required: + - account_id + - at + - event_id + - status_from + - status_to + - transfer_id + TradeUpdateEventType: + type: string + description: | + **Common events** + + These are the events that are the expected results of actions you may have taken by sending API requests. + + The meaning of the `timestamp` field changes for each type; the meanings have been specified here for which types the + timestamp field will be present. + + - `new`: Sent when an order has been routed to exchanges for execution. + - `fill`: Sent when your order has been completely filled. + - `timestamp`: The time at which the order was filled. + - `partial_fill`: Sent when a number of shares less than the total remaining quantity on your order has been filled. + - `timestamp`: The time at which the shares were filled. + - `canceled`: Sent when your requested cancellation of an order is processed. + - `timestamp`: The time at which the order was canceled. + - `expired`: Sent when an order has reached the end of its lifespan, as determined by the order’s time in force value. + - `timestamp`: The time at which the order expired. + - `done_for_day`: Sent when the order is done executing for the day, and will not receive further updates until the next trading day. + - `replaced`: Sent when your requested replacement of an order is processed. + - `timestamp`: The time at which the order was replaced. + + **Rarer events** + + These are events that may rarely be sent due to unexpected circumstances on the exchanges. It is unlikely you will need to design your code around them, but you may still wish to account for the possibility that they will occur. + + - `rejected`: Sent when your order has been rejected. + - `timestamp`: The time at which the rejection occurred. + - `pending_new`: Sent when the order has been received by Alpaca and routed to the exchanges, but has not yet been accepted for execution. + - `stopped`: Sent when your order has been stopped, and a trade is guaranteed for the order, usually at a stated price or better, but has not yet occurred. + - `pending_cancel`: Sent when the order is awaiting cancellation. Most cancellations will occur without the order entering this state. + - `pending_replace`: Sent when the order is awaiting replacement. + - `calculated`: Sent when the order has been completed for the day - it is either `filled` or `done_for_day` - but remaining settlement calculations are still pending. + - `suspended`: Sent when the order has been suspended and is not eligible for trading. + - `order_replace_rejected`: Sent when the order replace has been rejected. + - `order_cancel_rejected`: Sent when the order cancel has been rejected. + enum: + - new + - fill + - partial_fill + - canceled + - expired + - done_for_day + - replaced + - rejected + - pending_new + - stopped + - pending_cancel + - pending_replace + - calculated + - suspended + - order_replace_rejected + - order_cancel_rejected + TradeUpdateEvent: + description: 'Represents an update to an order/trade, sent over the events streaming api.' + type: object + title: TradeUpdateEvent + x-examples: + example-1: + account_id: 529248ad-c4cc-4a50-bea4-6bfd2953f83a + at: '2022-04-19T14:12:30.656741Z' + event: new + event_id: 37782 + execution_id: 7e544af3-3104-4e1a-8cbc-dab2624949ff + order: + asset_class: us_equity + asset_id: a4778bc8-fad1-47b7-87fe-d5cde10d43f4 + cancel_requested_at: null + canceled_at: null + client_order_id: 6d873193-dac6-4f72-8e13-c57853a9339d + commission: '1' + created_at: '2022-04-19T10:12:30.57117938-04:00' + expired_at: null + extended_hours: false + failed_at: null + filled_at: null + filled_avg_price: null + filled_qty: '0' + hwm: null + id: edada91a-8b55-4916-a153-8c7a9817e708 + legs: null + limit_price: '700' + notional: null + order_class: '' + order_type: limit + qty: '4' + replaced_at: null + replaced_by: null + replaces: null + side: buy + status: new + stop_price: null + submitted_at: '2022-04-19T10:12:30.403135025-04:00' + symbol: TSLA + time_in_force: day + trail_percent: null + trail_price: null + type: limit + updated_at: '2022-04-19T10:12:30.609783218-04:00' + timestamp: '2022-04-19T14:12:30.602193534Z' + properties: + account_id: + type: string + minLength: 1 + description: Account UUID + format: uuid + at: + type: string + minLength: 1 + description: Timestamp of event + format: date-time + event: + $ref: '#/components/schemas/TradeUpdateEventType' + event_id: + type: integer + format: int64 + description: Monotonically increasing 64bit integer + execution_id: + type: string + description: 'Corresponding execution of an order. If an order gets filled over two executions (a partial_fill for example), you will receive two events with different IDs.' + format: uuid + order: + $ref: '#/components/schemas/Order' + timestamp: + type: string + description: | + Has various different meanings depending on the value of `event`, please see the [Trading Events](https://alpaca.markets/docs/api-references/broker-api/events/#trade-events) + Enum in the documentation or the TradeUpdateEventType model for more details on when it means different things. + format: date-time + required: + - account_id + - at + - event + - event_id + - execution_id + - order + - timestamp + Watchlist: + title: Watchlist + type: object + description: Represents a set of securities observed by a user. + properties: + id: + type: string + format: uuid + description: | + Unique identifier of the watchlist itself. + account_id: + type: string + format: uuid + description: | + Unique identifier of the account that owns this watchlist. + created_at: + type: string + format: date-time + description: When watchlist was created + updated_at: + type: string + format: date-time + description: When watchlist was last updated + name: + type: string + pattern: '^[a-zA-Z0-9]+$' + description: User friendly Name of watchlist + assets: + type: array + description: 'The contents of the watchlist, in the order as registered' + items: + $ref: '#/components/schemas/Asset' + required: + - id + - name + Announcement: + description: |- + The announcements endpoint contains public information on previous and upcoming dividends, mergers, spinoffs, and stock splits. + + Announcement data is made available through the API as soon as it is ingested by Alpaca, which is typically the following trading day after the declaration date. This provides insight into future account stock position and cash balance changes that will take effect on an announcement’s payable date. Additionally, viewing previous announcement details can improve bookkeeping and reconciling previous account cash and position changes. + type: object + x-examples: + example-1: + id: bebc5ece-34be-47e9-b944-687e69a102be + corporate_action_id: 78467X109_AA22 + ca_type: dividend + ca_sub_type: cash + initiating_symbol: DIA + initiating_original_cusip: '252787106' + target_symbol: DIA + target_original_cusip: '252787106' + declaration_date: '2021-12-19' + ex_date: '2022-01-21' + record_date: '2022-01-24' + payable_date: '2022-02-14' + cash: '0' + old_rate: '1' + new_rate: '1' + title: Announcement + properties: + id: + type: string + minLength: 1 + description: ID that is specific to a single announcement. + corporate_action_id: + type: string + minLength: 1 + description: 'ID that remains consistent across all announcements for the same corporate action. Unlike ‘id’, this can be used to connect multiple announcements to see how the terms have changed throughout the lifecycle of the corporate action event.' + ca_type: + $ref: '#/components/schemas/AnnouncementCAType' + ca_sub_type: + $ref: '#/components/schemas/AnnouncementCASubType' + initiating_symbol: + type: string + minLength: 1 + description: Symbol of the company initiating the announcement. + initiating_original_cusip: + type: string + minLength: 1 + description: CUSIP of the company initiating the announcement. + target_symbol: + type: string + minLength: 1 + description: Symbol of the child company involved in the announcement. + nullable: true + target_original_cusip: + type: string + minLength: 1 + description: CUSIP of the child company involved in the announcement. + nullable: true + declaration_date: + type: string + minLength: 1 + description: Date the corporate action or subsequent terms update was announced. + ex_date: + type: string + minLength: 1 + description: The first date that purchasing a security will not result in a corporate action entitlement. + nullable: true + record_date: + type: string + minLength: 1 + description: The date an account must hold a settled position in the security in order to receive the corporate action entitlement. + nullable: true + payable_date: + type: string + minLength: 1 + description: 'The date the announcement will take effect. On this date, account stock and cash balances are expected to be processed accordingly.' + cash: + type: string + minLength: 1 + description: The amount of cash to be paid per share held by an account on the record date. + nullable: true + old_rate: + type: string + minLength: 1 + description: The denominator to determine any quantity change ratios in positions. + nullable: true + new_rate: + type: string + minLength: 1 + description: The numerator to determine any quantity change ratios in positions. + nullable: true + required: + - id + - corporate_action_id + - ca_type + - ca_sub_type + - initiating_symbol + - initiating_original_cusip + - target_symbol + - target_original_cusip + - declaration_date + - ex_date + - record_date + - payable_date + - cash + - old_rate + - new_rate + AnnouncementCAType: + type: string + description: |- + Announcements have both a type and a subtype to categorize them. This model represents the higher level abstract "types" of Announcement. Please see the AnnouncementCASubType model for finer grain descriptions of the subtypes + + Possible values are: + - dividend + can have `cash` and `stock` subtypes + - merger + has `merger_update` and `merger_completion` sub types + - split + has `stock_split`, `until_split`, `reverse_split`, and `recapitalization` sub types + - spinoff + currently has only the `spinoff` subtype and thus is just this higher level category for now. A disbursement of a newly tradable security when the intiating_symbol creates the target_symbol. + title: '' + enum: + - dividend + - merger + - split + - spinoff + example: dividend + AnnouncementCASubType: + type: string + description: |- + Announcements have both a type and a subtype to categorize them. This model represents the lowever level abstract "sub types" of Announcement. Please see the AnnouncementCAType model for higher level descriptions of the possible types + + Possible values are: + + - from the `dividend` type: + - **cash** + + A cash payment based on the number of shares the account holds on the record date. + - **stock** + + A stock payment based on the number of shares the account holds on the record date. + + - from the `merger` type: + - **merger_update** + + An update to the terms of an upcoming merger. This can happen any number of times before the merger is completed and can be tracked by using the id parameter. + + - **merger_completion** + + A final update in the terms of the merger in which the intiating_symbol will acquire the target_symbol. Any previous terms updates for this announcement will have the same id value. + + - from the `split` type: + - **stock_split** + + An increase in the number of shares outstanding with a decrease in the dollar value of each share. The new_rate and old_rate parameters will be returned in order to derive the ratio of the split + - **until_split** + + An increase in the number of shares outstanding with a decrease in the dollar value of each share. The new_rate and old_rate parameters will be returned in order to derive the ratio of the split. + - **reverse_split** + + A decrease in the number of shares outstanding with an increase in the dollar value of each share. The new_rate and old_rate parameters will be returned in order to derive the ratio of the spli + - **recapitalization** + + A stock recapitalization, typically used by a company to adjust debt and equity ratios. + + - from the `spinoff` type: + - **spinoff** + + A disbursement of a newly tradable security when the intiating_symbol creates the target_symbol. + title: '' + enum: + - cash + - stock + - merger_update + - merger_completion + - stock_split + - until_split + - reverse_split + - recapitalization + - spinoff + OathClientResponse: + title: OathClientResponse + type: object + example: + client_id: 7a3c52a910e1dc2abbb14da2b6b8e711 + name: TradingApp + description: Sample description + url: 'http://test.com' + terms_of_use: '' + privacy_policy: '' + status: ACTIVE + redirect_uri: + - 'http://localhost' + live_trading_approved: true + x-examples: + example-1: + client_id: 7a3c52a910e1dc2abbb14da2b6b8e711 + name: TradingApp + description: Sample description + url: 'http://test.com' + terms_of_use: '' + privacy_policy: '' + status: ACTIVE + redirect_uri: + - 'http://localhost' + live_trading_approved: true + properties: + client_id: + type: string + description: OAuth client id + name: + type: string + description: Broker name (your name) + description: + type: string + url: + type: string + terms_of_use: + type: string + description: URL of Terms of Use + privacy_policy: + type: string + description: URL of Privacy Policy + status: + type: string + enum: + - ACTIVE + - DISABLED + description: ACTIVE or DISABLED + example: ACTIVE + redirect_uri: + type: array + items: + type: string + live_trading_approved: + type: boolean + example: true + OAuthTokenRequest: + title: OAuthTokenRequest + type: object + example: + client_id: 7a3c52a910e1dc2abbb14da2b6b8e711 + client_secret: bbb14da2b6b8e7117a3c52a910e1dc2a + redirect_uri: 'http://localhost' + scope: general + account_id: 0d18ae51-3c94-4511-b209-101e1666416b + properties: + client_id: + type: string + description: OAuth client ID + client_secret: + type: string + description: OAuth client secret + redirect_uri: + type: string + description: redirect URI for the OAuth flow + scope: + type: string + description: scopes requested by the OAuth flow + account_id: + type: string + format: uuid + description: end-user account ID + required: + - client_id + - client_secret + - redirect_uri + - scope + - account_id + description: This model is used for both the Issue and Authorize OAuth token routes + IssueOAuthTokenResponse: + description: '' + type: object + x-examples: + example-1: + access_token: 87586f14-c3f4-4912-b107-f75bc17ff87a + token_type: Bearer + scope: general + properties: + access_token: + type: string + description: OAuth token + token_type: + type: string + description: Always `Bearer` + enum: + - Bearer + example: Bearer + scope: + type: string + description: Token’s scope + required: + - access_token + - token_type + - scope + AuthorizeOAuthTokenResponse: + description: '' + type: object + x-examples: + example-1: + code: 912b5502-c983-40f7-a01d-6a66f13a754d + client_id: 7a3c52a910e1dc2abbb14da2b6b8e711 + redirect_uri: 'http://localhost' + scope: '' + properties: + code: + type: string + minLength: 1 + description: OAuth code to exchange with token + client_id: + type: string + minLength: 1 + description: OAuth `client_id` + redirect_uri: + type: string + minLength: 1 + description: Redirect URI of OAuth flow + scope: + type: string + description: Granted scopes + required: + - code + - client_id + - redirect_uri + - scope + CreateWatchlistRequest: + title: CreateWatchlistRequest + type: object + description: This model represents the fields you can specify when Creating or Updating/Replacing a Watchlist + properties: + name: + type: string + description: The watchlist name + symbols: + type: array + description: The new list of symbol names to watch + items: + type: string + example: '["AAPL", "TSLA"]' + required: + - name + - symbols + DisclosureContextAnnotation: + title: DisclosureContextAnnotation + type: object + properties: + context_type: + type: string + enum: + - CONTROLLED_FIRM + - IMMEDIATE_FAMILY_EXPOSED + - AFFILIATE_FIRM + description: 'Specifies the type of disclosure annotation. Valid types are FINRA affiliations, for users affiliated with or employed by a FINRA member firm, a Stock Exchange Member, FINRA, Registered Investment Advisor, or a Municipal Securities Broker/Dealer; Company control relationships, for senior executives, and 10% or greater shareholders, of a publicly traded company; and immediate family members of politically exposed individuals.' + company_name: + type: string + description: Required for FINRA affiliations and controlled firms. + company_street_address: + type: string + description: Required for FINRA affiliations and controlled firms. + company_city: + type: string + description: Required for FINRA affiliations and controlled firms. + company_state: + type: string + description: Required if and only if `company_country` is `USA`. + company_country: + type: string + description: Required for FINRA affiliations and controlled firms. + company_compliance_email: + type: string + description: Required for FINRA affiliations and controlled firms. + given_name: + type: string + description: Required for immediate family members of politically exposed persons. + family_name: + type: string + description: Required for immediate family members of politically exposed persons. + required: + - context_type + responses: + Forbidden: + description: Request is forbidden + content: + application/json: + schema: + type: string + BadRequest: + description: Malformed input. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + NotAuthorized: + description: Client is not authorized for this operation. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + NotFound: + description: Resource does not exist. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + requestBodies: {} +paths: + /v1/accounts: + get: + tags: + - Accounts + summary: Get all accounts + parameters: + - name: query + in: query + schema: + type: string + description: 'Pass space-delimited tokens. The response will contain accounts that match with each of the tokens (logical AND). A match means the token is present in either the account’s associated account number, phone number, name, or e-mail address (logical OR).' + - schema: + type: string + format: date-time + in: query + name: created_after + - schema: + type: string + format: date-time + in: query + name: created_before + - schema: + type: string + in: query + name: status + description: See the AccountStatus model for values + - $ref: '#/components/parameters/Sort' + - schema: + type: string + in: query + name: entities + description: Comma-delimited entity names to include in the response + responses: + '200': + description: | + The response is a list of Account model up to 1000 items + per query order by created_at. To scroll the result, + please use the created_after parameter. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Account' + operationId: getAllAccounts + description: Retrieves all accounts found by the query' + post: + tags: + - Accounts + summary: Create an account + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AccountCreationRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Account' + '400': + description: The post body is not well formed. + content: + application/json: + schema: + type: string + '409': + description: There is already an existing account registered with the same email address. + '422': + description: One of the input values is not a valid value. + content: + application/json: + schema: + type: string + operationId: createAccount + description: 'Submit an account application with KYC information. This will create a trading account for the end user. The account status may or may not be ACTIVE immediately and you will receive account status updates on the event API. ' + '/v1/accounts/{account_id}': + get: + summary: Get an account by Id. + tags: + - Accounts + description: | + You can query a specific account that you submitted to Alpaca by passing into the query the account_id associated with the account you’re retrieving. + responses: + '200': + description: 'Will return an AccountExtended if an account with account_id exists, otherwise will throw an error.' + content: + application/json: + schema: + $ref: '#/components/schemas/AccountExtended' + operationId: getAccount + patch: + tags: + - Accounts + summary: Update an account + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AccountUpdateRequest' + responses: + '200': + description: 'If all parameters are valid and updates have been made, it returns with status code 200. The response is the account model.' + content: + application/json: + schema: + $ref: '#/components/schemas/AccountExtended' + '400': + description: The post body is not well formed. + content: + application/json: + schema: + type: string + '422': + description: ​ The request body contains an attribute that is not permitted to be updated or you are attempting to set an invalid value. + content: + application/json: + schema: + type: string + operationId: patchAccount + description: |- + This operation updates account information. + + If all parameters are valid and updates have been made, it returns with status code 200. The response is the account model. + delete: + summary: Request to close an account + tags: + - Accounts + responses: + '204': + description: No content. + operationId: deleteAccount + description: This operation closes an active account. + parameters: + - $ref: '#/components/parameters/AccountID' + '/v1/accounts/{account_id}/documents': + get: + summary: Return a list of account documents. + tags: + - Documents + description: 'This endpoint allows you to query all the documents that belong to a certain account. You can filter by date, or type of document.' + parameters: + - name: start_date + in: query + description: optional date value to filter the list (inclusive). + schema: + type: string + format: date + - name: end_date + in: query + description: optional date value to filter the list (inclusive). + schema: + type: string + format: date + - $ref: '#/components/parameters/DocumentType' + responses: + '200': + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Document' + examples: {} + '404': + description: Not found + content: + application/json: + schema: + type: string + operationId: getDocsForAccount + parameters: + - $ref: '#/components/parameters/AccountID' + '/v1/accounts/{account_id}/documents/upload': + post: + tags: + - Accounts + summary: Upload a document to an already existing account + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/DocumentUploadRequest' + responses: + '204': + description: Success (No Content) + '400': + description: Bad Request. The body in the request is not valid. + content: + application/json: + schema: + type: string + '404': + description: Not Found. No account was found for this account_id + content: + application/json: + schema: + type: string + operationId: uploadDocToAccount + description: |- + Upload a document to be attached to an account. + + Documents are binary objects whose contents are encoded in base64. Each encoded content size is limited to 10MB if you use Alpaca for KYCaaS. If you perform your own KYC there are no document size limitations. + parameters: + - $ref: '#/components/parameters/AccountID' + '/v1/accounts/{account_id}/documents/{document_id}/download': + get: + security: + - BasicAuth: [] + summary: Download a document file that belongs to an account. + tags: + - Documents + description: | + This endpoint allows you to download a document identified by the document_id passed in the header. The returned document is in PDF format. + + The operation returns a pre-signed downloadable link as a redirect with HTTP status code 301 if one is found. + responses: + '301': + description: | + Redirect to the pre-signed download link for the document PDF file. + '404': + description: The document is not found. + operationId: downloadDocFromAccount + parameters: + - $ref: '#/components/parameters/AccountID' + - $ref: '#/components/parameters/DocumentID' + '/v1/documents/{document_id}': + get: + security: + - BasicAuth: [] + summary: Download a document file directly + tags: + - Documents + description: | + The operation returns a pre-signed downloadable link as a redirect with HTTP status code 301 if one is found. + responses: + '301': + description: | + Redirect to the pre-signed download link for the document PDF file. + '404': + description: The document was not found. + operationId: downloadDocumentById + parameters: + - $ref: '#/components/parameters/DocumentID' + '/v1/accounts/{account_id}/recipient_banks': + parameters: + - $ref: '#/components/parameters/AccountID' + get: + tags: + - Funding + - Accounts + summary: Retrieve bank relationships for an account + parameters: + - name: status + in: query + schema: + type: string + enum: + - ACTIVE + - INACTIVE + example: ACTIVE + - name: bank_name + in: query + schema: + type: string + responses: + '200': + description: Success. Returns the bank relationship model. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Bank' + '400': + description: Bad request. The body in the request is not valid. + operationId: getRecipientBanks + description: Retrieves Bank Relationships for an account + post: + tags: + - Funding + - Accounts + summary: Create a Bank Relationship for an account + parameters: + - $ref: '#/components/parameters/AccountID' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateBankRequest' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/Bank' + '400': + description: Bad Request + '409': + description: Conflict + operationId: createRecipientBank + description: 'If successful, retrieves Bank Relationships for an account' + '/v1/accounts/{account_id}/recipient_banks/{bank_id}': + parameters: + - $ref: '#/components/parameters/AccountID' + - name: bank_id + in: path + required: true + schema: + type: string + format: uuid + delete: + tags: + - Accounts + - Funding + summary: Delete a Bank Relationship for an account + responses: + '204': + description: Success (No Content) + '400': + description: Bad Request + '404': + description: Bank Not Found + operationId: deleteRecipientBank + description: 'If successful, deletes Bank Relationship for an account' + '/v1/accounts/{account_id}/transfers': + parameters: + - $ref: '#/components/parameters/AccountID' + get: + summary: Return a list of transfers for an account. + tags: + - Funding + - Accounts + description: | + You can query a list of transfers for an account. + + + You can filter requested transfers by values such as direction and status. + parameters: + - name: direction + in: query + schema: + enum: + - INCOMING + - OUTGOING + type: string + description: INCOMING or OUTGOING + - name: limit + in: query + schema: + type: integer + format: int32 + - name: offset + in: query + schema: + type: integer + format: int32 + responses: + '200': + description: Success. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Transfer' + examples: + example-1: + value: + - id: 497f6eca-6276-4993-bfeb-53cbbbba6f08 + relationship_id: 81412018-ffa2-43f9-a3eb-d39f1c5e0f87 + bank_id: f1ae96de-94c1-468e-93a3-6b7213930ca8 + account_id: 449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65 + type: ach + status: QUEUED + reason: string + amount: string + direction: INCOMING + created_at: '2019-08-24T14:15:22Z' + updated_at: '2019-08-24T14:15:22Z' + expires_at: '2019-08-24T14:15:22Z' + additional_information: string + example-2: + value: + - id: 497f6eca-6276-4993-bfeb-53cbbbba6f08 + relationship_id: 81412018-ffa2-43f9-a3eb-d39f1c5e0f87 + bank_id: f1ae96de-94c1-468e-93a3-6b7213930ca8 + account_id: 449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65 + type: ach + status: QUEUED + reason: string + amount: string + direction: INCOMING + created_at: '2019-08-24T14:15:22Z' + updated_at: '2019-08-24T14:15:22Z' + expires_at: '2019-08-24T14:15:22Z' + additional_information: string + operationId: getTransfersForAccount + post: + summary: Request a new transfer + tags: + - Funding + - Accounts + description: |- + Create a new transfer to an account to fund it. + + In the sandbox environment, you can instantly deposit to or withdraw from an account with a virtual money amount. In the production environment, this endpoint is used only for requesting an outgoing (withdrawal) wire transfer at this moment. For the wire transfer (in production), you need to create a bank resource first using the Bank API. For more on how to fund an account in sandbox please check out this tutorial [here](https://alpaca.markets/learn/fund-broker-api/). + parameters: + - name: account_id + in: path + required: true + schema: + type: string + format: uuid + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateTransferRequest' + responses: + '200': + description: Successfully requested a transfer. + content: + application/json: + schema: + $ref: '#/components/schemas/Transfer' + operationId: createTransferForAccount + '/v1/accounts/{account_id}/transfers/{transfer_id}': + parameters: + - $ref: '#/components/parameters/AccountID' + - schema: + type: string + format: uuid + name: transfer_id + in: path + required: true + description: Tranfer identifier + delete: + summary: Request to close a transfer + operationId: deleteTransfer + responses: + '204': + description: Success (No Content) + '404': + $ref: '#/components/responses/NotFound' + description: Request to close a transfer + tags: + - Accounts + - Funding + /v1/accounts/activities: + get: + tags: + - Accounts + summary: Retrieve account activities + parameters: + - name: account_id + in: query + schema: + type: string + format: uuid + description: id of a single account to filter by + - name: date + in: query + schema: + type: string + description: 'Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported.' + - name: until + in: query + schema: + type: string + description: 'Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported.' + - name: after + in: query + schema: + type: string + description: 'Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported. Cannot be used with date.' + - $ref: '#/components/parameters/Direction' + - name: page_size + in: query + schema: + type: integer + minimum: 1 + maximum: 100 + default: 100 + description: The maximum number of entries to return in the response + - in: query + name: page_token + description: 'The Activity ID of the end of your current page of results. ' + schema: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Activity' + operationId: getAccountActivities + description: |- + Returns an array of Activities + + Notes: + * Pagination is handled using the `page_token` and `page_size` parameters. + * `page_token` represents the ID of the end of your current page of results. + for example if in your first response the id of the last Activiy item returned in the array was `20220203000000000::045b3b8d-c566-4bef-b741-2bf598dd6ae7`, you'd pass that value as `page_token` to get the next page of results + + * If specified with a `direction` of `desc`, for example, the results will end before the activity with the specified ID. + * If specified with a `direction` of `asc`, results will begin with the activity immediately after the one specified. + * `page_size` is the maximum number of entries to return in the response. + * If `date` is not specified, the default and maximum value is 100. + * If `date` is specified, the default behavior is to return all results, and there is no maximum page size. + '/v1/accounts/activities/{activity_type}': + parameters: + - $ref: '#/components/parameters/ActivityType' + get: + tags: + - Accounts + parameters: + - name: account_id + in: query + schema: + type: string + format: uuid + description: id of a single account to filter by + - name: date + in: query + schema: + type: string + format: date-time + description: 'Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported.' + - name: until + in: query + schema: + type: string + format: date-time + description: 'Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported.' + - name: after + in: query + schema: + type: string + format: date-time + description: 'Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ supported.' + - $ref: '#/components/parameters/Direction' + - name: page_size + in: query + schema: + type: integer + minimum: 1 + maximum: 100 + default: 100 + description: The maximum number of entries to return in the response + - name: page_token + in: query + schema: + type: string + description: The ID of the end of your current page of results + summary: Retrieve specific account activities + responses: + '200': + description: Success + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Activity' + operationId: getAccountActivitiesByType + description: |- + Retrieves an Array of Activies by type + + Notes: + * Pagination is handled using the `page_token` and `page_size` parameters. + * `page_token` represents the ID of the end of your current page of results. + for example if in your first response the id of the last Activiy item returned in the array was `20220203000000000::045b3b8d-c566-4bef-b741-2bf598dd6ae7`, you'd pass that value as `page_token` to get the next page of results + + * If specified with a `direction` of `desc`, for example, the results will end before the activity with the specified ID. + * If specified with a `direction` of `asc`, results will begin with the activity immediately after the one specified. + * `page_size` is the maximum number of entries to return in the response. + * If `date` is not specified, the default and maximum value is 100. + * If `date` is specified, the default behavior is to return all results, and there is no maximum page size. + '/v1/accounts/{account_id}/ach_relationships': + parameters: + - $ref: '#/components/parameters/AccountID' + get: + summary: Retrieve ACH Relationships for an account + tags: + - Accounts + - Funding + responses: + '200': + description: Success + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ACHRelationship' + operationId: getAccountACHRelationships + description: Returns a list of ACH Relationships for an account + parameters: + - schema: + type: string + in: query + name: statuses + description: Comma-separated status values + post: + summary: Create an ACH Relationship + operationId: createACHRelationshipForAccount + responses: + '200': + description: returns the newly created ACH Relationship entity. + content: + application/json: + schema: + $ref: '#/components/schemas/ACHRelationship' + '400': + $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/NotAuthorized' + '409': + description: The account already has an active relationship. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: |- + Create a new ACHRelationship for an account + + If successful, will return 200 code with a newly created ACH Relationship entity. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateACHRelationshipRequest' + description: 'Create ACH Relationship ' + tags: + - Accounts + - Funding + '/v1/accounts/{account_id}/ach_relationships/{ach_relationship_id}': + parameters: + - $ref: '#/components/parameters/AccountID' + - schema: + type: string + format: uuid + name: ach_relationship_id + in: path + description: ACH relationship identifier + required: true + delete: + summary: Delete an existing ACH relationship + operationId: deleteACHRelationshipFromAccount + responses: + '204': + description: Success (No Content) + '400': + description: the passed in account_id or relationship_id were invalid + '404': + $ref: '#/components/responses/NotFound' + description: Delete an existing ACH relationship for an account + tags: + - Accounts + - Funding + '/v1/trading/accounts/{account_id}/account': + parameters: + - $ref: '#/components/parameters/AccountID' + get: + operationId: getTradingAccount + summary: Retrieve trading details for an account. + tags: + - Accounts + description: |- + As a broker you can view more trading details about your users. + + The response is a Trading Account model. + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/TradeAccount' + '/v1/trading/accounts/{account_id}/positions': + parameters: + - $ref: '#/components/parameters/AccountID' + get: + summary: List open positions for an account + tags: + - Trading + responses: + '200': + description: Success + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Position' + operationId: getPositionsForAccount + description: List open positions for an account + delete: + summary: Close All Positions for an Account + operationId: closeAllPositionsForAccount + responses: + '207': + description: HTTP 207 Multi-Status with body; an array of objects that include the order id and http status code for each status request. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/PositionClosedResponse' + examples: + example-1: + value: + - symbol: TSLA + status: 200 + body: + id: d1143025-89fc-4952-8936-db2409d899f3 + client_order_id: 17dbfab4-cb86-4e0a-8fa6-f0606b0a9a4e + created_at: '2022-05-13T16:25:29.336330998Z' + updated_at: '2022-05-13T16:25:29.336330998Z' + submitted_at: '2022-05-13T16:25:29.335776073Z' + filled_at: null + expired_at: null + canceled_at: null + failed_at: null + replaced_at: null + replaced_by: null + replaces: null + asset_id: a4778bc8-fad1-47b7-87fe-d5cde10d43f4 + symbol: TSLA + asset_class: us_equity + notional: null + qty: '4' + filled_qty: '0' + filled_avg_price: null + order_class: '' + order_type: market + type: market + side: sell + time_in_force: day + limit_price: null + stop_price: null + status: accepted + extended_hours: false + legs: null + trail_percent: null + trail_price: null + hwm: null + source: null + '500': + description: Failed to liquidate some positions + description: 'Closes (liquidates) all of the account’s open long and short positions. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request.' + parameters: + - schema: + type: boolean + in: query + name: cancel_orders + description: 'If true is specified, cancel all open orders before liquidating all positions.' + tags: + - Trading + '/v1/trading/accounts/{account_id}/positions/{symbol_or_asset_id}': + parameters: + - $ref: '#/components/parameters/AccountID' + - schema: + type: string + name: symbol_or_asset_id + in: path + required: true + description: 'The symbol or asset_id ' + get: + summary: Get an Open Position for account by Symbol or AssetId + responses: + '200': + description: The requested Position object + content: + application/json: + schema: + $ref: '#/components/schemas/Position' + '404': + description: 'Account doesn''t have a position for this symbol or asset_id ' + operationId: getPositionsForAccountBySymbol + description: Retrieves the account’s open position for the given symbol or asset_id. + tags: + - Trading + delete: + summary: Close a Position for an Account + operationId: closePositionForAccountBySymbol + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + description: Closes (liquidates) the account’s open position for the given symbol. Works for both long and short positions. + tags: + - Trading + parameters: + - schema: + type: string + in: query + name: qty + description: Optional the number of shares to liquidate. Can accept up to 9 decimal points. Cannot work with percentage + - schema: + type: string + in: query + description: percentage of position to liquidate. Must be between 0 and 100. Would only sell fractional if position is originally fractional. Can accept up to 9 decimal points. Cannot work with qty + name: percentage + '/v1/trading/accounts/{account_id}/orders/{order_id}': + parameters: + - $ref: '#/components/parameters/AccountID' + - $ref: '#/components/parameters/OrderID' + get: + summary: Retrieves a single order for the given order_id. + tags: + - Trading + description: Retrieves a single order for the given order_id. + responses: + '200': + description: The requested Order object + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + $ref: '#/components/responses/BadRequest' + '404': + $ref: '#/components/responses/NotFound' + operationId: getOrderForAccount + patch: + summary: Replaces a single order with updated parameters + tags: + - Trading + description: |- + Replaces a single order with updated parameters. Each parameter overrides the corresponding attribute of the existing order. The other attributes remain the same as the existing order. + + A success return code from a replaced order does NOT guarantee the existing open order has been replaced. If the existing open order is filled before the replacing (new) order reaches the execution venue, the replacing (new) order is rejected, and these events are sent in the trade_updates stream channel found [here in the market data api](https://alpaca.markets/docs/api-references/market-data-api/#order-updates). + + While an order is being replaced, the account's buying power is reduced by the larger of the two orders that have been placed (the old order being replaced, and the newly placed order to replace it). If you are replacing a buy entry order with a higher limit price than the original order, the buying power is calculated based on the newly placed order. If you are replacing it with a lower limit price, the buying power is calculated based on the old order. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateOrderRequest' + responses: + '200': + description: A new Order object with a new order_id + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + $ref: '#/components/responses/BadRequest' + '403': + description: Buying power or shares are not sufficient + '404': + $ref: '#/components/responses/NotFound' + operationId: replaceOrderForAccount + delete: + summary: Attempts to cancel an open order. + tags: + - Trading + description: |- + Attempts to cancel an open order. If the order is no longer cancelable (for example if the status is "filled"), the server will respond with status 422, and reject the request. + + Upon acceptance of the cancel request, it returns status 204. + responses: + '204': + description: Success (No Content) + '400': + $ref: '#/components/responses/BadRequest' + '404': + $ref: '#/components/responses/NotFound' + operationId: deleteOrderForAccount + '/v1/trading/accounts/{account_id}/orders': + parameters: + - $ref: '#/components/parameters/AccountID' + get: + parameters: + - name: status + in: query + description: 'Order status to be queried. open, closed or all. Defaults to open.' + schema: + type: string + enum: + - open + - closed + - all + - name: limit + in: query + description: The maximum number of orders in response. Defaults to 50 and max is 500. + schema: + type: integer + example: 500 + - $ref: '#/components/parameters/After' + - $ref: '#/components/parameters/Until' + - $ref: '#/components/parameters/Direction' + - schema: + type: boolean + in: query + name: nested + description: 'If true, the result will roll up multi-leg orders under the legs field of primary order.' + - $ref: '#/components/parameters/Symbols' + summary: 'Retrieves a list of orders for the account, filtered by the supplied query parameters.' + tags: + - Trading + description: |- + Retrieves a list of orders for the account, filtered by the supplied query parameters. + + Endpoint defaults to open orders if no parameters are provided. + responses: + '200': + description: 'Retrieves a list of orders for the account, filtered by the supplied query parameters.' + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Order' + '400': + $ref: '#/components/responses/BadRequest' + '404': + $ref: '#/components/responses/NotFound' + operationId: getAllOrdersForAccount + post: + summary: Create an order for an account. + tags: + - Trading + description: Create an order for an account. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateOrderRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + $ref: '#/components/responses/BadRequest' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + operationId: createOrderForAccount + delete: + summary: Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. + tags: + - Trading + description: Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. + responses: + '207': + description: 'HTTP 207 Multi-Status with body, which is an array of objects that include the order id, http status code and an order object for each cancellation request.' + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/OrderClosedResponse' + examples: + example-1: + value: + - id: 872994c5-0620-40ad-8ae0-f224b9948df5 + status: 200 + '400': + $ref: '#/components/responses/BadRequest' + '404': + $ref: '#/components/responses/NotFound' + operationId: deleteAllOrdersForAccount + /v1/assets: + get: + tags: + - Assets + summary: Retrieve all assets + description: Returns all assets + responses: + '200': + description: An array of asset objects. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Asset' + operationId: getAssets + parameters: + - schema: + type: string + enum: + - active + - inactive + - all + example: all + default: all + in: query + name: status + description: 'Asset status to filter by, will default to `all`' + - schema: + type: string + enum: + - us_equity + - crypto + example: us_equity + default: us_equity + in: query + name: asset_class + description: 'Asset class to filter by, `us_equity` or `crypto`. Defaults to `us_equity`' + '/v1/assets/{symbol_or_asset_id}': + parameters: + - name: symbol_or_asset_id + required: true + in: path + schema: + type: string + description: you can use either the asset's Id or the symbol to search + get: + tags: + - Assets + summary: Retrieve an asset by UUID + description: 'Returns the requested asset, if found' + responses: + '200': + description: Returns asset + content: + application/json: + schema: + $ref: '#/components/schemas/Asset' + '404': + description: Asset not found + operationId: getAssetBySymbolOrId + /v1/calendar: + get: + tags: + - Calendar + summary: Query market calendar + parameters: + - name: start + description: The first date to retrieve data for. (Inclusive) in YYYY-MM-DD format + in: query + schema: + type: string + format: date + example: '2022-01-01' + - name: end + description: The last date to retrieve data for. (Inclusive) in YYYY-MM-DD format + in: query + schema: + type: string + format: date + example: '2022-01-01' + responses: + '200': + description: Returns the calendar object + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Calendar' + operationId: queryMarketCalendar + description: 'The calendar API serves the full list of market days from 1970 to 2029. It can also be queried by specifying a start and/or end time to narrow down the results. In addition to the dates, the response also contains the specific open and close times for the market days, taking into account early closures.' + /v1/clock: + get: + tags: + - Clock + summary: Query market clock + responses: + '200': + description: The current market's timestamp + content: + application/json: + schema: + $ref: '#/components/schemas/Clock' + examples: {} + operationId: queryMarketClock + description: 'The Clock API serves the current market timestamp, whether or not the market is currently open, as well as the times of the next market open and close.' + /v1/events/accounts/status: + get: + summary: Subscribe to account status events (SSE). + tags: + - Accounts + - Events + description: | + Events API provide event push as well as historical queries via SSE (server sent events). + + Historical events are streamed immediately if queried, and updates are pushed as events occur. + + Query Params Rules: + - `since` required if `until` specified + - `since_id` required if `until_id` specified + - `since` and `since_id` can’t be used at the same time + Behavior: + - if `since` or `since_id` not specified this will not return any historic data + - if `until` or `until_id` reached stream will end (status 200) + + --- + + Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. + + If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. + parameters: + - name: since + in: query + schema: + type: string + format: date + description: 'Format: YYYY-MM-DD' + - name: until + in: query + schema: + type: string + format: date + description: 'Format: YYYY-MM-DD' + - name: since_id + in: query + schema: + type: integer + - name: until_id + in: query + schema: + type: integer + responses: + '200': + description: Connected. Events will now start streaming as long as you keep the connection open. + content: + text/event-stream: + schema: + type: array + items: + $ref: '#/components/schemas/AccountStatusEvent' + examples: {} + operationId: suscribeToAccountStatusSSE + /v1/events/journals/status: + get: + summary: Subscribe to journal events (SSE). + tags: + - Journals + - Events + description: |- + The Events API provides event push as well as historical queries via SSE (server sent events). + + You can listen to journal status updates as they get processed by our backoffice. + + Historical events are streamed immediately if queried, and updates are pushed as events occur. + + Query Params Rules: + - `since` required if `until` specified + - `since_id` required if `until_id` specified + - `since` and `since_id` can’t be used at the same time + Behavior: + - if `since` or `since_id` not specified this will not return any historic data + - if `until` or `until_id` reached stream will end (status 200) + + --- + + Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. + + If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. + parameters: + - name: since + in: query + schema: + type: string + format: date-time + description: 'Format: YYYY-MM-DD' + - name: until + in: query + schema: + type: string + format: date-time + description: 'Format: YYYY-MM-DD' + - name: since_id + in: query + schema: + type: integer + - name: until_id + in: query + schema: + type: integer + responses: + '200': + description: Connected. Events will now start streaming as long as you keep the connection open. + content: + text/event-stream: + schema: + type: array + items: + $ref: '#/components/schemas/JournalStatusEvent' + operationId: subscribeToJournalStatusSSE + /v1/events/transfers/status: + get: + summary: Subscribe to Transfer Events (SSE) + tags: + - Events + - Funding + responses: + '200': + description: Connected. Events will now start streaming as long as you keep the connection open. + content: + text/event-stream: + schema: + type: array + items: + $ref: '#/components/schemas/TransferStatusEvent' + parameters: + - name: since + in: query + schema: + type: string + format: date-time + description: 'Format: YYYY-MM-DD' + - name: until + in: query + schema: + type: string + format: date-time + description: 'Format: YYYY-MM-DD' + - name: since_id + in: query + schema: + type: integer + - name: until_id + in: query + schema: + type: integer + operationId: subscribeToTransferStatusSSE + description: |- + The Events API provides event push as well as historical queries via SSE (server sent events). + + You can listen to transfer status updates as they get processed by our backoffice, for both end-user and firm accounts. + + Historical events are streamed immediately if queried, and updates are pushed as events occur. + + Query Params Rules: + - `since` required if `until` specified + - `since_id` required if `until_id` specified + - `since` and `since_id` can’t be used at the same time + Behavior: + - if `since` or `since_id` not specified this will not return any historic data + - if `until` or `until_id` reached stream will end (status 200) + + --- + + Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. + + If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. + parameters: [] + /v1/events/trades: + get: + summary: Subscribe to Trade Events (SSE) + tags: + - Events + - Trading + responses: + '200': + description: Connected. Events will now start streaming as long as you keep the connection open. + content: + text/event-stream: + schema: + type: array + items: + $ref: '#/components/schemas/TradeUpdateEvent' + parameters: + - name: since + in: query + schema: + type: string + format: date-time + description: 'Format: YYYY-MM-DD' + - name: until + in: query + schema: + type: string + format: date-time + description: 'Format: YYYY-MM-DD' + - name: since_id + in: query + schema: + type: integer + - name: until_id + in: query + schema: + type: integer + operationId: subscribeToTradeSSE + description: |- + The Events API provides event push as well as historical queries via SSE (server sent events). + + You can listen to events related to trade updates. Most market trades sent during market hours are filled instantly; you can listen to limit order updates through this endpoint. + + Historical events are streamed immediately if queried, and updates are pushed as events occur. + + Query Params Rules: + - `since` required if `until` specified + - `since_id` required if `until_id` specified + - `since` and `since_id` can’t be used at the same time + Behavior: + - if `since` or `since_id` not specified this will not return any historic data + - if `until` or `until_id` reached stream will end (status 200) + + --- + + Note for people using the clients generated from this OAS spec. Currently OAS-3 doesn't have full support for representing SSE style responses from an API, so if you are using a generated client and don't specify a `since` and `until` there is a good chance the generated clients will hang waiting for the response to end. + + If you require the streaming capabilities we recommend not using the generated clients for this specific usecase until the OAS-3 standards come to a consensus on how to represent this correcting in OAS-3. + parameters: [] + /v1/journals: + get: + summary: Return a list of requested journals. + tags: + - Journals + parameters: + - name: after + in: query + schema: + type: string + format: date + description: 'By journal creation date. Format: 2020-01-01' + - name: before + in: query + schema: + type: string + format: date + description: 'By journal creation date. Format: 2020-01-01' + - name: status + in: query + schema: + type: string + enum: + - pending + - canceled + - executed + - queued + - rejected + - deleted + description: See the JournalStatus model for more info + - name: entry_type + in: query + schema: + type: string + enum: + - JNLC + - JNLS + description: JNLC or JNLS + - name: to_account + in: query + schema: + type: string + format: uuid + description: The account id that received the journal + - name: from_account + in: query + schema: + type: string + format: uuid + description: The account id that initiated the journal + responses: + '200': + description: OK + content: + application/json: + schema: + discriminator: + propertyName: entry_type + mapping: + JNLC: '#/components/schemas/JNLC' + JNLS: '#/components/schemas/JNLS' + type: array + items: + $ref: '#/components/schemas/Journal' + operationId: getAllJournals + description: Returns an array of journal objects. + post: + summary: Create a Journal. + tags: + - Journals + description: | + A journal can be JNLC (move cash) or JNLS (move shares), dictated by `entry_type`. Generally, journal requests are subject to approval and starts from the `pending` status. The status changes are propagated through the Event API. Under certain conditions agreed for the partner, such journal transactions that meet the criteria are executed right away. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateJournalRequest' + example: + entry_type: JNLC + from_account: 7c891489-574f-4f9a-82f0-4082a07f4736 + to_account: 2d47a229-0c25-40a2-8cc7-b2c8821ff93a + amount: '115.5' + responses: + '200': + description: The New Journal object + content: + application/json: + schema: + $ref: '#/components/schemas/Journal' + '400': + description: One of the parameters is invalid. + content: + application/json: + schema: + type: string + '403': + description: The amount requested to move is not available. + content: + application/json: + schema: + type: string + '404': + description: One of the account is not found. + content: + application/json: + schema: + type: string + operationId: createJournal + '/v1/journals/{journal_id}': + parameters: + - name: journal_id + in: path + required: true + schema: + type: string + format: uuid + delete: + summary: Cancel a pending journal. + tags: + - Journals + description: 'You can only delete a journal if the journal is still in a pending state, if a journal is executed you will not be able to delete. The alternative is to create a mirror journal entry to reverse the flow of funds.' + responses: + '204': + description: | + The cancel request succeeded. (No-content) + '404': + description: | + The journal is not found. + '422': + description: | + The journal is not in the pending status. + operationId: deleteJournalById + /v1/journals/batch: + post: + summary: Create a Batch Journal Transaction (One-to-Many) + operationId: createBatchJournal + responses: + '200': + description: an array of journal objects with an extra attribute error_message in the case when a specific account fails to receive a journal. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BatchJournalResponse' + examples: {} + description: |- + You can create a batch of journal requests by using this endpoint. This is enabled on JNLC type Journals for now only. + + Every single request must be valid for the entire batch operation to succeed. + + In the case of a successful request, the response will contain an array of journal objects with an extra attribute error_message in the case when a specific account fails to receive a journal. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/BatchJournalRequest' + description: '' + tags: + - Journals + '/v1/oauth/clients/{client_id}': + parameters: + - name: client_id + required: true + in: path + schema: + type: string + format: uuid + get: + summary: Get an OAuth client + tags: + - OAuth + description: | + The endpoint returns the details of OAuth client to display in the authorization page. + parameters: + - name: response_type + in: query + schema: + type: string + enum: + - code + - token + example: token + description: code or token + - name: redirect_uri + in: query + schema: + type: string + example: 'https://example.com/authorize' + description: Redirect URI of the OAuth flow + - name: scope + in: query + schema: + type: string + example: general + description: Requested scopes by the OAuth flow + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/OathClientResponse' + examples: + example-1: + value: + client_id: 7a3c52a910e1dc2abbb14da2b6b8e711 + name: TradingApp + description: Sample description + url: 'http://test.com' + terms_of_use: '' + privacy_policy: '' + status: ACTIVE + redirect_uri: + - 'http://localhost' + live_trading_approved: false + '401': + description: | + Client does not exist or you do not have access to the client. + content: + application/json: + schema: + type: string + operationId: getOAuthClient + /v1/oauth/token: + post: + summary: Issue an OAuth token. + tags: + - OAuth + description: | + The operation issues an OAuth code which can be used in the OAuth code flow. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/OAuthTokenRequest' + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/IssueOAuthTokenResponse' + examples: + example-1: + value: + access_token: 87586f14-c3f4-4912-b107-f75bc17ff87a + token_type: Bearer + scope: general + '401': + description: | + Client does not exists, you do not have access to the client, or “client_secret” is incorrect. + content: + application/json: + schema: + type: string + '422': + description: | + Redirect URI or scope is invalid. + content: + application/json: + schema: + type: string + operationId: issueOAuthToken + /v1/oauth/authorize: + post: + summary: Authorize an OAuth Token + tags: + - OAuth + description: | + The operation issues an OAuth code which can be used in the OAuth code flow. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/OAuthTokenRequest' + responses: + '200': + description: Successfully issued a code. + content: + application/json: + schema: + $ref: '#/components/schemas/AuthorizeOAuthTokenResponse' + '401': + description: | + Client does not exists, you do not have access to the client, or “client_secret” is incorrect. + content: + application/json: + schema: + type: string + '422': + description: | + Redirect URI or scope is invalid. + content: + application/json: + schema: + type: string + operationId: authorizeOAuthToken + '/v1/trading/accounts/{account_id}/watchlists': + parameters: + - schema: + type: string + format: uuid + name: account_id + in: path + required: true + description: Unique identifier of an account. + get: + summary: Retrieve all watchlists + tags: + - Watchlist + responses: + '200': + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Watchlist' + operationId: getAllWatchlistsForAccount + description: Fetch a list of all watchlists currently in an account. + post: + summary: Create a new watchlist + tags: + - Watchlist + operationId: createWatchlistForAccount + description: Returns the watchlist object + responses: + '200': + description: Newly created watchlist + content: + application/json: + schema: + $ref: '#/components/schemas/Watchlist' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateWatchlistRequest' + '/v1/accounts/{account_id}/watchlists/{watchlist_id}': + parameters: + - schema: + type: string + format: uuid + name: account_id + in: path + required: true + description: Unique identifier of an account + - schema: + type: string + format: uuid + name: watchlist_id + in: path + required: true + description: Unique identifier of a watchlist + get: + summary: Manage watchlists + tags: + - Watchlist + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Watchlist' + operationId: getWatchlistForAccountById + description: Fetch a single watchlist by identifier. + put: + summary: Update an existing watchlist + tags: + - Watchlist + operationId: replaceWatchlistForAccountById + responses: + '200': + description: Updated watchlist. + content: + application/json: + schema: + $ref: '#/components/schemas/Watchlist' + description: Replace entirely the set of securities contained in the watchlist while optionally renaming it. Destructive operation. + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateWatchlistRequest' + delete: + summary: Remove a watchlist + tags: + - Watchlist + operationId: deleteWatchlistFromAccountById + responses: + '200': + description: Watchlist deleted. + description: Irrevocably delete a watchlist. + /v1/corporate_actions/announcements: + get: + summary: Retrieving Announcements + tags: + - Corporate Actions + responses: + '200': + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Announcement' + '400': + $ref: '#/components/responses/BadRequest' + operationId: getCorporateAnnouncements + description: This enables searching for an array of corporate action announcements based on criteria. + parameters: + - schema: + type: string + in: query + name: ca_types + description: A comma-delimited list of CorporateActionType values + required: true + - schema: + type: string + format: date + in: query + required: true + name: since + description: The start (inclusive) of the date range when searching corporate action announcements. This should follow the YYYY-MM-DD format. The date range is limited to 90 days. + - schema: + type: string + format: date + in: query + required: true + description: The end (inclusive) of the date range when searching corporate action announcements. This should follow the YYYY-MM-DD format. The date range is limited to 90 days. + name: until + - schema: + type: string + in: query + name: symbol + description: The symbol of the company initiating the announcement. + - schema: + type: string + in: query + name: cusip + description: The CUSIP of the company initiating the announcement. + - schema: + type: string + enum: + - declaration_date + - ex_date + - record_date + - payable_date + in: query + name: date_type + description: |- + An emum of possible ways to use the `since` and `until` parameters to search by. + + the types are: + + - **declaration_date**: The date of the preliminary announcement details or the date that any subsequent term updates took place. + - **ex_date**: The date on which any security purchasing activity will not result in a corporate action entitlement. Any selling activity that takes place on or after this date will result in a corporate action entitlement. + - **record_date**: The date the company checks its records to determine who is shareholder in order to allocate entitlements. + - **payable_date**: The date that the stock and cash positions will update according to the account positions as of the record date. +security: + - BasicAuth: [] diff --git a/crates/alpaca_openapi/openapi/data/openapi.yaml b/crates/alpaca_openapi/openapi/data/openapi.yaml new file mode 100644 index 0000000..759a51c --- /dev/null +++ b/crates/alpaca_openapi/openapi/data/openapi.yaml @@ -0,0 +1,3016 @@ +openapi: 3.0.0 +info: + title: Market Data API + description: 'Access Alpaca’s historical and real-time US stock market and crypto data through REST API and WebSocket. There are APIs for Stock Pricing, Crypto Pricing, and News.' + version: 2.0.0 + contact: + name: Alpaca Support + email: support@alpaca.markets + url: 'https://alpaca.markets/support' + termsOfService: 'https://s3.amazonaws.com/files.alpaca.markets/disclosures/library/TermsAndConditions.pdf' +servers: + - url: 'https://data.alpaca.markets' + description: Production + - description: Sandbox + url: 'https://data.sandbox.alpaca.markets' +tags: + - name: Stock Pricing Data API + - name: Crypto Pricing Data API + - name: News + - name: Logo + - name: Screener + - name: Forex +paths: + /v2/stocks/bars: + get: + tags: + - Stock Pricing Data API + summary: Get Bar data for multiple stock symbols + parameters: + - $ref: '#/components/parameters/stock-symbols' + - $ref: '#/components/parameters/start' + - $ref: '#/components/parameters/end' + - $ref: '#/components/parameters/timeframe' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/page_token' + - $ref: '#/components/parameters/adjustment' + - $ref: '#/components/parameters/feed' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/MultiBarsResponse' + examples: + example-1: + value: + bars: + AAPL: + - t: '2022-02-28T05:00:00Z' + o: 163.02 + h: 165.42 + l: 162.43 + c: 165.12 + v: 90552883 + 'n': 743379 + vw: 164.274348 + TSLA: + - t: '2022-02-28T05:00:00Z' + o: 815.72 + h: 876.86 + l: 814.7075 + c: 870.43 + v: 32122773 + 'n': 848700 + vw: 855.748243 + next_page_token: null + operationId: getBarsForMultipleStockSymbols + description: |- + The Multi Bars API returns aggregate historical data for multiple given ticker symbols over a specified time period. + + Returned results are sorted by symbol first then by Bar timestamp. This means that you are likely to see only one symbol in your first response if there are enough Bars for that symbol to hit the limit you requested on that request. + + In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Bars were found for them. + /v2/stocks/bars/latest: + get: + summary: Get Latest Bar data for multiple stock symbols + tags: + - Stock Pricing Data API + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/LatestMultiBarsResponse' + examples: + example-1: + value: + bars: + AAPL: + t: '2022-03-10T20:01:00Z' + o: 158.715 + h: 158.73 + l: 158.61 + c: 158.615 + v: 1211 + 'n': 21 + vw: 158.680756 + TSLA: + t: '2022-03-10T20:01:00Z' + o: 834.27 + h: 834.27 + l: 832.46 + c: 832.46 + v: 1257 + 'n': 48 + vw: 833.55574 + operationId: getLatestBarsForMultipleStockSymbols + description: The Bars API returns aggregate historical data for the requested security. Returns the latest bar data for the queried stock symbols. + parameters: + - $ref: '#/components/parameters/stock-symbols' + - $ref: '#/components/parameters/feed' + '/v2/stocks/{symbol}/bars': + get: + tags: + - Stock Pricing Data API + summary: Bars + parameters: + - $ref: '#/components/parameters/start' + - $ref: '#/components/parameters/end' + - $ref: '#/components/parameters/timeframe' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/page_token' + - $ref: '#/components/parameters/feed' + - $ref: '#/components/parameters/adjustment' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/BarsResponse' + examples: + getBarsStocks-example-1: + value: + bars: + - t: '2021-02-01T16:01:00Z' + o: 133.32 + h: 133.74 + l: 133.31 + c: 133.5 + v: 9876 + - t: '2021-02-01T16:02:00Z' + o: 133.5 + h: 133.58 + l: 133.44 + c: 133.58 + v: 3567 + symbol: AAPL + next_page_token: MjAyMS0wMi0wMVQxNDowMjowMFo7MQ== + operationId: getBarsForStockSymbol + description: The Bars API returns aggregate historical data for the requested security. Returns bars for the queried stock symbol. + parameters: + - $ref: '#/components/parameters/stock-symbol' + '/v2/stocks/{symbol}/bars/latest': + get: + tags: + - Stock Pricing Data API + summary: Get Latest Bars for Symbol + operationId: getLatestBarForStockSymbol + description: The Bars API returns aggregate historical data for the requested security. Returns the latest bar data for the queried stock symbol. + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/LatestBarResponse' + examples: + example-1: + value: + symbol: AAPL + bar: + t: '2022-03-10T19:26:00Z' + o: 158.035 + h: 158.21 + l: 158.035 + c: 158.21 + v: 800 + 'n': 15 + vw: 158.113144 + parameters: + - $ref: '#/components/parameters/feed' + parameters: + - $ref: '#/components/parameters/stock-symbol' + /v2/stocks/trades: + get: + tags: + - Stock Pricing Data API + summary: Get Trade data for multiple stock symbols + parameters: + - $ref: '#/components/parameters/stock-symbols' + - $ref: '#/components/parameters/start' + - $ref: '#/components/parameters/end' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/page_token' + - $ref: '#/components/parameters/feed' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/MultiTradesResponse' + examples: + geMultiTradesStocks-example-1: + value: + trades: + SPY: + - t: '2021-02-06T13:04:56.334320128Z' + x: C + p: 387.62 + s: 100 + c: + - ' ' + - T + i: 52983525029461 + z: B + - t: '2021-02-06T13:09:42.325484032Z' + x: C + p: 387.69 + s: 100 + c: + - ' ' + - T + i: 52983525033813 + z: B + next_page_token: MjAyMS0wMi0wNlQxMzowOTo0Mlo7MQ== + operationId: getTradesForMultipleStockSymbols + description: |- + The Multi Trades API provides historical trade data for multiple given ticker symbols over a specified time period. + + Returned results are sorted by symbol first then by Trade timestamp. This means that you are likely to see only one symbol in your first response if there are enough Trades for that symbol to hit the limit you requested on that request. + + In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Trades were found for them. + /v2/stocks/trades/latest: + get: + summary: Get Latest Trades data for multiple stock symbols + tags: + - Stock Pricing Data API + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/LatestMultiTradesResponse' + examples: + example-1: + value: + trades: + TSLA: + t: '2022-03-11T17:24:55.143671726Z' + x: V + p: 801.83 + s: 100 + c: + - '@' + i: 9924 + z: C + AAPL: + t: '2022-03-11T17:24:56.321817175Z' + x: V + p: 155.105 + s: 300 + c: + - '@' + i: 7741 + z: C + operationId: getLatestTradesForMultipleStockSymbols + description: Returns the latest trades data for the queried stock symbols. + parameters: + - $ref: '#/components/parameters/stock-symbols' + - $ref: '#/components/parameters/feed' + '/v2/stocks/{symbol}/trades': + get: + tags: + - Stock Pricing Data API + summary: Trades + parameters: + - $ref: '#/components/parameters/start' + - $ref: '#/components/parameters/end' + - name: symbol + in: path + schema: + type: string + required: true + description: The symbol to query for + example: AAPL + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/page_token' + - $ref: '#/components/parameters/feed' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/TradesResponse' + examples: + getTradeStocks-example-1: + value: + trades: + - t: '2021-02-06T13:04:56.334320128Z' + x: C + p: 387.62 + s: 100 + c: + - ' ' + - T + i: 52983525029461 + z: B + - t: '2021-02-06T13:09:42.325484032Z' + x: C + p: 387.69 + s: 100 + c: + - ' ' + - T + i: 52983525033813 + z: B + symbol: SPY + next_page_token: MjAyMS0wMi0wNlQxMzowOTo0Mlo7MQ== + operationId: getTradesForStockSymbol + description: The Trades API provides historical trade data for a given ticker symbol on a specified date. Returns trades for the queried stock signal. + parameters: + - $ref: '#/components/parameters/stock-symbol' + '/v2/stocks/{symbol}/trades/latest': + get: + tags: + - Stock Pricing Data API + summary: Latest Trade + parameters: + - name: symbol + in: path + schema: + type: string + required: true + description: The symbol to query for + example: AAPL + - $ref: '#/components/parameters/feed' + responses: + '200': + description: Successful response + content: + application/json: + examples: + example-1: + value: + symbol: AAPL + trade: + t: '2022-02-01T17:46:51.111055251Z' + x: V + p: 173.06 + s: 100 + c: + - '@' + i: 6519 + z: C + schema: + $ref: '#/components/schemas/LatestTradeResponse' + operationId: getLatestTradeForStockSymbol + description: The Latest Trade API provides the latest trade data for a given ticker symbol. + parameters: + - $ref: '#/components/parameters/stock-symbol' + /v2/stocks/quotes: + get: + tags: + - Stock Pricing Data API + summary: Get Quotes for multiple stock symbols + parameters: + - $ref: '#/components/parameters/stock-symbols' + - $ref: '#/components/parameters/start' + - $ref: '#/components/parameters/end' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/page_token' + - $ref: '#/components/parameters/feed' + responses: + '200': + description: | + Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/MultiQuotesReponse' + examples: + example-1: + value: + quotes: + AAPL: + - t: '2022-03-11T13:13:49.975594385Z' + ax: V + ap: 159.97 + as: 1 + bx: V + bp: 0 + bs: 0 + c: + - R + z: C + next_page_token: QUFQTHwyMDIyLTAzLTExVDEzOjEzOjQ5Ljk3NTU5NDM4NVp8MDFEQzVERDY= + operationId: getQuotesForMultipleStockSymbols + description: |- + The Multi Quotes API provides NBBO quotes for multiple given ticker symbols over a specified time period. + + Returned results are sorted by symbol first then by Quote timestamp. This means that you are likely to see only one symbol in your first response if there are enough Quotes for that symbol to hit the limit you requested on that request. + + In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Quotes were found for them. + /v2/stocks/quotes/latest: + get: + summary: Get Latest Quotes for multiple stock symbols + tags: + - Stock Pricing Data API + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/LatestMultiQuotesResponse' + examples: + example-1: + value: + quotes: + AAPL: + t: '2022-03-11T18:40:13.514830169Z' + ax: V + ap: 156.47 + as: 3 + bx: V + bp: 156.45 + bs: 1 + c: + - R + z: C + TSLA: + t: '2022-03-11T18:40:12.416216587Z' + ax: V + ap: 850 + as: 1 + bx: V + bp: 798 + bs: 2 + c: + - R + z: C + operationId: getLatestQuotesForMultipleStockSymbols + description: Returns the latest quotes data for the queried stock symbols. + parameters: + - $ref: '#/components/parameters/stock-symbols' + - $ref: '#/components/parameters/feed' + '/v2/stocks/{symbol}/quotes': + get: + tags: + - Stock Pricing Data API + summary: Get Quotes for stock symbol + parameters: + - $ref: '#/components/parameters/start' + - $ref: '#/components/parameters/end' + - name: symbol + in: path + schema: + type: string + required: true + description: The symbol to query for + example: AAPL + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/page_token' + - $ref: '#/components/parameters/feed' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/QuotesResponse' + examples: + getQuotesStocks-example-1: + value: + quotes: + - t: '2022-02-01T09:00:00.000448Z' + ax: K + ap: 175 + as: 1 + bx: Q + bp: 174.96 + bs: 4 + c: + - R + z: C + - t: '2022-02-01T09:00:00.000448Z' + ax: K + ap: 175 + as: 12 + bx: Q + bp: 174.96 + bs: 4 + c: + - R + z: C + symbol: AAPL + next_page_token: null + operationId: getQuotesForStockSymbol + description: The Quotes API provides NBBO quotes for a single given ticker symbol at a specified date. Returns quotes (NBBOs) for the querried stock symbol. + parameters: + - $ref: '#/components/parameters/stock-symbol' + '/v2/stocks/{symbol}/quotes/latest': + get: + tags: + - Stock Pricing Data API + summary: Get Latest Quote for stock symbol + parameters: + - name: symbol + in: path + schema: + type: string + required: true + description: The symbol to query for + example: AAPL + - $ref: '#/components/parameters/feed' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/LatestQuoteResponse' + examples: + example-1: + value: + symbol: AAPL + quote: + t: '2022-02-01T17:51:03.204726425Z' + ax: V + ap: 173.24 + as: 4 + bx: V + bp: 173.21 + bs: 4 + c: + - R + z: C + operationId: getLatestQuoteForStockSymbol + description: The Latest Quote API provides the latest quote data for a given ticker symbol. + parameters: + - $ref: '#/components/parameters/stock-symbol' + /v2/stocks/snapshots: + get: + tags: + - Stock Pricing Data API + summary: Get Snapshots for multiple stock symbols + parameters: + - $ref: '#/components/parameters/stock-symbols' + - $ref: '#/components/parameters/feed' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/MultiSnapshotResponse' + examples: + example-1: + value: + AAPL: + latestTrade: + t: '2022-03-11T19:08:43.947998695Z' + x: V + p: 156.055 + s: 100 + c: + - '@' + i: 10593 + z: C + latestQuote: + t: '2022-03-11T19:09:06.125564144Z' + ax: V + ap: 157.2 + as: 5 + bx: V + bp: 156.08 + bs: 1 + c: + - R + z: C + minuteBar: + t: '2022-03-11T19:08:00Z' + o: 156.02 + h: 156.1 + l: 156.02 + c: 156.055 + v: 4483 + 'n': 26 + vw: 156.055956 + dailyBar: + t: '2022-03-11T05:00:00Z' + o: 158.94 + h: 159.25 + l: 154.76 + c: 156.055 + v: 1180799 + 'n': 10408 + vw: 156.545239 + prevDailyBar: + t: '2022-03-10T05:00:00Z' + o: 160.23 + h: 160.38 + l: 155.98 + c: 158.52 + v: 1889292 + 'n': 17072 + vw: 157.845202 + TSLA: + latestTrade: + t: '2022-03-11T19:08:59.479520429Z' + x: V + p: 796.95 + s: 100 + c: + - '@' + i: 13647 + z: C + latestQuote: + t: '2022-03-11T19:09:06.159593323Z' + ax: V + ap: 850 + as: 1 + bx: V + bp: 796.49 + bs: 1 + c: + - R + z: C + minuteBar: + t: '2022-03-11T19:08:00Z' + o: 796.78 + h: 797.4 + l: 796.78 + c: 796.95 + v: 2139 + 'n': 46 + vw: 797.116889 + dailyBar: + t: '2022-03-11T05:00:00Z' + o: 840.38 + h: 843.055 + l: 795.33 + c: 796.95 + v: 466980 + 'n': 13232 + vw: 811.369454 + prevDailyBar: + t: '2022-03-10T05:00:00Z' + o: 851.5 + h: 853.355 + l: 810.76 + c: 838.21 + v: 578475 + 'n': 16118 + vw: 828.766436 + operationId: getSnapshotsForMultipleStockSymbols + description: 'The Snapshot API for multiple tickers provides the latest trade, latest quote, minute bar daily bar and previous daily bar data for the given ticker symbols.' + '/v2/stocks/{symbol}/snapshot': + get: + tags: + - Stock Pricing Data API + summary: Get a Snapshot for a stock symbol + parameters: + - name: symbol + in: path + schema: + type: string + required: true + description: The symbol to query for + example: AAPL + - $ref: '#/components/parameters/feed' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/Snapshot' + examples: + getSnapshotStocks-example-1: + value: + symbol: AAPL + latestTrade: + t: '2021-05-11T20:00:00.435997104Z' + x: Q + p: 125.91 + s: 5589631 + c: + - '@' + - M + i: 179430 + z: C + latestQuote: + t: '2021-05-11T22:05:02.307304704Z' + ax: P + ap: 125.68 + as: 12 + bx: P + bp: 125.6 + bs: 4 + c: + - R + minuteBar: + t: '2021-05-11T22:02:00Z' + o: 125.66 + h: 125.66 + l: 125.66 + c: 125.66 + v: 396 + dailyBar: + t: '2021-05-11T04:00:00Z' + o: 123.5 + h: 126.27 + l: 122.77 + c: 125.91 + v: 125863164 + prevDailyBar: + t: '2021-05-10T04:00:00Z' + o: 129.41 + h: 129.54 + l: 126.81 + c: 126.85 + v: 79569305 + operationId: getSnapshotForStockSymbol + description: 'The Snapshot API for one ticker provides the latest trade, latest quote, minute bar daily bar and previous daily bar data for a given ticker symbol. This endpoint returns the snapshot for the requested security.' + parameters: + - $ref: '#/components/parameters/stock-symbol' + /v1beta1/crypto/trades: + get: + tags: + - Crypto Pricing Data API + summary: Get Trade data for multiple crypto symbols + parameters: + - $ref: '#/components/parameters/start' + - $ref: '#/components/parameters/end' + - $ref: '#/components/parameters/crypto-exchanges' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/page_token' + - $ref: '#/components/parameters/crypto-symbols' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/MultiTradesResponse' + examples: + example-1: + value: + trades: + BTCUSD: + - t: '2022-03-02T06:00:00.028455Z' + x: CBSE + p: 44299.16 + s: 0.001 + tks: B + i: 289852921 + - t: '2022-03-02T06:00:00.028455Z' + x: CBSE + p: 44299.15 + s: 0.001 + tks: B + i: 289852922 + next_page_token: QlRDVVNEfDIwMjItMDMtMDJUMDY6MDA6MDAuMDI4NDU1MDAwWnxDQlNFfDA5MjIzMzcyMDM3MTQ0NjI4NzMw + operationId: getTradesForMultipleCryptoSymbols + description: |- + The Multi Trades API provides historical trade data for a list of given crypto symbols on a specified date. Returns trades for the queried crypto symbols. + + Returned results are sorted by symbol first then by Trade timestamp. This means that you are likely to see only one symbol in your first response if there are enough Trades for that symbol to hit the limit you requested on that request. + + In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Trades were found for them. + /v1beta1/crypto/trades/latest: + get: + summary: Get Latest Trade data for multiple Crypto symbols + tags: + - Crypto Pricing Data API + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/LatestMultiTradesResponse' + examples: + example-1: + value: + trades: + ETHUSD: + t: '2022-03-08T22:13:55.777631Z' + x: FTXU + p: 2562.8 + s: 0.881 + tks: S + i: 26271234 + BTCUSD: + t: '2022-03-08T22:14:47.379901Z' + x: FTXU + p: 38510 + s: 0.05 + tks: B + i: 26271277 + operationId: getLatestTradesForMultipleCryptoSymbols + description: 'Provides latest trade data for a list of given crypto symbols. ' + parameters: + - $ref: '#/components/parameters/crypto-symbols' + - $ref: '#/components/parameters/crypto-exchange' + '/v1beta1/crypto/{symbol}/trades': + get: + tags: + - Crypto Pricing Data API + summary: Get Trade data for a crypto symbol + parameters: + - $ref: '#/components/parameters/start' + - $ref: '#/components/parameters/end' + - $ref: '#/components/parameters/crypto-exchanges' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/page_token' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/TradesResponse' + examples: + example-1: + value: + trades: + - t: '2022-02-27T11:04:55.82622Z' + x: FTXU + p: 39330 + s: 0.0003 + tks: B + i: 25783365 + symbol: BTCUSD + next_page_token: QlRDVVNEfDIwMjItMDItMjdUMTE6MDQ6NTUuODI2MjIwMDAwWnxGVFhVfDA5MjIzMzcyMDM2ODgwNTU5MTcz + operationId: getTradesForCryptoSymbol + description: The Trades API provides historical trade data for a given crypto symbol on a specified date. Returns trades for the queried crypto symbol + parameters: + - $ref: '#/components/parameters/crypto-symbol' + '/v1beta1/crypto/{symbol}/trades/latest': + get: + tags: + - Crypto Pricing Data API + summary: Latest Trades + parameters: + - $ref: '#/components/parameters/crypto-exchange' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/LatestTradeResponse' + examples: + example-1: + value: + symbol: BTCUSD + trade: + t: '2022-03-08T22:27:26.573044Z' + x: FTXU + p: 38614 + s: 0.0019 + tks: S + i: 26271424 + operationId: getLatestTradesForCryptoSymbol + description: The Latest Trades API provides the latest historical trade data for a given crypto symbol. Returns trades for the queried crypto symbol. + parameters: + - $ref: '#/components/parameters/crypto-symbol' + /v1beta1/crypto/bars: + get: + tags: + - Crypto Pricing Data API + summary: Get Bars for multiple Crypto symbols + description: |- + returns aggregate historical data for the requested crypto symbols. + + Returned results are sorted by symbol first then by Bar timestamp. This means that you are likely to see only one symbol in your first response if there are enough Bars for that symbol to hit the limit you requested on that request. + + In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Bars were found for them. + parameters: + - $ref: '#/components/parameters/crypto-symbols' + - $ref: '#/components/parameters/start' + - $ref: '#/components/parameters/end' + - $ref: '#/components/parameters/timeframe' + - $ref: '#/components/parameters/page_token' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/crypto-exchanges' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/MultiBarsResponse' + examples: + example-1: + value: + bars: + BTCUSD: + - t: '2022-02-28T06:00:00Z' + x: FTXU + o: 37866 + h: 44340 + l: 37494 + c: 43241 + v: 2817.008 + 'n': 10116 + vw: 40876.4518611946 + next_page_token: QlRDVVNEfER8MjAyMi0wMi0yOFQwNjowMDowMC4wMDAwMDAwMDBafEZUWFU= + operationId: getBarsForMultipleCryptoSymbols + /v1beta1/crypto/bars/latest: + get: + summary: Get Latest Bars for multiple Crypto symbols + tags: + - Crypto Pricing Data API + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/LatestMultiBarsResponse' + examples: + example-1: + value: + bars: + LINKUSD: + t: '2022-03-08T17:33:00Z' + x: FTXU + o: 13.3565 + h: 13.3565 + l: 13.3565 + c: 13.3565 + v: 41.4 + 'n': 1 + vw: 13.3565 + BTCUSD: + t: '2022-03-08T17:40:00Z' + x: FTXU + o: 39055 + h: 39055 + l: 39055 + c: 39055 + v: 0.1 + 'n': 1 + vw: 39055 + operationId: getLatestBarsForMultipleCryptoSymbols + description: returns latest historical data for the requested crypto symbols for a specific exchange + parameters: + - $ref: '#/components/parameters/crypto-symbols' + - $ref: '#/components/parameters/crypto-exchange' + '/v1beta1/crypto/{symbol}/bars': + get: + tags: + - Crypto Pricing Data API + summary: Get Bar data for a crypto symbol + parameters: + - $ref: '#/components/parameters/start' + - $ref: '#/components/parameters/end' + - $ref: '#/components/parameters/timeframe' + - $ref: '#/components/parameters/crypto-exchanges' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/page_token' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/BarsResponse' + examples: + example-1: + value: + bars: + - t: '2022-02-01T09:04:00Z' + x: CBSE + o: 38702.54 + h: 39013.58 + l: 38702.54 + c: 39013.58 + v: 201.67087877 + 'n': 2965 + vw: 38889.6517051631 + symbol: BTCUSD + next_page_token: QlRDVVNEfE18MjAyMi0wMi0wMVQwOTowNDowMC4wMDAwMDAwMDBafENCU0U= + operationId: getBarsForCryptoSymbol + description: The Bars API returns aggregate historical data for the requested securities.. Returns bars for the queried crypto symbol + parameters: + - $ref: '#/components/parameters/crypto-symbol' + '/v1beta1/crypto/{symbol}/bars/latest': + parameters: + - $ref: '#/components/parameters/crypto-symbol' + get: + summary: Get Latest Bar data for a Crypto symbol + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/LatestBarResponse' + examples: + example-1: + value: + symbol: BTCUSD + bar: + t: '2022-03-08T21:05:00Z' + x: FTXU + o: 38576 + h: 38576 + l: 38576 + c: 38576 + v: 0.063 + 'n': 1 + vw: 38576 + operationId: getLatestBarsForCryptoSymbol + description: Gets latest historical bar data for the requested crypto symbol for a specific exchange + tags: + - Crypto Pricing Data API + parameters: + - $ref: '#/components/parameters/crypto-exchange' + /v1beta1/crypto/quotes: + get: + tags: + - Crypto Pricing Data API + summary: Get Quotes for multiple crypto symbols + parameters: + - $ref: '#/components/parameters/start' + - $ref: '#/components/parameters/end' + - $ref: '#/components/parameters/crypto-exchanges' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/page_token' + - $ref: '#/components/parameters/crypto-symbols' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/MultiQuotesReponse' + examples: + example-1: + value: + quotes: + BTCUSD: + - t: '2022-03-02T06:00:00.057935872Z' + x: FTXU + bp: 44154.14 + bs: 0.1048 + ap: 44427.88 + as: 2.3321 + - t: '2022-03-02T06:00:00.132880896Z' + x: FTXU + bp: 44154.14 + bs: 0.1048 + ap: 44427.88 + as: 2.3321 + next_page_token: QlRDVVNEfDIwMjItMDMtMDJUMDY6MDA6MDAuMTMyODgwODk2WnxGVFhVfEM3QkQ4QjI5 + operationId: getQuotesForMultipleCryptoSymbols + description: |- + The Multi Quotes API provides quotes for a list of given crypto symbols at a specified date. Returns quotes for each of the queried crypto symbols. + + Returned results are sorted by symbol first then by Quote timestamp. This means that you are likely to see only one symbol in your first response if there are enough Quotes for that symbol to hit the limit you requested on that request. + + In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Quotes were found for them. + /v1beta1/crypto/quotes/latest: + get: + summary: Get Latest Quotes for multiple Crypto symbols + tags: + - Crypto Pricing Data API + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/LatestMultiQuotesResponse' + examples: + example-1: + value: + quotes: + ETHUSD: + t: '2022-03-08T22:40:52.536436224Z' + x: FTXU + bp: 2562.99 + bs: 23.798 + ap: 2579.11 + as: 22.155 + BTCUSD: + t: '2022-03-08T22:40:52.662990848Z' + x: FTXU + bp: 38465.26 + bs: 2.641 + ap: 38698.75 + as: 1.3746 + operationId: getLatestQuotesForMultipleCryptoSymbols + description: Provides latest quotes for a list of given crypto symbols. + parameters: + - $ref: '#/components/parameters/crypto-symbols' + - $ref: '#/components/parameters/crypto-exchange' + '/v1beta1/crypto/{symbol}/quotes': + get: + tags: + - Crypto Pricing Data API + summary: Get Quotes for crypto symbol + parameters: + - $ref: '#/components/parameters/start' + - $ref: '#/components/parameters/end' + - $ref: '#/components/parameters/crypto-exchanges' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/page_token' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/QuotesResponse' + examples: + example-1: + value: + quotes: + - t: '2022-02-01T06:00:00.009249124Z' + x: ERSX + bp: 38422.64 + bs: 1.56 + ap: 38515.48 + as: 1.5 + - t: '2022-02-01T06:00:00.009249124Z' + x: ERSX + bp: 38419.54 + bs: 3 + ap: 38515.48 + as: 1.5 + symbol: BTCUSD + next_page_token: null + operationId: getQuotesForCryptoSymbol + description: The Quotes API provides quotes for a given crypto symbol at a specified date. Returns quotes for the queried crypto symbol + parameters: + - $ref: '#/components/parameters/crypto-symbol' + '/v1beta1/crypto/{symbol}/quotes/latest': + get: + tags: + - Crypto Pricing Data API + summary: Latest Quote + parameters: + - $ref: '#/components/parameters/crypto-exchange' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/LatestQuoteResponse' + examples: + example-1: + value: + symbol: BTCUSD + quote: + t: '2022-02-01T20:14:52.486171758Z' + x: ERSX + bp: 38511.45 + bs: 1.5 + ap: 38598.06 + as: 1.556 + operationId: getLatestQuoteForCryptoSymbol + description: Returns latest quote for the queried crypto symbol + parameters: + - $ref: '#/components/parameters/crypto-symbol' + /v1beta1/crypto/snapshots: + get: + tags: + - Crypto Pricing Data API + summary: Get Snapshots for multiple crypto symbols + parameters: + - $ref: '#/components/parameters/crypto-exchange' + - $ref: '#/components/parameters/crypto-symbols' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/MultiSnapshotResponse' + examples: {} + application/xml: + schema: + type: object + properties: {} + multipart/form-data: + schema: + type: object + properties: {} + operationId: getSnapshotsForMultipleCryptoSymbols + description: 'The Multi Snapshot API returns the latest trade, latest quote, minute bar daily bar, and previous daily bar data for list of given crypto symbols.' + parameters: [] + '/v1beta1/crypto/{symbol}/snapshot': + get: + tags: + - Crypto Pricing Data API + summary: Get a Snapshot for a crypto symbol + parameters: + - $ref: '#/components/parameters/crypto-exchange' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/Snapshot' + examples: {} + application/xml: + schema: + type: object + properties: {} + operationId: getSnapshotForCryptoSymbol + description: 'The Snapshot API returns the latest trade, latest quote, minute bar daily bar, and previous daily bar data for a given crypto symbol.' + parameters: + - $ref: '#/components/parameters/crypto-symbol' + /v1beta1/crypto/xbbos/latest: + get: + summary: Get Latest XBBO for multiple crypto symbols + tags: + - Crypto Pricing Data API + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/LatestMultiXBBOResponse' + examples: + example-1: + value: + xbbos: + BTCUSD: + t: '2022-03-08T22:59:49.514811056Z' + ax: ERSX + ap: 38556.7 + as: 1.556151 + bx: FTXU + bp: 38562 + bs: 2.5781 + operationId: getLatestXBBOForMultipleCryptoSymbols + description: Returns the latest XBBO for a given list crypto symbols that calculates the Best Bid and Offer across multiple exchanges. If exchanges is not specified then only the exchanges that can be traded on Alpaca are included in the calculation. + parameters: + - $ref: '#/components/parameters/crypto-symbols' + - $ref: '#/components/parameters/crypto-exchanges' + parameters: [] + '/v1beta1/crypto/{symbol}/xbbo/latest': + get: + tags: + - Crypto Pricing Data API + summary: Get Latest XBBO for a single crypto symbol + parameters: + - $ref: '#/components/parameters/crypto-exchanges' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/LatestXBBOResponse' + examples: + example-1: + value: + symbol: BTCUSD + xbbo: + t: '2022-02-01T20:21:03.323000342Z' + ax: FTXU + ap: 38529 + as: 0.0688 + bx: ERSX + bp: 38534 + bs: 1.5 + operationId: getLatestXBBOForCryptoSymbol + description: Returns the XBBO for a crypto symbol that calculates the Best Bid and Offer across multiple exchanges. If exchanges is not specified then only the exchanges that can be traded on Alpaca are included in the calculation. + parameters: + - $ref: '#/components/parameters/crypto-symbol' + /v1beta1/crypto/meta/spreads: + get: + summary: Get list of crypto spreads per exchange + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/CryptoSpreadsResponse' + examples: + example-1: + value: + spreads: + ERSX: 30 + FTXU: 30 + operationId: getCryptoMetaSpreads + description: Get list of crypto spreads for the different exchanges Alpaca supports in basis points. + tags: + - Crypto Pricing Data API + parameters: [] + /v1beta1/news: + get: + summary: News API + parameters: + - $ref: '#/components/parameters/start' + - $ref: '#/components/parameters/end' + - $ref: '#/components/parameters/crypto-symbols' + - $ref: '#/components/parameters/limit' + - name: sort + in: query + schema: + type: string + enum: + - DESC + - ASC + description: 'Sort articles by updated date. Options: DESC, ASC' + example: DESC + - name: include_content + in: query + schema: + type: boolean + description: Boolean indicator to include content for news articles (if available) + - name: exclude_contentless + in: query + schema: + type: boolean + description: 'Boolean indicator to exclude news articles that do not contain content ' + - $ref: '#/components/parameters/page_token' + responses: + '200': + description: Successful response + content: + application/json: + examples: + news-response-example: + value: + news: + - id: 24843171 + headline: 'Apple Leader in Phone Sales in China for Second Straight Month in November With 23.6% Share, According to Market Research Data' + author: Charles Gross + created_at: '2021-12-31T11:08:42Z' + updated_at: '2021-12-31T11:08:43Z' + summary: 'This headline-only article is meant to show you why a stock is moving, the most difficult aspect of stock trading' + content: '

This headline-only article is meant to show you why a stock is moving, the most difficult aspect of stock trading....

' + url: 'https://www.benzinga.com/news/21/12/24843171/apple-leader-in-phone-sales-in-china-for-second-straight-month-in-november-with-23-6-share-according' + images: [] + symbols: + - AAPL + source: benzinga + next_page_token: MTY0MDk0ODkyMzAwMDAwMDAwMHwyNDg0MzE3MQ== + schema: + $ref: '#/components/schemas/GetNewsResponse' + operationId: getNews + description: Returns latest news articles across stocks and crypto. By default returns latest 10 news articles. + tags: + - News + '/v1beta1/screener/{market_type}/movers': + parameters: + - schema: + type: string + enum: + - stocks + - crypto + name: market_type + in: path + description: Screen specific market (stocks or crypto) + required: true + get: + summary: Get Top Market Movers by Market type + tags: + - Screener + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/MarketMoversResponse' + examples: + example-1: + value: + gainers: + - symbol: AGRI + percent_change: 145.56 + change: 2.46 + price: 4.15 + - symbol: GRCYW + percent_change: 85.63 + change: 0.03 + price: 0.0594 + losers: + - symbol: MTACW + percent_change: -63.07 + change: -0.26 + price: 0.1502 + - symbol: TIG + percent_change: -51.21 + change: -3.61 + price: 3.435 + market_type: stocks + last_updated: '2022-03-10T17:53:30.088309839Z' + operationId: getTopMoversByMarketType + x-internal: true + description: Returns top market movers for stocks. By default will return top 5 market gainers and losers. + parameters: + - schema: + type: integer + default: 10 + maximum: 50 + in: query + name: top + description: Number of top market movers to fetch (gainers and losers). Will return number top for each. By default 10 gainers and 10 losers. + '/v1beta1/logos/{crypto_or_stock_symbol}': + get: + summary: Get Logo for symbol + tags: + - Logo + responses: + '200': + description: Returns the requested logo as an image. + content: + image/*: + schema: + type: string + format: binary + description: the requested logo + '404': + description: No Logo was found for this symbol. This code will only be returned if you set `placeholder` to false. Otherwise we will generate a placeholder image for this symbol + operationId: getLogoForSymbol + description: Returns logo image resource for provided symbol. + parameters: + - schema: + type: boolean + default: true + in: query + name: placeholder + description: If true then the api will generate a placeholder image if no logo was found. Defaults to true + parameters: + - schema: + type: string + name: crypto_or_stock_symbol + in: path + required: true + description: 'The crypto or stock symbol to query for. Note, currently all crypto symbols must be appended with "USD", ie "BTCUSD" would be how you query for BTC.' + /v2/stocks/meta/exchanges: + get: + summary: Get List of supported exchanges + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ExchangesResponse' + examples: + example-1: + value: + Z: Cboe BZ + I: International Securities Exchange + M: Chicago Stock Exchange + U: Members Exchange + L: Long Term Stock Exchange + W: CBOE + X: NASDAQ OMX PSX + B: NASDAQ OMX BX + D: FINRA ADF + J: Cboe EDGA + P: NYSE Arca + Q: NASDAQ OMX + S: NASDAQ Small Cap + V: IEX + A: NYSE American (AMEX) + E: Market Independent + 'N': New York Stock Exchange + T: NASDAQ Int + 'Y': Cboe BYX + C: National Stock Exchange + H: MIAX + K: Cboe EDGX + operationId: getExchanges + description: Returns a json object representing the exchanges we support. The keys are the short form codes you will see in our responses and the values are their respective full names. + tags: + - Stock Pricing Data API + '/v2/stocks/meta/conditions/{type}': + parameters: + - schema: + type: string + enum: + - trade + - quote + example: trade + name: type + in: path + required: true + description: either "trade" or "quote" + get: + summary: Get list of Conditions + responses: + '200': + description: |- + OK + + Response is a JSON object mapping a condition to a plain text description + content: + application/json: + schema: + type: object + additionalProperties: true + examples: + example-trading-A: + value: + '4': Derivatively Priced + '5': Market Center Reopening Trade + '6': Market Center Closing Trade + '7': Qualified Contingent Trade + '8': Reserved + '9': Corrected Consolidated Close Price as per Listing Market + F: Inter-market Sweep Order + O: Market Center Opening Trade + ' ': Regular Sale + B: Average Price Trade + C: Cash Trade (Same Day Clearing) + E: Automatic Execution + M: Market Center Official Close + T: Extended Hours Trade + U: Extended Hours Sold (Out Of Sequence) + I: Odd Lot Trade + K: Rule 127 (NYSE only) or Rule 155 (NYSE MKT only) + R: Seller + X: Cross Trade + Z: Sold (Out Of Sequence) + 'N': Next Day Trade (Next Day Clearing) + P: Prior Reference Price + Q: Market Center Official Open + V: Contingent Trade + H: Price Variation Trade + L: Sold Last (Late Reporting) + example-quote-C: + value: + '4': On Demand Intra Day Auction + U: Manual Bid And Ask Non Firm + B: Manual Bid Automated Ask + R: Regular Two Sided Open + A: Manual Ask Automated Bid + F: Fast Trading + H: Manual Bid And Ask + L: Closed Quote + 'N': Non Firm Quote + I: Order Imbalance + O: Opening Quote Automated + 'Y': No Offer No Bid One Sided Open + X: Order Influx + Z: No Open No Resume + operationId: getConditions + description: |- + Each feed/exchange uses its own set of codes to identify trade and quote conditions, so the same condition may have a different code depending on the originator of the data. + + See [Our documentation](https://alpaca.markets/docs/market-data/#conditions) for more information + parameters: + - schema: + type: string + enum: + - A + - B + - C + example: A + in: query + name: tape + required: true + description: 'What kind of conditions to retrieve, "A" and "B" return CTS, where "C" will give you UTP ' + tags: + - Stock Pricing Data API +components: + securitySchemes: + API_Key: + name: APCA-API-KEY-ID + type: apiKey + in: header + API_Secret: + name: APCA-API-SECRET-KEY + type: apiKey + in: header + schemas: + Trade: + title: Trade + type: object + description: A model representing a trade + x-examples: + trade-example-1: + t: '2021-02-06T13:04:56.334320128Z' + x: C + p: 387.62 + s: 100 + c: + - ' ' + - T + i: 52983525029461 + z: B + example-crypto: + t: '2022-02-27T11:04:55.82622Z' + x: FTXU + p: 39330 + s: 0.0003 + tks: B + i: 25783365 + properties: + t: + type: string + description: Timestamp in RFC-3339 format with nanosecond precision + format: date-time + x: + type: string + description: Exchange where the trade happened. + p: + type: number + description: Trade price. + s: + type: number + description: Trade Size. + c: + type: array + description: Trade conditions (Stock trade only) + items: + type: string + i: + type: integer + description: Trade ID + format: int64 + z: + type: string + description: Tape (Stock trade only) + tks: + type: string + description: Taker's side (crypto trade only) + required: + - x + - i + TradesResponse: + title: TradesResponse + type: object + description: |- + A model representing the result of hitting the Trades api. + + Represents multiple Trades for a single symbol with support for paging. + x-examples: + trades-example-1: + trades: + - t: '2021-02-06T13:04:56.334320128Z' + x: C + p: 387.62 + s: 100 + c: + - ' ' + - T + i: 52983525029461 + z: B + - t: '2021-02-06T13:09:42.325484032Z' + x: C + p: 387.69 + s: 100 + c: + - ' ' + - T + i: 52983525033813 + z: B + symbol: SPY + next_page_token: MjAyMS0wMi0wNlQxMzowOTo0Mlo7MQ== + properties: + trades: + type: array + description: Array of trades + items: + $ref: '#/components/schemas/Trade' + symbol: + type: string + description: Symbol that was queried + example: AAPL + minLength: 1 + next_page_token: + type: string + description: Token that can be used to query the next page + nullable: true + required: + - trades + - symbol + LatestTradeResponse: + title: LatestTradeResponse + type: object + description: |- + A model representing the result of hitting the Latest Trade api. + + Represents a single Trade that should be the latest trade data for a given ticker symbol + x-examples: + latestTradesResponse-example-1: + symbol: AAPL + trade: + t: '2022-02-01T17:46:51.111055251Z' + x: V + p: 173.06 + s: 100 + c: + - '@' + i: 6519 + z: C + crypto-example-1: + symbol: BTCUSD + trade: + t: '2022-03-08T22:27:26.573044Z' + x: FTXU + p: 38614 + s: 0.0019 + tks: S + i: 26271424 + properties: + trade: + $ref: '#/components/schemas/Trade' + symbol: + type: string + description: Symbol that was queried + example: AAPL + minLength: 1 + required: + - symbol + MultiTradesResponse: + title: MultiTradesResponse + type: object + description: | + A model representing the result of hitting the Multi Trades api; represents multiple trades for multiple symbols. + + Returned results are sorted by symbol first then by Trade timestamp. This means that you are likely to see only one symbol in your first response if there are enough Trades for that symbol to hit the limit you requested on that request. + + In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Trades were found for them. + x-examples: + multiTradesResponse-example-1: + trades: + SPY: + - t: '2021-02-06T13:04:56.334320128Z' + x: C + p: 387.62 + s: 100 + c: + - ' ' + - T + i: 52983525029461 + z: B + - t: '2021-02-06T13:09:42.325484032Z' + x: C + p: 387.69 + s: 100 + c: + - ' ' + - T + i: 52983525033813 + z: B + next_page_token: MjAyMS0wMi0wNlQxMzowOTo0Mlo7MQ== + multiTradesResponse-with-multiple-symbols-at-once-example-1: + trades: + AAPL: + - t: '2021-02-06T13:04:56.334320128Z' + x: C + p: 387.62 + s: 100 + c: + - ' ' + - T + i: 52983525029461 + z: B + - t: '2021-02-06T13:09:42.325484032Z' + x: C + p: 387.69 + s: 100 + c: + - ' ' + - T + i: 52983525033813 + z: B + SPY: + - t: '2021-02-06T05:09:42.325484032Z' + x: C + p: 400.55 + s: 100 + c: + - ' ' + - T + i: 52983525033954 + z: B + next_page_token: MjAyMS0wMi0wNlQxMzowOTo0Mlo7MQ== + properties: + trades: + type: object + additionalProperties: + type: array + items: + $ref: '#/components/schemas/Trade' + next_page_token: + type: string + nullable: true + required: + - trades + LatestMultiTradesResponse: + description: '' + type: object + x-examples: + example-crypto-1: + trades: + ETHUSD: + t: '2022-03-08T22:13:55.777631Z' + x: FTXU + p: 2562.8 + s: 0.881 + tks: S + i: 26271234 + BTCUSD: + t: '2022-03-08T22:14:47.379901Z' + x: FTXU + p: 38510 + s: 0.05 + tks: B + i: 26271277 + example-1: + trades: + TSLA: + t: '2022-03-11T17:24:55.143671726Z' + x: V + p: 801.83 + s: 100 + c: + - '@' + i: 9924 + z: C + AAPL: + t: '2022-03-11T17:24:56.321817175Z' + x: V + p: 155.105 + s: 300 + c: + - '@' + i: 7741 + z: C + properties: + trades: + type: object + additionalProperties: + $ref: '#/components/schemas/Trade' + required: + - trades + Snapshot: + title: Snapshot + type: object + description: | + The Snapshot API for one ticker provides the latest trade, latest quote, minute bar daily bar and previous daily bar data for a given ticker symbol. + x-examples: + snapshot-example-1: + symbol: AAPL + latestTrade: + t: '2021-05-11T20:00:00.435997104Z' + x: Q + p: 125.91 + s: 5589631 + c: + - '@' + - M + i: 179430 + z: C + latestQuote: + t: '2021-05-11T22:05:02.307304704Z' + ax: P + ap: 125.68 + as: 12 + bx: P + bp: 125.6 + bs: 4 + c: + - R + minuteBar: + t: '2021-05-11T22:02:00Z' + o: 125.66 + h: 125.66 + l: 125.66 + c: 125.66 + v: 396 + dailyBar: + t: '2021-05-11T04:00:00Z' + o: 123.5 + h: 126.27 + l: 122.77 + c: 125.91 + v: 125863164 + prevDailyBar: + t: '2021-05-10T04:00:00Z' + o: 129.41 + h: 129.54 + l: 126.81 + c: 126.85 + v: 79569305 + properties: + latestTrade: + $ref: '#/components/schemas/Trade' + latestQuote: + $ref: '#/components/schemas/Quote' + minuteBar: + $ref: '#/components/schemas/Bar' + dailyBar: + $ref: '#/components/schemas/Bar' + prevDailyBar: + $ref: '#/components/schemas/Bar' + MultiSnapshotResponse: + title: MultiSnapshotResponse + type: object + description: | + A model representing the result of hitting the Multi Snapshots api; represents Snapshots for multiple symbols. + + The result is an object whose keys are the requested symbols and values are their respecitve Snapshot + additionalProperties: + $ref: '#/components/schemas/Snapshot' + x-examples: + example-1: + AAPL: + latestTrade: + t: '2022-03-11T19:08:43.947998695Z' + x: V + p: 156.055 + s: 100 + c: + - '@' + i: 10593 + z: C + latestQuote: + t: '2022-03-11T19:09:06.125564144Z' + ax: V + ap: 157.2 + as: 5 + bx: V + bp: 156.08 + bs: 1 + c: + - R + z: C + minuteBar: + t: '2022-03-11T19:08:00Z' + o: 156.02 + h: 156.1 + l: 156.02 + c: 156.055 + v: 4483 + 'n': 26 + vw: 156.055956 + dailyBar: + t: '2022-03-11T05:00:00Z' + o: 158.94 + h: 159.25 + l: 154.76 + c: 156.055 + v: 1180799 + 'n': 10408 + vw: 156.545239 + prevDailyBar: + t: '2022-03-10T05:00:00Z' + o: 160.23 + h: 160.38 + l: 155.98 + c: 158.52 + v: 1889292 + 'n': 17072 + vw: 157.845202 + TSLA: + latestTrade: + t: '2022-03-11T19:08:59.479520429Z' + x: V + p: 796.95 + s: 100 + c: + - '@' + i: 13647 + z: C + latestQuote: + t: '2022-03-11T19:09:06.159593323Z' + ax: V + ap: 850 + as: 1 + bx: V + bp: 796.49 + bs: 1 + c: + - R + z: C + minuteBar: + t: '2022-03-11T19:08:00Z' + o: 796.78 + h: 797.4 + l: 796.78 + c: 796.95 + v: 2139 + 'n': 46 + vw: 797.116889 + dailyBar: + t: '2022-03-11T05:00:00Z' + o: 840.38 + h: 843.055 + l: 795.33 + c: 796.95 + v: 466980 + 'n': 13232 + vw: 811.369454 + prevDailyBar: + t: '2022-03-10T05:00:00Z' + o: 851.5 + h: 853.355 + l: 810.76 + c: 838.21 + v: 578475 + 'n': 16118 + vw: 828.766436 + Quote: + title: Quote + type: object + description: | + The Quotes API provides NBBO quotes for a given ticker symbol at a specified date. + x-examples: + example-1: + t: '2022-03-11T13:13:49.975594385Z' + ax: V + ap: 18696.3338 + as: 1 + bx: V + bp: 0 + bs: 0 + c: + - R + z: C + example-crypto: + t: '2022-03-21T05:00:00.011543552Z' + x: FTXU + bp: 40761.35 + bs: 0.465 + ap: 41007.66 + as: 2.8675 + properties: + t: + type: string + description: Timestamp in RFC-3339 format with nanosecond precision + format: date-time + ax: + type: string + description: ask exchange (Stock quote only) + ap: + type: number + description: | + ask price + as: + type: number + description: | + ask size + bx: + type: string + description: bid exchange (Stock quote only) + bp: + type: number + description: | + bid price + bs: + description: bid size + type: number + c: + type: array + description: quote conditions (Stock quotes only) + items: + type: string + x: + type: string + description: Exchange (Crypto quote Only) + z: + type: string + description: Tape (Stock quote only) + required: + - t + QuotesResponse: + description: | + The Quotes API provides NBBO quotes for a given ticker symbol at a specified date. + type: object + x-examples: + quotesResponse-example-1: + quotes: + - t: '2022-02-01T09:00:00.000448Z' + ax: K + ap: 175 + as: 1 + bx: Q + bp: 174.96 + bs: 4 + c: + - R + z: C + - t: '2022-02-01T09:00:00.000448Z' + ax: K + ap: 175 + as: 12 + bx: Q + bp: 174.96 + bs: 4 + c: + - R + z: C + symbol: AAPL + next_page_token: QUFQTHwyMDIyLTAyLTAxVDA5OjAwOjAwLjAwMDQ0ODAwMFp8MzFDODgxNkY= + no-data-found-example: + quotes: null + symbol: AAPL + next_page_token: null + title: QuotesResponse + properties: + quotes: + type: array + uniqueItems: true + minItems: 1 + nullable: true + items: + $ref: '#/components/schemas/Quote' + symbol: + type: string + minLength: 1 + example: AAPL + next_page_token: + type: string + minLength: 1 + nullable: true + required: + - quotes + - symbol + LatestQuoteResponse: + description: |- + A model representing the result of hitting the Latest Quote api. + + Represents a single Quote that should be the latest quote data for a given ticker symbol + type: object + x-examples: + quotesResponse-example-1: + symbol: AAPL + quote: + t: '2022-02-01T17:51:03.204726425Z' + ax: V + ap: 173.24 + as: 4 + bx: V + bp: 173.21 + bs: 4 + c: + - R + z: C + title: LatestQuotesResponse + properties: + quote: + $ref: '#/components/schemas/Quote' + symbol: + type: string + minLength: 1 + example: AAPL + required: + - quote + - symbol + MultiQuotesReponse: + title: MultiQuotesReponse + type: object + description: | + A model representing the result of hitting the Multi Quotes api; represents multiple Quotes for multiple symbols. + + Returned results are sorted by symbol first then by Quote timestamp. This means that you are likely to see only one symbol in your first response if there are enough Quotes for that symbol to hit the limit you requested on that request. + + In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Quotes were found for them. + x-examples: + multiQuotesResponse-example-1: + quotes: + AAPL: + - t: '2022-02-01T09:00:00.000448Z' + ax: K + ap: 175 + as: 1 + bx: Q + bp: 174.96 + bs: 4 + c: + - R + z: C + next_page_token: QUFQTHwyMDIyLTAyLTAxVDA5OjAwOjAwLjAwMDQ0ODAwMFp8MjIzMEUxOUM= + multiTradesResponse-with-multiple-symbols-at-once-example-1: + quotes: + AAPL: + - t: '2022-02-01T09:00:00.000448Z' + ax: K + ap: 175 + as: 1 + bx: Q + bp: 174.96 + bs: 4 + c: + - R + z: C + GOOGL: + - t: '2022-02-01T09:00:00.000448Z' + ax: K + ap: 175 + as: 1 + bx: Q + bp: 175 + bs: 4 + c: + - R + z: C + next_page_token: QUFQTHwyMDIyLTAyLTAxVDA5OjAwOjAwLjAwMDQ0ODAwMFp8MjIzMEUxOUM= + properties: + quotes: + type: object + additionalProperties: + type: array + items: + $ref: '#/components/schemas/Quote' + next_page_token: + type: string + description: pass this token with your request again to get the next page of results + nullable: true + required: + - quotes + LatestMultiQuotesResponse: + description: '' + type: object + x-examples: + example-crypto: + quotes: + ETHUSD: + t: '2022-03-08T22:40:52.536436224Z' + x: FTXU + bp: 2562.99 + bs: 23.798 + ap: 2579.11 + as: 22.155 + BTCUSD: + t: '2022-03-08T22:40:52.662990848Z' + x: FTXU + bp: 38465.26 + bs: 2.641 + ap: 38698.75 + as: 1.3746 + example-1: + quotes: + AAPL: + t: '2022-03-11T18:40:13.514830169Z' + ax: V + ap: 156.47 + as: 3 + bx: V + bp: 156.45 + bs: 1 + c: + - R + z: C + TSLA: + t: '2022-03-11T18:40:12.416216587Z' + ax: V + ap: 850 + as: 1 + bx: V + bp: 798 + bs: 2 + c: + - R + z: C + properties: + quotes: + type: object + additionalProperties: + $ref: '#/components/schemas/Quote' + required: + - quotes + Bar: + title: Bar + type: object + description: | + The bars API returns aggregate historical data for the requested securities. + x-examples: + stock-example-1: + t: '2022-03-10T19:26:00Z' + o: 158.035 + h: 158.21 + l: 158.035 + c: 158.21 + v: 800 + 'n': 15 + vw: 158.113144 + crypto-example-1: + t: '2022-03-10T19:30:00Z' + x: FTXU + o: 39284 + h: 39284 + l: 39200 + c: 39200 + v: 1.1271 + 'n': 9 + vw: 39233.9329252063 + properties: + t: + type: string + description: Timestamp in RFC-3339 format with nanosecond precision. + format: date-time + x: + type: string + description: Exchange. Only present on Bars for Crypto symbols + enum: + - FTXU + - ERSX + - CBSE + o: + type: number + description: Open price + h: + type: number + description: High price. + l: + type: number + description: | + Low price. + c: + type: number + description: Close price. + v: + description: Volume. + type: number + 'n': + type: integer + description: Number of trades. + format: int64 + vw: + description: Volume weighted average price. + type: number + required: + - t + - o + - h + - l + - c + - v + BarsResponse: + description: '' + type: object + x-examples: + barsResponse-stock-example-1: + bars: + - t: '2021-02-01T16:01:00Z' + o: 133.32 + h: 133.74 + l: 133.31 + c: 133.5 + v: 9876 + - t: '2021-02-01T16:02:00Z' + o: 133.5 + h: 133.58 + l: 133.44 + c: 133.58 + v: 3567 + symbol: AAPL + next_page_token: MjAyMS0wMi0wMVQxNDowMjowMFo7MQ== + barsResponse-crypto-example-1: + bars: + - t: '2022-03-10T06:00:00Z' + x: CBSE + o: 39230.55 + h: 40302.06 + l: 38560.85 + c: 39259.91 + v: 11328.17046589 + 'n': 353132 + vw: 39208.3129673941 + - t: '2022-03-10T06:00:00Z' + x: ERSX + o: 39246.4 + h: 40151 + l: 38791 + c: 39270 + v: 153.254034 + 'n': 230 + vw: 39255.8594375793 + - t: '2022-03-10T06:00:00Z' + x: FTXU + o: 39170 + h: 40290 + l: 38560 + c: 39200 + v: 1511.2828 + 'n': 5248 + vw: 39214.2388224758 + symbol: BTCUSD + next_page_token: null + title: BarsResponse + properties: + bars: + type: array + uniqueItems: true + minItems: 1 + description: The array of Bar data + items: + $ref: '#/components/schemas/Bar' + symbol: + type: string + minLength: 1 + example: AAPL + description: the stock ticker or crypto symbol this set of bar data is for + next_page_token: + type: string + minLength: 1 + nullable: true + required: + - bars + - symbol + - next_page_token + LatestBarResponse: + description: |- + A model representing the result of hitting one of the Latest Bar api endpoints. + + Represents a single Bar that should be the latest Bar data for a given ticker symbol + type: object + x-examples: + crypto-example-1: + symbol: BTCUSD + bar: + t: '2022-03-08T21:05:00Z' + x: FTXU + o: 38576 + h: 38576 + l: 38576 + c: 38576 + v: 0.063 + 'n': 1 + vw: 38576 + stock-example-1: + symbol: AAPL + bar: + t: '2022-03-10T19:26:00Z' + o: 158.035 + h: 158.21 + l: 158.035 + c: 158.21 + v: 800 + 'n': 15 + vw: 158.113144 + properties: + symbol: + type: string + minLength: 1 + bar: + $ref: '#/components/schemas/Bar' + required: + - symbol + - bar + MultiBarsResponse: + description: | + A model representing the result of hitting the Multi Bars api; represents multiple Bars for multiple symbols. + + Returned results are sorted by symbol first then by Bar timestamp. This means that you are likely to see only one symbol in your first response if there are enough Bars in the duration you specified for that symbol to hit the limit you requested on that request. + + In these situations if you keep requesting again with the next_page_token you will eventually reach the next symbols if any Bars were found for them in the timeframe. + type: object + x-examples: + multiBarsResponse-with-multiple-symbols-at-once-example-1: + bars: + AAPL: + - t: '2022-02-01T09:04:00Z' + o: 175.14 + h: 175.16 + l: 175.12 + c: 175.16 + v: 1395 + 'n': 61 + vw: 175.174624 + - t: '2022-02-01T09:05:00Z' + o: 175.21 + h: 175.21 + l: 175.1 + c: 175.13 + v: 1821 + 'n': 61 + vw: 175.143635 + TSLA: + - t: '2022-02-01T09:05:00Z' + o: 944.99 + h: 944.99 + l: 944.99 + c: 944.99 + v: 2520 + 'n': 207 + vw: 944.437393 + next_page_token: null + multiBarsResponse-with-page-token-example-1: + bars: + BTCUSD: + - t: '2022-02-28T06:00:00Z' + x: FTXU + o: 37866 + h: 44340 + l: 37494 + c: 43241 + v: 2817.008 + 'n': 10116 + vw: 40876.4518611946 + next_page_token: QlRDVVNEfER8MjAyMi0wMi0yOFQwNjowMDowMC4wMDAwMDAwMDBafEZUWFU= + title: MultiBarsResponse + properties: + bars: + type: object + additionalProperties: + type: array + items: + $ref: '#/components/schemas/Bar' + next_page_token: + type: string + nullable: true + required: + - bars + LatestMultiBarsResponse: + title: LatestMultiBarsResponse + type: object + x-examples: + example-1: + bars: + LINKUSD: + t: '2022-03-08T17:33:00Z' + x: FTXU + o: 13.3565 + h: 13.3565 + l: 13.3565 + c: 13.3565 + v: 41.4 + 'n': 1 + vw: 13.3565 + BTCUSD: + t: '2022-03-08T17:40:00Z' + x: FTXU + o: 39055 + h: 39055 + l: 39055 + c: 39055 + v: 0.1 + 'n': 1 + vw: 39055 + description: | + A model representing the result of hitting the Latest Multi Bars api; represents the latest Bars for multiple symbols. + properties: + bars: + type: object + additionalProperties: + $ref: '#/components/schemas/Bar' + required: + - bars + News: + description: Model representing a news article from the Alpaca Market Data API + type: object + x-examples: + news-example-1: + id: 24803233 + headline: Benzinga's Top 5 Articles For 2021 — Or 'Who Let The Dog Out?' + author: Sue Strachan + created_at: '2021-12-29T15:11:03Z' + updated_at: '2021-12-30T20:37:41Z' + summary: '2021 may have been the Year of the Ox in the Chinese calendar, but for Benzinga, it was the Year of the Dog, or should we say, Year of the Dogecoin (CRYPTO: DOGE).' + content: "

2021 may have been the Year of the Ox in the Chinese calendar, but for Benzinga, it was the Year of the Dog, or should we say, Year of the Dogecoin (CRYPTO: DOGE).

\r\n\r\n

The memecoin created in 2013...." + url: 'https://www.benzinga.com/news/21/12/24843171/apple-leader-in-phone-sales-in-china-for-second-straight-month-in-november-with-23-6-share-according' + images: + - size: large + url: 'https://cdn.benzinga.com/files/imagecache/2048x1536xUP/images/story/2012/doge_12.jpg' + - size: small + url: 'https://cdn.benzinga.com/files/imagecache/1024x768xUP/images/story/2012/doge_12.jpg' + - size: thumb + url: 'https://cdn.benzinga.com/files/imagecache/250x187xUP/images/story/2012/doge_12.jpg' + symbols: + - AMZN + - BTCUSD + - COIN + - DOGEUSD + - SPCE + - TSLA + - TWTR + source: benzinga + properties: + id: + type: integer + format: int64 + description: News article ID + headline: + type: string + minLength: 1 + description: Headline or title of the article + author: + type: string + minLength: 1 + description: Original author of news article + created_at: + type: string + format: date-time + description: Date article was created (RFC 3339) + updated_at: + type: string + format: date-time + description: Date article was updated (RFC 3339) + summary: + type: string + minLength: 1 + description: Summary text for the article (may be first sentence of content) + content: + type: string + minLength: 1 + description: Content of the news article (might contain HTML) + url: + type: string + format: uri + description: URL of article (if applicable) + nullable: true + images: + type: array + uniqueItems: true + description: List of images (URLs) related to given article (may be empty) + items: + $ref: '#/components/schemas/NewsImage' + symbols: + type: array + description: List of related or mentioned symbols + items: + type: string + source: + type: string + minLength: 1 + description: Source where the news originated from (e.g. Benzinga) + required: + - id + - headline + - author + - created_at + - updated_at + - summary + - content + - images + - symbols + - source + NewsImage: + description: A model representing images for news article. simply a url to the image along with a size parameter suggesting the display size of the image + type: object + x-examples: + newsimage-example-1: + size: thumb + url: 'https://cdn.benzinga.com/files/imagecache/250x187xUP/images/story/2012/doge_12.jpg' + title: NewsImage + properties: + size: + type: string + minLength: 1 + description: 'Possible values for size are thumb, small and large.' + example: thumb + enum: + - thumb + - small + - large + readOnly: true + url: + type: string + minLength: 1 + description: url to image from news article + format: uri + readOnly: true + required: + - size + - url + GetNewsResponse: + title: GetNewsResponse + type: object + properties: + news: + type: array + items: + $ref: '#/components/schemas/News' + next_page_token: + type: string + description: Pagination token for next page + XBBO: + description: XBBO or Cross Best Bid and Offer represents the Best Bid and Offer for an exchange + type: object + x-examples: + example-1: + t: '2022-02-01T20:21:03.323000342Z' + ax: FTXU + ap: 38529 + as: 0.0688 + bx: ERSX + bp: 38534 + bs: 1.5 + properties: + t: + type: string + format: date-time + description: Timestamp in RFC-3339 format with nanosecond precision. + ax: + type: string + minLength: 1 + description: Ask exchange. + ap: + type: number + description: Ask price. + as: + type: number + description: Ask size. + bx: + type: string + minLength: 1 + description: Bid exchange. + bp: + type: number + description: Bid price. + bs: + type: number + description: Bid size. + required: + - t + - ax + - ap + - as + - bx + - bp + - bs + title: XBBO + LatestXBBOResponse: + description: Represents the Latest XBBO for a crypto symbol that calculates the Best Bid and Offer across multiple exchanges. + type: object + x-examples: + example-1: + symbol: BTCUSD + xbbo: + t: '2022-02-01T20:21:03.323000342Z' + ax: FTXU + ap: 38529 + as: 0.0688 + bx: ERSX + bp: 38534 + bs: 1.5 + properties: + symbol: + type: string + minLength: 1 + xbbo: + $ref: '#/components/schemas/XBBO' + required: + - symbol + - xbbo + title: LatestXBBOResponse + LatestMultiXBBOResponse: + description: '' + type: object + x-examples: + example-1: + xbbos: + BTCUSD: + t: '2022-03-08T22:59:49.514811056Z' + ax: ERSX + ap: 38556.7 + as: 1.556151 + bx: FTXU + bp: 38562 + bs: 2.5781 + properties: + xbbos: + type: object + additionalProperties: + $ref: '#/components/schemas/XBBO' + required: + - xbbos + CryptoSpreadsResponse: + description: '' + type: object + x-examples: + example-1: + spreads: + ERSX: 30 + FTXU: 30 + properties: + spreads: + type: object + additionalProperties: + type: integer + required: + - spreads + MarketMoversResponse: + title: MarketMovers + type: object + description: 'Contains list of market movers ' + x-internal: true + x-examples: + example-1: + gainers: + - symbol: AAPL + percent_change: 10 + change: 0.1 + price: 150.23 + losers: + - symbol: TSLA + percent_change: 15 + change: 0.15 + price: 220.24 + market_type: stocks + last_updated: '2022-01-14T20:46:00.392227' + properties: + gainers: + type: array + description: List of top N gainers + items: + $ref: '#/components/schemas/MarketMoverAsset' + losers: + description: List of top N losers + type: array + items: + $ref: '#/components/schemas/MarketMoverAsset' + market_type: + type: string + enum: + - stocks + - crypto + description: Market type (stocks or crypto) + last_updated: + type: string + description: Time the movers where last computed + required: + - gainers + - losers + - market_type + - last_updated + MarketMoverAsset: + title: MarketMoverAsset + type: object + description: Name or source of given news article + x-examples: + example-1: + symbol: AGRI + percent_change: 145.56 + change: 2.46 + price: 4.15 + x-internal: true + properties: + symbol: + type: string + description: Symbol of market moving asset + percent_change: + type: number + description: Percentage difference change for the day + change: + type: number + description: Difference in change for the day + price: + type: number + description: Current price of market moving asset + required: + - symbol + - percent_change + - change + - price + ExchangesResponse: + title: ExchangesResponse + type: object + additionalProperties: + type: string + x-examples: + example-1: + Z: Cboe BZ + I: International Securities Exchange + M: Chicago Stock Exchange + U: Members Exchange + L: Long Term Stock Exchange + W: CBOE + X: NASDAQ OMX PSX + B: NASDAQ OMX BX + D: FINRA ADF + J: Cboe EDGA + P: NYSE Arca + Q: NASDAQ OMX + S: NASDAQ Small Cap + V: IEX + A: NYSE American (AMEX) + E: Market Independent + 'N': New York Stock Exchange + T: NASDAQ Int + 'Y': Cboe BYX + C: National Stock Exchange + H: MIAX + K: Cboe EDGX + description: Returns an object representing the exchanges we support. The keys are the short form codes you will see in our responses and the values are their respective full names. + parameters: + crypto-exchanges: + name: exchanges + in: query + required: false + schema: + type: string + example: 'ERSX,CBSE' + description: 'A comma separated list of which crypto exchanges to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU`' + crypto-exchange: + name: exchange + in: query + required: true + schema: + type: string + enum: + - ERSX + - CBSE + - FTXU + example: ERSX + description: 'Which crypto exchange to pull the data from. Alpaca currently supports `ERSX`, `CBSE`, and `FTXU`' + crypto-symbols: + name: symbols + in: query + required: true + schema: + type: string + example: 'BTCUSD,ETHUSD' + description: 'The comma-separated list of crypto symbols to query for. Note, currently all crypto symbols must be appended with "USD", ie "BTCUSD,ETHUSD" would get both BTC and ETH' + crypto-symbol: + name: symbol + in: path + required: true + schema: + type: string + example: BTCUSD + description: 'The crypto symbol to query for. Note, currently all crypto symbols must be appended with "USD", ie "BTCUSD" would be how you query for BTC.' + timeframe: + name: timeframe + in: query + required: true + schema: + type: string + description: 'Timeframe for the aggregation. Values are customizeable, frequently used examples: 1Min, 15Min, 1Hour, 1Day. Limits: 1Min-59Min, 1Hour-23Hour.' + page_token: + name: page_token + in: query + required: false + schema: + type: string + description: Pagination token to continue from. The value to pass here is returned in specific requests when more data is available than the request limit allows. + start: + name: start + in: query + required: false + schema: + type: string + format: date-time + example: '2021-01-01T00:00:00Z' + description: Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + end: + name: end + in: query + required: false + schema: + type: string + format: date-time + example: '2021-01-01T00:00:00Z' + description: Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + limit: + name: limit + in: query + required: false + schema: + type: integer + minimum: 1 + maximum: 10000 + description: 'Number of data points to return. Must be in range 1-10000, defaults to 1000.' + stock-symbol: + name: symbol + in: path + required: true + schema: + type: string + example: AAPL + description: The stock ticker symbol to query for. + feed: + name: feed + in: query + required: false + schema: + type: string + enum: + - iex + - sip + - otc + example: sip + description: 'Which feed to pull market data from. This is either `iex`, `otc`, or `sip`. `sip` and `otc` are only available to those with a subscription' + adjustment: + name: adjustment + in: query + required: false + schema: + type: string + enum: + - raw + - split + - dividend + - all + description: specifies the corporate action adjustment(s) for bars data + stock-symbols: + name: symbols + in: query + required: true + schema: + type: string + example: 'AAPL,TSLA' + description: The comma-separated list of stock ticker symbols to query for. +security: + - API_Key: [] + API_Secret: [] diff --git a/crates/alpaca_openapi/openapi/oauth/openapi.yaml b/crates/alpaca_openapi/openapi/oauth/openapi.yaml new file mode 100644 index 0000000..8dd5b69 --- /dev/null +++ b/crates/alpaca_openapi/openapi/oauth/openapi.yaml @@ -0,0 +1,129 @@ +openapi: 3.0.0 +info: + title: OAuth API + version: 1.0.0 + description: |- + The OAuth API allows you to request market data and manage portfolios on behalf of your end-users. + + For more information, visit https://alpaca.markets/docs/build-apps_services-with-alpaca/oauth-guide/. + contact: + name: Alpaca Support + email: support@alpaca.markets + url: 'https://alpaca.markets/support' + termsOfService: 'https://s3.amazonaws.com/files.alpaca.markets/disclosures/library/TermsAndConditions.pdf' +servers: + - url: 'https://data.alpaca.markets/v2' + description: Production + - description: Sandbox + url: 'https://data.sandbox.alpaca.markets/v2' +tags: + - name: OAuth + - name: Crypto Pricing Data API + - name: Stock Pricing Data API +paths: + '/v2/stocks/{symbol}/bars': + get: + tags: + - Stock Pricing Data API + summary: Bars + parameters: + - name: Apca-Api-Key-Id + in: header + schema: + type: string + example: '{{APCA_API_KEY_ID}}' + - name: Apca-Api-Secret-Key + in: header + schema: + type: string + example: '{{APCA_API_SECRET_KEY}}' + - name: start + in: query + schema: + type: string + description: Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + example: '2020-04-01T0:00:00Z' + - name: end + in: query + schema: + type: string + description: Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + example: '2021-08-26T11:00:00Z' + - name: timeframe + in: query + schema: + type: string + description: 'Timeframe for the aggregation. Values are customizeable, frequently used examples: 1Min, 15Min, 1Hour, 1Day.' + example: 1Min + - name: symbol + in: path + schema: + type: string + required: true + description: The symbol to query for + example: AAPL + responses: + '200': + description: Successful response + content: + application/json: {} + operationId: 'getBarsStocks' #simply copying the id used in the data spec + description: 'The bars API returns aggregate historical data for the requested securities' + parameters: + - schema: + type: string + name: symbol + in: path + required: true + '/v2/stocks/{symbol}/trades': + get: + tags: + - Stock Pricing Data API + summary: Trades + operationId: getTradesStocks #just using same values from the data api + description: The Trades API provides historcial trade data for a given ticker symbol on a specified date. Returns trades for the queried stock signal. + parameters: + - name: Apca-Api-Key-Id + in: header + schema: + type: string + example: '{{APCA_API_KEY_ID}}' + - name: Apca-Api-Secret-Key + in: header + schema: + type: string + example: '{{APCA_API_SECRET_KEY}}' + - name: start + in: query + schema: + type: string + description: Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. + example: '2020-04-01T0:00:00Z' + - name: end + in: query + schema: + type: string + description: Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. + example: '2021-08-26T11:00:00Z' + - name: symbol + in: path + schema: + type: string + required: true + description: The symbol to query for + example: AAPL + responses: + '200': + description: Successful response + content: + application/json: {} +components: + securitySchemes: + API_Key: + name: APCA-API-KEY-ID + type: apiKey + in: header + API_Secret: + name: APCA-API-SECRET-KEY + type: apiKey + in: header diff --git a/crates/alpaca_openapi/openapi/oauth/redirect/openapi.yaml b/crates/alpaca_openapi/openapi/oauth/redirect/openapi.yaml new file mode 100644 index 0000000..fdea931 --- /dev/null +++ b/crates/alpaca_openapi/openapi/oauth/redirect/openapi.yaml @@ -0,0 +1,63 @@ +openapi: 3.0.0 +info: + title: OAuth API + version: 1.0.0 + description: |- + The OAuth API allows you to request market data and manage portfolios on behalf of your end-users. + + For more information, visit https://alpaca.markets/docs/build-apps_services-with-alpaca/oauth-guide/. + contact: + name: Alpaca Support + email: support@alpaca.markets + url: 'https://alpaca.markets/support/' +servers: + - description: App + url: 'https://app.alpaca.markets' +tags: + - name: OAuth +paths: + /oauth/authorize: + get: + summary: Redirect user for authorization + tags: + - OAuth + responses: + '200': + description: OK + operationId: get-oauth-authorize + description: Redirect your user from your application to this endpoint with the following query parameters. + parameters: + - schema: + type: string + in: query + name: response_type + required: true + description: Must be code to request an authorization code. + - schema: + type: string + in: query + name: client_id + description: The Client ID you received when you registered the application. + required: true + - schema: + type: string + in: query + name: redirect_uri + description: The URL where the user will be sent after authorization. It must match one of the whitelisted redirect URIs for your application. + required: true + - schema: + type: string + in: query + name: state + description: 'An unguessable random string, used to protect against request forgery attacks.' + - schema: + type: string + enum: + - 'account:write' + - trading + - data + in: query + name: scope + description: A space-delimited list of scopes your application requests access to. Read-only endpoint access is assumed by default. +components: + securitySchemes: {} diff --git a/crates/alpaca_openapi/openapi/oauth/token/openapi.yaml b/crates/alpaca_openapi/openapi/oauth/token/openapi.yaml new file mode 100644 index 0000000..ada4a37 --- /dev/null +++ b/crates/alpaca_openapi/openapi/oauth/token/openapi.yaml @@ -0,0 +1,74 @@ +openapi: 3.0.0 +info: + title: OAuth API + version: 1.0.0 + description: |- + The OAuth API allows you to request market data and manage portfolios on behalf of your end-users. + + For more information, visit https://alpaca.markets/docs/build-apps_services-with-alpaca/oauth-guide/. + contact: + name: Alpaca Support + email: support@alpaca.markets + url: 'https://alpaca.markets/support/' +servers: + - url: 'https://api.alpaca.markets' + description: Api +tags: + - name: OAuth +paths: + /oauth/token: + post: + summary: Retrieve an access token + operationId: post-oauth-token + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + access_token: + type: string + token_type: + type: string + scope: + type: string + tags: + - OAuth + description: Exchange your temporary code for an access token. + requestBody: + content: + application/x-www-form-urlencoded: + schema: + description: '' + type: object + x-examples: + example-1: + grant_type: authorization_code + properties: + grant_type: + type: string + description: Must be set to authorization_code for an access token request. + code: + type: string + description: The temporary authorization code received from redirection request. + client_id: + type: string + description: The Client ID you received when you registered the application. + client_secret: + type: string + description: The Client Secret you received when you registered the application. + redirect_uri: + type: string + description: The redirect URI you used for the authorization code request. + required: + - grant_type + - code + - client_id + - client_secret + - redirect_uri + description: '' + parameters: [] +components: + securitySchemes: {} \ No newline at end of file diff --git a/crates/alpaca_openapi/openapi/trading/openapi.yaml b/crates/alpaca_openapi/openapi/trading/openapi.yaml new file mode 100644 index 0000000..bdb2629 --- /dev/null +++ b/crates/alpaca_openapi/openapi/trading/openapi.yaml @@ -0,0 +1,2071 @@ +openapi: 3.0.0 +info: + title: Trader API + description: |- + Alpaca's Trading API is a modern platform for algorithmic trading. + + For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started. + version: 2.0.0 + contact: + name: Alpaca Support + email: support@alpaca.markets + url: 'https://alpaca.markets/support' + termsOfService: 'https://s3.amazonaws.com/files.alpaca.markets/disclosures/library/TermsAndConditions.pdf' +servers: + - url: 'https://paper-api.alpaca.markets' + description: Paper + - url: 'https://api.alpaca.markets' + description: Live +tags: + - name: Accounts + description: 'Head to https://alpaca.markets/docs/api-references/trading-api/account/ to view complete documentation on the Accounts API.' + - name: Orders + description: 'Head to https://alpaca.markets/docs/api-documentation/api-v2/orders/ to view complete documentation on the Orders API.' + - name: Positions + description: 'Head to https://alpaca.markets/docs/api-documentation/api-v2/positions/ to view complete documentation on the Positions API.' + - name: Portfolio History + description: 'Head to https://alpaca.markets/docs/api-documentation/api-v2/portfolio-history/ to view complete documentation on the Portfolio History API.' + - name: Watchlists + description: 'Head to https://alpaca.markets/docs/api-documentation/api-v2/watchlist/ to view complete documentation on the Watchlist API.' + - name: Account Configurations + description: 'Head to https://alpaca.markets/docs/api-documentation/api-v2/account-configuration/ to view complete documentation on the Account Configurations API.' + - name: Account Activities + description: 'Head to https://alpaca.markets/docs/api-references/trading-api/account-activities/ to view complete documentation on the Account Activities API.' + - name: Calendar + description: 'Head to https://alpaca.markets/docs/api-references/trading-api/calendar/ to view complete documentation on the Market Calendar API.' + - name: Clock + description: 'Head to https://alpaca.markets/docs/api-references/trading-api/clock/ to view complete documentation on the Market Clock API.' +paths: + /v2/account: + get: + summary: Get account + tags: + - Accounts + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Account' + operationId: getAccount + parameters: [] + description: Returns the account associated with the API key. + /v2/orders: + post: + tags: + - Orders + summary: Order + operationId: postOrder + description: 'Places a new order for the given account. An order request may be rejected if the account is not authorized for trading, or if the tradable balance is insufficient to fill the order..' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + description: '' + parameters: [] + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + '403': + description: |- + Forbidden + + Buying power or shares is not sufficient. + '422': + description: |- + Unprocessable + + Input parameters are not recognized. + get: + tags: + - Orders + summary: All Orders + parameters: + - schema: + type: string + enum: + - open + - closed + - all + example: open + in: query + name: status + description: 'Order status to be queried. open, closed or all. Defaults to open.' + - schema: + type: integer + in: query + name: limit + description: The maximum number of orders in response. Defaults to 50 and max is 500. + - schema: + type: string + in: query + name: after + description: The response will include only ones submitted after this timestamp (exclusive.) + - schema: + type: string + in: query + name: until + description: The response will include only ones submitted until this timestamp (exclusive.) + - schema: + type: string + enum: + - asc + - desc + in: query + name: direction + description: The chronological order of response based on the submission time. asc or desc. Defaults to desc. + - schema: + type: boolean + in: query + name: nested + description: 'If true, the result will roll up multi-leg orders under the legs field of primary order.' + - schema: + type: string + in: query + name: symbols + description: 'A comma-separated list of symbols to filter by (ex. “AAPL,TSLA,MSFT”). A currency pair is required for crypto orders (ex. “BTCUSD,BCHUSD,LTCUSD,ETCUSD”).' + responses: + '200': + description: |- + Successful response + + An array of Order objects + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Order' + operationId: getAllOrders + description: 'Retrieves a list of orders for the account, filtered by the supplied query parameters.' + x-internal: false + delete: + tags: + - Orders + summary: All Orders + parameters: [] + responses: + '207': + description: |- + Multi-Status with body. + + an array of objects that include the order id and http status code for each status request. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/CanceledOrderResponse' + '500': + description: Failed to cancel order. + operationId: deleteAllOrders + description: 'Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request.' + '/v2/orders/{order_id}': + get: + tags: + - Orders + summary: Order by Order ID + parameters: + - schema: + type: boolean + in: query + name: nested + description: 'If true, the result will roll up multi-leg orders under the legs field of primary order.' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + operationId: getOrderByOrderID + description: Retrieves a single order for the given order_id. + patch: + tags: + - Orders + summary: Order + description: | + Replaces a single order with updated parameters. Each parameter overrides the corresponding attribute of the existing order. The other attributes remain the same as the existing order. + + A success return code from a replaced order does NOT guarantee the existing open order has been replaced. If the existing open order is filled before the replacing (new) order reaches the execution venue, the replacing (new) order is rejected, and these events are sent in the trade_updates stream channel. + + While an order is being replaced, buying power is reduced by the larger of the two orders that have been placed (the old order being replaced, and the newly placed order to replace it). If you are replacing a buy entry order with a higher limit price than the original order, the buying power is calculated based on the newly placed order. If you are replacing it with a lower limit price, the buying power is calculated based on the old order. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PatchOrderRequest' + responses: + '200': + description: |- + Successful response + + The new Order object with the new order ID. + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + operationId: patchOrderByOrderId + delete: + tags: + - Orders + summary: Order by Order ID + parameters: [] + responses: + '204': + description: No Content + '422': + description: The order status is not cancelable. + operationId: deleteOrderByOrderID + description: 'Attempts to cancel an Open Order. If the order is no longer cancelable, the request will be rejected with status 422; otherwise accepted with return status 204.' + parameters: + - schema: + type: string + format: uuid + name: order_id + in: path + required: true + description: order id + /v2/positions: + get: + tags: + - Positions + summary: All Open Positions + parameters: [] + responses: + '200': + description: Successful response + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Position' + operationId: getAllOpenPositions + description: |- + The positions API provides information about an account’s current open positions. The response will include information such as cost basis, shares traded, and market value, which will be updated live as price information is updated. Once a position is closed, it will no longer be queryable through this API + + Retrieves a list of the account’s open positions + delete: + tags: + - Positions + summary: All Positions + parameters: + - schema: + type: boolean + in: query + name: cancel_orders + description: 'If true is specified, cancel all open orders before liquidating all positions.' + responses: + '207': + description: |- + Multi-Status with body. + + an array of PositionClosed responses + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/PositionClosedReponse' + '500': + description: Failed to liquidate + operationId: deleteAllOpenPositions + description: 'Closes (liquidates) all of the account’s open long and short positions. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request.' + '/v2/positions/{symbol_or_asset_id}': + get: + tags: + - Positions + summary: Open Position + description: Retrieves the account’s open position for the given symbol or assetId. + parameters: [] + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/Position' + operationId: getOpenPosition + delete: + tags: + - Positions + summary: Position + parameters: + - schema: + type: number + in: query + name: qty + description: the number of shares to liquidate. Can accept up to 9 decimal points. Cannot work with percentage + - schema: + type: number + in: query + name: percentage + description: percentage of position to liquidate. Must be between 0 and 100. Would only sell fractional if position is originally fractional. Can accept up to 9 decimal points. Cannot work with qty + responses: + '200': + description: |- + Successful response + + Returns the order created to close out this position + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + description: Closes (liquidates) the account’s open position for the given symbol. Works for both long and short positions. + operationId: deleteOpenPosition + parameters: + - schema: + type: string + name: symbol_or_asset_id + in: path + required: true + description: symbol or assetId + /v2/account/portfolio/history: + get: + tags: + - Portfolio History + summary: Account Portfolio History + parameters: + - schema: + type: string + in: query + name: period + description: 'The duration of the data in + , such as 1D, where can be D for day, W for week, M for month and A for year. Defaults to 1M.' + - schema: + type: string + in: query + name: timeframe + description: 'The resolution of time window. 1Min, 5Min, 15Min, 1H, or 1D. If omitted, 1Min for less than 7 days period, 15Min for less than 30 days, or otherwise 1D.' + - schema: + type: string + format: date + example: '2022-05-15' + in: query + name: date_end + description: 'The date the data is returned up to, in “YYYY-MM-DD” format. Defaults to the current market date (rolls over at the market open if extended_hours is false, otherwise at 7am ET)' + - schema: + type: string + in: query + name: extended_hours + description: 'If true, include extended hours in the result. This is effective only for timeframe less than 1D.' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/PortfolioHistory' + operationId: getAccountPortfolioHistory + description: Returns timeseries data about equity and profit/loss (P/L) of the account in requested timespan. + /v2/watchlists: + get: + tags: + - Watchlists + summary: Watchlists + parameters: [] + responses: + '200': + description: Successful response + content: + application/json: + examples: + example-1: + value: + - id: 3174d6df-7726-44b4-a5bd-7fda5ae6e009 + account_id: abe25343-a7ba-4255-bdeb-f7e013e9ee5d + created_at: '2022-01-31T21:49:05.14628Z' + updated_at: '2022-01-31T21:49:05.14628Z' + name: Primary Watchlist + schema: + type: array + items: + $ref: '#/components/schemas/Watchlist' + operationId: getWatchlists + description: Returns the list of watchlists registered under the account. + post: + tags: + - Watchlists + summary: Watchlist + description: Create a new watchlist with initial set of assets. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateWatchlistRequest' + parameters: [] + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/Watchlist' + operationId: postWatchlist + '/v2/watchlists/{watchlist_id}': + get: + tags: + - Watchlists + summary: Get Watchlist by ID + parameters: [] + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/Watchlist' + operationId: getWatchlistById + description: Returns a watchlist identified by the ID. + put: + tags: + - Watchlists + summary: Update Watchlist By Id + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateWatchlistRequest' + parameters: [] + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/Watchlist' + operationId: updateWatchlistById + description: Update the name and/or content of watchlist + post: + tags: + - Watchlists + summary: Add Asset to Watchlist + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/AddAssetToWatchlistRequest' + parameters: [] + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/Watchlist' + operationId: addAssetToWatchlist + description: Append an asset for the symbol to the end of watchlist asset list + delete: + tags: + - Watchlists + summary: Delete Watchlist By Id + parameters: [] + responses: + '204': + description: No Content + operationId: deleteWatchlistById + description: Delete a watchlist. This is a permanent deletion. + parameters: + - schema: + type: string + format: uuid + name: watchlist_id + in: path + required: true + description: watchlist id + '/v2/watchlists:by_name': + get: + tags: + - Watchlists + summary: Get Watchlist by Name + parameters: + - schema: + type: string + in: query + name: name + required: true + description: name of the watchlist + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/Watchlist' + operationId: getWatchlistByName + description: Returns a watchlist by name + put: + tags: + - Watchlists + summary: Update Watchlist By Name + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateWatchlistRequest' + parameters: + - schema: + type: string + in: query + name: name + required: true + description: name of the watchlist + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/Watchlist' + operationId: updateWatchlistByName + description: Update the name and/or content of watchlist + post: + tags: + - Watchlists + summary: Add Asset to Watchlist By Name + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/AddAssetToWatchlistRequest' + parameters: + - schema: + type: string + in: query + name: name + required: true + description: name of the watchlist + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/Watchlist' + operationId: addAssetToWatchlistByName + description: Append an asset for the symbol to the end of watchlist asset list + delete: + tags: + - Watchlists + summary: Delete Watchlist By Name + parameters: + - schema: + type: string + in: query + name: name + required: true + description: name of the watchlist + responses: + '204': + description: No Content + operationId: deleteWatchlistByName + description: Delete a watchlist. This is a permanent deletion. + parameters: [] + '/v2/watchlists/{watchlist_id}/{symbol}': + delete: + tags: + - Watchlists + summary: Symbol from Watchlist + parameters: [] + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Watchlist' + description: Returns the updated watchlist + operationId: removeAssetFromWatchlist + description: Delete one entry for an asset by symbol name + parameters: + - schema: + type: string + format: uuid + name: watchlist_id + in: path + required: true + description: Watchlist ID + - schema: + type: string + name: symbol + in: path + required: true + description: symbol name to remove from the watchlist content + /v2/account/configurations: + get: + tags: + - Account Configurations + summary: Account Configurations + parameters: [] + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/AccountConfigurations' + operationId: getAccountConfig + description: gets the current account configuration values + patch: + tags: + - Account Configurations + summary: Account Configurations + parameters: [] + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/AccountConfigurations' + responses: + '200': + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/AccountConfigurations' + operationId: patchAccountConfig + description: Updates and returns the current account configuration values + /v2/account/activities: + get: + summary: Get account activities of one type + tags: + - Account Activities + responses: + '200': + description: returns an array of Account activities + content: + application/json: + schema: + type: array + items: + anyOf: + - $ref: '#/components/schemas/TradingActivities' + - $ref: '#/components/schemas/NonTradeActivities' + description: Will be a mix of TradingActivity or NonTradeActivity objects based on what is passed in the activity_types parameter + operationId: getAccountActivities + description: Returns account activity entries for many types of activities. + parameters: + - schema: + type: string + format: date-time + in: query + name: date + description: The date for which you want to see activities. + - schema: + type: string + format: date-time + in: query + description: The response will contain only activities submitted before this date. (Cannot be used with date.) + name: until + - schema: + type: string + format: date-time + in: query + description: The response will contain only activities submitted after this date. (Cannot be used with date.) + name: after + - schema: + type: string + enum: + - asc + - desc + example: desc + in: query + name: direction + description: asc or desc (default desc if unspecified.) + - schema: + type: integer + in: query + name: page_size + description: The maximum number of entries to return in the response. (See the section on paging above.) + - schema: + type: string + in: query + description: 'The ID of the end of your current page of results. ' + name: page_token + - schema: + type: string + example: FILL + in: query + name: activity_types + description: 'A comma-separated list of the activity types to include in the response. If unspecified, activities of all types will be returned. See ActivityType model for values' + '/v2/account/activities/{activity_type}': + parameters: + - schema: + type: string + name: activity_type + in: path + description: The activity type you want to view entries for. A list of valid activity types can be found at the bottom of this page. + required: true + get: + summary: Get account activities of one type + tags: + - Account Activities + responses: + '200': + description: returns an array of Account activities + content: + application/json: + schema: + type: array + items: + oneOf: + - $ref: '#/components/schemas/TradingActivities' + - $ref: '#/components/schemas/NonTradeActivities' + description: Will be one of a TradingActivity or NonTradeActivity based on activity_type used in path + operationId: getAccountActivitiesByActivityType + description: Returns account activity entries for a specific type of activity. + parameters: + - schema: + type: string + format: date-time + in: query + name: date + description: The date for which you want to see activities. + - schema: + type: string + format: date-time + in: query + description: The response will contain only activities submitted before this date. (Cannot be used with date.) + name: until + - schema: + type: string + format: date-time + in: query + description: The response will contain only activities submitted after this date. (Cannot be used with date.) + name: after + - schema: + type: string + enum: + - asc + - desc + example: desc + in: query + name: direction + description: asc or desc (default desc if unspecified.) + - schema: + type: integer + in: query + name: page_size + description: The maximum number of entries to return in the response. (See the section on paging above.) + - schema: + type: string + in: query + description: 'The ID of the end of your current page of results. ' + name: page_token + /v2/calendar: + get: + summary: Get Market Calendar info + tags: + - Calendar + parameters: + - schema: + type: string + format: date-time + in: query + name: start + description: The first date to retrieve data for (inclusive) + - schema: + type: string + format: date-time + in: query + name: end + description: The last date to retrieve data for (inclusive) + responses: + '200': + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Calendar' + operationId: getCalendar + description: Returns the market calendar. + /v2/clock: + get: + summary: Get Market Clock info + parameters: [] + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Clock' + operationId: getClock + description: |- + The clock API serves the current market timestamp, whether or not the market is currently open, as well as the times of the next market open and close. + + Returns the market clock. + tags: + - Clock +components: + securitySchemes: + API_Key: + name: APCA-API-KEY-ID + type: apiKey + in: header + description: '' + API_Secret: + name: APCA-API-SECRET-KEY + type: apiKey + in: header + description: '' + schemas: + Account: + title: Account + type: object + description: | + The account API serves important information related to an account, including account status, funds available for trade, funds available for withdrawal, and various flags relevant to an account’s ability to trade. An account maybe be blocked for just for trades (trades_blocked flag) or for both trades and transfers (account_blocked flag) if Alpaca identifies the account to engaging in any suspicious activity. Also, in accordance with FINRA’s pattern day trading rule, an account may be flagged for pattern day trading (pattern_day_trader flag), which would inhibit an account from placing any further day-trades. Please note that cryptocurrencies are not eligible assets to be used as collateral for margin accounts and will require the asset be traded using cash only. + x-examples: + example-1: + account_blocked: false + account_number: 010203ABCD + buying_power: '262113.632' + cash: '-23140.2' + created_at: '2019-06-12T22:47:07.99658Z' + currency: USD + daytrade_count: 0 + daytrading_buying_power: '262113.632' + equity: '103820.56' + id: e6fe16f3-64a4-4921-8928-cadf02f92f98 + initial_margin: '63480.38' + last_equity: '103529.24' + last_maintenance_margin: '38000.832' + long_market_value: '126960.76' + maintenance_margin: '38088.228' + multiplier: '4' + pattern_day_trader: false + portfolio_value: '103820.56' + regt_buying_power: '80680.36' + short_market_value: '0' + shorting_enabled: true + sma: '0' + status: ACTIVE + trade_suspended_by_user: false + trading_blocked: false + transfers_blocked: false + properties: + id: + type: string + description: | + Account Id. + format: uuid + account_number: + type: string + description: Account number. + status: + $ref: '#/components/schemas/AccountStatus' + currency: + type: string + description: | + USD + example: USD + cash: + description: | + Cash Balance + type: string + portfolio_value: + description: Total value of cash + holding positions (This field is deprecated. It is equivalent to the equity field.) + type: string + pattern_day_trader: + type: boolean + description: Whether or not the account has been flagged as a pattern day trader + trade_suspended_by_user: + type: boolean + description: 'User setting. If true, the account is not allowed to place orders.' + trading_blocked: + type: boolean + description: | + If true, the account is not allowed to place orders. + transfers_blocked: + type: boolean + description: 'If true, the account is not allowed to request money transfers.' + account_blocked: + type: boolean + description: 'If true, the account activity by user is prohibited.' + created_at: + type: string + description: | + Timestamp this account was created at + format: date-time + shorting_enabled: + type: boolean + description: Flag to denote whether or not the account is permitted to short + long_market_value: + description: | + Real-time MtM value of all long positions held in the account + type: string + short_market_value: + description: Real-time MtM value of all short positions held in the account + type: string + equity: + description: Cash + long_market_value + short_market_value + type: string + last_equity: + description: 'Equity as of previous trading day at 16:00:00 ET' + type: string + multiplier: + description: 'Buying power multiplier that represents account margin classification; valid values 1 (standard limited margin account with 1x buying power), 2 (reg T margin account with 2x intraday and overnight buying power; this is the default for all non-PDT accounts with $2,000 or more equity), 4 (PDT account with 4x intraday buying power and 2x reg T overnight buying power)' + type: string + buying_power: + description: 'Current available $ buying power; If multiplier = 4, this is your daytrade buying power which is calculated as (last_equity - (last) maintenance_margin) * 4; If multiplier = 2, buying_power = max(equity – initial_margin,0) * 2; If multiplier = 1, buying_power = cash' + type: string + initial_margin: + description: Reg T initial margin requirement (continuously updated value) + type: string + maintenance_margin: + description: Maintenance margin requirement (continuously updated value) + type: string + sma: + type: string + description: Value of special memorandum account (will be used at a later date to provide additional buying_power) + daytrade_count: + type: integer + description: The current number of daytrades that have been made in the last 5 trading days (inclusive of today) + last_maintenance_margin: + description: Your maintenance margin requirement on the previous trading day + type: string + daytrading_buying_power: + description: Your buying power for day trades (continuously updated value) + type: string + regt_buying_power: + description: | + Your buying power under Regulation T (your excess equity - equity minus margin value - times your margin multiplier) + type: string + required: + - id + - status + AccountStatus: + type: string + title: AccountStatus + enum: + - ONBOARDING + - SUBMISSION_FAILED + - SUBMITTED + - ACCOUNT_UPDATED + - APPROVAL_PENDING + - ACTIVE + - REJECTED + description: |- + An enum representing the various possible account status values. + + Most likely, the account status is ACTIVE unless there is any problem. The account status may get in ACCOUNT_UPDATED when personal information is being updated from the dashboard, in which case you may not be allowed trading for a short period of time until the change is approved. + + - ONBOARDING + The account is onboarding. + - SUBMISSION_FAILED + The account application submission failed for some reason. + - SUBMITTED + The account application has been submitted for review. + - ACCOUNT_UPDATED + The account information is being updated. + - APPROVAL_PENDING + The final account approval is pending. + - ACTIVE + The account is active for trading. + - REJECTED + The account application has been rejected. + x-examples: + example-1: ACTIVE + example: ACTIVE + AccountConfigurations: + title: AccountConfigurations + type: object + x-examples: + example-1: + dtbp_check: entry + trade_confirm_email: all + suspend_trade: false + no_shorting: false + fractional_trading: true + max_margin_multiplier: '4' + pdt_check: entry + description: The account configuration API provides custom configurations about your trading account settings. These configurations control various allow you to modify settings to suit your trading needs. + properties: + dtbp_check: + type: string + description: 'both, entry, or exit. Controls Day Trading Margin Call (DTMC) checks.' + enum: + - both + - entry + - exit + trade_confirm_email: + type: string + description: 'all or none. If none, emails for order fills are not sent.' + suspend_trade: + type: boolean + description: 'If true, new orders are blocked.' + no_shorting: + type: boolean + description: 'If true, account becomes long-only mode.' + fractional_trading: + type: boolean + description: 'If true, account is able to participate in fractional trading' + max_margin_multiplier: + type: string + description: Can be "1" or "2" + pdt_check: + type: string + example: entry + TradingActivities: + title: AccountTradingActivities + type: object + x-examples: + example-1: + id: '20220202135509981::2d7be4ff-d1f3-43e9-856a-0f5cf5c5088e' + activity_type: FILL + transaction_time: '2022-02-02T18:55:09.981482Z' + type: fill + price: '174.78' + qty: '2' + side: buy + symbol: AAPL + leaves_qty: '0' + order_id: b5abe576-6a8a-49f3-a353-46b72c1ccae9 + cum_qty: '2' + order_status: filled + properties: + activity_type: + $ref: '#/components/schemas/ActivityType' + id: + type: string + description: 'An id for the activity. Always in “::” format. Can be sent as page_token in requests to facilitate the paging of results.' + cum_qty: + description: The cumulative quantity of shares involved in the execution. + type: string + leaves_qty: + type: string + description: | + For partially_filled orders, the quantity of shares that are left to be filled. + price: + type: string + description: The per-share price that the trade was executed at. + qty: + type: string + description: The number of shares involved in the trade execution. + side: + type: string + description: buy or sell + symbol: + type: string + description: The symbol of the security being traded. + example: AAPL + transaction_time: + type: string + description: The time at which the execution occurred. + format: date-time + order_id: + type: string + description: The id for the order that filled. + format: uuid + type: + type: string + description: fill or partial_fill + enum: + - fill + - partial_fill + example: fill + order_status: + $ref: '#/components/schemas/OrderStatus' + NonTradeActivities: + title: AccountNonTradeActivities + type: object + properties: + activity_type: + $ref: '#/components/schemas/ActivityType' + id: + type: string + description: 'An ID for the activity, always in “::” format. Can be sent as page_token in requests to facilitate the paging of results.' + date: + type: string + description: The date on which the activity occurred or on which the transaction associated with the activity settled. + format: date-time + net_amount: + type: string + description: The net amount of money (positive or negative) associated with the activity. + symbol: + type: string + description: The symbol of the security involved with the activity. Not present for all activity types. + qty: + type: string + description: | + For dividend activities, the number of shares that contributed to the payment. Not present for other activity types. + per_share_amount: + type: string + description: 'For dividend activities, the average amount paid per share. Not present for other activity types.' + x-examples: + example-1: + activity_type: DIV + id: '20190801011955195::5f596936-6f23-4cef-bdf1-3806aae57dbf' + date: '2019-08-01' + net_amount: '1.02' + symbol: T + qty: '2' + per_share_amount: '0.51' + ActivityType: + type: string + title: ActivityType + description: |- + - FILL + Order fills (both partial and full fills) + + - TRANS + Cash transactions (both CSD and CSW) + + - MISC + Miscellaneous or rarely used activity types (All types except those in TRANS, DIV, or FILL) + + - ACATC + ACATS IN/OUT (Cash) + + - ACATS + ACATS IN/OUT (Securities) + + - CFEE + Crypto fee + + - CSD + Cash deposit(+) + + - CSW + Cash withdrawal(-) + + - DIV + Dividends + + - DIVCGL + Dividend (capital gain long term) + + - DIVCGS + Dividend (capital gain short term) + + - DIVFEE + Dividend fee + + - DIVFT + Dividend adjusted (Foreign Tax Withheld) + + - DIVNRA + Dividend adjusted (NRA Withheld) + + - DIVROC + Dividend return of capital + + - DIVTW + Dividend adjusted (Tefra Withheld) + + - DIVTXEX + Dividend (tax exempt) + + - FEE + Fee denominated in USD + + - INT + Interest (credit/margin) + + - INTNRA + Interest adjusted (NRA Withheld) + + - INTTW + Interest adjusted (Tefra Withheld) + + - JNL + Journal entry + + - JNLC + Journal entry (cash) + + - JNLS + Journal entry (stock) + + - MA + Merger/Acquisition + + - NC + Name change + + - OPASN + Option assignment + + - OPEXP + Option expiration + + - OPXRC + Option exercise + + - PTC + Pass Thru Charge + + - PTR + Pass Thru Rebate + + - REORG + Reorg CA + + - SC + Symbol change + + - SSO + Stock spinoff + + - SSP + Stock split + enum: + - FILL + - TRANS + - MISC + - ACATC + - ACATS + - CSD + - CSW + - DIV + - DIVCGL + - DIVCGS + - DIVFEE + - DIVFT + - DIVNRA + - DIVROC + - DIVTW + - DIVTXEX + - INT + - INTNRA + - INTTW + - JNL + - JNLC + - JNLS + - MA + - NC + - OPASN + - OPEXP + - OPXRC + - PTC + - PTR + - REORG + - SC + - SSO + - SSP + - CFEE + - FEE + x-examples: + example-1: FILL + Order: + description: |- + The Orders API allows a user to monitor, place and cancel their orders with Alpaca. + + Each order has a unique identifier provided by the client. This client-side unique order ID will be automatically generated by the system if not provided by the client, and will be returned as part of the order object along with the rest of the fields described below. Once an order is placed, it can be queried using the client-side order ID to check the status. + + Updates on open orders at Alpaca will also be sent over the streaming interface, which is the recommended method of maintaining order state. + type: object + x-examples: + example-1: + id: 61e69015-8549-4bfd-b9c3-01e75843f47d + client_order_id: eb9e2aaa-f71a-4f51-b5b4-52a6c565dad4 + created_at: '2021-03-16T18:38:01.942282Z' + updated_at: '2021-03-16T18:38:01.942282Z' + submitted_at: '2021-03-16T18:38:01.937734Z' + filled_at: null + expired_at: null + canceled_at: null + failed_at: null + replaced_at: null + replaced_by: null + replaces: null + asset_id: b0b6dd9d-8b9b-48a9-ba46-b9d54906e415 + symbol: AAPL + asset_class: us_equity + notional: '500' + qty: null + filled_qty: '0' + filled_avg_price: null + order_class: '' + order_type: market + type: market + side: buy + time_in_force: day + limit_price: null + stop_price: null + status: accepted + extended_hours: false + legs: null + trail_percent: null + trail_price: null + hwm: null + title: Order + properties: + id: + type: string + description: Order ID + client_order_id: + type: string + description: Client unique order ID + maxLength: 48 + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + nullable: true + submitted_at: + type: string + format: date-time + nullable: true + filled_at: + type: string + format: date-time + nullable: true + expired_at: + type: string + format: date-time + nullable: true + canceled_at: + type: string + format: date-time + nullable: true + failed_at: + type: string + format: date-time + nullable: true + replaced_at: + type: string + format: date-time + nullable: true + replaced_by: + type: string + format: uuid + description: The order ID that this order was replaced by + nullable: true + replaces: + type: string + format: uuid + description: The order ID that this order replaces + nullable: true + asset_id: + type: string + format: uuid + description: Asset ID + symbol: + type: string + minLength: 1 + description: Asset symbol + asset_class: + $ref: '#/components/schemas/AssetClass' + notional: + type: string + minLength: 1 + description: 'Ordered notional amount. If entered, qty will be null. Can take up to 9 decimal points.' + nullable: true + qty: + type: string + minLength: 1 + description: 'Ordered quantity. If entered, notional will be null. Can take up to 9 decimal points.' + nullable: true + filled_qty: + type: string + minLength: 1 + description: Filled quantity + filled_avg_price: + type: string + description: Filled average price + nullable: true + order_class: + $ref: '#/components/schemas/OrderClass' + order_type: + type: string + deprecated: true + description: 'Deprecated in favour of the field "type" ' + type: + $ref: '#/components/schemas/OrderType' + side: + $ref: '#/components/schemas/OrderSide' + time_in_force: + $ref: '#/components/schemas/TimeInForce' + limit_price: + type: string + description: Limit price + nullable: true + stop_price: + description: Stop price + type: string + nullable: true + status: + $ref: '#/components/schemas/OrderStatus' + extended_hours: + type: boolean + description: 'If true, eligible for execution outside regular trading hours.' + legs: + type: array + description: 'When querying non-simple order_class orders in a nested style, an array of Order entities associated with this order. Otherwise, null.' + nullable: true + items: + $ref: '#/components/schemas/Order' + trail_percent: + type: string + description: The percent value away from the high water mark for trailing stop orders. + trail_price: + type: string + description: The dollar value away from the high water mark for trailing stop orders. + hwm: + type: string + description: The highest (lowest) market price seen since the trailing stop order was submitted. + required: + - symbol + - notional + - qty + - type + - side + - time_in_force + OrderType: + type: string + enum: + - market + - limit + - stop + - stop_limit + - trailing_stop + example: stop + description: |- + Represents the types of orders Alpaca currently supports + + - market + - limit + - stop + - stop_limit + - trailing_stop + title: OrderType + OrderSide: + type: string + enum: + - buy + - sell + example: buy + title: OrderSide + description: |- + Represents which side this order was on: + + - buy + - sell + OrderClass: + type: string + enum: + - simple + - bracket + - oco + - oto + - '' + example: bracket + description: 'This will either be the empty string "", "simple", "bracket", "oco", or "oto".' + title: OrderClass + OrderStatus: + type: string + title: OrderStatus + description: |- + An order executed through Alpaca can experience several status changes during its lifecycle. The most common statuses are described in detail below: + + - new + The order has been received by Alpaca, and routed to exchanges for execution. This is the usual initial state of an order. + + - partially_filled + The order has been partially filled. + + - filled + The order has been filled, and no further updates will occur for the order. + + - done_for_day + The order is done executing for the day, and will not receive further updates until the next trading day. + + - canceled + The order has been canceled, and no further updates will occur for the order. This can be either due to a cancel request by the user, or the order has been canceled by the exchanges due to its time-in-force. + + - expired + The order has expired, and no further updates will occur for the order. + + - replaced + The order was replaced by another order, or was updated due to a market event such as corporate action. + + - pending_cancel + The order is waiting to be canceled. + + - pending_replace + The order is waiting to be replaced by another order. The order will reject cancel request while in this state. + + Less common states are described below. Note that these states only occur on very rare occasions, and most users will likely never see their orders reach these states: + + - accepted + The order has been received by Alpaca, but hasn’t yet been routed to the execution venue. This could be seen often out side of trading session hours. + + - pending_new + The order has been received by Alpaca, and routed to the exchanges, but has not yet been accepted for execution. This state only occurs on rare occasions. + + - accepted_for_bidding + The order has been received by exchanges, and is evaluated for pricing. This state only occurs on rare occasions. + + - stopped + The order has been stopped, and a trade is guaranteed for the order, usually at a stated price or better, but has not yet occurred. This state only occurs on rare occasions. + + - rejected + The order has been rejected, and no further updates will occur for the order. This state occurs on rare occasions and may occur based on various conditions decided by the exchanges. + + - suspended + The order has been suspended, and is not eligible for trading. This state only occurs on rare occasions. + + - calculated + The order has been completed for the day (either filled or done for day), but remaining settlement calculations are still pending. This state only occurs on rare occasions. + + + An order may be canceled through the API up until the point it reaches a state of either filled, canceled, or expired. + enum: + - new + - partially_filled + - filled + - done_for_day + - canceled + - expired + - replaced + - pending_cancel + - pending_replace + - accepted + - pending_new + - accepted_for_bidding + - stopped + - rejected + - suspended + - calculated + example: new + TimeInForce: + type: string + title: TimeInForce + description: |- + Note: For Crypto Trading, Alpaca supports the following Time-In-Force designations: day, gtc, ioc and fok. OPG and CLS are not supported. + + Alpaca supports the following Time-In-Force designations: + + - day + A day order is eligible for execution only on the day it is live. By default, the order is only valid during Regular Trading Hours (9:30am - 4:00pm ET). If unfilled after the closing auction, it is automatically canceled. If submitted after the close, it is queued and submitted the following trading day. However, if marked as eligible for extended hours, the order can also execute during supported extended hours. + + - gtc + The order is good until canceled. Non-marketable GTC limit orders are subject to price adjustments to offset corporate actions affecting the issue. We do not currently support Do Not Reduce(DNR) orders to opt out of such price adjustments. + + - opg + Use this TIF with a market/limit order type to submit “market on open” (MOO) and “limit on open” (LOO) orders. This order is eligible to execute only in the market opening auction. Any unfilled orders after the open will be cancelled. OPG orders submitted after 9:28am but before 7:00pm ET will be rejected. OPG orders submitted after 7:00pm will be queued and routed to the following day’s opening auction. On open/on close orders are routed to the primary exchange. Such orders do not necessarily execute exactly at 9:30am / 4:00pm ET but execute per the exchange’s auction rules. + + - cls + Use this TIF with a market/limit order type to submit “market on close” (MOC) and “limit on close” (LOC) orders. This order is eligible to execute only in the market closing auction. Any unfilled orders after the close will be cancelled. CLS orders submitted after 3:50pm but before 7:00pm ET will be rejected. CLS orders submitted after 7:00pm will be queued and routed to the following day’s closing auction. Only available with API v2. + + - ioc + An Immediate Or Cancel (IOC) order requires all or part of the order to be executed immediately. Any unfilled portion of the order is canceled. Only available with API v2. Most market makers who receive IOC orders will attempt to fill the order on a principal basis only, and cancel any unfilled balance. On occasion, this can result in the entire order being cancelled if the market maker does not have any existing inventory of the security in question. + + - fok + A Fill or Kill (FOK) order is only executed if the entire order quantity can be filled, otherwise the order is canceled. Only available with API v2. + enum: + - day + - gtc + - opg + - cls + - ioc + - fok + example: day + Assets: + description: | + The assets API serves as the master list of assets available for trade and data consumption from Alpaca. Assets are sorted by asset class, exchange and symbol. Some assets are only available for data consumption via Polygon, and are not tradable with Alpaca. These assets will be marked with the flag tradable=false. + type: object + x-examples: + example-1: + id: b0b6dd9d-8b9b-48a9-ba46-b9d54906e415 + class: us_equity + exchange: NASDAQ + symbol: AAPL + name: Apple Inc. Common Stock + status: active + tradable: true + marginable: true + shortable: true + easy_to_borrow: true + fractionable: true + title: Assets + properties: + id: + type: string + format: uuid + description: Asset ID + class: + $ref: '#/components/schemas/AssetClass' + exchange: + $ref: '#/components/schemas/Exchange' + symbol: + type: string + description: The symbol of the asset + example: AAPL + name: + type: string + minLength: 1 + description: The official name of the asset + status: + type: string + description: active or inactive + example: active + enum: + - active + - inactive + tradable: + type: boolean + description: Asset is tradable on Alpaca or not + marginable: + type: boolean + description: Asset is marginable or not + shortable: + type: boolean + description: Asset is shortable or not + easy_to_borrow: + type: boolean + description: Asset is easy-to-borrow or not (filtering for easy_to_borrow = True is the best way to check whether the name is currently available to short at Alpaca). + fractionable: + type: boolean + description: Asset is fractionable or not + required: + - id + - class + - exchange + - symbol + - name + - status + - tradable + - marginable + - shortable + - easy_to_borrow + - fractionable + AssetClass: + type: string + title: AssetClass + enum: + - us_equity + - crypto + example: us_equity + description: Represents what class of asset this is. Currently only supports `us_equity` or `crypto` + x-examples: + example-1: us_equity + Position: + description: 'The positions API provides information about an account’s current open positions. The response will include information such as cost basis, shares traded, and market value, which will be updated live as price information is updated. Once a position is closed, it will no longer be queryable through this API.' + type: object + x-examples: + example-1: + asset_id: 904837e3-3b76-47ec-b432-046db621571b + symbol: AAPL + exchange: NASDAQ + asset_class: us_equity + avg_entry_price: '100.0' + qty: '5' + qty_available: '4' + side: long + market_value: '600.0' + cost_basis: '500.0' + unrealized_pl: '100.0' + unrealized_plpc: '0.20' + unrealized_intraday_pl: '10.0' + unrealized_intraday_plpc: '0.0084' + current_price: '120.0' + lastday_price: '119.0' + change_today: '0.0084' + example-2: + asset_id: b0b6dd9d-8b9b-48a9-ba46-b9d54906e415 + symbol: AAPL + exchange: NASDAQ + asset_class: us_equity + asset_marginable: false + qty: '2' + qty_available: '2' + avg_entry_price: '174.78' + side: long + market_value: '348.58' + cost_basis: '349.56' + unrealized_pl: '-0.98' + unrealized_plpc: '-0.0028035244307129' + unrealized_intraday_pl: '-0.98' + unrealized_intraday_plpc: '-0.0028035244307129' + current_price: '174.29' + lastday_price: '174.61' + change_today: '-0.0018326556325525' + title: Position + properties: + asset_id: + type: string + description: Asset ID + format: uuid + symbol: + type: string + description: Symbol name of the asset + example: AAPL + exchange: + $ref: '#/components/schemas/Exchange' + asset_class: + $ref: '#/components/schemas/AssetClass' + avg_entry_price: + type: string + minLength: 1 + description: Average entry price of the position + qty: + type: string + minLength: 1 + description: The number of shares + qty_available: + type: string + minLength: 1 + description: Total number of shares available minus open orders + side: + type: string + minLength: 1 + description: “long” + market_value: + type: string + minLength: 1 + description: Total dollar amount of the position + cost_basis: + type: string + minLength: 1 + description: Total cost basis in dollar + unrealized_pl: + type: string + minLength: 1 + description: Unrealized profit/loss in dollars + unrealized_plpc: + type: string + minLength: 1 + description: Unrealized profit/loss percent (by a factor of 1) + unrealized_intraday_pl: + type: string + minLength: 1 + description: Unrealized profit/loss in dollars for the day + unrealized_intraday_plpc: + type: string + minLength: 1 + description: Unrealized profit/loss percent (by a factor of 1) + current_price: + type: string + minLength: 1 + description: Current asset price per share + lastday_price: + type: string + minLength: 1 + description: Last day’s asset price per share based on the closing value of the last trading day + change_today: + type: string + minLength: 1 + description: Percent change from last day price (by a factor of 1) + asset_marginable: + type: boolean + required: + - asset_id + - symbol + - exchange + - asset_class + - avg_entry_price + - qty + - side + - market_value + - cost_basis + - unrealized_pl + - unrealized_plpc + - unrealized_intraday_pl + - unrealized_intraday_plpc + - current_price + - lastday_price + - change_today + - asset_marginable + Watchlist: + description: | + The watchlist API provides CRUD operation for the account’s watchlist. An account can have multiple watchlists and each is uniquely identified by id but can also be addressed by user-defined name. Each watchlist is an ordered list of assets. + type: object + x-examples: + example-1: + id: 3174d6df-7726-44b4-a5bd-7fda5ae6e009 + account_id: abe25343-a7ba-4255-bdeb-f7e013e9ee5d + created_at: '2022-01-31T21:49:05.14628Z' + updated_at: '2022-01-31T21:49:05.14628Z' + name: Primary Watchlist + assets: + - id: 8ccae427-5dd0-45b3-b5fe-7ba5e422c766 + class: us_equity + exchange: NASDAQ + symbol: TSLA + name: 'Tesla, Inc. Common Stock' + status: active + tradable: true + marginable: true + shortable: true + easy_to_borrow: true + fractionable: true + title: Watchlist + properties: + id: + type: string + format: uuid + description: watchlist id + account_id: + type: string + format: uuid + description: account ID + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + name: + type: string + minLength: 1 + description: user-defined watchlist name (up to 64 characters) + assets: + type: array + description: 'the content of this watchlist, in the order as registered by the client' + items: + $ref: '#/components/schemas/Assets' + required: + - id + - account_id + - created_at + - updated_at + - name + Calendar: + description: '' + type: object + x-examples: + example-1: + date: '2022-02-01' + open: '09:30' + close: '16:00' + session_open: '0700' + session_close: '1900' + title: Calendar + properties: + date: + type: string + minLength: 1 + description: Date string in “%Y-%m-%d” format + open: + type: string + minLength: 1 + description: 'The time the market opens at on this date in “%H:%M” format' + close: + type: string + minLength: 1 + description: 'The time the market closes at on this date in “%H:%M” format' + session_open: + type: string + minLength: 1 + session_close: + type: string + minLength: 1 + required: + - date + - open + - close + - session_open + - session_close + Clock: + title: Clock + type: object + properties: + timestamp: + type: string + description: | + Current timestamp + format: date-time + is_open: + type: boolean + description: | + Whether or not the market is open + next_open: + type: string + description: Next Market open timestamp + format: date-time + next_close: + type: string + description: Next market close timestamp + format: date-time + x-examples: + example-1: + timestamp: '2019-08-24T14:15:22Z' + is_open: true + next_open: '2019-08-24T14:15:22Z' + next_close: '2019-08-24T14:15:22Z' + PortfolioHistory: + title: PortfolioHistory + type: object + properties: + timestamp: + type: array + description: 'time of each data element, left-labeled (the beginning of time window)' + items: + type: integer + equity: + type: array + description: equity value of the account in dollar amount as of the end of each time window + items: + type: number + profit_loss: + type: array + description: profit/loss in dollar from the base value + items: + type: number + profit_loss_pct: + type: array + description: profit/loss in percentage from the base value + items: + type: number + base_value: + type: number + description: basis in dollar of the profit loss calculation + timeframe: + type: string + description: time window size of each data element + example: 15Min + Exchange: + title: Exchange + type: string + description: |- + Represents the current exchanges Alpaca supports. List is currently: + + - AMEX + - ARCA + - BATS + - NYSE + - NASDAQ + - NYSEARCA + - OTC + enum: + - AMEX + - ARCA + - BATS + - NYSE + - NASDAQ + - NYSEARCA + - OTC + example: NYSE + CanceledOrderResponse: + title: CanceledOrderResponse + type: object + x-examples: + example-1: + id: d56ba3ea-6d04-48ce-8175-817e242ee608 + status: 200 + description: Represents the result of a request to cancel and order + properties: + id: + type: string + format: uuid + description: orderId + status: + type: integer + description: http response code + example: 200 + PatchOrderRequest: + title: PatchOrderRequest + type: object + description: Represents a request to patch an order. + properties: + qty: + type: string + description: number of shares to trade + time_in_force: + $ref: '#/components/schemas/TimeInForce' + limit_price: + type: string + description: required if original order type is limit or stop_limit + stop_price: + type: string + description: required if original order type is limit or stop_limit + trail: + type: string + description: the new value of the trail_price or trail_percent value (works only for type=“trailing_stop”) + client_order_id: + type: string + description: A unique identifier for the order. Automatically generated if not sent. + maxLength: 48 + PositionClosedReponse: + title: PositionClosedReponse + type: object + description: 'Represents the result of asking the api to close a position. ' + properties: + symbol: + type: string + description: Symbol name of the asset + status: + type: string + description: Http status code for the attempt to close this position + body: + $ref: '#/components/schemas/Order' + required: + - symbol + - status + x-examples: + example-1: + symbol: AAPL + status: 200 + body: + id: f7f25e89-939a-4587-aaf6-414a6b3c341d + client_order_id: 52f8574c-96d5-49b6-94c1-2570a268434e + created_at: '2022-02-04T16:53:29.53427917Z' + updated_at: '2022-02-04T16:53:29.53427917Z' + submitted_at: '2022-02-04T16:53:29.533738219Z' + filled_at: null + expired_at: null + canceled_at: null + failed_at: null + replaced_at: null + replaced_by: null + replaces: null + asset_id: b0b6dd9d-8b9b-48a9-ba46-b9d54906e415 + symbol: AAPL + asset_class: us_equity + notional: null + qty: '2' + filled_qty: '0' + filled_avg_price: null + order_class: '' + order_type: market + type: market + side: sell + time_in_force: day + limit_price: null + stop_price: null + status: accepted + extended_hours: false + legs: null + trail_percent: null + trail_price: null + hwm: null + UpdateWatchlistRequest: + title: PostWatchlistRequest + type: object + description: Request format used for creating a new watchlist or updating an existing watchlist with a set of assets and name. + properties: + name: + type: string + symbols: + type: array + items: + type: string + nullable: true + required: + - name + AddAssetToWatchlistRequest: + title: AddAssetToWatchlistRequest + type: object + description: Append an asset for the symbol to the end of watchlist asset list + properties: + symbol: + type: string + example: AAPL + description: symbol name to append to watchlist +security: + - API_Key: [] + API_Secret: [] diff --git a/crates/alpaca_openapi/src/lib.rs b/crates/alpaca_openapi/src/lib.rs new file mode 100644 index 0000000..a05c92c --- /dev/null +++ b/crates/alpaca_openapi/src/lib.rs @@ -0,0 +1,3 @@ +pub use alpaca_broker as broker; +pub use alpaca_data as market_data; +pub use alpaca_trading as trading; diff --git a/crates/sanetrade/.gitignore b/crates/sanetrade/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/crates/sanetrade/.gitignore @@ -0,0 +1 @@ +/target diff --git a/crates/sanetrade/Cargo.toml b/crates/sanetrade/Cargo.toml new file mode 100644 index 0000000..4d5be9e --- /dev/null +++ b/crates/sanetrade/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "sanetrade" +version = "0.1.0" +edition = "2021" + +[dependencies] +tokio.workspace = true +tonic.workspace = true +tinkoff_invest = { path = "../tinkoff_invest", optional = true } +alpaca_openapi = { path = "../alpaca_openapi", optional = true } +uuid = { version = "1.8.0", features = ["v4"] } +miette = "7.2.0" +thiserror = "1.0.61" + +[features] +alpaca = ["dep:alpaca_openapi"] +tinkoff = ["dep:tinkoff_invest"] diff --git a/crates/sanetrade/src/lib.rs b/crates/sanetrade/src/lib.rs new file mode 100644 index 0000000..2e6839d --- /dev/null +++ b/crates/sanetrade/src/lib.rs @@ -0,0 +1,16 @@ +#[cfg(feature = "alpaca")] +pub use alpaca_openapi as alpaca_api; +#[cfg(feature = "tinkoff")] +pub use tinkoff_invest as tinkoff_api; + +#[cfg(feature = "tinkoff")] +mod tinkoff; + +#[cfg(feature = "tinkoff")] +pub use tinkoff::*; + +pub mod market_data; + +pub trait GenericClient { + type Error: miette::Diagnostic; +} diff --git a/crates/sanetrade/src/market_data.rs b/crates/sanetrade/src/market_data.rs new file mode 100644 index 0000000..58a9353 --- /dev/null +++ b/crates/sanetrade/src/market_data.rs @@ -0,0 +1 @@ +pub trait MarketData: crate::GenericClient {} diff --git a/crates/sanetrade/src/tinkoff.rs b/crates/sanetrade/src/tinkoff.rs new file mode 100644 index 0000000..f48ba0c --- /dev/null +++ b/crates/sanetrade/src/tinkoff.rs @@ -0,0 +1,112 @@ +use tinkoff_invest::{ + instruments_service_client::InstrumentsServiceClient, + operations_service_client::OperationsServiceClient, users_service_client::UsersServiceClient, GetAccountsRequest, +}; +pub use tinkoff_invest::Account; + +use tonic::{ + service::{interceptor::InterceptedService, Interceptor}, + transport::Channel, + *, +}; + +#[derive(Debug)] +pub struct TinkoffInterceptor { + token: String, +} + +impl Interceptor for TinkoffInterceptor { + fn call(&mut self, request: tonic::Request<()>) -> Result, Status> { + let mut req = request; + req.metadata_mut().append( + "authorization", + format!("bearer {}", self.token).parse().unwrap(), + ); + req.metadata_mut().append( + "x-tracking-id", + uuid::Uuid::new_v4().to_string().parse().unwrap(), + ); + req.metadata_mut() + .append("x-app-name", "sanetrade".parse().unwrap()); + + Ok(req) + } +} + +#[derive(Debug, thiserror::Error, miette::Diagnostic)] +pub enum TinkoffError { + #[error("transport error: {0}")] + Transport(#[from] transport::Error), + #[error("{}: {}", _0.code(), _0.message())] + StatusError(#[from] Status), +} + +pub struct TinkoffGenericClient { + token: String, + sandbox: bool, +} + +impl TinkoffGenericClient { + pub fn new(token: String, sandbox: bool) -> Self { + Self { token, sandbox } + } + + pub async fn create_channel(&self) -> Result { + Ok(Channel::from_static(if self.sandbox { + "https://sandbox-invest-public-api.tinkoff.ru:443" + } else { + "https://invest-public-api.tinkoff.ru:443" + }) + .connect() + .await?) + } + + pub async fn operations(&self) -> Result { + Ok(TinkoffOperationsClient( + OperationsServiceClient::with_interceptor( + self.create_channel().await?, + TinkoffInterceptor { + token: self.token.clone(), + }, + ), + )) + } + + pub async fn instruments(&self) -> Result { + Ok(TinkoffInstrumentsClient( + InstrumentsServiceClient::with_interceptor( + self.create_channel().await?, + TinkoffInterceptor { + token: self.token.clone(), + }, + ), + )) + } + + pub async fn users(&self) -> Result { + Ok(TinkoffUsersClient(UsersServiceClient::with_interceptor( + self.create_channel().await?, + TinkoffInterceptor { + token: self.token.clone(), + }, + ))) + } +} + +pub struct TinkoffOperationsClient( + pub OperationsServiceClient>, +); + +pub struct TinkoffInstrumentsClient( + pub InstrumentsServiceClient>, +); + +pub struct TinkoffUsersClient( + pub UsersServiceClient>, +); + +impl TinkoffUsersClient { + pub async fn accounts(&mut self) -> Result, TinkoffError> { + Ok(self.0.get_accounts(GetAccountsRequest {}).await?.into_inner().accounts) + } +} diff --git a/crates/tinkoff_invest/Cargo.toml b/crates/tinkoff_invest/Cargo.toml new file mode 100644 index 0000000..8f200af --- /dev/null +++ b/crates/tinkoff_invest/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "tinkoff_invest" +version = "0.1.0" +edition = "2021" +build = "build.rs" + +[dependencies] +prost.workspace = true +prost-types.workspace = true +tonic.workspace = true + +[build-dependencies] +tonic-build = "0.11.0" diff --git a/crates/tinkoff_invest/build.rs b/crates/tinkoff_invest/build.rs new file mode 100644 index 0000000..9cdb7c2 --- /dev/null +++ b/crates/tinkoff_invest/build.rs @@ -0,0 +1,19 @@ +fn main() -> Result<(), Box> { + tonic_build::configure() + .build_client(true) + .build_server(false) + .compile( + &[ + "investapi/src/docs/contracts/instruments.proto", + "investapi/src/docs/contracts/marketdata.proto", + "investapi/src/docs/contracts/operations.proto", + "investapi/src/docs/contracts/orders.proto", + "investapi/src/docs/contracts/sandbox.proto", + "investapi/src/docs/contracts/stoporders.proto", + "investapi/src/docs/contracts/users.proto", + ], + &["investapi/src/docs/contracts/"], + )?; + + Ok(()) +} diff --git a/crates/tinkoff_invest/investapi b/crates/tinkoff_invest/investapi new file mode 160000 index 0000000..ce04fc7 --- /dev/null +++ b/crates/tinkoff_invest/investapi @@ -0,0 +1 @@ +Subproject commit ce04fc7251515b555c0b959b2ec46c096bad1b03 diff --git a/crates/tinkoff_invest/src/lib.rs b/crates/tinkoff_invest/src/lib.rs new file mode 100644 index 0000000..0b9c15e --- /dev/null +++ b/crates/tinkoff_invest/src/lib.rs @@ -0,0 +1,4 @@ +include!(concat!( + env!("OUT_DIR"), + "/tinkoff.public.invest.api.contract.v1.rs" +)); diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..55e8fde --- /dev/null +++ b/flake.lock @@ -0,0 +1,597 @@ +{ + "nodes": { + "cachix": { + "inputs": { + "devenv": "devenv_2", + "flake-compat": [ + "devenv", + "flake-compat" + ], + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "pre-commit-hooks": [ + "devenv", + "pre-commit-hooks" + ] + }, + "locked": { + "lastModified": 1712055811, + "narHash": "sha256-7FcfMm5A/f02yyzuavJe06zLa9hcMHsagE28ADcmQvk=", + "owner": "cachix", + "repo": "cachix", + "rev": "02e38da89851ec7fec3356a5c04bc8349cae0e30", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "cachix", + "type": "github" + } + }, + "crane": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1715274763, + "narHash": "sha256-3Iv1PGHJn9sV3HO4FlOVaaztOxa9uGLfOmUWrH7v7+A=", + "owner": "ipetkov", + "repo": "crane", + "rev": "27025ab71bdca30e7ed0a16c88fd74c5970fc7f5", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "devenv": { + "inputs": { + "cachix": "cachix", + "flake-compat": "flake-compat_2", + "nix": "nix_2", + "nixpkgs": "nixpkgs_2", + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1715593316, + "narHash": "sha256-S7XatU9uV3q9bVBcg/ER0VMQcnPZprrVlN209ne7LDw=", + "owner": "cachix", + "repo": "devenv", + "rev": "725c90407ef53cc2a1b53701c6d2d0745cf2484f", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "devenv_2": { + "inputs": { + "flake-compat": [ + "devenv", + "cachix", + "flake-compat" + ], + "nix": "nix", + "nixpkgs": "nixpkgs", + "poetry2nix": "poetry2nix", + "pre-commit-hooks": [ + "devenv", + "cachix", + "pre-commit-hooks" + ] + }, + "locked": { + "lastModified": 1708704632, + "narHash": "sha256-w+dOIW60FKMaHI1q5714CSibk99JfYxm0CzTinYWr+Q=", + "owner": "cachix", + "repo": "devenv", + "rev": "2ee4450b0f4b95a1b90f2eb5ffea98b90e48c196", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "python-rewrite", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1714641030, + "narHash": "sha256-yzcRNDoyVP7+SCNX0wmuDju1NUCt8Dz9+lyUXEI0dbI=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "e5d10a24b66c3ea8f150e47dfdb0416ab7c3390e", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "devenv", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nix": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "devenv", + "cachix", + "devenv", + "nixpkgs" + ], + "nixpkgs-regression": "nixpkgs-regression" + }, + "locked": { + "lastModified": 1712911606, + "narHash": "sha256-BGvBhepCufsjcUkXnEEXhEVjwdJAwPglCC2+bInc794=", + "owner": "domenkozar", + "repo": "nix", + "rev": "b24a9318ea3f3600c1e24b4a00691ee912d4de12", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "devenv-2.21", + "repo": "nix", + "type": "github" + } + }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "devenv", + "cachix", + "devenv", + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1688870561, + "narHash": "sha256-4UYkifnPEw1nAzqqPOTL2MvWtm3sNGw1UTYTalkTcGY=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "165b1650b753316aa7f1787f3005a8d2da0f5301", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, + "nix_2": { + "inputs": { + "flake-compat": [ + "devenv", + "flake-compat" + ], + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "nixpkgs-regression": "nixpkgs-regression_2" + }, + "locked": { + "lastModified": 1712911606, + "narHash": "sha256-BGvBhepCufsjcUkXnEEXhEVjwdJAwPglCC2+bInc794=", + "owner": "domenkozar", + "repo": "nix", + "rev": "b24a9318ea3f3600c1e24b4a00691ee912d4de12", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "devenv-2.21", + "repo": "nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1692808169, + "narHash": "sha256-x9Opq06rIiwdwGeK2Ykj69dNc2IvUH1fY55Wm7atwrE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9201b5ff357e781bf014d0330d18555695df7ba8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1714640452, + "narHash": "sha256-QBx10+k6JWz6u7VsohfSw8g8hjdBZEf8CFzXH1/1Z94=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz" + } + }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgs-regression_2": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1710695816, + "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "614b4613980a522ba49f0d194531beddbb7220d3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1713361204, + "narHash": "sha256-TA6EDunWTkc5FvDCqU3W2T3SFn0gRZqh6D/hJnM02MM=", + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "285676e87ad9f0ca23d8714a6ab61e7e027020c6", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1715530780, + "narHash": "sha256-bBz4/T/zBzv9Xi5XUlFDeosmSNppLaCQTizMKSksAvk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3281bec7174f679eabf584591e75979a258d8c40", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1706487304, + "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1708475490, + "narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "0e74ca98a74bc7270d28838369593635a5db3260", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "poetry2nix": { + "inputs": { + "flake-utils": "flake-utils", + "nix-github-actions": "nix-github-actions", + "nixpkgs": [ + "devenv", + "cachix", + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1692876271, + "narHash": "sha256-IXfZEkI0Mal5y1jr6IRWMqK8GW2/f28xJenZIPQqkY0=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "d5006be9c2c2417dafb2e2e5034d83fabd207ee3", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": [ + "devenv", + "flake-compat" + ], + "flake-utils": "flake-utils_2", + "gitignore": "gitignore", + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1713775815, + "narHash": "sha256-Wu9cdYTnGQQwtT20QQMg7jzkANKQjwBD9iccfGKkfls=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "2ac4dcbf55ed43f3be0bae15e181f08a57af24a4", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "devenv": "devenv", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs_3", + "rust-overlay": "rust-overlay", + "treefmt-nix": "treefmt-nix" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1715566659, + "narHash": "sha256-OpI0TnN+uE0vvxjPStlTzf5RTohIXVSMwrP9NEgMtaY=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "6c465248316cd31502c82f81f1a3acf2d621b01c", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1714058656, + "narHash": "sha256-Qv4RBm4LKuO4fNOfx9wl40W2rBbv5u5m+whxRYUMiaA=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "c6aaf729f34a36c445618580a9f95a48f5e4e03f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..84a57d7 --- /dev/null +++ b/flake.nix @@ -0,0 +1,79 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + devenv.url = "github:cachix/devenv"; + rust-overlay.url = "github:oxalica/rust-overlay"; + flake-parts.url = "github:hercules-ci/flake-parts"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + crane.url = "github:ipetkov/crane"; + crane.inputs.nixpkgs.follows = "nixpkgs"; + }; + + nixConfig = { + extra-trusted-public-keys = [ + "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=" + "surrealdb.cachix.org-1:rbm7Qs+s36pxbfk9jhIa5HRld6gZ63koZz1h/9sSxaA=" + ]; + extra-substituters = + [ "https://devenv.cachix.org" "https://surrealdb.cachix.org" ]; + }; + + outputs = { flake-parts, ... }@inputs: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ inputs.devenv.flakeModule inputs.treefmt-nix.flakeModule ]; + systems = inputs.nixpkgs.lib.systems.flakeExposed; + perSystem = { config, pkgs, system, ... }: { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + config.allowUnfree = true; + overlays = [ inputs.rust-overlay.overlays.default ]; + }; + + treefmt = { + package = pkgs.treefmt; + programs = { + leptosfmt.enable = true; + prettier.enable = true; + nixfmt-rfc-style.enable = true; + rustfmt.enable = true; + }; + projectRootFile = ./flake.nix; + }; + + devenv.shells.default = rec { + packages = with pkgs; [ + pkg-config + fontconfig.dev + freetype.dev + openssl + protobuf + + # If on x11 + xorg.libX11 + xorg.libX11 + xorg.libXcursor + xorg.libXi + xorg.libXrandr + # If on wayland + libxkbcommon + wayland + + vulkan-tools + vulkan-headers + vulkan-validation-layers + vulkan-loader + udev + + openapi-generator-cli + ]; + + env.LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath packages; + + scripts = { + fmt.exec = "${config.treefmt.build.wrapper}/bin/treefmt ."; + sanetrade.exec = "RUST_LOG=error,sanetrade=trace,ming=trace cargo run -p sanetrade_app -- $@"; + }; + }; + }; + }; +}